quickwin 2.1.0 → 2.2.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/README.en.md +8 -8
- package/README.md +6 -7
- package/examples/{exec_server.js → execd.js} +618 -228
- package/examples/execd.tsx +798 -0
- package/examples/execd_worker.js +122 -0
- package/examples/execd_worker.ts +127 -0
- package/examples/pdf_viewer.js +100 -111
- package/examples/test_gallery.js +100 -111
- package/examples/test_react_lazy.js +96 -109
- package/examples/test_react_listbox.js +96 -109
- package/examples/test_root_window.js +96 -109
- package/examples/test_tab.js +96 -109
- package/lib/ffi/ctype.ts +3 -1
- package/lib/ffi/struct.js +23 -7
- package/lib/ffi/struct.ts +50 -23
- package/lib/http-server.js +1 -1
- package/lib/http-server.ts +1 -1
- package/lib/windows/gdi32.js +1 -1
- package/lib/windows/gdi32.ts +1 -1
- package/lib/windows/structs.js +176 -92
- package/lib/windows/structs.ts +216 -92
- package/package.json +1 -1
- package/quickwin_const.d.ts +26 -0
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/test/test_ffi_bind.js +5 -3
- package/test/test_ffi_bind.ts +6 -4
- package/test/test_ffi_struct.js +58 -24
- package/test/test_ffi_struct.ts +55 -25
- package/test/test_gdi_draw.js +1 -1
- package/test/test_gdi_draw.ts +1 -1
- package/test/test_react_complex.js +96 -109
- package/test/test_react_counter.js +96 -109
- package/test/test_react_flex.js +96 -109
- package/test/test_react_hidden.js +96 -109
- package/test/test_react_listview_link.js +96 -109
- package/test/test_react_notify.js +96 -109
- package/test/test_react_render.js +96 -109
- package/examples/exec_server.tsx +0 -489
- package/examples/exec_server_worker.js +0 -395
- package/examples/exec_server_worker.ts +0 -417
- package/examples/setres.js +0 -79
- package/examples/setres.ts +0 -86
package/lib/windows/structs.ts
CHANGED
|
@@ -1,47 +1,65 @@
|
|
|
1
1
|
import { struct } from '../ffi/struct.js'
|
|
2
|
+
import type { C_Struct } from '../ffi/ctype.js'
|
|
2
3
|
|
|
3
4
|
// 全仓库 Win32 结构的集中定义点(CType IR,按本机架构 MSVC 对齐;这批全为定长标量/字符串,
|
|
4
5
|
// ia32/x64 同布局)。形参位方向约定见 lib/windows/user32.ts 头注释:
|
|
5
6
|
// 纯入参位注册 encoder(DeepPartial 对象直传,缺省字段跳过),出参/双向位不注册
|
|
6
7
|
// (位只收 def 分配的 .ptr,读回走 decode —— 对象 encode 进调用方拿不到的临时 buffer 会丢结果)。
|
|
7
|
-
//
|
|
8
|
-
//
|
|
8
|
+
// 每个结构拆两行(本库是 lib,DECL 全部导出):
|
|
9
|
+
// X_DECL = 平铺字段表 + '#' 指令键(对象字面量,satisfies C_Struct 编译期验 kind/token);
|
|
10
|
+
// X = /* @__PURE__ */ struct(name, X_DECL) —— PURE 标记 esbuild 据此摇掉 bundle
|
|
11
|
+
// 未引用的布局;集中到一个文件后没这个标记会把全部结构拖进每个 bundle。
|
|
12
|
+
// 嵌套一律引用 X_DECL(标识符引用可整链摇树;成员读 X.__struct 是可观察副作用,会拖住
|
|
13
|
+
// 整个 X —— 嵌套方与被嵌套方从此死绑,摇不掉)。DECL 是纯数据、构造时拷贝,无闭包捕获。
|
|
9
14
|
|
|
10
15
|
/** 矩形(16B):GetClientRect/GetWindowRect 出参、InvalidateRect/FillRect 入参 */
|
|
11
|
-
export const
|
|
16
|
+
export const RECT_DECL = {
|
|
17
|
+
'#': 'struct',
|
|
12
18
|
left: 'i32',
|
|
13
19
|
top: 'i32',
|
|
14
20
|
right: 'i32',
|
|
15
21
|
bottom: 'i32',
|
|
16
|
-
}
|
|
22
|
+
} satisfies C_Struct
|
|
23
|
+
|
|
24
|
+
export const RECT = /* @__PURE__ */ struct('RECT', RECT_DECL)
|
|
17
25
|
|
|
18
26
|
/** 点(8B):GetCursorPos 出参、ScreenToClient/ClientToScreen 就地更新 */
|
|
19
|
-
export const
|
|
27
|
+
export const POINT_DECL = {
|
|
28
|
+
'#': 'struct',
|
|
20
29
|
x: 'i32',
|
|
21
30
|
y: 'i32',
|
|
22
|
-
}
|
|
31
|
+
} satisfies C_Struct
|
|
32
|
+
|
|
33
|
+
export const POINT = /* @__PURE__ */ struct('POINT', POINT_DECL)
|
|
23
34
|
|
|
24
35
|
/** 尺寸(8B,双架构同布局):Button BM_GETIDEALSIZE 等出参槽(cx/cy 像素) */
|
|
25
|
-
export const
|
|
36
|
+
export const SIZE_DECL = {
|
|
37
|
+
'#': 'struct',
|
|
26
38
|
cx: 'i32',
|
|
27
39
|
cy: 'i32',
|
|
28
|
-
}
|
|
40
|
+
} satisfies C_Struct
|
|
41
|
+
|
|
42
|
+
export const SIZE = /* @__PURE__ */ struct('SIZE', SIZE_DECL)
|
|
29
43
|
|
|
30
44
|
/** 混合函数(4B,双架构同布局):AlphaBlend 末参**按值**传(bind 的按值位
|
|
31
45
|
* `<BLENDFUNCTION>`,非 `<BLENDFUNCTION>ptr`)——4B POD 聚合体在 x64 走位置寄存器、
|
|
32
46
|
* ia32 压 4 字节,字段序须与 windows.h 逐字节一致。BlendOp 仅 AC_SRC_OVER(0)、
|
|
33
47
|
* BlendFlags 恒 0(MSDN);AC_SRC_ALPHA(1) 是 AlphaFormat 的值(源带 premultiplied
|
|
34
48
|
* alpha 通道时置位)。纯入参位注册 encoder(对象直传,缺省字段跳过的零值合法)。 */
|
|
35
|
-
export const
|
|
49
|
+
export const BLENDFUNCTION_DECL = {
|
|
50
|
+
'#': 'struct',
|
|
36
51
|
BlendOp: 'u8',
|
|
37
52
|
BlendFlags: 'u8',
|
|
38
53
|
SourceConstantAlpha: 'u8',
|
|
39
54
|
AlphaFormat: 'u8',
|
|
40
|
-
}
|
|
55
|
+
} satisfies C_Struct
|
|
56
|
+
|
|
57
|
+
export const BLENDFUNCTION = /* @__PURE__ */ struct('BLENDFUNCTION', BLENDFUNCTION_DECL)
|
|
41
58
|
|
|
42
59
|
/** 滚动参数(28B):cbSize 必须 = SCROLLINFO.size(结构自描述是 Win32 要求,缺省跳过帮不了);
|
|
43
60
|
* fMask = SIF_* 决定 Set 写哪些项 / Get 读哪些项 */
|
|
44
|
-
export const
|
|
61
|
+
export const SCROLLINFO_DECL = {
|
|
62
|
+
'#': 'struct',
|
|
45
63
|
cbSize: 'u32',
|
|
46
64
|
fMask: 'u32',
|
|
47
65
|
nMin: 'i32',
|
|
@@ -49,11 +67,14 @@ export const SCROLLINFO = /* @__PURE__ */ struct('SCROLLINFO', {
|
|
|
49
67
|
nPage: 'u32',
|
|
50
68
|
nPos: 'i32',
|
|
51
69
|
nTrackPos: 'i32',
|
|
52
|
-
}
|
|
70
|
+
} satisfies C_Struct
|
|
71
|
+
|
|
72
|
+
export const SCROLLINFO = /* @__PURE__ */ struct('SCROLLINFO', SCROLLINFO_DECL)
|
|
53
73
|
|
|
54
74
|
/** LOGFONTW(92B):lfFaceName 走字符串糖(u16[32]@utf-16le)直读写 string;
|
|
55
75
|
* 精度/质量类字段缺省跳过 = 保持 0(FW_DONTCARE/ANSI_CHARSET 等合法零值语义) */
|
|
56
|
-
export const
|
|
76
|
+
export const LOGFONTW_DECL = {
|
|
77
|
+
'#': 'struct',
|
|
57
78
|
lfHeight: 'i32',
|
|
58
79
|
lfWidth: 'i32',
|
|
59
80
|
lfEscapement: 'i32',
|
|
@@ -68,11 +89,14 @@ export const LOGFONTW = /* @__PURE__ */ struct('LOGFONTW', {
|
|
|
68
89
|
lfQuality: 'u8',
|
|
69
90
|
lfPitchAndFamily: 'u8',
|
|
70
91
|
lfFaceName: 'u16[32]@utf-16le',
|
|
71
|
-
}
|
|
92
|
+
} satisfies C_Struct
|
|
93
|
+
|
|
94
|
+
export const LOGFONTW = /* @__PURE__ */ struct('LOGFONTW', LOGFONTW_DECL)
|
|
72
95
|
|
|
73
96
|
/** TEXTMETRICW(60B = 11 LONG + 4 WCHAR + 5 BYTE 尾部补齐,双架构同布局):
|
|
74
97
|
* GetTextMetrics 纯出参位(不注册 encoder:TEXTMETRICW.alloc().ptr 进、decode 读回) */
|
|
75
|
-
export const
|
|
98
|
+
export const TEXTMETRICW_DECL = {
|
|
99
|
+
'#': 'struct',
|
|
76
100
|
tmHeight: 'i32',
|
|
77
101
|
tmAscent: 'i32',
|
|
78
102
|
tmDescent: 'i32',
|
|
@@ -93,14 +117,18 @@ export const TEXTMETRICW = /* @__PURE__ */ struct('TEXTMETRICW', {
|
|
|
93
117
|
tmStruckOut: 'u8',
|
|
94
118
|
tmPitchAndFamily: 'u8',
|
|
95
119
|
tmCharSet: 'u8',
|
|
96
|
-
}
|
|
120
|
+
} satisfies C_Struct
|
|
121
|
+
|
|
122
|
+
export const TEXTMETRICW = /* @__PURE__ */ struct('TEXTMETRICW', TEXTMETRICW_DECL)
|
|
97
123
|
|
|
98
124
|
/** WIN32_FIND_DATAW(592B 双架构同布局 = 8 头字段 44B + WCHAR[260] + WCHAR[14],
|
|
99
125
|
* mingw wingdi.h 的 cAlternateFileName 为 WCHAR[14] 非 MSDN 的 CHAR[14]):
|
|
100
126
|
* FindFirstFile/FindNextFile 纯出参位(不注册 encoder:WIN32_FIND_DATAW.alloc().ptr
|
|
101
127
|
* 进、decode 读回)。FILETIME 是 align 4 的 8B 时间,以 u64 + pack 4 忠实布局
|
|
102
128
|
* (u64 自然 align 8 须 pack 压到 4);时间值为 1601 起的 100ns 单元(bigint) */
|
|
103
|
-
export const
|
|
129
|
+
export const WIN32_FIND_DATAW_DECL = {
|
|
130
|
+
'#': 'struct',
|
|
131
|
+
'#pack': 4,
|
|
104
132
|
dwFileAttributes: 'u32',
|
|
105
133
|
ftCreationTime: 'u64',
|
|
106
134
|
ftLastAccessTime: 'u64',
|
|
@@ -111,22 +139,28 @@ export const WIN32_FIND_DATAW = /* @__PURE__ */ struct('WIN32_FIND_DATAW', {
|
|
|
111
139
|
dwReserved1: 'u32',
|
|
112
140
|
cFileName: 'u16[260]@utf-16le',
|
|
113
141
|
cAlternateFileName: 'u16[14]@utf-16le',
|
|
114
|
-
}
|
|
142
|
+
} satisfies C_Struct
|
|
143
|
+
|
|
144
|
+
export const WIN32_FIND_DATAW = /* @__PURE__ */ struct('WIN32_FIND_DATAW', WIN32_FIND_DATAW_DECL)
|
|
115
145
|
|
|
116
146
|
/** DOC_INFO_1W(3 指针随位宽:x64 24B / ia32 12B):StartDocPrinter 纯入参位
|
|
117
147
|
* (注册 encoder:{ pDocName: WCHAR.encode(s).ptr, ... } 对象直传——指针字段收裸
|
|
118
148
|
* 地址 number,字符串缓冲自行 WCHAR.encode 分配并保持引用) */
|
|
119
|
-
export const
|
|
149
|
+
export const DOC_INFO_1W_DECL = {
|
|
150
|
+
'#': 'struct',
|
|
120
151
|
pDocName: '<>ptr',
|
|
121
152
|
pOutputFile: '<>ptr',
|
|
122
153
|
pDatatype: '<>ptr',
|
|
123
|
-
}
|
|
154
|
+
} satisfies C_Struct
|
|
155
|
+
|
|
156
|
+
export const DOC_INFO_1W = /* @__PURE__ */ struct('DOC_INFO_1W', DOC_INFO_1W_DECL)
|
|
124
157
|
|
|
125
158
|
/** PRINTER_INFO_2W(13 指针 + 8 DWORD:x64 136B / ia32 84B,双架构已由 test_ffi raw 实测):
|
|
126
159
|
* EnumPrinters(Level=2) 出参数组元素。指针字段 decode 出地址 number,字符串须
|
|
127
160
|
* 逐字宽读跟进;数组 = 单缓冲读回(structArray().decode(buf, count):元素间无空洞,
|
|
128
161
|
* 但缓冲尾部含字符串区 → byteLength 非整数倍,须显式 count)。纯出参不注册 encoder */
|
|
129
|
-
export const
|
|
162
|
+
export const PRINTER_INFO_2W_DECL = {
|
|
163
|
+
'#': 'struct',
|
|
130
164
|
pServerName: '<>ptr',
|
|
131
165
|
pPrinterName: '<>ptr',
|
|
132
166
|
pShareName: '<>ptr',
|
|
@@ -148,12 +182,15 @@ export const PRINTER_INFO_2W = /* @__PURE__ */ struct('PRINTER_INFO_2W', {
|
|
|
148
182
|
Status: 'u32',
|
|
149
183
|
cJobs: 'u32',
|
|
150
184
|
AveragePPM: 'u32',
|
|
151
|
-
}
|
|
185
|
+
} satisfies C_Struct
|
|
186
|
+
|
|
187
|
+
export const PRINTER_INFO_2W = /* @__PURE__ */ struct('PRINTER_INFO_2W', PRINTER_INFO_2W_DECL)
|
|
152
188
|
|
|
153
189
|
/** 进程启动信息(CreateProcessW 纯入参位):指针字段随进程位宽(x86 68B / x64 104B,struct 按 os.arch 推,
|
|
154
190
|
* os.arch 是编译期进程指针宽度,WOW64 下 32 位进程得 ia32 布局)。cb 必须 = STARTUPINFOW.size
|
|
155
191
|
* (结构自描述是 Win32 要求);dwFlags 含 STARTF_USESTDHANDLES(0x100) 时才读 hStd* */
|
|
156
|
-
export const
|
|
192
|
+
export const STARTUPINFOW_DECL = {
|
|
193
|
+
'#': 'struct',
|
|
157
194
|
cb: 'u32',
|
|
158
195
|
lpReserved: '<>ptr',
|
|
159
196
|
lpDesktop: '<>ptr',
|
|
@@ -172,22 +209,28 @@ export const STARTUPINFOW = /* @__PURE__ */ struct('STARTUPINFOW', {
|
|
|
172
209
|
hStdInput: '<HFILE>ptr',
|
|
173
210
|
hStdOutput: '<HFILE>ptr',
|
|
174
211
|
hStdError: '<HFILE>ptr',
|
|
175
|
-
}
|
|
212
|
+
} satisfies C_Struct
|
|
213
|
+
|
|
214
|
+
export const STARTUPINFOW = /* @__PURE__ */ struct('STARTUPINFOW', STARTUPINFOW_DECL)
|
|
176
215
|
|
|
177
216
|
/** 新进程信息(CreateProcessW 出参位:x86 16B / x64 24B):hProcess/hThread 用完要 CloseHandle。
|
|
178
217
|
* 字段标 '!':CreatePipe/CreateProcess 成功路径下句柄必非零 —— decode 直出 Ptr 免收窄,
|
|
179
218
|
* 且对 0 当场 throw:忘判 CreateProcess 成功就 decode 时在 decode 处拦下(下游 '! 消费位'
|
|
180
219
|
* 的 callPacked 检查为第二层兜底)。 */
|
|
181
|
-
export const
|
|
220
|
+
export const PROCESS_INFORMATION_DECL = {
|
|
221
|
+
'#': 'struct',
|
|
182
222
|
hProcess: '<HPROCESS>ptr!',
|
|
183
223
|
hThread: '<HTHREAD>ptr!',
|
|
184
224
|
dwProcessId: 'u32',
|
|
185
225
|
dwThreadId: 'u32',
|
|
186
|
-
}
|
|
226
|
+
} satisfies C_Struct
|
|
227
|
+
|
|
228
|
+
export const PROCESS_INFORMATION = /* @__PURE__ */ struct('PROCESS_INFORMATION', PROCESS_INFORMATION_DECL)
|
|
187
229
|
|
|
188
230
|
/** 位图信息头(40B):GetDIBits/SetDIBitsToDevice 的 BITMAPINFO 头部(32bpp BI_RGB 无颜色表,
|
|
189
231
|
* 头部即全部);biHeight 负 = 自顶向下;写 BMP 文件时也是文件内的信息头 */
|
|
190
|
-
export const
|
|
232
|
+
export const BITMAPINFOHEADER_DECL = {
|
|
233
|
+
'#': 'struct',
|
|
191
234
|
biSize: 'u32',
|
|
192
235
|
biWidth: 'i32',
|
|
193
236
|
biHeight: 'i32',
|
|
@@ -199,23 +242,30 @@ export const BITMAPINFOHEADER = /* @__PURE__ */ struct('BITMAPINFOHEADER', {
|
|
|
199
242
|
biYPelsPerMeter: 'i32',
|
|
200
243
|
biClrUsed: 'u32',
|
|
201
244
|
biClrImportant: 'u32',
|
|
202
|
-
}
|
|
245
|
+
} satisfies C_Struct
|
|
246
|
+
|
|
247
|
+
export const BITMAPINFOHEADER = /* @__PURE__ */ struct('BITMAPINFOHEADER', BITMAPINFOHEADER_DECL)
|
|
203
248
|
|
|
204
249
|
/** BMP 文件头(14B,pack 2:文件格式按 2 字节紧凑排布,不是 Win32 调用的结构):
|
|
205
250
|
* bfType = 0x4d42('BM'),bfOffBits = 14 + 40(文件头 + 信息头,无颜色表) */
|
|
206
|
-
export const
|
|
251
|
+
export const BITMAPFILEHEADER_DECL = {
|
|
252
|
+
'#': 'struct',
|
|
253
|
+
'#pack': 2,
|
|
207
254
|
bfType: 'u16',
|
|
208
255
|
bfSize: 'u32',
|
|
209
256
|
bfReserved1: 'u16',
|
|
210
257
|
bfReserved2: 'u16',
|
|
211
258
|
bfOffBits: 'u32',
|
|
212
|
-
}
|
|
259
|
+
} satisfies C_Struct
|
|
260
|
+
|
|
261
|
+
export const BITMAPFILEHEADER = /* @__PURE__ */ struct('BITMAPFILEHEADER', BITMAPFILEHEADER_DECL)
|
|
213
262
|
|
|
214
263
|
// ── 通用对话框(跨组件/示例共享)───────────────────────────────────────
|
|
215
264
|
|
|
216
265
|
/** OPENFILENAMEW(GetOpenFileNameW)。Win2000+ 定义含尾部 pvReserved/dwReserved/FlagsEx
|
|
217
266
|
* (即 XP 系统上的真实 sizeof=152/88) */
|
|
218
|
-
export const
|
|
267
|
+
export const OPENFILENAMEW_DECL = {
|
|
268
|
+
'#': 'struct',
|
|
219
269
|
lStructSize: 'u32',
|
|
220
270
|
hwndOwner: '<HWND>ptr',
|
|
221
271
|
hInstance: '<HMODULE>ptr',
|
|
@@ -239,10 +289,13 @@ export const OPENFILENAMEW = /* @__PURE__ */ struct('OPENFILENAMEW', {
|
|
|
239
289
|
pvReserved: '<>ptr',
|
|
240
290
|
dwReserved: 'u32',
|
|
241
291
|
FlagsEx: 'u32',
|
|
242
|
-
}
|
|
292
|
+
} satisfies C_Struct
|
|
293
|
+
|
|
294
|
+
export const OPENFILENAMEW = /* @__PURE__ */ struct('OPENFILENAMEW', OPENFILENAMEW_DECL)
|
|
243
295
|
|
|
244
296
|
/** BROWSEINFOW(SHBrowseForFolderW) */
|
|
245
|
-
export const
|
|
297
|
+
export const BROWSEINFOW_DECL = {
|
|
298
|
+
'#': 'struct',
|
|
246
299
|
hwndOwner: '<HWND>ptr',
|
|
247
300
|
pidlRoot: '<>ptr',
|
|
248
301
|
pszDisplayName: '<>ptr',
|
|
@@ -251,20 +304,26 @@ export const BROWSEINFOW = /* @__PURE__ */ struct('BROWSEINFOW', {
|
|
|
251
304
|
lpfn: '<>ptr',
|
|
252
305
|
lParam: '<>ptr',
|
|
253
306
|
iImage: 'i32',
|
|
254
|
-
}
|
|
307
|
+
} satisfies C_Struct
|
|
255
308
|
|
|
256
|
-
|
|
309
|
+
export const BROWSEINFOW = /* @__PURE__ */ struct('BROWSEINFOW', BROWSEINFOW_DECL)
|
|
310
|
+
|
|
311
|
+
// ── WM_NOTIFY 通知结构(NMHDR 必须先定义,各通知结构嵌套其 DECL)────────
|
|
257
312
|
|
|
258
313
|
// NMHDR = hwndFrom(ptr) + idFrom(ptr) + code(i32)。
|
|
259
314
|
// 用 ffi-struct 定义以复现 MSVC/嵌套结构的“尾 padding 传染”(内嵌 NMHDR 占满 24/12 字节)。
|
|
260
|
-
// 各通知结构把它作为首字段嵌套(
|
|
261
|
-
export const
|
|
315
|
+
// 各通知结构把它作为首字段嵌套(NMHDR_DECL),字段偏移由 struct 按进程位宽推出。
|
|
316
|
+
export const NMHDR_DECL = {
|
|
317
|
+
'#': 'struct',
|
|
262
318
|
hwndFrom: '<HWND>ptr',
|
|
263
319
|
idFrom: '<>ptr',
|
|
264
320
|
code: 'i32',
|
|
265
|
-
}
|
|
321
|
+
} satisfies C_Struct
|
|
322
|
+
|
|
323
|
+
export const NMHDR = /* @__PURE__ */ struct('NMHDR', NMHDR_DECL)
|
|
266
324
|
|
|
267
|
-
export const
|
|
325
|
+
export const SYSTEMTIME_DECL = {
|
|
326
|
+
'#': 'struct',
|
|
268
327
|
wYear: 'u16',
|
|
269
328
|
wMonth: 'u16',
|
|
270
329
|
wDayOfWeek: 'u16',
|
|
@@ -273,46 +332,61 @@ export const SYSTEMTIME = /* @__PURE__ */ struct('SYSTEMTIME', {
|
|
|
273
332
|
wMinute: 'u16',
|
|
274
333
|
wSecond: 'u16',
|
|
275
334
|
wMilliseconds: 'u16',
|
|
276
|
-
}
|
|
335
|
+
} satisfies C_Struct
|
|
336
|
+
|
|
337
|
+
export const SYSTEMTIME = /* @__PURE__ */ struct('SYSTEMTIME', SYSTEMTIME_DECL)
|
|
277
338
|
|
|
278
339
|
/** DTN_DATETIMECHANGE 通知(DateTimePicker):NMHDR + dwFlags + SYSTEMTIME */
|
|
279
|
-
export const
|
|
280
|
-
|
|
340
|
+
export const NMDATETIMECHANGE_DECL = {
|
|
341
|
+
'#': 'struct',
|
|
342
|
+
hdr: NMHDR_DECL,
|
|
281
343
|
dwFlags: 'u32',
|
|
282
|
-
st:
|
|
283
|
-
}
|
|
344
|
+
st: SYSTEMTIME_DECL,
|
|
345
|
+
} satisfies C_Struct
|
|
346
|
+
|
|
347
|
+
export const NMDATETIMECHANGE = /* @__PURE__ */ struct('NMDATETIMECHANGE', NMDATETIMECHANGE_DECL)
|
|
284
348
|
|
|
285
349
|
// LITEM = Link 控件项。MAX_LINKID_TEXT = 48,L_MAX_URL_LENGTH = 2048 + 32 + sizeof("://") = 2084;
|
|
286
350
|
// 宽字符数组走字符串糖('u16[N]@utf-16le'),decode 直接得到 string(读到 NUL 为止)。
|
|
287
|
-
export const
|
|
351
|
+
export const LITEM_DECL = {
|
|
352
|
+
'#': 'struct',
|
|
288
353
|
mask: 'u32',
|
|
289
354
|
iLink: 'i32',
|
|
290
355
|
state: 'u32',
|
|
291
356
|
stateMask: 'u32',
|
|
292
357
|
szID: 'u16[48]@utf-16le',
|
|
293
358
|
szUrl: 'u16[2084]@utf-16le',
|
|
294
|
-
}
|
|
359
|
+
} satisfies C_Struct
|
|
360
|
+
|
|
361
|
+
export const LITEM = /* @__PURE__ */ struct('LITEM', LITEM_DECL)
|
|
295
362
|
|
|
296
363
|
/** NMLINK = NMHDR + LITEM(Link 的 NM_CLICK 等通知) */
|
|
297
|
-
export const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
364
|
+
export const NMLINK_DECL = {
|
|
365
|
+
'#': 'struct',
|
|
366
|
+
hdr: NMHDR_DECL,
|
|
367
|
+
item: LITEM_DECL,
|
|
368
|
+
} satisfies C_Struct
|
|
369
|
+
|
|
370
|
+
export const NMLINK = /* @__PURE__ */ struct('NMLINK', NMLINK_DECL)
|
|
301
371
|
|
|
302
372
|
/** NMCUSTOMDRAW(自绘通知基结构):嵌套 NMHDR 以复现 MSVC 尾 padding 传染,offsetOf 保证 ia32/x64 均正确 */
|
|
303
|
-
export const
|
|
304
|
-
|
|
373
|
+
export const NMCUSTOMDRAW_DECL = {
|
|
374
|
+
'#': 'struct',
|
|
375
|
+
hdr: NMHDR_DECL,
|
|
305
376
|
dwDrawStage: 'u32',
|
|
306
377
|
hdc: '<HDC>ptr',
|
|
307
378
|
rc: 'i32[4]',
|
|
308
379
|
dwItemSpec: '<>ptr',
|
|
309
380
|
uItemState: 'u32',
|
|
310
381
|
lItemlParam: '<>ptr',
|
|
311
|
-
}
|
|
382
|
+
} satisfies C_Struct
|
|
383
|
+
|
|
384
|
+
export const NMCUSTOMDRAW = /* @__PURE__ */ struct('NMCUSTOMDRAW', NMCUSTOMDRAW_DECL)
|
|
312
385
|
|
|
313
386
|
/** NMLVCUSTOMDRAW = NMCUSTOMDRAW + 颜色/子项字段(ListView 自绘) */
|
|
314
|
-
export const
|
|
315
|
-
|
|
387
|
+
export const NMLVCUSTOMDRAW_DECL = {
|
|
388
|
+
'#': 'struct',
|
|
389
|
+
hdr: NMHDR_DECL,
|
|
316
390
|
dwDrawStage: 'u32',
|
|
317
391
|
hdc: '<HDC>ptr',
|
|
318
392
|
rc: 'i32[4]',
|
|
@@ -323,11 +397,14 @@ export const NMLVCUSTOMDRAW = /* @__PURE__ */ struct('NMLVCUSTOMDRAW', {
|
|
|
323
397
|
clrTextBk: 'u32',
|
|
324
398
|
iSubItem: 'i32',
|
|
325
399
|
dwItemType: 'u32',
|
|
326
|
-
}
|
|
400
|
+
} satisfies C_Struct
|
|
401
|
+
|
|
402
|
+
export const NMLVCUSTOMDRAW = /* @__PURE__ */ struct('NMLVCUSTOMDRAW', NMLVCUSTOMDRAW_DECL)
|
|
327
403
|
|
|
328
404
|
// NMLISTVIEW / NMITEMACTIVATE 前缀字段布局一致(iItem..uChanged)
|
|
329
|
-
export const
|
|
330
|
-
|
|
405
|
+
export const NMLISTVIEW_DECL = {
|
|
406
|
+
'#': 'struct',
|
|
407
|
+
hdr: NMHDR_DECL,
|
|
331
408
|
iItem: 'i32',
|
|
332
409
|
iSubItem: 'i32',
|
|
333
410
|
uNewState: 'u32',
|
|
@@ -335,11 +412,14 @@ export const NMLISTVIEW = /* @__PURE__ */ struct('NMLISTVIEW', {
|
|
|
335
412
|
uChanged: 'u32',
|
|
336
413
|
ptAction: 'i32[2]',
|
|
337
414
|
lParam: '<>ptr',
|
|
338
|
-
}
|
|
415
|
+
} satisfies C_Struct
|
|
416
|
+
|
|
417
|
+
export const NMLISTVIEW = /* @__PURE__ */ struct('NMLISTVIEW', NMLISTVIEW_DECL)
|
|
339
418
|
|
|
340
419
|
// ── 通用控件(comctl32)结构 ────────────────────────────────────────
|
|
341
420
|
|
|
342
|
-
export const
|
|
421
|
+
export const TCITEMW_DECL = {
|
|
422
|
+
'#': 'struct',
|
|
343
423
|
mask: 'u32',
|
|
344
424
|
dwState: 'u32',
|
|
345
425
|
dwStateMask: 'u32',
|
|
@@ -347,9 +427,12 @@ export const TCITEMW = /* @__PURE__ */ struct('TCITEMW', {
|
|
|
347
427
|
cchTextMax: 'i32',
|
|
348
428
|
iImage: 'i32',
|
|
349
429
|
lParam: '<>ptr',
|
|
350
|
-
}
|
|
430
|
+
} satisfies C_Struct
|
|
431
|
+
|
|
432
|
+
export const TCITEMW = /* @__PURE__ */ struct('TCITEMW', TCITEMW_DECL)
|
|
351
433
|
|
|
352
|
-
export const
|
|
434
|
+
export const TTTOOLINFOW_DECL = {
|
|
435
|
+
'#': 'struct',
|
|
353
436
|
cbSize: 'u32',
|
|
354
437
|
uFlags: 'u32',
|
|
355
438
|
hwnd: '<HWND>ptr',
|
|
@@ -359,9 +442,12 @@ export const TTTOOLINFOW = /* @__PURE__ */ struct('TTTOOLINFOW', {
|
|
|
359
442
|
lpszText: '<>ptr',
|
|
360
443
|
lParam: '<>ptr',
|
|
361
444
|
lpReserved: '<>ptr', // WinXP+ 追加字段(系统 sizeof 含之)
|
|
362
|
-
}
|
|
445
|
+
} satisfies C_Struct
|
|
363
446
|
|
|
364
|
-
export const
|
|
447
|
+
export const TTTOOLINFOW = /* @__PURE__ */ struct('TTTOOLINFOW', TTTOOLINFOW_DECL)
|
|
448
|
+
|
|
449
|
+
export const TVITEM_DECL = {
|
|
450
|
+
'#': 'struct',
|
|
365
451
|
mask: 'u32',
|
|
366
452
|
hItem: '<>ptr',
|
|
367
453
|
state: 'u32',
|
|
@@ -372,25 +458,34 @@ export const TVITEM = /* @__PURE__ */ struct('TVITEM', {
|
|
|
372
458
|
iSelectedImage: 'i32',
|
|
373
459
|
cChildren: 'i32',
|
|
374
460
|
lParam: '<>ptr',
|
|
375
|
-
}
|
|
461
|
+
} satisfies C_Struct
|
|
462
|
+
|
|
463
|
+
export const TVITEM = /* @__PURE__ */ struct('TVITEM', TVITEM_DECL)
|
|
376
464
|
|
|
377
465
|
/** TVINSERTSTRUCT:hParent/hInsertAfter + item 内嵌 TVITEM(TreeView 插入项) */
|
|
378
|
-
export const
|
|
466
|
+
export const TVINSERTSTRUCT_DECL = {
|
|
467
|
+
'#': 'struct',
|
|
379
468
|
hParent: '<>ptr',
|
|
380
469
|
hInsertAfter: '<>ptr',
|
|
381
|
-
item:
|
|
382
|
-
}
|
|
470
|
+
item: TVITEM_DECL,
|
|
471
|
+
} satisfies C_Struct
|
|
472
|
+
|
|
473
|
+
export const TVINSERTSTRUCT = /* @__PURE__ */ struct('TVINSERTSTRUCT', TVINSERTSTRUCT_DECL)
|
|
383
474
|
|
|
384
475
|
/** LVM_SUBITEMHITTEST 的 LVHITTESTINFO(24B):pt 是入参,iItem/iSubItem 是出参(入参先置 -1) */
|
|
385
|
-
export const
|
|
476
|
+
export const LVHITTESTINFO_DECL = {
|
|
477
|
+
'#': 'struct',
|
|
386
478
|
pt: 'i32[2]',
|
|
387
479
|
flags: 'u32',
|
|
388
480
|
iItem: 'i32',
|
|
389
481
|
iSubItem: 'i32',
|
|
390
482
|
iGroup: 'i32',
|
|
391
|
-
}
|
|
483
|
+
} satisfies C_Struct
|
|
392
484
|
|
|
393
|
-
export const
|
|
485
|
+
export const LVHITTESTINFO = /* @__PURE__ */ struct('LVHITTESTINFO', LVHITTESTINFO_DECL)
|
|
486
|
+
|
|
487
|
+
export const LVITEMW_DECL = {
|
|
488
|
+
'#': 'struct',
|
|
394
489
|
mask: 'u32',
|
|
395
490
|
iItem: 'i32',
|
|
396
491
|
iSubItem: 'i32',
|
|
@@ -406,9 +501,12 @@ export const LVITEMW = /* @__PURE__ */ struct('LVITEMW', {
|
|
|
406
501
|
puColumns: '<>ptr',
|
|
407
502
|
piColFmt: '<>ptr',
|
|
408
503
|
iGroup: 'i32',
|
|
409
|
-
}
|
|
504
|
+
} satisfies C_Struct
|
|
505
|
+
|
|
506
|
+
export const LVITEMW = /* @__PURE__ */ struct('LVITEMW', LVITEMW_DECL)
|
|
410
507
|
|
|
411
|
-
export const
|
|
508
|
+
export const LVCOLUMNW_DECL = {
|
|
509
|
+
'#': 'struct',
|
|
412
510
|
mask: 'u32',
|
|
413
511
|
fmt: 'i32',
|
|
414
512
|
cx: 'i32',
|
|
@@ -420,32 +518,41 @@ export const LVCOLUMNW = /* @__PURE__ */ struct('LVCOLUMNW', {
|
|
|
420
518
|
cxMin: 'i32',
|
|
421
519
|
cxDefault: 'i32',
|
|
422
520
|
cxIdeal: 'i32',
|
|
423
|
-
}
|
|
521
|
+
} satisfies C_Struct
|
|
522
|
+
|
|
523
|
+
export const LVCOLUMNW = /* @__PURE__ */ struct('LVCOLUMNW', LVCOLUMNW_DECL)
|
|
424
524
|
|
|
425
525
|
// ── 消息循环 / 绘制 / 窗口类(user32;偏移经 MinGW 头 x64+ia32 双架构实测)────────
|
|
426
526
|
|
|
427
527
|
/** MSG(48B x64 / 28B ia32):GetMessage/PeekMessage/DispatchMessage 的消息槽 */
|
|
428
|
-
export const
|
|
528
|
+
export const MSG_DECL = {
|
|
529
|
+
'#': 'struct',
|
|
429
530
|
hwnd: '<HWND>ptr',
|
|
430
531
|
message: 'u32',
|
|
431
532
|
wParam: '<>ptr',
|
|
432
533
|
lParam: '<>ptr',
|
|
433
534
|
time: 'u32',
|
|
434
|
-
pt:
|
|
435
|
-
}
|
|
535
|
+
pt: POINT_DECL,
|
|
536
|
+
} satisfies C_Struct
|
|
537
|
+
|
|
538
|
+
export const MSG = /* @__PURE__ */ struct('MSG', MSG_DECL)
|
|
436
539
|
|
|
437
540
|
/** PAINTSTRUCT(72B x64 / 64B ia32):BeginPaint 出参(整结构由 API 写入),EndPaint 归还 */
|
|
438
|
-
export const
|
|
541
|
+
export const PAINTSTRUCT_DECL = {
|
|
542
|
+
'#': 'struct',
|
|
439
543
|
hdc: '<HDC>ptr',
|
|
440
544
|
fErase: 'i32',
|
|
441
|
-
rcPaint:
|
|
545
|
+
rcPaint: RECT_DECL,
|
|
442
546
|
fRestore: 'i32',
|
|
443
547
|
fIncUpdate: 'i32',
|
|
444
548
|
rgbReserved: 'u8[32]',
|
|
445
|
-
}
|
|
549
|
+
} satisfies C_Struct
|
|
550
|
+
|
|
551
|
+
export const PAINTSTRUCT = /* @__PURE__ */ struct('PAINTSTRUCT', PAINTSTRUCT_DECL)
|
|
446
552
|
|
|
447
553
|
/** WNDCLASSEXW(80B x64 / 48B ia32):RegisterClassExW 入参;cbSize 必须 = WNDCLASSEXW.size */
|
|
448
|
-
export const
|
|
554
|
+
export const WNDCLASSEXW_DECL = {
|
|
555
|
+
'#': 'struct',
|
|
449
556
|
cbSize: 'u32',
|
|
450
557
|
style: 'u32',
|
|
451
558
|
lpfnWndProc: '<>ptr',
|
|
@@ -458,7 +565,9 @@ export const WNDCLASSEXW = /* @__PURE__ */ struct('WNDCLASSEXW', {
|
|
|
458
565
|
lpszMenuName: '<>ptr',
|
|
459
566
|
lpszClassName: '<>ptr',
|
|
460
567
|
hIconSm: '<>ptr',
|
|
461
|
-
}
|
|
568
|
+
} satisfies C_Struct
|
|
569
|
+
|
|
570
|
+
export const WNDCLASSEXW = /* @__PURE__ */ struct('WNDCLASSEXW', WNDCLASSEXW_DECL)
|
|
462
571
|
|
|
463
572
|
// ── 显示模式(user32 EnumDisplaySettingsW/ChangeDisplaySettingsW)────────────────
|
|
464
573
|
|
|
@@ -466,7 +575,8 @@ export const WNDCLASSEXW = /* @__PURE__ */ struct('WNDCLASSEXW', {
|
|
|
466
575
|
* union 的 display 分支平铺(dmPosition/ dmDisplayOrientation/ dmDisplayFixedOutput)——
|
|
467
576
|
* printer 分支同为 16B,平铺后偏移与 sizeof 均与实测一致;printer 场景不在本库用途内。
|
|
468
577
|
* dmSize/ dmDriverExtra 入参先置(dmSize = DEVMODEW.size;dmDriverExtra = 0),否则 API 拒绝 */
|
|
469
|
-
export const
|
|
578
|
+
export const DEVMODEW_DECL = {
|
|
579
|
+
'#': 'struct',
|
|
470
580
|
dmDeviceName: 'u16[32]@utf-16le',
|
|
471
581
|
dmSpecVersion: 'u16',
|
|
472
582
|
dmDriverVersion: 'u16',
|
|
@@ -496,7 +606,9 @@ export const DEVMODEW = /* @__PURE__ */ struct('DEVMODEW', {
|
|
|
496
606
|
dmReserved2: 'u32',
|
|
497
607
|
dmPanningWidth: 'u32',
|
|
498
608
|
dmPanningHeight: 'u32',
|
|
499
|
-
}
|
|
609
|
+
} satisfies C_Struct
|
|
610
|
+
|
|
611
|
+
export const DEVMODEW = /* @__PURE__ */ struct('DEVMODEW', DEVMODEW_DECL)
|
|
500
612
|
|
|
501
613
|
// ── 系统版本(ntdll RtlGetVersion)────────────────────────────────────────────
|
|
502
614
|
|
|
@@ -504,14 +616,17 @@ export const DEVMODEW = /* @__PURE__ */ struct('DEVMODEW', {
|
|
|
504
616
|
* dwOSVersionInfoSize 填成同值(尾部 128 字节 = szCSDVersion 区),否则 RtlGetVersion
|
|
505
617
|
* 会越界写坏调用方堆导致子进程挂起。标准 OSVERSIONINFOW(宽字符 szCSDVersion[128])
|
|
506
618
|
* 应为 276B;148 是 win11 上实测过的值,保持不变 */
|
|
507
|
-
export const
|
|
619
|
+
export const OSVERSIONINFO_148_DECL = {
|
|
620
|
+
'#': 'struct',
|
|
508
621
|
dwOSVersionInfoSize: 'u32',
|
|
509
622
|
dwMajorVersion: 'u32',
|
|
510
623
|
dwMinorVersion: 'u32',
|
|
511
624
|
dwBuildNumber: 'u32',
|
|
512
625
|
dwPlatformId: 'u32',
|
|
513
626
|
szCSDVersion: 'u8[128]',
|
|
514
|
-
}
|
|
627
|
+
} satisfies C_Struct
|
|
628
|
+
|
|
629
|
+
export const OSVERSIONINFO_148 = /* @__PURE__ */ struct('OSVERSIONINFO_148', OSVERSIONINFO_148_DECL)
|
|
515
630
|
|
|
516
631
|
// ── 进程快照 / 内存统计(toolhelp + psapi,布局来源官方 tlhelp32.h / psapi.h)────────
|
|
517
632
|
|
|
@@ -520,7 +635,8 @@ export const OSVERSIONINFO_148 = /* @__PURE__ */ struct('OSVERSIONINFO_148', {
|
|
|
520
635
|
* 成 size(MSDN:不初始化 dwSize 则 Process32First 失败)——alloc() 后
|
|
521
636
|
* new Uint32Array(buf)[0] = PROCESSENTRY32W.size 一次;First/Next 迭代间复用同一 buf
|
|
522
637
|
* (API 只改内容不改 dwSize),每轮 N.decode(buf) 读回 */
|
|
523
|
-
export const
|
|
638
|
+
export const PROCESSENTRY32W_DECL = {
|
|
639
|
+
'#': 'struct',
|
|
524
640
|
dwSize: 'u32',
|
|
525
641
|
cntUsage: 'u32',
|
|
526
642
|
th32ProcessID: 'u32',
|
|
@@ -531,12 +647,15 @@ export const PROCESSENTRY32W = /* @__PURE__ */ struct('PROCESSENTRY32W', {
|
|
|
531
647
|
pcPriClassBase: 'i32',
|
|
532
648
|
dwFlags: 'u32',
|
|
533
649
|
szExeFile: 'u16[260]@utf-16le',
|
|
534
|
-
}
|
|
650
|
+
} satisfies C_Struct
|
|
651
|
+
|
|
652
|
+
export const PROCESSENTRY32W = /* @__PURE__ */ struct('PROCESSENTRY32W', PROCESSENTRY32W_DECL)
|
|
535
653
|
|
|
536
654
|
/** MODULEENTRY32W(Module32First/Next 就地迭代位;x86 1072B / x64 1088B——BYTE* +
|
|
537
655
|
* HMODULE 随位宽)。dwSize 预写同 PROCESSENTRY32W;modBaseAddr/hModule 仅在
|
|
538
656
|
* th32ProcessID 的进程上下文有效;szModule 定长 256 = MAX_MODULE_NAME32+1 */
|
|
539
|
-
export const
|
|
657
|
+
export const MODULEENTRY32W_DECL = {
|
|
658
|
+
'#': 'struct',
|
|
540
659
|
dwSize: 'u32',
|
|
541
660
|
th32ModuleID: 'u32',
|
|
542
661
|
th32ProcessID: 'u32',
|
|
@@ -547,12 +666,15 @@ export const MODULEENTRY32W = /* @__PURE__ */ struct('MODULEENTRY32W', {
|
|
|
547
666
|
hModule: '<HMODULE>ptr',
|
|
548
667
|
szModule: 'u16[256]@utf-16le',
|
|
549
668
|
szExePath: 'u16[260]@utf-16le',
|
|
550
|
-
}
|
|
669
|
+
} satisfies C_Struct
|
|
670
|
+
|
|
671
|
+
export const MODULEENTRY32W = /* @__PURE__ */ struct('MODULEENTRY32W', MODULEENTRY32W_DECL)
|
|
551
672
|
|
|
552
673
|
/** PROCESS_MEMORY_COUNTERS(GetProcessMemoryInfo 出参位;x86 40B / x64 72B):官方 psapi.h
|
|
553
674
|
* 为 cb + PageFaultCount 后接 8×SIZE_T——SIZE_T 随位宽(非全 DWORD),struct 按 os.arch 推。
|
|
554
675
|
* 调用前 offset 0 的 cb 预写成 size(new Uint32Array(buf)[0] = N.size),实参 u32 cb 同传 size */
|
|
555
|
-
export const
|
|
676
|
+
export const PROCESS_MEMORY_COUNTERS_DECL = {
|
|
677
|
+
'#': 'struct',
|
|
556
678
|
cb: 'u32',
|
|
557
679
|
PageFaultCount: 'u32',
|
|
558
680
|
PeakWorkingSetSize: '<>ptr',
|
|
@@ -563,4 +685,6 @@ export const PROCESS_MEMORY_COUNTERS = /* @__PURE__ */ struct('PROCESS_MEMORY_CO
|
|
|
563
685
|
QuotaNonPagedPoolUsage: '<>ptr',
|
|
564
686
|
PagefileUsage: '<>ptr',
|
|
565
687
|
PeakPagefileUsage: '<>ptr',
|
|
566
|
-
}
|
|
688
|
+
} satisfies C_Struct
|
|
689
|
+
|
|
690
|
+
export const PROCESS_MEMORY_COUNTERS = /* @__PURE__ */ struct('PROCESS_MEMORY_COUNTERS', PROCESS_MEMORY_COUNTERS_DECL)
|