@bun-win32/wtsapi32 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI.md +71 -0
- package/README.md +81 -0
- package/index.ts +4 -0
- package/package.json +59 -0
- package/structs/Wtsapi32.ts +474 -0
- package/types/Wtsapi32.ts +127 -0
package/AI.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# AI Guide for @bun-win32/wtsapi32
|
|
2
|
+
|
|
3
|
+
How to use this package, not what the Win32 API does.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import Wtsapi32, { SomeFlag } from '@bun-win32/wtsapi32';
|
|
9
|
+
|
|
10
|
+
// Methods bind lazily on first call
|
|
11
|
+
const result = Wtsapi32.SomeFunctionW(arg1, arg2);
|
|
12
|
+
|
|
13
|
+
// Preload: array, single string, or no args (all symbols)
|
|
14
|
+
Wtsapi32.Preload(['SomeFunctionW', 'AnotherFunction']);
|
|
15
|
+
Wtsapi32.Preload('SomeFunctionW');
|
|
16
|
+
Wtsapi32.Preload();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Where To Look
|
|
20
|
+
|
|
21
|
+
| Need | Read |
|
|
22
|
+
| --------------------------------- | --------------------- |
|
|
23
|
+
| Find a method or its MS Docs link | `structs/Wtsapi32.ts` |
|
|
24
|
+
| Find types, enums, constants | `types/Wtsapi32.ts` |
|
|
25
|
+
| Quick examples | `README.md` |
|
|
26
|
+
|
|
27
|
+
`index.ts` re-exports the class and all types - import from `@bun-win32/wtsapi32` directly.
|
|
28
|
+
|
|
29
|
+
## Calling Convention
|
|
30
|
+
|
|
31
|
+
All documented `wtsapi32.dll` exports are bound. Each method maps 1:1 to its DLL export. Names, parameter names, and order match Microsoft Docs.
|
|
32
|
+
|
|
33
|
+
### Strings
|
|
34
|
+
|
|
35
|
+
`W` methods take UTF-16LE NUL-terminated buffers. `A` methods take ANSI strings.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const wide = Buffer.from('Hello\0', 'utf16le'); // LPCWSTR
|
|
39
|
+
Wtsapi32.SomeFunctionW(wide.ptr);
|
|
40
|
+
|
|
41
|
+
// Reading a wide string back from a buffer:
|
|
42
|
+
const text = new TextDecoder('utf-16').decode(buf).replace(/\0.*$/, '');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Return types
|
|
46
|
+
|
|
47
|
+
- `HANDLE`, `HWND`, etc. -> `bigint`
|
|
48
|
+
- `DWORD`, `UINT`, `BOOL`, `INT`, `LONG` -> `number`
|
|
49
|
+
- `LPVOID`, `LPWSTR`, etc. -> `Pointer`
|
|
50
|
+
- Win32 `BOOL` is `number` (0 or non-zero), **not** JS `boolean`. Do not compare with `=== true`.
|
|
51
|
+
|
|
52
|
+
### Pointers, handles, out-parameters
|
|
53
|
+
|
|
54
|
+
- **Pointer** params (`LP*`, `P*`, `Pointer`): pass `buffer.ptr` from a caller-allocated `Buffer`.
|
|
55
|
+
- **Handle** params (`HANDLE`, `HWND`, etc.): pass a `bigint` value.
|
|
56
|
+
- **Out-parameters**: allocate a `Buffer`, pass `.ptr`, read the result after the call.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const out = Buffer.alloc(4);
|
|
60
|
+
Wtsapi32.SomeFunction(out.ptr);
|
|
61
|
+
const value = out.readUInt32LE(0);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Nullability
|
|
65
|
+
|
|
66
|
+
- `| NULL` in a signature -> pass `null` (optional pointer).
|
|
67
|
+
- `| 0n` in a signature -> pass `0n` (optional handle).
|
|
68
|
+
|
|
69
|
+
## Errors and Cleanup
|
|
70
|
+
|
|
71
|
+
Return values are raw. If the Win32 function uses last-error semantics, read via `GetLastError()`. Resource cleanup is your responsibility - same as raw Win32.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @bun-win32/wtsapi32
|
|
2
|
+
|
|
3
|
+
Zero-dependency, zero-overhead Win32 Wtsapi32 bindings for [Bun](https://bun.sh) on Windows.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@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()`.
|
|
8
|
+
|
|
9
|
+
The bindings are strongly typed for a smooth DX in TypeScript.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.
|
|
14
|
+
- Direct FFI to `wtsapi32.dll` (sessions, processes, virtual channels, remote desktop, and more).
|
|
15
|
+
- In-source docs in `structs/Wtsapi32.ts` with links to Microsoft Docs.
|
|
16
|
+
- Lazy binding on first call; optional eager preload (`Wtsapi32.Preload()`).
|
|
17
|
+
- No wrapper overhead; calls map 1:1 to native APIs.
|
|
18
|
+
- Strongly-typed Win32 aliases (see `types/Wtsapi32.ts`).
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- [Bun](https://bun.sh) runtime
|
|
23
|
+
- Windows 10 or later
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
bun add @bun-win32/wtsapi32
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { ptr, read } from 'bun:ffi';
|
|
35
|
+
import Wtsapi32, { WTS_CURRENT_SERVER_HANDLE, WTS_INFO_CLASS } from '@bun-win32/wtsapi32';
|
|
36
|
+
|
|
37
|
+
// Enumerate sessions on the local machine
|
|
38
|
+
const ppSessionInfo = Buffer.alloc(8);
|
|
39
|
+
const pCount = Buffer.alloc(4);
|
|
40
|
+
|
|
41
|
+
Wtsapi32.WTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE, 0, 1, ppSessionInfo.ptr, pCount.ptr);
|
|
42
|
+
const sessionCount = pCount.readUInt32LE(0);
|
|
43
|
+
console.log(`Found ${sessionCount} sessions`);
|
|
44
|
+
|
|
45
|
+
// Query user name for the current session
|
|
46
|
+
const ppBuffer = Buffer.alloc(8);
|
|
47
|
+
const pBytes = Buffer.alloc(4);
|
|
48
|
+
Wtsapi32.WTSQuerySessionInformationW(
|
|
49
|
+
WTS_CURRENT_SERVER_HANDLE,
|
|
50
|
+
0xFFFFFFFF, // WTS_CURRENT_SESSION
|
|
51
|
+
WTS_INFO_CLASS.WTSUserName,
|
|
52
|
+
ppBuffer.ptr,
|
|
53
|
+
pBytes.ptr,
|
|
54
|
+
);
|
|
55
|
+
const bufPtr = ppBuffer.readBigUInt64LE(0);
|
|
56
|
+
const userName = new TextDecoder('utf-16le')
|
|
57
|
+
.decode(Buffer.from(read.ptr(ptr(bufPtr)!, 0, pBytes.readUInt32LE(0))!))
|
|
58
|
+
.replace(/\0.*$/, '');
|
|
59
|
+
console.log(`Current user: ${userName}`);
|
|
60
|
+
|
|
61
|
+
// Cleanup
|
|
62
|
+
Wtsapi32.WTSFreeMemory(ptr(ppSessionInfo.readBigUInt64LE(0))!);
|
|
63
|
+
Wtsapi32.WTSFreeMemory(ptr(bufPtr)!);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> 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.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
Run the included examples:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
bun run example:session-diagnostic
|
|
75
|
+
bun run example:session-monitor
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- Either rely on lazy binding or call `Wtsapi32.Preload()`.
|
|
81
|
+
- Windows only. Bun runtime required.
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Stev Peifer <stev@bell.net>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/ObscuritySRL/bun-win32/issues"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@bun-win32/core": "1.1.2"
|
|
8
|
+
},
|
|
9
|
+
"description": "Zero-dependency, zero-overhead Win32 WTSAPI32 bindings for Bun (FFI) on Windows.",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/bun": "latest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./index.ts"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"module": "index.ts",
|
|
18
|
+
"name": "@bun-win32/wtsapi32",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"typescript": "^5"
|
|
21
|
+
},
|
|
22
|
+
"private": false,
|
|
23
|
+
"homepage": "https://github.com/ObscuritySRL/bun-win32#readme",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git://github.com/ObscuritySRL/bun-win32.git",
|
|
27
|
+
"directory": "packages/wtsapi32"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"main": "./index.ts",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"bun",
|
|
34
|
+
"ffi",
|
|
35
|
+
"win32",
|
|
36
|
+
"windows",
|
|
37
|
+
"wtsapi32",
|
|
38
|
+
"terminal-services",
|
|
39
|
+
"remote-desktop",
|
|
40
|
+
"bindings",
|
|
41
|
+
"typescript",
|
|
42
|
+
"dll"
|
|
43
|
+
],
|
|
44
|
+
"files": [
|
|
45
|
+
"AI.md",
|
|
46
|
+
"README.md",
|
|
47
|
+
"index.ts",
|
|
48
|
+
"structs/*.ts",
|
|
49
|
+
"types/*.ts"
|
|
50
|
+
],
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"engines": {
|
|
53
|
+
"bun": ">=1.1.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"example:session-diagnostic": "bun ./example/session-diagnostic.ts",
|
|
57
|
+
"example:session-monitor": "bun ./example/session-monitor.ts"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { type FFIFunction, FFIType } from 'bun:ffi';
|
|
2
|
+
|
|
3
|
+
import { Win32 } from '@bun-win32/core';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
BOOL,
|
|
7
|
+
BYTE,
|
|
8
|
+
DWORD,
|
|
9
|
+
HANDLE,
|
|
10
|
+
HRESULT,
|
|
11
|
+
HWND,
|
|
12
|
+
LPDWORD,
|
|
13
|
+
LPSTR,
|
|
14
|
+
LPWSTR,
|
|
15
|
+
NULL,
|
|
16
|
+
PBOOL,
|
|
17
|
+
PBYTE,
|
|
18
|
+
PCHAR,
|
|
19
|
+
PHANDLE,
|
|
20
|
+
PSECURITY_DESCRIPTOR,
|
|
21
|
+
PULONG,
|
|
22
|
+
PVOID,
|
|
23
|
+
PWTSLISTENERCONFIGA,
|
|
24
|
+
PWTSLISTENERCONFIGW,
|
|
25
|
+
PWTSLISTENERNAMEA,
|
|
26
|
+
PWTSLISTENERNAMEW,
|
|
27
|
+
SECURITY_INFORMATION,
|
|
28
|
+
ULONG,
|
|
29
|
+
USHORT,
|
|
30
|
+
WTS_CONFIG_CLASS,
|
|
31
|
+
WTS_INFO_CLASS,
|
|
32
|
+
WTS_TYPE_CLASS,
|
|
33
|
+
WTS_VIRTUAL_CLASS,
|
|
34
|
+
} from '../types/Wtsapi32';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Thin, lazy-loaded FFI bindings for `wtsapi32.dll`.
|
|
38
|
+
*
|
|
39
|
+
* Each static method corresponds one-to-one with a Win32 export declared in `Symbols`.
|
|
40
|
+
* The first call to a method binds the underlying native symbol via `bun:ffi` and
|
|
41
|
+
* memoizes it on the class for subsequent calls. For bulk, up-front binding, use `Preload`.
|
|
42
|
+
*
|
|
43
|
+
* Symbols are defined with explicit `FFIType` signatures and kept alphabetized.
|
|
44
|
+
* You normally do not access `Symbols` directly; call the static methods or preload
|
|
45
|
+
* a subset for hot paths.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import Wtsapi32 from './structs/Wtsapi32';
|
|
50
|
+
*
|
|
51
|
+
* // Lazy: bind on first call
|
|
52
|
+
* const result = Wtsapi32.WTSEnumerateSessionsW(0n, 0, 1, ppSessionInfo.ptr, pCount.ptr);
|
|
53
|
+
*
|
|
54
|
+
* // Or preload a subset to avoid per-symbol lazy binding cost
|
|
55
|
+
* Wtsapi32.Preload(['WTSEnumerateSessionsW', 'WTSFreeMemory']);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
class Wtsapi32 extends Win32 {
|
|
59
|
+
protected static override name = 'wtsapi32.dll';
|
|
60
|
+
|
|
61
|
+
/** @inheritdoc */
|
|
62
|
+
protected static override readonly Symbols = {
|
|
63
|
+
WTSCloseServer: { args: [FFIType.u64], returns: FFIType.void },
|
|
64
|
+
WTSConnectSessionA: { args: [FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
65
|
+
WTSConnectSessionW: { args: [FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
66
|
+
WTSCreateListenerA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
67
|
+
WTSCreateListenerW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
68
|
+
WTSDisconnectSession: { args: [FFIType.u64, FFIType.u32, FFIType.i32], returns: FFIType.i32 },
|
|
69
|
+
WTSEnableChildSessions: { args: [FFIType.i32], returns: FFIType.i32 },
|
|
70
|
+
WTSEnumerateListenersA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
71
|
+
WTSEnumerateListenersW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
72
|
+
WTSEnumerateProcessesA: { args: [FFIType.u64, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
73
|
+
WTSEnumerateProcessesExA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
74
|
+
WTSEnumerateProcessesExW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
75
|
+
WTSEnumerateProcessesW: { args: [FFIType.u64, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
76
|
+
WTSEnumerateServersA: { args: [FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
77
|
+
WTSEnumerateServersW: { args: [FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
78
|
+
WTSEnumerateSessionsA: { args: [FFIType.u64, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
79
|
+
WTSEnumerateSessionsExA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
80
|
+
WTSEnumerateSessionsExW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
81
|
+
WTSEnumerateSessionsW: { args: [FFIType.u64, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
82
|
+
WTSFreeMemory: { args: [FFIType.ptr], returns: FFIType.void },
|
|
83
|
+
WTSFreeMemoryExA: { args: [FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
84
|
+
WTSFreeMemoryExW: { args: [FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
85
|
+
WTSGetChildSessionId: { args: [FFIType.ptr], returns: FFIType.i32 },
|
|
86
|
+
WTSGetListenerSecurityA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
87
|
+
WTSGetListenerSecurityW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
88
|
+
WTSIsChildSessionsEnabled: { args: [FFIType.ptr], returns: FFIType.i32 },
|
|
89
|
+
WTSLogoffSession: { args: [FFIType.u64, FFIType.u32, FFIType.i32], returns: FFIType.i32 },
|
|
90
|
+
WTSOpenServerA: { args: [FFIType.ptr], returns: FFIType.u64 },
|
|
91
|
+
WTSOpenServerExA: { args: [FFIType.ptr], returns: FFIType.u64 },
|
|
92
|
+
WTSOpenServerExW: { args: [FFIType.ptr], returns: FFIType.u64 },
|
|
93
|
+
WTSOpenServerW: { args: [FFIType.ptr], returns: FFIType.u64 },
|
|
94
|
+
WTSQueryListenerConfigA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
95
|
+
WTSQueryListenerConfigW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
96
|
+
WTSQuerySessionInformationA: { args: [FFIType.u64, FFIType.u32, FFIType.i32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
97
|
+
WTSQuerySessionInformationW: { args: [FFIType.u64, FFIType.u32, FFIType.i32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
98
|
+
WTSQueryUserConfigA: { args: [FFIType.ptr, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
99
|
+
WTSQueryUserConfigW: { args: [FFIType.ptr, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
100
|
+
WTSQueryUserToken: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
101
|
+
WTSRegisterSessionNotification: { args: [FFIType.u64, FFIType.u32], returns: FFIType.i32 },
|
|
102
|
+
WTSRegisterSessionNotificationEx: { args: [FFIType.u64, FFIType.u64, FFIType.u32], returns: FFIType.i32 },
|
|
103
|
+
WTSSendMessageA: { args: [FFIType.u64, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
104
|
+
WTSSendMessageW: { args: [FFIType.u64, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
105
|
+
WTSSetListenerSecurityA: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
106
|
+
WTSSetListenerSecurityW: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
107
|
+
WTSSetRenderHint: { args: [FFIType.ptr, FFIType.u64, FFIType.u32, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
108
|
+
WTSSetSessionInformationA: { args: [FFIType.u64, FFIType.u32, FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
109
|
+
WTSSetSessionInformationW: { args: [FFIType.u64, FFIType.u32, FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
110
|
+
WTSSetUserConfigA: { args: [FFIType.ptr, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
111
|
+
WTSSetUserConfigW: { args: [FFIType.ptr, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
112
|
+
WTSShutdownSystem: { args: [FFIType.u64, FFIType.u32], returns: FFIType.i32 },
|
|
113
|
+
WTSStartRemoteControlSessionA: { args: [FFIType.ptr, FFIType.u32, FFIType.u8, FFIType.u16], returns: FFIType.i32 },
|
|
114
|
+
WTSStartRemoteControlSessionW: { args: [FFIType.ptr, FFIType.u32, FFIType.u8, FFIType.u16], returns: FFIType.i32 },
|
|
115
|
+
WTSStopRemoteControlSession: { args: [FFIType.u32], returns: FFIType.i32 },
|
|
116
|
+
WTSTerminateProcess: { args: [FFIType.u64, FFIType.u32, FFIType.u32], returns: FFIType.i32 },
|
|
117
|
+
WTSUnRegisterSessionNotification: { args: [FFIType.u64], returns: FFIType.i32 },
|
|
118
|
+
WTSUnRegisterSessionNotificationEx: { args: [FFIType.u64, FFIType.u64], returns: FFIType.i32 },
|
|
119
|
+
WTSVirtualChannelClose: { args: [FFIType.u64], returns: FFIType.i32 },
|
|
120
|
+
WTSVirtualChannelOpen: { args: [FFIType.u64, FFIType.u32, FFIType.ptr], returns: FFIType.u64 },
|
|
121
|
+
WTSVirtualChannelOpenEx: { args: [FFIType.u32, FFIType.ptr, FFIType.u32], returns: FFIType.u64 },
|
|
122
|
+
WTSVirtualChannelPurgeInput: { args: [FFIType.u64], returns: FFIType.i32 },
|
|
123
|
+
WTSVirtualChannelPurgeOutput: { args: [FFIType.u64], returns: FFIType.i32 },
|
|
124
|
+
WTSVirtualChannelQuery: { args: [FFIType.u64, FFIType.i32, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
125
|
+
WTSVirtualChannelRead: { args: [FFIType.u64, FFIType.u32, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
126
|
+
WTSVirtualChannelWrite: { args: [FFIType.u64, FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
127
|
+
WTSWaitSystemEvent: { args: [FFIType.u64, FFIType.u32, FFIType.ptr], returns: FFIType.i32 },
|
|
128
|
+
} as const satisfies Record<string, FFIFunction>;
|
|
129
|
+
|
|
130
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtscloseserver
|
|
131
|
+
public static WTSCloseServer(hServer: HANDLE): void {
|
|
132
|
+
return Wtsapi32.Load('WTSCloseServer')(hServer);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsconnectsessiona
|
|
136
|
+
public static WTSConnectSessionA(LogonId: ULONG, TargetLogonId: ULONG, pPassword: LPSTR, bWait: BOOL): BOOL {
|
|
137
|
+
return Wtsapi32.Load('WTSConnectSessionA')(LogonId, TargetLogonId, pPassword, bWait);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsconnectsessionw
|
|
141
|
+
public static WTSConnectSessionW(LogonId: ULONG, TargetLogonId: ULONG, pPassword: LPWSTR, bWait: BOOL): BOOL {
|
|
142
|
+
return Wtsapi32.Load('WTSConnectSessionW')(LogonId, TargetLogonId, pPassword, bWait);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtscreatelistenera
|
|
146
|
+
public static WTSCreateListenerA(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPSTR, pBuffer: PWTSLISTENERCONFIGA, flag: DWORD): BOOL {
|
|
147
|
+
return Wtsapi32.Load('WTSCreateListenerA')(hServer, pReserved, Reserved, pListenerName, pBuffer, flag);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtscreatelistenerw
|
|
151
|
+
public static WTSCreateListenerW(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPWSTR, pBuffer: PWTSLISTENERCONFIGW, flag: DWORD): BOOL {
|
|
152
|
+
return Wtsapi32.Load('WTSCreateListenerW')(hServer, pReserved, Reserved, pListenerName, pBuffer, flag);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsdisconnectsession
|
|
156
|
+
public static WTSDisconnectSession(hServer: HANDLE, SessionId: DWORD, bWait: BOOL): BOOL {
|
|
157
|
+
return Wtsapi32.Load('WTSDisconnectSession')(hServer, SessionId, bWait);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenablechildsessions
|
|
161
|
+
public static WTSEnableChildSessions(bEnable: BOOL): BOOL {
|
|
162
|
+
return Wtsapi32.Load('WTSEnableChildSessions')(bEnable);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratelistenersa
|
|
166
|
+
public static WTSEnumerateListenersA(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListeners: PWTSLISTENERNAMEA | NULL, pCount: LPDWORD): BOOL {
|
|
167
|
+
return Wtsapi32.Load('WTSEnumerateListenersA')(hServer, pReserved, Reserved, pListeners, pCount);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratelistenersw
|
|
171
|
+
public static WTSEnumerateListenersW(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListeners: PWTSLISTENERNAMEW | NULL, pCount: LPDWORD): BOOL {
|
|
172
|
+
return Wtsapi32.Load('WTSEnumerateListenersW')(hServer, pReserved, Reserved, pListeners, pCount);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateprocessesa
|
|
176
|
+
public static WTSEnumerateProcessesA(hServer: HANDLE, Reserved: DWORD, Version: DWORD, ppProcessInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
177
|
+
return Wtsapi32.Load('WTSEnumerateProcessesA')(hServer, Reserved, Version, ppProcessInfo, pCount);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateprocessesexa
|
|
181
|
+
public static WTSEnumerateProcessesExA(hServer: HANDLE, pLevel: LPDWORD, SessionId: DWORD, ppProcessInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
182
|
+
return Wtsapi32.Load('WTSEnumerateProcessesExA')(hServer, pLevel, SessionId, ppProcessInfo, pCount);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateprocessesexw
|
|
186
|
+
public static WTSEnumerateProcessesExW(hServer: HANDLE, pLevel: LPDWORD, SessionId: DWORD, ppProcessInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
187
|
+
return Wtsapi32.Load('WTSEnumerateProcessesExW')(hServer, pLevel, SessionId, ppProcessInfo, pCount);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateprocessesw
|
|
191
|
+
public static WTSEnumerateProcessesW(hServer: HANDLE, Reserved: DWORD, Version: DWORD, ppProcessInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
192
|
+
return Wtsapi32.Load('WTSEnumerateProcessesW')(hServer, Reserved, Version, ppProcessInfo, pCount);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateserversa
|
|
196
|
+
public static WTSEnumerateServersA(pDomainName: LPSTR | NULL, Reserved: DWORD, Version: DWORD, ppServerInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
197
|
+
return Wtsapi32.Load('WTSEnumerateServersA')(pDomainName, Reserved, Version, ppServerInfo, pCount);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumerateserversw
|
|
201
|
+
public static WTSEnumerateServersW(pDomainName: LPWSTR | NULL, Reserved: DWORD, Version: DWORD, ppServerInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
202
|
+
return Wtsapi32.Load('WTSEnumerateServersW')(pDomainName, Reserved, Version, ppServerInfo, pCount);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratesessionsa
|
|
206
|
+
public static WTSEnumerateSessionsA(hServer: HANDLE, Reserved: DWORD, Version: DWORD, ppSessionInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
207
|
+
return Wtsapi32.Load('WTSEnumerateSessionsA')(hServer, Reserved, Version, ppSessionInfo, pCount);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratesessionsexa
|
|
211
|
+
public static WTSEnumerateSessionsExA(hServer: HANDLE, pLevel: LPDWORD, Filter: DWORD, ppSessionInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
212
|
+
return Wtsapi32.Load('WTSEnumerateSessionsExA')(hServer, pLevel, Filter, ppSessionInfo, pCount);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratesessionsexw
|
|
216
|
+
public static WTSEnumerateSessionsExW(hServer: HANDLE, pLevel: LPDWORD, Filter: DWORD, ppSessionInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
217
|
+
return Wtsapi32.Load('WTSEnumerateSessionsExW')(hServer, pLevel, Filter, ppSessionInfo, pCount);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratesessionsw
|
|
221
|
+
public static WTSEnumerateSessionsW(hServer: HANDLE, Reserved: DWORD, Version: DWORD, ppSessionInfo: PVOID, pCount: LPDWORD): BOOL {
|
|
222
|
+
return Wtsapi32.Load('WTSEnumerateSessionsW')(hServer, Reserved, Version, ppSessionInfo, pCount);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsfreememory
|
|
226
|
+
public static WTSFreeMemory(pMemory: PVOID): void {
|
|
227
|
+
return Wtsapi32.Load('WTSFreeMemory')(pMemory);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsfreememoryexa
|
|
231
|
+
public static WTSFreeMemoryExA(WTSTypeClass: WTS_TYPE_CLASS, pMemory: PVOID, NumberOfEntries: ULONG): BOOL {
|
|
232
|
+
return Wtsapi32.Load('WTSFreeMemoryExA')(WTSTypeClass, pMemory, NumberOfEntries);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsfreememoryexw
|
|
236
|
+
public static WTSFreeMemoryExW(WTSTypeClass: WTS_TYPE_CLASS, pMemory: PVOID, NumberOfEntries: ULONG): BOOL {
|
|
237
|
+
return Wtsapi32.Load('WTSFreeMemoryExW')(WTSTypeClass, pMemory, NumberOfEntries);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsgetchildsessionid
|
|
241
|
+
public static WTSGetChildSessionId(pSessionId: PULONG): BOOL {
|
|
242
|
+
return Wtsapi32.Load('WTSGetChildSessionId')(pSessionId);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsgetlistenersecuritya
|
|
246
|
+
public static WTSGetListenerSecurityA(
|
|
247
|
+
hServer: HANDLE,
|
|
248
|
+
pReserved: PVOID | NULL,
|
|
249
|
+
Reserved: DWORD,
|
|
250
|
+
pListenerName: LPSTR,
|
|
251
|
+
SecurityInformation: SECURITY_INFORMATION,
|
|
252
|
+
pSecurityDescriptor: PSECURITY_DESCRIPTOR | NULL,
|
|
253
|
+
nLength: DWORD,
|
|
254
|
+
lpnLengthNeeded: LPDWORD,
|
|
255
|
+
): BOOL {
|
|
256
|
+
return Wtsapi32.Load('WTSGetListenerSecurityA')(hServer, pReserved, Reserved, pListenerName, SecurityInformation, pSecurityDescriptor, nLength, lpnLengthNeeded);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsgetlistenersecurityw
|
|
260
|
+
public static WTSGetListenerSecurityW(
|
|
261
|
+
hServer: HANDLE,
|
|
262
|
+
pReserved: PVOID | NULL,
|
|
263
|
+
Reserved: DWORD,
|
|
264
|
+
pListenerName: LPWSTR,
|
|
265
|
+
SecurityInformation: SECURITY_INFORMATION,
|
|
266
|
+
pSecurityDescriptor: PSECURITY_DESCRIPTOR | NULL,
|
|
267
|
+
nLength: DWORD,
|
|
268
|
+
lpnLengthNeeded: LPDWORD,
|
|
269
|
+
): BOOL {
|
|
270
|
+
return Wtsapi32.Load('WTSGetListenerSecurityW')(hServer, pReserved, Reserved, pListenerName, SecurityInformation, pSecurityDescriptor, nLength, lpnLengthNeeded);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsischildsessionsenabled
|
|
274
|
+
public static WTSIsChildSessionsEnabled(pbEnabled: PBOOL): BOOL {
|
|
275
|
+
return Wtsapi32.Load('WTSIsChildSessionsEnabled')(pbEnabled);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtslogoffsession
|
|
279
|
+
public static WTSLogoffSession(hServer: HANDLE, SessionId: DWORD, bWait: BOOL): BOOL {
|
|
280
|
+
return Wtsapi32.Load('WTSLogoffSession')(hServer, SessionId, bWait);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenservera
|
|
284
|
+
public static WTSOpenServerA(pServerName: LPSTR): HANDLE {
|
|
285
|
+
return Wtsapi32.Load('WTSOpenServerA')(pServerName);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenserverexa
|
|
289
|
+
public static WTSOpenServerExA(pServerName: LPSTR): HANDLE {
|
|
290
|
+
return Wtsapi32.Load('WTSOpenServerExA')(pServerName);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenserverexw
|
|
294
|
+
public static WTSOpenServerExW(pServerName: LPWSTR): HANDLE {
|
|
295
|
+
return Wtsapi32.Load('WTSOpenServerExW')(pServerName);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenserverw
|
|
299
|
+
public static WTSOpenServerW(pServerName: LPWSTR): HANDLE {
|
|
300
|
+
return Wtsapi32.Load('WTSOpenServerW')(pServerName);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsquerylistenerconfiga
|
|
304
|
+
public static WTSQueryListenerConfigA(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPSTR, pBuffer: PWTSLISTENERCONFIGA): BOOL {
|
|
305
|
+
return Wtsapi32.Load('WTSQueryListenerConfigA')(hServer, pReserved, Reserved, pListenerName, pBuffer);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsquerylistenerconfigw
|
|
309
|
+
public static WTSQueryListenerConfigW(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPWSTR, pBuffer: PWTSLISTENERCONFIGW): BOOL {
|
|
310
|
+
return Wtsapi32.Load('WTSQueryListenerConfigW')(hServer, pReserved, Reserved, pListenerName, pBuffer);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsquerysessioninformationa
|
|
314
|
+
public static WTSQuerySessionInformationA(hServer: HANDLE, SessionId: DWORD, WTSInfoClass: WTS_INFO_CLASS, ppBuffer: PVOID, pBytesReturned: LPDWORD): BOOL {
|
|
315
|
+
return Wtsapi32.Load('WTSQuerySessionInformationA')(hServer, SessionId, WTSInfoClass, ppBuffer, pBytesReturned);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsquerysessioninformationw
|
|
319
|
+
public static WTSQuerySessionInformationW(hServer: HANDLE, SessionId: DWORD, WTSInfoClass: WTS_INFO_CLASS, ppBuffer: PVOID, pBytesReturned: LPDWORD): BOOL {
|
|
320
|
+
return Wtsapi32.Load('WTSQuerySessionInformationW')(hServer, SessionId, WTSInfoClass, ppBuffer, pBytesReturned);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsqueryuserconfiga
|
|
324
|
+
public static WTSQueryUserConfigA(pServerName: LPSTR, pUserName: LPSTR, WTSConfigClass: WTS_CONFIG_CLASS, ppBuffer: PVOID, pBytesReturned: LPDWORD): BOOL {
|
|
325
|
+
return Wtsapi32.Load('WTSQueryUserConfigA')(pServerName, pUserName, WTSConfigClass, ppBuffer, pBytesReturned);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsqueryuserconfigw
|
|
329
|
+
public static WTSQueryUserConfigW(pServerName: LPWSTR, pUserName: LPWSTR, WTSConfigClass: WTS_CONFIG_CLASS, ppBuffer: PVOID, pBytesReturned: LPDWORD): BOOL {
|
|
330
|
+
return Wtsapi32.Load('WTSQueryUserConfigW')(pServerName, pUserName, WTSConfigClass, ppBuffer, pBytesReturned);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsqueryusertoken
|
|
334
|
+
public static WTSQueryUserToken(SessionId: ULONG, phToken: PHANDLE): BOOL {
|
|
335
|
+
return Wtsapi32.Load('WTSQueryUserToken')(SessionId, phToken);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsregistersessionnotification
|
|
339
|
+
public static WTSRegisterSessionNotification(hWnd: HWND, dwFlags: DWORD): BOOL {
|
|
340
|
+
return Wtsapi32.Load('WTSRegisterSessionNotification')(hWnd, dwFlags);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsregistersessionnotificationex
|
|
344
|
+
public static WTSRegisterSessionNotificationEx(hServer: HANDLE, hWnd: HWND, dwFlags: DWORD): BOOL {
|
|
345
|
+
return Wtsapi32.Load('WTSRegisterSessionNotificationEx')(hServer, hWnd, dwFlags);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssendmessagea
|
|
349
|
+
public static WTSSendMessageA(hServer: HANDLE, SessionId: DWORD, pTitle: LPSTR, TitleLength: DWORD, pMessage: LPSTR, MessageLength: DWORD, Style: DWORD, Timeout: DWORD, pResponse: LPDWORD, bWait: BOOL): BOOL {
|
|
350
|
+
return Wtsapi32.Load('WTSSendMessageA')(hServer, SessionId, pTitle, TitleLength, pMessage, MessageLength, Style, Timeout, pResponse, bWait);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssendmessagew
|
|
354
|
+
public static WTSSendMessageW(hServer: HANDLE, SessionId: DWORD, pTitle: LPWSTR, TitleLength: DWORD, pMessage: LPWSTR, MessageLength: DWORD, Style: DWORD, Timeout: DWORD, pResponse: LPDWORD, bWait: BOOL): BOOL {
|
|
355
|
+
return Wtsapi32.Load('WTSSendMessageW')(hServer, SessionId, pTitle, TitleLength, pMessage, MessageLength, Style, Timeout, pResponse, bWait);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetlistenersecuritya
|
|
359
|
+
public static WTSSetListenerSecurityA(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPSTR, SecurityInformation: SECURITY_INFORMATION, pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL {
|
|
360
|
+
return Wtsapi32.Load('WTSSetListenerSecurityA')(hServer, pReserved, Reserved, pListenerName, SecurityInformation, pSecurityDescriptor);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetlistenersecurityw
|
|
364
|
+
public static WTSSetListenerSecurityW(hServer: HANDLE, pReserved: PVOID | NULL, Reserved: DWORD, pListenerName: LPWSTR, SecurityInformation: SECURITY_INFORMATION, pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL {
|
|
365
|
+
return Wtsapi32.Load('WTSSetListenerSecurityW')(hServer, pReserved, Reserved, pListenerName, SecurityInformation, pSecurityDescriptor);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtshintapi/nf-wtshintapi-wtssetrenderhint
|
|
369
|
+
public static WTSSetRenderHint(pRenderHintID: PVOID, hwndOwner: HWND, renderHintType: DWORD, cbHintDataLength: DWORD, pHintData: PBYTE | NULL): HRESULT {
|
|
370
|
+
return Wtsapi32.Load('WTSSetRenderHint')(pRenderHintID, hwndOwner, renderHintType, cbHintDataLength, pHintData);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetsessioninformationa
|
|
374
|
+
public static WTSSetSessionInformationA(hServer: HANDLE, SessionId: DWORD, WTSInfoClass: WTS_INFO_CLASS, pBuffer: LPSTR, DataLength: DWORD): BOOL {
|
|
375
|
+
return Wtsapi32.Load('WTSSetSessionInformationA')(hServer, SessionId, WTSInfoClass, pBuffer, DataLength);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetsessioninformationw
|
|
379
|
+
public static WTSSetSessionInformationW(hServer: HANDLE, SessionId: DWORD, WTSInfoClass: WTS_INFO_CLASS, pBuffer: LPWSTR, DataLength: DWORD): BOOL {
|
|
380
|
+
return Wtsapi32.Load('WTSSetSessionInformationW')(hServer, SessionId, WTSInfoClass, pBuffer, DataLength);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetuserconfiga
|
|
384
|
+
public static WTSSetUserConfigA(pServerName: LPSTR, pUserName: LPSTR, WTSConfigClass: WTS_CONFIG_CLASS, pBuffer: LPSTR, DataLength: DWORD): BOOL {
|
|
385
|
+
return Wtsapi32.Load('WTSSetUserConfigA')(pServerName, pUserName, WTSConfigClass, pBuffer, DataLength);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssetuserconfigw
|
|
389
|
+
public static WTSSetUserConfigW(pServerName: LPWSTR, pUserName: LPWSTR, WTSConfigClass: WTS_CONFIG_CLASS, pBuffer: LPWSTR, DataLength: DWORD): BOOL {
|
|
390
|
+
return Wtsapi32.Load('WTSSetUserConfigW')(pServerName, pUserName, WTSConfigClass, pBuffer, DataLength);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsshutdownsystem
|
|
394
|
+
public static WTSShutdownSystem(hServer: HANDLE, ShutdownFlag: DWORD): BOOL {
|
|
395
|
+
return Wtsapi32.Load('WTSShutdownSystem')(hServer, ShutdownFlag);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsstartremotecontrolsessiona
|
|
399
|
+
public static WTSStartRemoteControlSessionA(pTargetServerName: LPSTR, TargetLogonId: ULONG, HotkeyVk: BYTE, HotkeyModifiers: USHORT): BOOL {
|
|
400
|
+
return Wtsapi32.Load('WTSStartRemoteControlSessionA')(pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsstartremotecontrolsessionw
|
|
404
|
+
public static WTSStartRemoteControlSessionW(pTargetServerName: LPWSTR, TargetLogonId: ULONG, HotkeyVk: BYTE, HotkeyModifiers: USHORT): BOOL {
|
|
405
|
+
return Wtsapi32.Load('WTSStartRemoteControlSessionW')(pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsstopremotecontrolsession
|
|
409
|
+
public static WTSStopRemoteControlSession(LogonId: ULONG): BOOL {
|
|
410
|
+
return Wtsapi32.Load('WTSStopRemoteControlSession')(LogonId);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsterminateprocess
|
|
414
|
+
public static WTSTerminateProcess(hServer: HANDLE, ProcessId: DWORD, ExitCode: DWORD): BOOL {
|
|
415
|
+
return Wtsapi32.Load('WTSTerminateProcess')(hServer, ProcessId, ExitCode);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsunregistersessionnotification
|
|
419
|
+
public static WTSUnRegisterSessionNotification(hWnd: HWND): BOOL {
|
|
420
|
+
return Wtsapi32.Load('WTSUnRegisterSessionNotification')(hWnd);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsunregistersessionnotificationex
|
|
424
|
+
public static WTSUnRegisterSessionNotificationEx(hServer: HANDLE, hWnd: HWND): BOOL {
|
|
425
|
+
return Wtsapi32.Load('WTSUnRegisterSessionNotificationEx')(hServer, hWnd);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelclose
|
|
429
|
+
public static WTSVirtualChannelClose(hChannelHandle: HANDLE): BOOL {
|
|
430
|
+
return Wtsapi32.Load('WTSVirtualChannelClose')(hChannelHandle);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelopen
|
|
434
|
+
public static WTSVirtualChannelOpen(hServer: HANDLE, SessionId: DWORD, pVirtualName: LPSTR): HANDLE {
|
|
435
|
+
return Wtsapi32.Load('WTSVirtualChannelOpen')(hServer, SessionId, pVirtualName);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelopenex
|
|
439
|
+
public static WTSVirtualChannelOpenEx(SessionId: DWORD, pVirtualName: LPSTR, flags: DWORD): HANDLE {
|
|
440
|
+
return Wtsapi32.Load('WTSVirtualChannelOpenEx')(SessionId, pVirtualName, flags);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelpurgeinput
|
|
444
|
+
public static WTSVirtualChannelPurgeInput(hChannelHandle: HANDLE): BOOL {
|
|
445
|
+
return Wtsapi32.Load('WTSVirtualChannelPurgeInput')(hChannelHandle);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelpurgeoutput
|
|
449
|
+
public static WTSVirtualChannelPurgeOutput(hChannelHandle: HANDLE): BOOL {
|
|
450
|
+
return Wtsapi32.Load('WTSVirtualChannelPurgeOutput')(hChannelHandle);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelquery
|
|
454
|
+
public static WTSVirtualChannelQuery(hChannelHandle: HANDLE, WTSVirtualClass: WTS_VIRTUAL_CLASS, ppBuffer: PVOID, pBytesReturned: LPDWORD): BOOL {
|
|
455
|
+
return Wtsapi32.Load('WTSVirtualChannelQuery')(hChannelHandle, WTSVirtualClass, ppBuffer, pBytesReturned);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelread
|
|
459
|
+
public static WTSVirtualChannelRead(hChannelHandle: HANDLE, TimeOut: ULONG, Buffer: PCHAR, BufferSize: ULONG, pBytesRead: PULONG): BOOL {
|
|
460
|
+
return Wtsapi32.Load('WTSVirtualChannelRead')(hChannelHandle, TimeOut, Buffer, BufferSize, pBytesRead);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsvirtualchannelwrite
|
|
464
|
+
public static WTSVirtualChannelWrite(hChannelHandle: HANDLE, Buffer: PCHAR, Length: ULONG, pBytesWritten: PULONG): BOOL {
|
|
465
|
+
return Wtsapi32.Load('WTSVirtualChannelWrite')(hChannelHandle, Buffer, Length, pBytesWritten);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtswaitsystemevent
|
|
469
|
+
public static WTSWaitSystemEvent(hServer: HANDLE, EventMask: DWORD, pEventFlags: LPDWORD): BOOL {
|
|
470
|
+
return Wtsapi32.Load('WTSWaitSystemEvent')(hServer, EventMask, pEventFlags);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export default Wtsapi32;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Pointer } from 'bun:ffi';
|
|
2
|
+
|
|
3
|
+
import type { DWORD, HANDLE } from '@bun-win32/core';
|
|
4
|
+
export type { BOOL, BYTE, DWORD, HANDLE, HRESULT, HWND, LPDWORD, LPSTR, LPWSTR, NULL, PBYTE, PHANDLE, PULONG, PVOID, ULONG, USHORT } from '@bun-win32/core';
|
|
5
|
+
|
|
6
|
+
export const WTS_ANY_SESSION: DWORD = 0xffff_fffe;
|
|
7
|
+
export const WTS_CHANNEL_OPTION_DYNAMIC: DWORD = 0x0000_0001;
|
|
8
|
+
export const WTS_CURRENT_SERVER_HANDLE: HANDLE = 0n;
|
|
9
|
+
export const WTS_CURRENT_SESSION: DWORD = 0xffff_ffff;
|
|
10
|
+
export const WTS_LISTENER_CREATE: DWORD = 0x0000_0001;
|
|
11
|
+
export const WTS_LISTENER_UPDATE: DWORD = 0x0000_0010;
|
|
12
|
+
|
|
13
|
+
export enum WTS_CONFIG_CLASS {
|
|
14
|
+
WTSUserConfigBrokenTimeoutSettings = 0x0000_000a,
|
|
15
|
+
WTSUserConfigInitialProgram = 0x0000_0000,
|
|
16
|
+
WTSUserConfigModemCallbackPhoneNumber = 0x0000_000d,
|
|
17
|
+
WTSUserConfigModemCallbackSettings = 0x0000_000c,
|
|
18
|
+
WTSUserConfigReconnectSettings = 0x0000_000b,
|
|
19
|
+
WTSUserConfigShadowingSettings = 0x0000_000e,
|
|
20
|
+
WTSUserConfigTerminalServerHomeDir = 0x0000_0010,
|
|
21
|
+
WTSUserConfigTerminalServerHomeDirDrive = 0x0000_0011,
|
|
22
|
+
WTSUserConfigTerminalServerProfilePath = 0x0000_000f,
|
|
23
|
+
WTSUserConfigTimeoutSettingsConnections = 0x0000_0004,
|
|
24
|
+
WTSUserConfigTimeoutSettingsDisconnections = 0x0000_0005,
|
|
25
|
+
WTSUserConfigTimeoutSettingsIdle = 0x0000_0006,
|
|
26
|
+
WTSUserConfigWorkingDirectory = 0x0000_0001,
|
|
27
|
+
WTSUserConfigfAllowLogonTerminalServer = 0x0000_0003,
|
|
28
|
+
WTSUserConfigfDeviceClientDefaultPrinter = 0x0000_0009,
|
|
29
|
+
WTSUserConfigfDeviceClientDrives = 0x0000_0007,
|
|
30
|
+
WTSUserConfigfDeviceClientPrinters = 0x0000_0008,
|
|
31
|
+
WTSUserConfigfInheritInitialProgram = 0x0000_0002,
|
|
32
|
+
WTSUserConfigfTerminalServerRemoteHomeDir = 0x0000_0012,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export enum WTS_CONNECTSTATE_CLASS {
|
|
36
|
+
WTSActive = 0x0000_0000,
|
|
37
|
+
WTSConnectQuery = 0x0000_0002,
|
|
38
|
+
WTSConnected = 0x0000_0001,
|
|
39
|
+
WTSDisconnected = 0x0000_0004,
|
|
40
|
+
WTSDown = 0x0000_0008,
|
|
41
|
+
WTSIdle = 0x0000_0005,
|
|
42
|
+
WTSInit = 0x0000_0009,
|
|
43
|
+
WTSListen = 0x0000_0006,
|
|
44
|
+
WTSReset = 0x0000_0007,
|
|
45
|
+
WTSShadow = 0x0000_0003,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export enum WTS_EVENT {
|
|
49
|
+
WTS_EVENT_ALL = 0x7fff_ffff,
|
|
50
|
+
WTS_EVENT_CONNECT = 0x0000_0008,
|
|
51
|
+
WTS_EVENT_CREATE = 0x0000_0001,
|
|
52
|
+
WTS_EVENT_DELETE = 0x0000_0002,
|
|
53
|
+
WTS_EVENT_DISCONNECT = 0x0000_0010,
|
|
54
|
+
WTS_EVENT_FLUSH = 0x8000_0000,
|
|
55
|
+
WTS_EVENT_LICENSE = 0x0000_0100,
|
|
56
|
+
WTS_EVENT_LOGOFF = 0x0000_0040,
|
|
57
|
+
WTS_EVENT_LOGON = 0x0000_0020,
|
|
58
|
+
WTS_EVENT_NONE = 0x0000_0000,
|
|
59
|
+
WTS_EVENT_RENAME = 0x0000_0004,
|
|
60
|
+
WTS_EVENT_STATECHANGE = 0x0000_0080,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export enum WTS_INFO_CLASS {
|
|
64
|
+
WTSApplicationName = 0x0000_0001,
|
|
65
|
+
WTSClientAddress = 0x0000_000e,
|
|
66
|
+
WTSClientBuildNumber = 0x0000_0009,
|
|
67
|
+
WTSClientDirectory = 0x0000_000b,
|
|
68
|
+
WTSClientDisplay = 0x0000_000f,
|
|
69
|
+
WTSClientHardwareId = 0x0000_000d,
|
|
70
|
+
WTSClientInfo = 0x0000_0017,
|
|
71
|
+
WTSClientName = 0x0000_000a,
|
|
72
|
+
WTSClientProductId = 0x0000_000c,
|
|
73
|
+
WTSClientProtocolType = 0x0000_0010,
|
|
74
|
+
WTSConfigInfo = 0x0000_001a,
|
|
75
|
+
WTSConnectState = 0x0000_0008,
|
|
76
|
+
WTSDomainName = 0x0000_0007,
|
|
77
|
+
WTSIdleTime = 0x0000_0011,
|
|
78
|
+
WTSIncomingBytes = 0x0000_0013,
|
|
79
|
+
WTSIncomingFrames = 0x0000_0015,
|
|
80
|
+
WTSInitialProgram = 0x0000_0000,
|
|
81
|
+
WTSIsRemoteSession = 0x0000_001d,
|
|
82
|
+
WTSLogonTime = 0x0000_0012,
|
|
83
|
+
WTSOEMId = 0x0000_0003,
|
|
84
|
+
WTSOutgoingBytes = 0x0000_0014,
|
|
85
|
+
WTSOutgoingFrames = 0x0000_0016,
|
|
86
|
+
WTSSessionAddressV4 = 0x0000_001c,
|
|
87
|
+
WTSSessionId = 0x0000_0004,
|
|
88
|
+
WTSSessionInfo = 0x0000_0018,
|
|
89
|
+
WTSSessionInfoEx = 0x0000_0019,
|
|
90
|
+
WTSUserName = 0x0000_0005,
|
|
91
|
+
WTSValidationInfo = 0x0000_001b,
|
|
92
|
+
WTSWinStationName = 0x0000_0006,
|
|
93
|
+
WTSWorkingDirectory = 0x0000_0002,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export enum WTS_NOTIFY {
|
|
97
|
+
NOTIFY_FOR_ALL_SESSIONS = 0x0000_0001,
|
|
98
|
+
NOTIFY_FOR_THIS_SESSION = 0x0000_0000,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export enum WTS_TYPE_CLASS {
|
|
102
|
+
WTSTypeProcessInfoLevel0 = 0x0000_0000,
|
|
103
|
+
WTSTypeProcessInfoLevel1 = 0x0000_0001,
|
|
104
|
+
WTSTypeSessionInfoLevel1 = 0x0000_0002,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export enum WTS_VIRTUAL_CLASS {
|
|
108
|
+
WTSVirtualClientData = 0x0000_0000,
|
|
109
|
+
WTSVirtualFileHandle = 0x0000_0001,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export enum WTS_WSD {
|
|
113
|
+
WTS_WSD_FASTREBOOT = 0x0000_0010,
|
|
114
|
+
WTS_WSD_LOGOFF = 0x0000_0001,
|
|
115
|
+
WTS_WSD_POWEROFF = 0x0000_0008,
|
|
116
|
+
WTS_WSD_REBOOT = 0x0000_0004,
|
|
117
|
+
WTS_WSD_SHUTDOWN = 0x0000_0002,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type PBOOL = Pointer;
|
|
121
|
+
export type PCHAR = Pointer;
|
|
122
|
+
export type PSECURITY_DESCRIPTOR = Pointer;
|
|
123
|
+
export type PWTSLISTENERCONFIGA = Pointer;
|
|
124
|
+
export type PWTSLISTENERCONFIGW = Pointer;
|
|
125
|
+
export type PWTSLISTENERNAMEA = Pointer;
|
|
126
|
+
export type PWTSLISTENERNAMEW = Pointer;
|
|
127
|
+
export type SECURITY_INFORMATION = number;
|