{"_id":"@bun-win32/mi","_rev":"3-d47b318a9497aa151c090e3b195155d7","name":"@bun-win32/mi","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/mi","version":"1.0.0","keywords":["bun","ffi","win32","windows","mi","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/mi@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"60d778759929a77b17d57159f15f398f3366db42","tarball":"https://registry.npmjs.org/@bun-win32/mi/-/mi-1.0.0.tgz","fileCount":6,"integrity":"sha512-HuE1KLSR/lmph85YqxYE1pNNrdMnEmXaHkYm5ulHcVEO8JkjClAn3HjjjPv56BBK+16co+9bT1fImS26/KQ+xg==","signatures":[{"sig":"MEUCIELC1vi9TWm7bgun9jfmyogRqhBe8kA0w9TFPwPcr1zOAiEA/ttVZUo3Mn4/dEG2Ank3rnnQtBGG6+o7rBTF85c2jzI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11437},"main":"./index.ts","type":"module","module":"index.ts","shasum":"60d778759929a77b17d57159f15f398f3366db42","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:mi-client-audit":"bun ./example/mi-client-audit.ts","example:mi-bootstrap-beacon":"bun ./example/mi-bootstrap-beacon.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-HuE1KLSR/lmph85YqxYE1pNNrdMnEmXaHkYm5ulHcVEO8JkjClAn3HjjjPv56BBK+16co+9bT1fImS26/KQ+xg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/mi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 Windows Management Infrastructure bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"1.0.21"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mi_1.0.0_1775846085344_0.7100698965848438","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/mi","version":"2.0.0","keywords":["bun","ffi","win32","windows","mi","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/mi@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"1b411b495c1197136d83d6f0e76ef23961add32f","tarball":"https://registry.npmjs.org/@bun-win32/mi/-/mi-2.0.0.tgz","fileCount":6,"integrity":"sha512-KQCXJLs3jihWmZ9/hSBZH+RKVar2DC7HjAF3O02Qxwod1uLnekYXUmA72ToRjlY2Nwk2YGj8OzZ38v0faBvU1g==","signatures":[{"sig":"MEQCIGQqY+Vnn14iulNQ7oY/AhXk9EpRJIJ3h0fKhJq1H8cmAiBAmDsW699ngiQOQb9RqVNAxE/g9s0/4kE6ub8C/7yu3g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12256},"main":"./index.ts","type":"module","module":"index.ts","shasum":"1b411b495c1197136d83d6f0e76ef23961add32f","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:mi-client-audit":"bun ./example/mi-client-audit.ts","example:mi-bootstrap-beacon":"bun ./example/mi-bootstrap-beacon.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-KQCXJLs3jihWmZ9/hSBZH+RKVar2DC7HjAF3O02Qxwod1uLnekYXUmA72ToRjlY2Nwk2YGj8OzZ38v0faBvU1g==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/mi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 Windows Management Infrastructure bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"2.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mi_2.0.0_1782435470957_0.3757392276245548","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 Windows Management Infrastructure bindings for Bun (FFI) on Windows.","devDependencies":{"@bun-win32/kernel32":"2.0.1","@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/mi","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/mi"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","mi","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:mi-bootstrap-beacon":"bun ./example/mi-bootstrap-beacon.ts","example:mi-client-audit":"bun ./example/mi-client-audit.ts"},"_id":"@bun-win32/mi@2.0.1","_integrity":"sha512-aCoDYMwjj0pyXNV3Pk5QCpBs4HPzfM2mi9dDmrmqo+eKiKg96K49p2ysekit80OHnKA1Zkrxk18FG7vT6IW6tA==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"3e0d6920f353d33a08506f3cc0baa4abe4a3c4bb","dist":{"integrity":"sha512-aCoDYMwjj0pyXNV3Pk5QCpBs4HPzfM2mi9dDmrmqo+eKiKg96K49p2ysekit80OHnKA1Zkrxk18FG7vT6IW6tA==","shasum":"3e0d6920f353d33a08506f3cc0baa4abe4a3c4bb","tarball":"https://registry.npmjs.org/@bun-win32/mi/-/mi-2.0.1.tgz","fileCount":6,"unpackedSize":12256,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBEkdJZARPeqeqjS8M0WOeeKwvT/fosQeXjj8f/Wo3MFAiBXDhbaBH/0nIhwOGsNhn/cKlzNbxjKc3iKDUSkWqhOgg=="}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mi_2.0.1_1782438128104_0.653967517831231"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-10T18:34:45.204Z","modified":"2026-06-26T01:42:08.395Z","1.0.0":"2026-04-10T18:34:45.506Z","2.0.0":"2026-06-26T00:57:51.111Z","2.0.1":"2026-06-26T01:42:08.251Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","mi","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/mi"},"description":"Zero-dependency, zero-overhead Win32 Windows Management Infrastructure bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/mi\n\nZero-dependency, zero-overhead Win32 Windows Management Infrastructure bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/mi` exposes the documented callable export from `mi.dll` using [Bun](https://bun.sh)'s FFI. It provides a single class, `Mi`, which lazily binds native symbols on first use. You can optionally preload the export up-front via `Preload()`.\n\nThe package intentionally binds the callable bootstrap entry point, `MI_Application_InitializeV1`. The global `mi_clientFT_V1` symbol is also exported by `mi.dll`, but it is exported data rather than a callable function, so it is documented and inspected in the examples instead of being surfaced as a `Win32.Load()` method.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `mi.dll` (Windows Management Infrastructure client bootstrap).\n- In-source docs in `structs/Mi.ts` with links to Microsoft Learn.\n- Lazy binding on first call; optional eager preload (`Mi.Preload()`).\n- No wrapper overhead; calls map 1:1 to native exports.\n- Strongly-typed MI result codes and pointer aliases (see `types/Mi.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n\n## Installation\n\n```sh\nbun add @bun-win32/mi @bun-win32/kernel32\n```\n\n`@bun-win32/kernel32` is used in the runnable examples below to follow the inline `MI_Application_Close` path from `mi.h`.\n\n## Quick Start\n\n```ts\nimport { FFIType, linkSymbols } from 'bun:ffi';\n\nimport Mi, { MI_Result } from '@bun-win32/mi';\nimport Kernel32 from '@bun-win32/kernel32';\n\nconst MI_APPLICATION_FUNCTION_TABLE_OFFSET = 0x10;\nconst MI_APPLICATION_SIZE = 0x18;\nconst POINTER_SIZE = 0x08;\nconst currentProcessHandle = Kernel32.GetCurrentProcess();\n\nfunction createWideStringBuffer(value: string): Buffer {\n  return Buffer.from(value + '\\0', 'utf16le');\n}\n\nfunction readPointerValue(address: bigint): bigint {\n  const buffer = Buffer.alloc(POINTER_SIZE);\n  const readResult = Kernel32.ReadProcessMemory(currentProcessHandle, address, buffer.ptr, BigInt(buffer.length), 0n);\n\n  if (readResult === 0) {\n    throw new Error(`ReadProcessMemory failed with ${Kernel32.GetLastError()}`);\n  }\n\n  return buffer.readBigUInt64LE(0);\n}\n\nfunction closeApplication(applicationBuffer: Buffer): MI_Result {\n  const applicationFunctionTableAddress = applicationBuffer.readBigUInt64LE(MI_APPLICATION_FUNCTION_TABLE_OFFSET);\n  const closeProcedureAddress = readPointerValue(applicationFunctionTableAddress);\n  const closeLibrary = linkSymbols({\n    Close: {\n      ptr: closeProcedureAddress,\n      args: [FFIType.ptr],\n      returns: FFIType.u32,\n    },\n  });\n\n  try {\n    return closeLibrary.symbols.Close(applicationBuffer.ptr);\n  } finally {\n    closeLibrary.close();\n  }\n}\n\nMi.Preload('MI_Application_InitializeV1');\nKernel32.Preload(['GetCurrentProcess', 'GetLastError', 'ReadProcessMemory']);\n\nconst applicationID = createWideStringBuffer('example/bun-win32/mi');\nconst extendedErrorBuffer = Buffer.alloc(POINTER_SIZE);\nconst applicationBuffer = Buffer.alloc(MI_APPLICATION_SIZE);\nconst initializeStatus = Mi.MI_Application_InitializeV1(0, applicationID.ptr, extendedErrorBuffer.ptr, applicationBuffer.ptr);\n\nif (initializeStatus !== MI_Result.MI_RESULT_OK) {\n  throw new Error(`MI_Application_InitializeV1 failed with ${initializeStatus}`);\n}\n\nconst closeStatus = closeApplication(applicationBuffer);\nconsole.log(`Initialize: ${MI_Result[initializeStatus]}`);\nconsole.log(`Close: ${MI_Result[closeStatus]}`);\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\nbun run example:mi-bootstrap-beacon\nbun run example:mi-client-audit\n```\n\n## Notes\n\n- `MI_Application_InitializeV1` is the only callable export in `mi.dll`.\n- `MI_Application_Close` is inline in `mi.h`, so shutdown happens through the returned `MI_Application.ft` function table rather than a second DLL export.\n- `mi_clientFT_V1` is exported data. `GetProcAddress` returns the address of the exported pointer variable, so dereference it once to reach the actual `MI_ClientFT_V1` table, as shown in `example/mi-client-audit.ts`.\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}