win32-api
Version:
FFI definitions of windows win32 api for node-ffi
849 lines (796 loc) • 39.3 kB
JavaScript
/**
* win32-api
* FFI definitions of windows win32 api for node-ffi
*
* @version 26.1.1
* @author waiting
* @license MIT
* @link https://waitingsong.github.io/node-win32-api
*/
'use strict';
var win32Def = require('win32-def');
var D = require('win32-def/def');
var S = require('win32-def/struct');
var assert = require('node:assert');
var types = require('win32-def/types');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var D__namespace = /*#__PURE__*/_interopNamespaceDefault(D);
var S__namespace = /*#__PURE__*/_interopNamespaceDefault(S);
var types__namespace = /*#__PURE__*/_interopNamespaceDefault(types);
exports.DllNames = void 0;
(function (DllNames) {
DllNames["comctl32"] = "comctl32";
DllNames["gdi32"] = "gdi32";
DllNames["kernel32"] = "kernel32";
DllNames["ntdll"] = "ntdll";
DllNames["spoolss"] = "spoolss";
DllNames["user32"] = "user32";
DllNames["winspool"] = "winspool.drv";
})(exports.DllNames || (exports.DllNames = {}));
class DefComctl32 {
/** https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-initcommoncontrolsex */
static InitCommonControlsEx = [D__namespace.BOOL, [S__namespace.LPINITCOMMONCONTROLSEX]];
}
class Comctl32 {
/** https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-initcommoncontrolsex */
InitCommonControlsEx;
}
/* c8 ignore stop */
const dllName$5 = exports.DllNames.comctl32;
const load$5 = (fns) => win32Def.load({
dll: dllName$5 + '.dll',
dllFuncs: DefComctl32,
usedFuncNames: fns,
});
var index$5 = /*#__PURE__*/Object.freeze({
__proto__: null,
Comctl32: Comctl32,
DefComctl32: DefComctl32,
dllName: dllName$5,
load: load$5
});
class DefGdi32 {
// static CreateBitmap = [W.HBITMAP, [W.INT, W.INT, W.UINT, W.UINT, W.VOID] ]
/** https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatiblebitmap */
static CreateCompatibleBitmap = [D__namespace.HBITMAP, [D__namespace.HDC, D__namespace.INT, D__namespace.INT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatibledc */
static CreateCompatibleDC = [D__namespace.HDC, [D__namespace.HDC]];
}
class Gdi32 {
// CreateBitmap: (
// nWidth: M.INT,
// nHeight: M.INT,
// nPlanes: M.UINT,
// nBitCount: M.UINT,
// lpBits: M.LPVOID,
// ) => M.HBITMAP
/**
* Creates a bitmap compatible with the device that is associated with the specified device context.
* @link https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatiblebitmap
*/
CreateCompatibleBitmap;
/** https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatibledc */
CreateCompatibleDC;
}
/* c8 ignore stop */
const dllName$4 = exports.DllNames.gdi32;
const load$4 = (fns) => win32Def.load({
dll: dllName$4 + '.dll',
dllFuncs: DefGdi32,
usedFuncNames: fns,
});
var index$4 = /*#__PURE__*/Object.freeze({
__proto__: null,
DefGdi32: DefGdi32,
Gdi32: Gdi32,
dllName: dllName$4,
load: load$4
});
class DefKernel32 {
static FormatMessageW = [
D__namespace.DWORD,
[D__namespace.DWORD, D__namespace.LPCVOID, D__namespace.DWORD, D__namespace.DWORD, `_Out_ ${D__namespace.LPTSTR}`, D__namespace.DWORD, D__namespace.va_list],
];
static FreeConsole = [D__namespace.BOOL, []];
static GenerateConsoleCtrlEvent = [D__namespace.BOOL, [D__namespace.DWORD, D__namespace.DWORD]];
/** err code: https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms681381(v=vs.85).aspx */
static GetLastError = [D__namespace.DWORD, []];
/** retrieve value from buf by readUInt32() */
static GetModuleHandleW = [D__namespace.HMODULE, [D__namespace.WString]];
/** flags, optional LPCTSTR name, ref hModule */
static GetModuleHandleExW = [D__namespace.BOOL, [D__namespace.DWORD, D__namespace.WString, `_Out_ ${D__namespace.HMODULE}*`]];
static GetProcessHeaps = [D__namespace.DWORD, [D__namespace.DWORD, D__namespace.PHANDLE]];
/** https://learn.microsoft.com/zh-cn/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress */
static GetProcAddress = ['intptr_t', [D__namespace.HMODULE, D__namespace.WString]]; // FARPROC
static GetSystemTimes = [D__namespace.BOOL, [`_Out_ ${S__namespace.LPFILETIME}`, `_Out_ ${S__namespace.LPFILETIME}`, `_Out_ ${S__namespace.LPFILETIME}`]];
/** https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount */
static GetTickCount = [D__namespace.DWORD, []];
static HeapFree = [D__namespace.BOOL, [D__namespace.HANDLE, D__namespace.DWORD, D__namespace.LPVOID]];
/** https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw */
static LoadLibraryExW = [D__namespace.HMODULE, [D__namespace.WString, D__namespace.HANDLE, D__namespace.DWORD]];
static OpenProcess = [D__namespace.HANDLE, [D__namespace.DWORD, D__namespace.BOOL, D__namespace.DWORD]];
static OutputDebugStringW = [D__namespace.VOID, [D__namespace.LPCTSTR]];
static SetLastError = [D__namespace.VOID, [D__namespace.DWORD]];
static SetThreadExecutionState = [D__namespace.INT, [D__namespace.INT]];
}
class Kernel32 {
/**
* https://learn.microsoft.com/zh-cn/windows/win32/api/winbase/nf-winbase-formatmessage?redirectedfrom=MSDN
* dwLanguageId: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
*/
FormatMessageW;
FreeConsole;
GenerateConsoleCtrlEvent;
GetLastError;
GetModuleHandleW;
GetModuleHandleExW;
GetProcessHeaps;
/** https://learn.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getsystemtimes */
GetSystemTimes;
/** https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount */
GetTickCount;
HeapFree;
OpenProcess;
/** https://learn.microsoft.com/zh-cn/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress */
GetProcAddress;
/** https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw */
LoadLibraryExW;
/** https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw */
OutputDebugStringW;
/** https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx */
SetLastError;
/**
* Enables an application to inform the system that it is in use,
* thereby preventing the system from entering sleep or turning off
* the display while the application is running.
*
* @example
* // Television recording is beginning. Enable away mode and prevent the sleep idle time-out.
* SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
*
* // Clear EXECUTION_STATE flags to disable away mode and allow the system to idle to sleep normally.
* SetThreadExecutionState(ES_CONTINUOUS);
*
* @param esFlags The thread's execution requirements.
* This parameter can be one or more of the following values. Join them with single |
* @returns If the function succeeds, the return value is the previous thread execution state.
* If the function fails, the return value is NULL.
* @see [Docs](https://learn.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setthreadexecutionstate)
*
*/
SetThreadExecutionState;
}
/* c8 ignore stop */
const dllName$3 = exports.DllNames.kernel32;
const load$3 = (fns) => win32Def.load({
dll: dllName$3 + '.dll',
dllFuncs: DefKernel32,
usedFuncNames: fns,
});
var index$3 = /*#__PURE__*/Object.freeze({
__proto__: null,
DefKernel32: DefKernel32,
Kernel32: Kernel32,
dllName: dllName$3,
load: load$3
});
class DefSpoolss {
static EndDocPrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
static EndPagePrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
/** https://learn.microsoft.com/en-us/windows/win32/printdocs/writeprinter */
static WritePrinter = [D__namespace.BOOL, [D__namespace.HANDLE, D__namespace.LPVOID, D__namespace.DWORD, `_Out_ ${D__namespace.LPDWORD}`]];
}
class Spoolss {
/** https://learn.microsoft.com/en-us/windows/win32/printdocs/enddocprinter */
EndDocPrinter;
EndPagePrinter;
/** https://learn.microsoft.com/zh-cn/windows/win32/printdocs/writeprinter */
WritePrinter;
}
/* c8 ignore stop */
const dllName$2 = exports.DllNames.spoolss;
const load$2 = (fns) => win32Def.load({
dll: dllName$2 + '.dll',
dllFuncs: DefSpoolss,
usedFuncNames: fns,
});
var index$2 = /*#__PURE__*/Object.freeze({
__proto__: null,
DefSpoolss: DefSpoolss,
Spoolss: Spoolss,
dllName: dllName$2,
load: load$2
});
class DefUser32_B {
static BringWindowToTop = [D__namespace.BOOL, [D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-broadcastsystemmessage */
static BroadcastSystemMessage = [D__namespace.LRESULT, [D__namespace.DWORD, D__namespace.LPDWORD, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM]];
}
class DefUser32_C extends DefUser32_B {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-callwindowprocw */
static CallWindowProcW = [D__namespace.LRESULT, [D__namespace.WNDPROC, D__namespace.HWND, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexw */
static ChangeDisplaySettingsExW = [D__namespace.LONG, [D__namespace.WString, S__namespace.LPDEVMODEW, D__namespace.HWND, D__namespace.DWORD, D__namespace.LPVOID]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-clienttoscreen */
static ClientToScreen = [D__namespace.BOOL, [D__namespace.HWND, `_Inout_ ${S__namespace.LPPOINT}`]];
static CloseWindow = [D__namespace.BOOL, [D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw */
static CreateWindowExW = [
D__namespace.HWND, [
D__namespace.DWORD,
D__namespace.WString,
D__namespace.WString,
D__namespace.DWORD,
D__namespace.INT,
D__namespace.INT,
D__namespace.INT,
D__namespace.INT,
D__namespace.HWND,
D__namespace.HMENU,
D__namespace.HINSTANCE,
D__namespace.LPVOID,
],
];
}
class DefUser32_D extends DefUser32_C {
static DefWindowProcW = [D__namespace.LRESULT, [D__namespace.HWND, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroywindow */
static DestroyWindow = [D__namespace.BOOL, [D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew */
static DispatchMessageW = [D__namespace.LRESULT, [S__namespace.LPMSG]];
}
class DefUser32_E extends DefUser32_D {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumchildwindows */
static EnumChildWindows = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.WNDENUMPROC, D__namespace.LPARAM]];
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesw */
static EnumDisplayDevicesW = [D__namespace.BOOL, [D__namespace.LPCWSTR, D__namespace.DWORD, `_Inout_ ${S__namespace.LPDISPLAY_DEVICEW}`, D__namespace.DWORD]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumthreadwindows */
static EnumThreadWindows = [D__namespace.BOOL, [D__namespace.DWORD, D__namespace.WNDENUMPROC, D__namespace.LPARAM]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows */
static EnumWindows = [D__namespace.BOOL, [D__namespace.WNDENUMPROC, D__namespace.LPARAM]];
}
class DefUser32_F extends DefUser32_E {
/** https=//learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindowexw */
static FindWindowExW = [D__namespace.HWND, [D__namespace.HWND, D__namespace.HWND, D__namespace.LPCTSTR, D__namespace.LPCTSTR]];
static FlashWindow = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.BOOL]];
static FlashWindowEx = [D__namespace.BOOL, [S__namespace.PFLASHWINFO]];
}
class DefUser32_G extends DefUser32_F {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getancestor */
static GetAncestor = [D__namespace.HWND, [D__namespace.HWND, D__namespace.UINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getalttabinfow */
static GetAltTabInfoW = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.INT, `_Inout_ ${S__namespace.LPALTTABINFO}`, `_Out_ ${D__namespace.LPWSTR}`, D__namespace.INT]];
/**
* Copies the caret's position to the specified POINT structure.
* @link https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcaretpos
*/
static GetCaretPos = [D__namespace.BOOL, [`_Out_ ${S__namespace.LPPOINT}`]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassinfoexw */
static GetClassInfoExW = [D__namespace.BOOL, [D__namespace.HINSTANCE, [D__namespace.WString], `_Out_ ${S__namespace.LPWNDCLASSEXW}`]];
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclassnamew */
static GetClassNameW = [D__namespace.INT, [D__namespace.HWND, D__namespace.LPTSTR, D__namespace.INT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcursorpos */
static GetCursorPos = [D__namespace.BOOL, [`_Out_ ${S__namespace.LPPOINT}`]];
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclasslongptrw */
static GetClassLongPtrW = [D__namespace.ULONG_PTR, [D__namespace.HWND, D__namespace.INT]];
static GetForegroundWindow = [D__namespace.HWND, []];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessagew */
static GetMessageW = [D__namespace.BOOL, [`_Out_ ${S__namespace.LPMSG}`, D__namespace.HWND, D__namespace.UINT, D__namespace.UINT]];
static GetParent = [D__namespace.HWND, [D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdata */
static GetRawInputData = [D__namespace.UINT, [S__namespace.LPRAWINPUT, D__namespace.UINT, D__namespace.LPVOID, `_Inout_ ${D__namespace.PUINT}`, D__namespace.UINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdeviceinfow */
static GetRawInputDeviceInfoW = [D__namespace.UINT, [D__namespace.HANDLE, D__namespace.UINT, `_Inout_ ${D__namespace.LPVOID}`, D__namespace.PUINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdevicelist */
static GetRawInputDeviceList = [D__namespace.INT, [`_Out_ ${S__namespace.LPRAWINPUTDEVICELIST}`, D__namespace.PUINT, D__namespace.UINT]];
static GetTopWindow = [D__namespace.HWND, [D__namespace.HWND]];
static GetWindow = [D__namespace.HWND, [D__namespace.HWND, D__namespace.UINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowinfo */
static GetWindowInfo = [D__namespace.BOOL, [D__namespace.HWND, `_Inout_ ${S__namespace.LPWINDOWINFO}`]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongw */
static GetWindowLongW = [D__namespace.LONG, [D__namespace.HWND, D__namespace.INT]];
/** only under x64 */
static GetWindowLongPtrW = [D__namespace.LONG_PTR, [D__namespace.HWND, D__namespace.INT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrect */
static GetWindowRect = [D__namespace.BOOL, [D__namespace.HWND, `_Out_ ${S__namespace.LPRECT}`]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowtextw */
static GetWindowTextW = [D__namespace.INT, [D__namespace.HWND, D__namespace.LPTSTR, D__namespace.INT]];
static GetWindowThreadProcessId = [D__namespace.DWORD, [D__namespace.HWND, D__namespace.LPDWORD]];
}
class DefUser32_I extends DefUser32_G {
static IsIconic = [D__namespace.BOOL, [D__namespace.HWND]];
static IsWindowVisible = [D__namespace.BOOL, [D__namespace.HWND]];
}
class DefUser32_M extends DefUser32_I {
static MonitorFromWindow = [D__namespace.HWND, [D__namespace.HANDLE, D__namespace.DWORD]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxexw */
static MessageBoxExW = [D__namespace.INT, [D__namespace.HWND, D__namespace.WString, D__namespace.WString, D__namespace.UINT, D__namespace.WORD]];
}
class DefUser32_P extends DefUser32_M {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-peekmessagew */
static PeekMessageW = [D__namespace.BOOL, [`_Out_ ${S__namespace.LPMSG}`, D__namespace.HWND, D__namespace.UINT, D__namespace.UINT, D__namespace.UINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postmessagew */
static PostMessageW = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-printwindow */
static PrintWindow = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.HDC, D__namespace.UINT]];
}
class DefUser32_R extends DefUser32_P {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-registerclassexw */
static RegisterClassExW = [D__namespace.ATOM, [S__namespace.LPWNDCLASSEXW]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerwindowmessagew */
static RegisterWindowMessageW = [D__namespace.UINT, [D__namespace.LPCWSTR]];
}
class DefUser32_S extends DefUser32_R {
/**
* @link https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
*/
static SendInput = [D__namespace.UINT, [D__namespace.UINT, S__namespace.LPINPUT, D__namespace.INT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew */
static SendMessageW = [D__namespace.LRESULT, [D__namespace.HWND, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw */
static SendMessageTimeoutW = [D__namespace.LRESULT, [D__namespace.HWND, D__namespace.UINT, D__namespace.WPARAM, D__namespace.LPARAM, D__namespace.UINT, D__namespace.UINT, D__namespace.DWORD_PTR]];
static SetForegroundWindow = [D__namespace.BOOL, [D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setparent */
static SetParent = [D__namespace.HWND, [D__namespace.HWND, D__namespace.HWND]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos */
static SetWindowPos = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.HWND, D__namespace.INT, D__namespace.INT, D__namespace.INT, D__namespace.INT, D__namespace.UINT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowtextw */
static SetWindowTextW = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.WString]];
// @TODO WINEVENTPROC
static SetWinEventHook = [D__namespace.HWINEVENTHOOK, [D__namespace.UINT, D__namespace.UINT, D__namespace.HMODULE, D__namespace.WINEVENTPROC, D__namespace.DWORD, D__namespace.DWORD, D__namespace.UINT]];
static ShowWindow = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.INT]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindowasync */
static ShowWindowAsync = [D__namespace.BOOL, [D__namespace.HWND, D__namespace.INT]];
}
class DefUser32_T extends DefUser32_S {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-translatemessage */
static TranslateMessage = [D__namespace.BOOL, [S__namespace.LPMSG]];
/** https://learn.microsoft.com/en-us/windows/win32/winmsg/translatemessageex */
static TranslateMessageEx = [D__namespace.BOOL, [S__namespace.LPMSG]];
}
class DefUser32_U extends DefUser32_T {
static UnhookWinEvent = [D__namespace.BOOL, [D__namespace.HWINEVENTHOOK]];
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unregisterclassw */
static UnregisterClassW = [D__namespace.BOOL, [D__namespace.WString, D__namespace.HINSTANCE]];
static UpdateWindow = [D__namespace.BOOL, [D__namespace.HWND]];
}
class DefUser32 extends DefUser32_U {
}
class User32_B {
BringWindowToTop;
/**
* https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-broadcastsystemmessage
*/
BroadcastSystemMessage;
}
/* c8 ignore stop */
class User32_C extends User32_B {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-callwindowprocw */
CallWindowProcW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexw */
ChangeDisplaySettingsExW;
ClientToScreen;
/** https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-closewindow */
CloseWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw */
CreateWindowExW;
}
class User32_D extends User32_C {
DefWindowProcW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroywindow */
DestroyWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew */
DispatchMessageW;
}
/* c8 ignore stop */
class User32_E extends User32_D {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumchildwindows */
EnumChildWindows;
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesw */
EnumDisplayDevicesW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumthreadwindows */
EnumThreadWindows;
/**
* EnumWindows: EnumWindows
* https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows
*/
EnumWindows;
}
class User32_F extends User32_E {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindowexw */
FindWindowExW;
FlashWindow;
FlashWindowEx;
}
/* c8 ignore stop */
class User32_G extends User32_F {
GetAncestor;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getalttabinfow */
GetAltTabInfoW;
/**
* Copies the caret's position to the specified POINT structure.
* @link https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcaretpos
*/
GetCaretPos;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassinfoexw */
GetClassInfoExW;
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclassnamew */
GetClassNameW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcursorpos */
GetCursorPos;
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getclasslongptrw */
GetClassLongPtrW;
GetForegroundWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessagew */
GetMessageW;
GetParent;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdata */
GetRawInputData;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdeviceinfow */
GetRawInputDeviceInfoW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdevicelist */
GetRawInputDeviceList;
GetTopWindow;
GetWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowinfo */
GetWindowInfo; // Note that you must set the pwi.cbSize!
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongw */
GetWindowLongW;
/** only under x64 */
GetWindowLongPtrW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrect */
GetWindowRect;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowtextw */
GetWindowTextW;
GetWindowThreadProcessId;
}
/* c8 ignore stop */
class User32_I extends User32_G {
IsIconic;
IsWindowVisible;
}
class User32_M extends User32_I {
/**
* @learn https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromwindow
*/
MonitorFromWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxexw */
MessageBoxExW;
}
/* c8 ignore stop */
class User32_P extends User32_M {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-peekmessagew */
PeekMessageW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postmessagew */
PostMessageW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-printwindow */
PrintWindow;
}
class User32_R extends User32_P {
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-registerclassexw */
RegisterClassExW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerwindowmessagew */
RegisterWindowMessageW;
}
/* c8 ignore stop */
class User32_S extends User32_R {
/**
* @link https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
*/
SendInput;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew */
SendMessageW;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw */
SendMessageTimeoutW;
/** https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-setforegroundwindow */
SetForegroundWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setparent */
SetParent;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos */
SetWindowPos;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowtextw */
SetWindowTextW;
SetWinEventHook;
ShowWindow;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindowasync */
ShowWindowAsync;
}
/* c8 ignore stop */
class User32_T extends User32_S {
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-translatemessage */
TranslateMessage;
/** https://learn.microsoft.com/en-us/windows/win32/winmsg/translatemessageex */
TranslateMessageEx;
}
class User32_U extends User32_T {
UnhookWinEvent;
/** https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unregisterclassw */
UnregisterClassW;
UpdateWindow;
}
/* c8 ignore stop */
class User32Combo extends User32_U {
}
class User32 extends User32Combo {
}
/* c8 ignore stop */
const funcName$1 = 'GetClassInfoExW';
const GetClassInfoExW_mapper = (name, runtimeArgs, defParamsArray) => {
if (name !== funcName$1) {
return;
}
const lpszClass = runtimeArgs[1];
for (const row of defParamsArray) {
assert(Array.isArray(row));
const defArg = row[1];
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (typeof lpszClass) {
case 'string': {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (defArg === D.WString) { // WString
return row;
}
break;
}
case 'object': {
assert(lpszClass instanceof Buffer, 'Invalid lpszClass type, must Buffer if object');
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (defArg === D.WString) { // WString
return row;
}
break;
}
default:
throw new Error(`Invalid lpszClass type: ${typeof lpszClass}`);
}
}
// return [] // will throw Error
};
const multipleChoiceMapperList$1 = new Map();
const multipleChoiceMapperSet$1 = new Set();
multipleChoiceMapperList$1.set(funcName$1, multipleChoiceMapperSet$1);
multipleChoiceMapperSet$1.add(GetClassInfoExW_mapper);
const dllName$1 = exports.DllNames.user32;
const load$1 = (fns) => win32Def.load({
dll: dllName$1 + '.dll',
dllFuncs: DefUser32,
usedFuncNames: fns,
multipleChoiceMapperList: multipleChoiceMapperList$1,
});
var index$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
DefUser32: DefUser32,
User32: User32,
dllName: dllName$1,
load: load$1
});
class DefWinspool {
static ClosePrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
static EndDocPrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
static EndPagePrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
/**
* Enumerates available printers, print servers, domains, or print providers.
* using multipleChoice to accept payload `pPrinterEnum` depends on `Level`
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprinters
*/
static EnumPrintersW = [D__namespace.BOOL,
[
D__namespace.DWORD,
D__namespace.WString,
D__namespace.DWORD,
`_Out_ ${D__namespace.LPBYTE}`,
D__namespace.DWORD,
D__namespace.LPDWORD,
D__namespace.LPDWORD,
]];
/**
* Enumerates the print processors installed on the specified server.
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprintprocessors
*/
static EnumPrintProcessorsW = [D__namespace.BOOL, [D__namespace.LPTSTR, D__namespace.LPTSTR, D__namespace.DWORD, `_Out_ ${D__namespace.LPBYTE}`, D__namespace.DWORD, `_Out_ ${D__namespace.LPDWORD}`, `_Out_ ${D__namespace.LPDWORD}`]];
/**
* Enumerates the data types that a specified print processor supports.
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprintprocessordatatypes
*/
static EnumPrintProcessorDatatypesW = [D__namespace.BOOL, [D__namespace.LPTSTR, D__namespace.LPTSTR, D__namespace.DWORD, `_Out_ ${D__namespace.LPBYTE}`, D__namespace.DWORD, `_Out_ ${D__namespace.LPDWORD}`, `_Out_ ${D__namespace.LPDWORD}`]];
/** https://learn.microsoft.com/en-us/windows/win32/printdocs/getdefaultprinter */
static GetDefaultPrinterW = [D__namespace.BOOL, [D__namespace.LPTSTR, `_Inout_ ${D__namespace.LPDWORD}`]];
/**
* Retrieves information about a specified print job
* https://learn.microsoft.com/en-us/windows/win32/printdocs/getjob
* @param pJob JOB_INFO_1 or a JOB_INFO_2
*/
static GetJobW = [D__namespace.BOOL, [D__namespace.HANDLE, D__namespace.DWORD, D__namespace.DWORD, `_Out_ ${D__namespace.LPBYTE}`, D__namespace.DWORD, `_Out_ ${D__namespace.LPDWORD}`]];
/**
* Retrieves information about a specified printer.
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/getprinter
* @link https://learn.microsoft.com/zh-cn/windows/win32/printdocs/getprinter
*/
static GetPrinterW = [D__namespace.BOOL, [
D__namespace.HANDLE,
D__namespace.DWORD,
// multiple choice instead of `_Out_ ${D.LPBYTE}`,
// @TODO 2|7
[
`_Out_ ${S__namespace.PPRINTER_INFO_1}`,
`_Out_ ${S__namespace.PPRINTER_INFO_4}`,
`_Out_ ${S__namespace.PPRINTER_INFO_5}`,
`_Out_ ${S__namespace.PPRINTER_INFO_6}`,
`_Out_ ${S__namespace.PPRINTER_INFO_8}`,
`_Out_ ${S__namespace.PPRINTER_INFO_9}`,
],
D__namespace.DWORD,
`_Out_ ${D__namespace.LPDWORD}`,
]]; // `as const` is required for multipleChoice
/**
* Retrieves a handle to the specified printer or print server or other types of handles in the print subsystem.
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/openprinter
* @docs https://learn.microsoft.com/zh-cn/windows/win32/printdocs/openprinter
*/
static OpenPrinterW = [D__namespace.BOOL, [D__namespace.WString, `_Out_ ${D__namespace.LPHANDLE}`, S__namespace.PPRINTER_DEFAULTS]];
/**
* Notifies the print spooler that a document is to be spooled for printing.
* @param pDocInfo A pointer to a DOC_INFO_1 structure that describes the document to print.
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/startdocprinter
*/
static StartDocPrinterW = [D__namespace.DWORD, [D__namespace.HANDLE, D__namespace.DWORD, S__namespace.LPDOC_INFO_1]];
/**
* Notifies the spooler that a page is about to be printed on the specified printer.
* @docs https://learn.microsoft.com/zh-cn/windows/win32/printdocs/startpageprinter
*/
static StartPagePrinter = [D__namespace.BOOL, [D__namespace.HANDLE]];
/**
* Notifies the print spooler that data should be written to the specified printer.
* @note Only supports GDI printing and must not be used for XPS printing
* @link https://learn.microsoft.com/zh-cn/windows/win32/printdocs/writeprinter
*/
static WritePrinter = [D__namespace.BOOL, [D__namespace.HANDLE, D__namespace.LPVOID, D__namespace.DWORD, `_Out_ ${D__namespace.LPDWORD}`]];
}
class Winspool {
/**
* @docs https://docs.microsoft.com/en-us/windows/win32/printdocs/closeprinter
*/
ClosePrinter;
/**
* @docs https://docs.microsoft.com/en-us/windows/win32/printdocs/enddocprinter
*/
EndDocPrinter;
EndPagePrinter;
/**
* Enumerates available printers, print servers, domains, or print providers.
* using `Level` to determine the type of `pPrinterEnum`
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprinters
*/
EnumPrintersW;
/**
* Enumerates available printers, print servers, domains, or print providers.
* using `Level` to determine the type of `pPrinterEnum`
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprinters
* @description Asynchronous version of EnumPrintersW only for generic type `Level`
*/
EnumPrintersW_Async;
/**
* Enumerates the print processors installed on the specified server.
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprintprocessors
*/
EnumPrintProcessorsW;
/**
* Enumerates the data types that a specified print processor supports.
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/enumprintprocessordatatypes
*/
EnumPrintProcessorDatatypesW;
/** https://learn.microsoft.com/en-us/windows/win32/printdocs/getdefaultprinter */
GetDefaultPrinterW;
/**
* Retrieves information about a specified print job
* @param pJob JOB_INFO_1 or a JOB_INFO_2
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/getjob
*/
GetJobW;
/**
* Retrieves information about a specified printer.
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/getprinter
* @docs https://learn.microsoft.com/zh-cn/windows/win32/printdocs/getprinter
*/
GetPrinterW;
/**
* Retrieves information about a specified printer.
* @docs https://learn.microsoft.com/en-us/windows/win32/printdocs/getprinter
* @docs https://learn.microsoft.com/zh-cn/windows/win32/printdocs/getprinter
*/
GetPrinterW_Async;
/**
* Retrieves a handle to the specified printer or print server or other types of handles in the print subsystem.
* @link https://leran.microsoft.com/en-us/windows/win32/printdocs/openprinter
* @link https://leran.microsoft.com/zh-cn/windows/win32/printdocs/openprinter
*/
OpenPrinterW;
/**
* Notifies the print spooler that a document is to be spooled for printing.
* @param pDocInfo A pointer to a DOC_INFO_1 structure that describes the document to print.
* @link https://learn.microsoft.com/en-us/windows/win32/printdocs/startdocprinter
*/
StartDocPrinterW;
/**
* Notifies the spooler that a page is about to be printed on the specified printer.
* @link https://learn.microsoft.com/zh-cn/windows/win32/printdocs/startpageprinter
*/
StartPagePrinter;
/**
* Notifies the print spooler that data should be written to the specified printer.
* @note Only supports GDI printing and must not be used for XPS printing
* @link https://learn.microsoft.com/zh-cn/windows/win32/printdocs/writeprinter
*/
WritePrinter;
}
/* c8 ignore stop */
const funcName = 'GetPrinterW';
const GetPrinterW_mapper = (name, runtimeArgs, defParamsArray) => {
if (name !== funcName) {
return;
}
const argLevel = runtimeArgs[1];
const argPtr = S.getPRINTER_INFO_X_Ptr(argLevel);
assert(argPtr, `getPRINTER_INFO_X_Ptr(${argLevel}) failed`);
for (const row of defParamsArray) {
assert(Array.isArray(row));
const defPtr = row[2];
if (defPtr.endsWith(argPtr)) {
return row;
}
}
// return [] // will throw Error
};
const multipleChoiceMapperList = new Map();
const multipleChoiceMapperSet = new Set();
multipleChoiceMapperList.set(funcName, multipleChoiceMapperSet);
multipleChoiceMapperSet.add(GetPrinterW_mapper);
const dllName = exports.DllNames.winspool;
const load = (fns) => win32Def.load({
dll: dllName,
dllFuncs: DefWinspool,
usedFuncNames: fns,
multipleChoiceMapperList: multipleChoiceMapperList,
});
var index = /*#__PURE__*/Object.freeze({
__proto__: null,
DefWinspool: DefWinspool,
Winspool: Winspool,
dllName: dllName,
load: load
});
const isArch64 = process.arch.includes('64');
Object.defineProperty(exports, "config", {
enumerable: true,
get: function () { return win32Def.config; }
});
Object.defineProperty(exports, "ffi", {
enumerable: true,
get: function () { return win32Def.ffi; }
});
exports.Def = D__namespace;
exports.Struct = S__namespace;
exports.Types = types__namespace;
exports.Comctl32 = index$5;
exports.Gdi32 = index$4;
exports.Kernel32 = index$3;
exports.Spoolss = index$2;
exports.User32 = index$1;
exports.Winspool = index;
exports.isArch64 = isArch64;
//# sourceMappingURL=index.cjs.map