{"_id":"@bun-win32/wtsapi32","_rev":"3-d4a0f9e0f0f4eb444b9d3480db9a4b4a","name":"@bun-win32/wtsapi32","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/wtsapi32","version":"1.0.0","keywords":["bun","ffi","win32","windows","wtsapi32","terminal-services","remote-desktop","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/wtsapi32@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":"aed66132ac5e8e123020b7f3d6b543570e0ca147","tarball":"https://registry.npmjs.org/@bun-win32/wtsapi32/-/wtsapi32-1.0.0.tgz","fileCount":6,"integrity":"sha512-pvVcSxZFgpj+xYTQSEGTLnQG9gjPeIjevaXMGJhRBf1ES4rvhuzi3eV/8O40XMCF0fTET69GjWMtRnz4LbKP4w==","signatures":[{"sig":"MEQCIBiyg7/CCiFV9x3RVv91sP3XnugdBnyYads4nWeWaqilAiAkMMt9IqZWI01ZefsmpJs39xfifJHaxLRZtOs3pMNOcw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40775},"main":"./index.ts","type":"module","module":"index.ts","shasum":"aed66132ac5e8e123020b7f3d6b543570e0ca147","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:session-monitor":"bun ./example/session-monitor.ts","example:session-diagnostic":"bun ./example/session-diagnostic.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-pvVcSxZFgpj+xYTQSEGTLnQG9gjPeIjevaXMGJhRBf1ES4rvhuzi3eV/8O40XMCF0fTET69GjWMtRnz4LbKP4w==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/wtsapi32"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 WTSAPI32 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"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/wtsapi32_1.0.0_1775710106326_0.03064697972123298","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/wtsapi32","version":"2.0.0","keywords":["bun","ffi","win32","windows","wtsapi32","terminal-services","remote-desktop","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/wtsapi32@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":"60108e093a9b7ca9fe00b66b93f69e266d481fb8","tarball":"https://registry.npmjs.org/@bun-win32/wtsapi32/-/wtsapi32-2.0.0.tgz","fileCount":6,"integrity":"sha512-sUrJOcv+BnXsPL7H4oJ6BajbSnu2Ui6zPUaic0zPIn5ObBrB4fj9YULfKdavWhDyiehXPg2qTWxE6ZZpYjRa5Q==","signatures":[{"sig":"MEUCIBAJtZE/Xh7xo5xzGkk6jgo+c3QoXPinmQnFxqrOBCmYAiEAgUIevhKYxeJE5VtBGg6HkUfhs0pxPpmvDpDpuNAcp8c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42429},"main":"./index.ts","type":"module","module":"index.ts","shasum":"60108e093a9b7ca9fe00b66b93f69e266d481fb8","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:session-monitor":"bun ./example/session-monitor.ts","example:session-diagnostic":"bun ./example/session-diagnostic.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-sUrJOcv+BnXsPL7H4oJ6BajbSnu2Ui6zPUaic0zPIn5ObBrB4fj9YULfKdavWhDyiehXPg2qTWxE6ZZpYjRa5Q==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/wtsapi32"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 WTSAPI32 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"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/wtsapi32_2.0.0_1782436008140_0.5934178783331825","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 WTSAPI32 bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/wtsapi32","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/wtsapi32"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","wtsapi32","terminal-services","remote-desktop","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:session-diagnostic":"bun ./example/session-diagnostic.ts","example:session-monitor":"bun ./example/session-monitor.ts"},"_id":"@bun-win32/wtsapi32@2.0.1","_integrity":"sha512-JTC9aWBu/YxuZtLEQwg/FHG/WT31XXd9Vvmfwo7zm0sdYKd8FVZjoP+NfUU/6HmustqHd71M9Lr3A3SCjmzOPA==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"2cf56c1096febf59a8fd66f1f9951d2e958e05c4","dist":{"integrity":"sha512-JTC9aWBu/YxuZtLEQwg/FHG/WT31XXd9Vvmfwo7zm0sdYKd8FVZjoP+NfUU/6HmustqHd71M9Lr3A3SCjmzOPA==","shasum":"2cf56c1096febf59a8fd66f1f9951d2e958e05c4","tarball":"https://registry.npmjs.org/@bun-win32/wtsapi32/-/wtsapi32-2.0.1.tgz","fileCount":6,"unpackedSize":42429,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCyTPl5n3IQGx0FiNI1kqdBCIZWIxukG35hYrZkrt1kWQIgVLgeIj6VU4NqzFsKvCQMbr8Tkug/NyCP2pty5FOQgFw="}]},"_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/wtsapi32_2.0.1_1782438233321_0.8936282985523314"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-09T04:48:26.255Z","modified":"2026-06-26T01:43:53.596Z","1.0.0":"2026-04-09T04:48:26.483Z","2.0.0":"2026-06-26T01:06:48.300Z","2.0.1":"2026-06-26T01:43:53.453Z"},"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","wtsapi32","terminal-services","remote-desktop","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/wtsapi32"},"description":"Zero-dependency, zero-overhead Win32 WTSAPI32 bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/wtsapi32\n\nZero-dependency, zero-overhead Win32 Wtsapi32 bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/wtsapi32` exposes the `wtsapi32.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Wtsapi32`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `wtsapi32.dll` (sessions, processes, virtual channels, remote desktop, and more).\n- In-source docs in `structs/Wtsapi32.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Wtsapi32.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/Wtsapi32.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/wtsapi32\n```\n\n## Quick Start\n\n```ts\nimport { ptr, read } from 'bun:ffi';\nimport Wtsapi32, { WTS_CURRENT_SERVER_HANDLE, WTS_INFO_CLASS } from '@bun-win32/wtsapi32';\n\n// Enumerate sessions on the local machine\nconst ppSessionInfo = Buffer.alloc(8);\nconst pCount = Buffer.alloc(4);\n\nWtsapi32.WTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE, 0, 1, ppSessionInfo.ptr, pCount.ptr);\nconst sessionCount = pCount.readUInt32LE(0);\nconsole.log(`Found ${sessionCount} sessions`);\n\n// Query user name for the current session\nconst ppBuffer = Buffer.alloc(8);\nconst pBytes = Buffer.alloc(4);\nWtsapi32.WTSQuerySessionInformationW(\n  WTS_CURRENT_SERVER_HANDLE,\n  0xFFFFFFFF, // WTS_CURRENT_SESSION\n  WTS_INFO_CLASS.WTSUserName,\n  ppBuffer.ptr,\n  pBytes.ptr,\n);\nconst bufPtr = ppBuffer.readBigUInt64LE(0);\nconst userName = new TextDecoder('utf-16le')\n  .decode(Buffer.from(read.ptr(ptr(bufPtr)!, 0, pBytes.readUInt32LE(0))!))\n  .replace(/\\0.*$/, '');\nconsole.log(`Current user: ${userName}`);\n\n// Cleanup\nWtsapi32.WTSFreeMemory(ptr(ppSessionInfo.readBigUInt64LE(0))!);\nWtsapi32.WTSFreeMemory(ptr(bufPtr)!);\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:session-diagnostic\nbun run example:session-monitor\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Wtsapi32.Preload()`.\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"}