-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathWindowsUtilities.js
2424 lines (2186 loc) · 85 KB
/
WindowsUtilities.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Windows Registry Settings Handler
*
* Copyright 2012 Raising the Floor - International
* Copyright 2012 Antranig Basman
* Copyright 2012 Astea Solutions AD
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The research leading to these results has received funding from the European Union's
* Seventh Framework Programme (FP7/2007-2013)
* under grant agreement no. 289016.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
"use strict";
// GPII-3445: Monkey patch the Callback constructor to keep a reference of the callback info buffer, to prevent it from
// being GC'd. Otherwise, callbacks (such as the message window's window procedure) will end up reading a freed or
// reallocated piece of memory. This constructor is used by ffi-napi, so needs to be patched before it's included.
var ffiBindings = require("ffi-napi/lib/bindings.js");
var origCallback = ffiBindings.Callback;
ffiBindings.Callback = function (cif, size, argc, errorReportCallback, fn) {
var ret = origCallback(cif, size, argc, errorReportCallback, fn);
// Attach the data onto the returned callback pointer, so it lasts as long as the callback.
ret["ffi.cif"] = cif;
return ret;
};
var ffi = require("ffi-napi"),
child_process = require("child_process"),
fluid = require("gpii-universal"),
fs = require("fs"),
path = require("path");
var gpii = fluid.registerNamespace("gpii");
var windows = fluid.registerNamespace("gpii.windows");
var ref = require("ref");
var Struct = require("ref-struct");
var arrayType = require("ref-array");
var NULL = ref.NULL;
var os = require("os");
var arch = os.arch();
/**
* A map between Windows and C types.
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx
*/
windows.types = {
"BOOL": "int",
"PBOOL": "*int",
"INT": "int",
"PINT": ref.refType("int"),
"UINT": "uint",
"PUINT": ref.refType("uint"),
"ULONG": "ulong",
"DWORD": "ulong",
"LPDWORD": "*ulong",
"HKL": "void*",
"ULONG_PTR": arch === "x64" ? "uint64" : "uint32",
"LONG": "long",
"HANDLE": arch === "x64" ? "uint64" : "uint32",
"PVOID": ref.refType("void"),
"WORD": "uint16",
"LUID": "uint64",
// TODO: TCHAR should support Unicode and Windows code pages. We are just guessing
// the system is using Unicode (wchar_t == uint16 type). The implementation should
// support both modes.
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd374131(v=vs.85).aspx
"TCHAR": "uint16",
"PTCHAR": ref.refType("uint16"),
"LP": "void*"
};
var t = windows.types;
windows.kernel32 = ffi.Library("kernel32", {
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx
// UINT, DWORD, LPCSTR, INT, LPWSTR, INT
"MultiByteToWideChar": [
"int", ["uint", "uint32", "char*", "int", "void*", "int"]
],
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx
// UINT, DWORD, LPCWSTR, int, LPSTR, int, LPCSTR, LPBOOL
"WideCharToMultiByte": [
"int", ["uint", "uint32", "void*", "int", "char*", "int", "char*", "bool*"]
],
"GetLastError": [
"uint32", []
],
"SetLastError": [
"void", [ "int32" ]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx
"CreateToolhelp32Snapshot": [
t.HANDLE, [t.DWORD, t.DWORD]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684834%28v=vs.85%29.aspx
"Process32First": [
"bool", [t.DWORD, "pointer"]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684320%28v=vs.85%29.aspx
"OpenProcess": [
t.HANDLE, [t.DWORD, t.BOOL, t.DWORD]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686714%28v=vs.85%29.aspx
"TerminateProcess": [
t.BOOL, [t.HANDLE, t.UINT]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211%28v=vs.85%29.aspx
"CloseHandle": [
t.BOOL, [t.HANDLE]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684836%28v=vs.85%29.aspx
"Process32Next": [
t.BOOL, [t.HANDLE, "pointer"]
],
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684139.aspx
"IsWow64Process": [
t.BOOL, [t.INT, t.PBOOL ]
],
// https://msdn.microsoft.com/library/ms684919.aspx
"QueryFullProcessImageNameW": [
t.BOOL, [t.HANDLE, t.DWORD, "char*", t.LPDWORD ]
],
// https://msdn.microsoft.com/library/ms683199
"GetModuleHandleW": [
t.HANDLE, ["int"]
],
// https://msdn.microsoft.com/library/ms683223
"GetProcessTimes": [
t.BOOL, [ t.HANDLE, "void*", "void*", "void*", "void*" ]
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-formatmessage
"FormatMessageW": [
t.DWORD, [t.DWORD, t.PVOID, t.DWORD, t.DWORD, t.PTCHAR, t.DWORD, t.PVOID]
],
// https://msdn.microsoft.com/library/ms686227
"SetProcessShutdownParameters": [
t.BOOL, [ t.DWORD, t.DWORD ]
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-localfree
"LocalFree": [
"uint32", [ "int" ]
],
// https://docs.microsoft.com/windows/desktop/api/winnls/nf-winnls-getthreaduilanguage
"GetThreadUILanguage": [
t.WORD, [ ]
],
// https://docs.microsoft.com/windows/desktop/api/winnls/nf-winnls-lcidtolocalename
"LCIDToLocaleName": [
"int", [ t.WORD, "char*", "int", t.DWORD ]
],
// https://docs.microsoft.com/windows/desktop/api/fileapi/nf-fileapi-getlogicaldrivestringsw
"GetLogicalDriveStringsW": [
t.DWORD, [ t.DWORD, "char*" ]
],
// https://docs.microsoft.com/windows/desktop/api/fileapi/nf-fileapi-getdrivetypew
"GetDriveTypeW": [
t.UINT, [ "char*" ]
],
// https://docs.microsoft.com/windows/desktop/api/ioapiset/nf-ioapiset-deviceiocontrol
"DeviceIoControl": [
t.BOOL, [
t.HANDLE, // hDevice,
t.DWORD, // dwIoControlCode,
t.PVOID, // lpInBuffer,
t.DWORD, // nInBufferSize,
t.PVOID, // lpOutBuffer,
t.DWORD, // nOutBufferSize,
t.LPDWORD, // lpBytesReturned,
"int" // lpOverlapped
]
],
// https://msdn.microsoft.com/library/aa363858
"CreateFileW": [
t.HANDLE, [ "char*", t.DWORD, t.DWORD, t.HANDLE, t.DWORD, t.DWORD, t.HANDLE ]
],
// https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
"CreateProcessW": [
t.BOOL, [
"char*", // LPCTSTR lpApplicationName,
"char*", // LPTSTR lpCommandLine,
t.LP, // LPSECURITY_ATTRIBUTES lpProcessAttributes,
t.LP, // LPSECURITY_ATTRIBUTES lpThreadAttributes,
t.BOOL, // BOOL bInheritHandles,
t.DWORD, // DWORD dwCreationFlags,
t.LP, // LPVOID lpEnvironment,
t.LP, // LPCTSTR lpCurrentDirectory,
t.LP, // LPSTARTUPINFO lpStartupInfo,
t.LP // LPPROCESS_INFORMATION lpProcessInformation
]
],
// https://msdn.microsoft.com/library/ms686211
"SetEvent": [
t.BOOL, [ t.HANDLE ]
],
// https://docs.microsoft.com/windows/win32/api/winnls/nf-winnls-getsystemdefaultlocalename
"GetSystemDefaultLocaleName": [
t.INT, [ "char*", t.INT ]
],
// https://msdn.microsoft.com/library/ms724265
"ExpandEnvironmentStringsW": [
t.BOOL, [ "char*", "char*", t.UINT ]
]
});
windows.user32 = ffi.Library("user32", {
// https://msdn.microsoft.com/library/ms633497
"EnumWindows": [
t.BOOL, ["void*", t.HANDLE]
],
// https://msdn.microsoft.com/library/ms633494
"EnumChildWindows": [
t.BOOL, [t.HANDLE, "void*", t.HANDLE]
],
// https://msdn.microsoft.com/library/windows/desktop/ms633522
"GetWindowThreadProcessId": [
t.DWORD, [t.HANDLE, t.LPDWORD]
],
// https://msdn.microsoft.com/library/windows/desktop/ms644944
"PostMessageW": [
t.BOOL, [t.HANDLE, t.UINT, t.UINT, t.HANDLE ]
],
// https://msdn.microsoft.com/library/ms633505
"GetForegroundWindow": [
t.HANDLE, []
],
// https://msdn.microsoft.com/library/ms646306
"MapVirtualKeyW": [
t.UINT, [ t.UINT, t.UINT ]
],
// https://msdn.microsoft.com/en-us/library/dd145064.aspx
"MonitorFromWindow": [
t.HANDLE, [ t.HANDLE, t.DWORD ]
],
// https://msdn.microsoft.com/library/dd144901
"GetMonitorInfoW": [
// HMONITOR, LPMONITORINFO
t.BOOL, [t.HANDLE, "pointer"]
],
// https://msdn.microsoft.com/library/ms632680
"CreateWindowExW": [
t.HANDLE, [
t.DWORD, // dwExStyle
"char*", // lpClassName
"char*", // lpWindowName
t.DWORD, // dwStyle
t.INT, // X
t.INT, // Y
t.INT, // nWidth
t.INT, // nHeight
t.HANDLE, // hWndParent
t.HANDLE, // hMenu
t.HANDLE, // hInstance
t.HANDLE // lpParam
]
],
// https://msdn.microsoft.com/library/ms633586
"RegisterClassW": [
t.HANDLE, [ t.PVOID ]
],
// https://msdn.microsoft.com/library/ms633572
"DefWindowProcW": [
t.HANDLE, [ t.HANDLE, t.UINT, t.UINT, t.PVOID ]
],
// https://msdn.microsoft.com/library/ms644943
"PeekMessageW": [
t.BOOL, [ t.PVOID, t.HANDLE, t.UINT, t.UINT, t.UINT ]
],
// https://msdn.microsoft.com/library/ms644955
"TranslateMessage": [
t.BOOL, [ t.PVOID ]
],
// https://msdn.microsoft.com/library/ms644934
"DispatchMessageW": [
t.BOOL, [ t.PVOID ]
],
// https://msdn.microsoft.com/library/ms632682
"DestroyWindow": [
t.BOOL, [ t.HANDLE ]
],
// https://msdn.microsoft.com/library/ms644989
"RegisterShellHookWindow": [
t.BOOL, [ t.HANDLE ]
],
// https://msdn.microsoft.com/library/ms644947
"RegisterWindowMessageW": [
t.UINT, [ "char*" ]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getclipboardformatnamew
"GetClipboardFormatNameW": [
t.UINT, [ t.UINT, "char*", "int" ]
],
// https://msdn.microsoft.com/library/ms644950
"SendMessageW": [
"int", [t.HANDLE, t.UINT, t.UINT, "int" ]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendnotifymessagew
"SendNotifyMessageW": [
"int", [t.HANDLE, t.UINT, t.UINT, "int" ]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendmessagecallbackw
"SendMessageCallbackW": [
"int", [t.HANDLE, t.UINT, t.UINT, "int", "void*", t.ULONG_PTR ]
],
// https://msdn.microsoft.com/library/ms633519
"GetWindowRect": [
t.BOOL, [ t.HANDLE, t.PVOID ]
],
// https://msdn.microsoft.com/library/ms646304
"keybd_event": [
"void", [ "char", "char", t.DWORD, t.ULONG_PTR ]
],
// https://msdn.microsoft.com/library/ms646260
"mouse_event": [
"void", [ t.DWORD, t.DWORD, t.DWORD, t.LONG, t.ULONG_PTR ]
],
// https://msdn.microsoft.com/library/ms648394
"GetCursorPos": [
t.BOOL, [ t.PVOID ]
],
// https://msdn.microsoft.com/library/ms648394
"SetCursorPos": [
t.BOOL, [ "int", "int" ]
],
// https://msdn.microsoft.com/library/ms633582
"GetClassNameW": [
t.INT, [ t.HANDLE, "char*", t.INT ]
],
// https://msdn.microsoft.com/library/ms646329
"VkKeyScanW": [
"short", [ t.TCHAR ]
],
// https://msdn.microsoft.com/library/ms633558
"WindowFromPoint": [
// Normally defined as WindowFromPoint(POINT)
t.HANDLE, [ t.LONG, t.LONG ]
],
// https://msdn.microsoft.com/library/ms633548
"ShowWindow": [
t.BOOL, [ t.HANDLE, "int" ]
],
// https://msdn.microsoft.com/library/ms633510
"GetParent": [
t.HANDLE, [ t.HANDLE ]
],
// https://msdn.microsoft.com/library/ms633527
"IsIconic": [
t.BOOL, [ t.HANDLE ]
],
// https://msdn.microsoft.com/library/ms633499
"FindWindowW": [
gpii.windows.types.HANDLE, ["char*", "char*"]
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setsyscolors
"SetSysColors": [
t.INT, [t.INT, t.PINT, t.PUINT]
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getsyscolor
"GetSysColor": [
t.UINT, [t.INT]
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdoubleclicktime
"GetDoubleClickTime": [
"uint32", []
],
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setdoubleclicktime
"SetDoubleClickTime": [
"int32", ["uint32"]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getsystemmetrics
"GetSystemMetrics": [
"int", ["int"]
],
// https://msdn.microsoft.com/library/ms646301
"GetKeyState": [
"short", ["int"]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setdisplayconfig
"SetDisplayConfig": [
"int32", ["uint32", "void*", "uint32", "void*", "uint32"]
],
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-querydisplayconfig
"QueryDisplayConfig": [
"int32", ["uint32", "uint32*", t.PVOID, "uint32*", t.PVOID, "uint32*"]
],
"GetDisplayConfigBufferSizes": [
"int32", ["uint32", "uint32*", "uint32*"]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-getasynckeystate
"GetAsyncKeyState": [
"short", ["int"]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput
"SendInput": [
t.UINT, [t.UINT, t.LP, "int"]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-oemkeyscan
"OemKeyScan": [
t.DWORD, [ t.WORD ]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-enumwindows
"RegisterRawInputDevices": [
t.BOOL, [t.PVOID, t.UINT, t.UINT]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-getrawinputdata
"GetRawInputData": [
t.INT, [t.PVOID, t.UINT, t.PVOID, t.PVOID, t.UINT]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagetime
"GetMessageTime": [
t.LONG, []
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos
"SetWindowPos": [
t.BOOL, [ t.HANDLE, t.HANDLE, "int", "int", "int", "int", t.UINT ]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowvisible
"IsWindowVisible": [
t.BOOL, [ t.HANDLE ]
],
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow
"SetForegroundWindow": [
"uint", [ "uint" ]
],
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext
"SetThreadDpiAwarenessContext": [
t.UINT, [ t.UINT ]
]
});
gpii.windows.advapi32 = new ffi.Library("advapi32", {
// https://msdn.microsoft.com/library/ms684323
"OpenSCManagerW": [
t.HANDLE, [ t.HANDLE, t.HANDLE, t.DWORD ]
],
// https://msdn.microsoft.com/library/ms684323
"OpenServiceW": [
t.HANDLE, [ t.HANDLE, "char*", t.DWORD ]
],
// https://msdn.microsoft.com/library/ms684939
"QueryServiceStatus": [
t.BOOL, [ t.HANDLE, t.PVOID ]
],
// https://msdn.microsoft.com/library/ms682028
"CloseServiceHandle": [
t.BOOL, [ t.HANDLE ]
]
});
gpii.windows.shlwapi = new ffi.Library("shlwapi", {
// https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-shloadindirectstring
"SHLoadIndirectString": [
t.HANDLE, [ "char*", "char*", t.UINT, t.PVOID ]
]
});
gpii.windows.shcore = new ffi.Library("Shcore", {
// https://msdn.microsoft.com/library/dn302122
"SetProcessDpiAwareness": [
t.HANDLE, [ t.UINT ]
]
});
gpii.windows.shell32 = new ffi.Library("shell32", {
"SHAppBarMessage": [
t.UINT, [ t.UINT, "void*" ]
]
});
// Make the process aware of DPI scaling, so Windows doesn't lie about non-client metrics (and perhaps other things).
// See GPII-3099.
gpii.windows.shcore.SetProcessDpiAwareness(1);
// Make gpii shutdown last, so it doesn't close before the shutdown is cancelled by another process.
gpii.windows.kernel32.SetProcessShutdownParameters(0x100, 0);
/**
* Gets a function pointer for an EnumWindowsProc callback for EnumWindows.
*
* See: https://msdn.microsoft.com/en-us/library/ms633498
*
* @param {function} callback The callback.
* @return {*} Function pointer for the given callback, to be passed to EnumWindows
*/
windows.EnumWindowsProc = function (callback) {
return ffi.Callback(t.BOOL, [t.HANDLE, t.HANDLE], callback);
};
// Windows API constants delved from the unfathomable deeps of windows.h
windows.API_constants = {
HKEY_CLASSES_ROOT: 0x80000000,
HKEY_CURRENT_USER: 0x80000001,
HKEY_LOCAL_MACHINE: 0x80000002,
HKEY_USERS: 0x80000003,
HKEY_CURRENT_CONFIG: 0x80000005,
CP_UTF8: 65001,
KEY_QUERY_VALUE: 1,
KEY_SET_VALUE: 2,
KEY_ENUMERATE_SUB_KEYS: 0x8,
KEY_WOW64_32KEY: 0x200,
KEY_WOW64_64KEY : 0x100,
returnCodesLookup: {
0: "ERROR_SUCCESS",
1: "ERROR_INVALID_FUNCTION",
2: "FILE_NOT_FOUND",
3: "PATH_NOT_FOUND",
6: "ERROR_INVALID_HANDLE",
259: "ERROR_NO_MORE_ITEMS"
},
returnCodes: {},
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684880%28v=vs.85%29.aspx
PROCESS_TERMINATE: 0x0001,
PROCESS_QUERY_LIMITED_INFORMATION: 0x1000,
PROCESS_QUERY_INFORMATION: 0x0400,
PROCESS_VM_READ: 0x0010,
// https://msdn.microsoft.com/library/ms685981
SC_MANAGER_CONNECT: 0x0001,
SERVICE_QUERY_STATUS : 0x0004,
// https://msdn.microsoft.com/library/ms685996
SERVICE_CONTINUE_PENDING: 0x00000005,
SERVICE_PAUSE_PENDING: 0x00000006,
SERVICE_PAUSED: 0x00000007,
SERVICE_RUNNING: 0x00000004,
SERVICE_START_PENDING: 0x00000002,
SERVICE_STOP_PENDING: 0x00000003,
SERVICE_STOPPED: 0x00000001,
// http://stackoverflow.com/questions/23452271/is-max-path-always-same-size-even-if-unicode-macro-is-defined
MAX_PATH: 260,
MAX_NAME: 32,
ENUM_CURRENT_SETTINGS: 0xffffffff, // ((DWORD)-1)
DISP_CHANGE_SUCCESSFUL: 0,
DISP_CHANGE_RESTART: 1,
FALSE: 0,
TRUE: 1,
// https://msdn.microsoft.com/library/windows/desktop/ms632641
WM_QUIT: 0x12,
// https://docs.microsoft.com/en-us/windows/desktop/winmsg/wm-close
WM_CLOSE: 0x10,
// https://docs.microsoft.com/windows/desktop/shutdown/wm-queryendsession
WM_QUERYENDSESSION: 0x11,
// https://docs.microsoft.com/windows/desktop/shutdown/wm-endsession
WM_ENDSESSION: 0x16,
// https://msdn.microsoft.com/library/ms912654
WM_KEYDOWN: 0x100,
// https://msdn.microsoft.com/library/ms646281
WM_KEYUP: 0x101,
// https://docs.microsoft.com/windows/desktop/inputdev/wm-syskeyup
WM_SYSKEYUP: 0x105,
// https://msdn.microsoft.com/library/ms645616
WM_MOUSEMOVE: 0x200,
// https://msdn.microsoft.com/library/ms645608
WM_LBUTTONUP: 0x202,
// https://msdn.microsoft.com/library/ms646243
WM_RBUTTONUP: 0x205,
// https://docs.microsoft.com/windows/desktop/inputdev/wm-mousewheel
WM_MOUSEWHEEL: 0x20A,
// https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-input
WM_INPUT: 0x00FF,
// https://msdn.microsoft.com/library/aa363480
WM_DEVICECHANGE: 0x219,
// https://docs.microsoft.com/windows/desktop/winmsg/wm-user
WM_USER: 0x400,
// https://docs.microsoft.com/windows/desktop/dataxchg/wm-copydata
WM_COPYDATA: 0x4a,
// https://docs.microsoft.com/windows/desktop/power/wm-powerbroadcast
WM_POWERBROADCAST: 0x0218,
// Registered messages
WM_SHELLHOOK: "SHELLHOOK",
HWND_BROADCAST: 0xffff,
// https://docs.microsoft.com/windows/desktop/winmsg/wm-inputlangchange
WM_INPUTLANGCHANGE: 0x51,
// https://docs.microsoft.com/windows/desktop/winmsg/wm-settingchange
WM_SETTINGCHANGE: 0x1a,
// https://docs.microsoft.com/windows/desktop/hidpi/wm-dpichanged
WM_DPICHANGED: 0x02E0,
// https://docs.microsoft.com/windows/desktop/gdi/wm-syscolorchange
WM_SYSCOLORCHANGE: 0x15,
// https://docs.microsoft.com/windows/desktop/gdi/wm-displaychange
WM_DISPLAYCHANGE: 0x7e,
// https://docs.microsoft.com/windows/desktop/winmsg/wm-themechanged
WM_THEMECHANGED: 0x31a,
// https://docs.microsoft.com/windows/win32/inputdev/wm-appcommand
WM_APPCOMMAND: 0x319,
// https://docs.microsoft.com/windows/win32/inputdev/wm-activate
WM_ACTIVATE: 0x0006,
// https://docs.microsoft.com/windows/win32/winmsg/wm-windowposchanging
WM_WINDOWPOSCHANGING: 0x0046,
// https://docs.microsoft.com/windows/win32/winmsg/wm-windowposchanged
WM_WINDOWPOSCHANGED: 0x0047,
// https://docs.microsoft.com/windows/win32/winmsg/window-styles
WS_VISIBLE: 0x10000000,
// https://docs.microsoft.com/windows/win32/winmsg/extended-window-styles
WS_EX_TOOLWINDOW: 0x00000080,
// https://msdn.microsoft.com/library/aa363205
DBT_DEVNODES_CHANGED: 0x7,
DBT_DEVICEARRIVAL: 0x8000,
DBT_DEVICEREMOVEPENDING: 0x8003,
DBT_DEVICEREMOVECOMPLETE: 0x8004,
DBT_DEVTYP_VOLUME: 0x2,
// https://docs.microsoft.com/windows/desktop/power/wm-powerbroadcast
PBT_APMSUSPEND: 0x4,
PBT_APMRESUMEAUTOMATIC: 0x12,
// https://docs.microsoft.com/windows/win32/inputdev/wm-appcommand
APPCOMMAND_VOLUME_DOWN: 9,
APPCOMMAND_VOLUME_UP: 10,
// https://msdn.microsoft.com/library/dd375731
virtualKeyCodes: {
VK_LBUTTON: 0x01, // Left mouse button
VK_RBUTTON: 0x02, // Right mouse button
VK_CANCEL: 0x03, // Control-break processing
VK_MBUTTON: 0x04, // Middle mouse button (three-button mouse)
VK_XBUTTON1: 0x05, // X1 mouse button
VK_XBUTTON2: 0x06, // X2 mouse button
VK_BACK: 0x08, // BACKSPACE key
VK_TAB: 0x09, // TAB key
VK_CLEAR: 0x0C, // CLEAR key
VK_RETURN: 0x0D, // ENTER key
VK_SHIFT: 0x10, // SHIFT key
VK_CONTROL: 0x11, // CTRL key
VK_MENU: 0x12, // ALT key
VK_PAUSE: 0x13, // PAUSE key
VK_CAPITAL: 0x14, // CAPS LOCK key
VK_KANA: 0x15, // IME Kana mode
VK_HANGUL: 0x15, // IME Hangul mode
VK_HANGUEL: 0x15, // IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
VK_JUNJA: 0x17, // IME Junja mode
VK_FINAL: 0x18, // IME final mode
VK_HANJA: 0x19, // IME Hanja mode
VK_KANJI: 0x19, // IME Kanji mode
VK_ESCAPE: 0x1B, // ESC key
VK_CONVERT: 0x1C, // IME convert
VK_NONCONVERT: 0x1D, // IME nonconvert
VK_ACCEPT: 0x1E, // IME accept
VK_MODECHANGE: 0x1F, // IME mode change request
VK_SPACE: 0x20, // SPACEBAR
VK_PAGEUP: 0x21, // PAGE UP key
VK_PAGEDOWN: 0x22, // PAGE DOWN key
VK_PRIOR: 0x21, // PAGE UP key
VK_NEXT: 0x22, // PAGE DOWN key
VK_END: 0x23, // END key
VK_HOME: 0x24, // HOME key
VK_LEFT: 0x25, // LEFT ARROW key
VK_UP: 0x26, // UP ARROW key
VK_RIGHT: 0x27, // RIGHT ARROW key
VK_DOWN: 0x28, // DOWN ARROW key
VK_SELECT: 0x29, // SELECT key
VK_PRINT: 0x2A, // PRINT key
VK_EXECUTE: 0x2B, // EXECUTE key
VK_SNAPSHOT: 0x2C, // PRINT SCREEN key
VK_INSERT: 0x2D, // INS key
VK_DELETE: 0x2E, // DEL key
VK_HELP: 0x2F, // HELP key
VK_LWIN: 0x5B, // Left Windows key (Natural keyboard)
VK_RWIN: 0x5C, // Right Windows key (Natural keyboard)
VK_APPS: 0x5D, // Applications key (Natural keyboard)
VK_SLEEP: 0x5F, // Computer Sleep key
VK_NUMPAD0: 0x60, // Numeric keypad 0 key
VK_NUMPAD1: 0x61, // Numeric keypad 1 key
VK_NUMPAD2: 0x62, // Numeric keypad 2 key
VK_NUMPAD3: 0x63, // Numeric keypad 3 key
VK_NUMPAD4: 0x64, // Numeric keypad 4 key
VK_NUMPAD5: 0x65, // Numeric keypad 5 key
VK_NUMPAD6: 0x66, // Numeric keypad 6 key
VK_NUMPAD7: 0x67, // Numeric keypad 7 key
VK_NUMPAD8: 0x68, // Numeric keypad 8 key
VK_NUMPAD9: 0x69, // Numeric keypad 9 key
VK_MULTIPLY: 0x6A, // Multiply key
VK_ADD: 0x6B, // Add key
VK_SEPARATOR: 0x6C, // Separator key
VK_SUBTRACT: 0x6D, // Subtract key
VK_DECIMAL: 0x6E, // Decimal key
VK_DIVIDE: 0x6F, // Divide key
VK_F1: 0x70, // F1 key
VK_F2: 0x71, // F2 key
VK_F3: 0x72, // F3 key
VK_F4: 0x73, // F4 key
VK_F5: 0x74, // F5 key
VK_F6: 0x75, // F6 key
VK_F7: 0x76, // F7 key
VK_F8: 0x77, // F8 key
VK_F9: 0x78, // F9 key
VK_F10: 0x79, // F10 key
VK_F11: 0x7A, // F11 key
VK_F12: 0x7B, // F12 key
VK_F13: 0x7C, // F13 key
VK_F14: 0x7D, // F14 key
VK_F15: 0x7E, // F15 key
VK_F16: 0x7F, // F16 key
VK_F17: 0x80, // F17 key
VK_F18: 0x81, // F18 key
VK_F19: 0x82, // F19 key
VK_F20: 0x83, // F20 key
VK_F21: 0x84, // F21 key
VK_F22: 0x85, // F22 key
VK_F23: 0x86, // F23 key
VK_F24: 0x87, // F24 key
VK_NUMLOCK: 0x90, // NUM LOCK key
VK_SCROLL: 0x91, // SCROLL LOCK key
VK_LSHIFT: 0xA0, // Left SHIFT key
VK_RSHIFT: 0xA1, // Right SHIFT key
VK_LCONTROL: 0xA2, // Left CONTROL key
VK_RCONTROL: 0xA3, // Right CONTROL key
VK_LMENU: 0xA4, // Left MENU key
VK_RMENU: 0xA5, // Right MENU key
VK_BROWSER_BACK: 0xA6, // Browser Back key
VK_BROWSER_FORWARD: 0xA7, // Browser Forward key
VK_BROWSER_REFRESH: 0xA8, // Browser Refresh key
VK_BROWSER_STOP: 0xA9, // Browser Stop key
VK_BROWSER_SEARCH: 0xAA, // Browser Search key
VK_BROWSER_FAVORITES: 0xAB, // Browser Favorites key
VK_BROWSER_HOME: 0xAC, // Browser Start and Home key
VK_VOLUME_MUTE: 0xAD, // Volume Mute key
VK_VOLUME_DOWN: 0xAE, // Volume Down key
VK_VOLUME_UP: 0xAF, // Volume Up key
VK_MEDIA_NEXT_TRACK: 0xB0, // Next Track key
VK_MEDIA_PREV_TRACK: 0xB1, // Previous Track key
VK_MEDIA_STOP: 0xB2, // Stop Media key
VK_MEDIA_PLAY_PAUSE: 0xB3, // Play/Pause Media key
VK_LAUNCH_MAIL: 0xB4, // Start Mail key
VK_LAUNCH_MEDIA_SELECT: 0xB5, // Select Media key
VK_LAUNCH_APP1: 0xB6, // Start Application 1 key
VK_LAUNCH_APP2: 0xB7, // Start Application 2 key
VK_OEM_1: 0xBA, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key
VK_OEM_PLUS: 0xBB, // For any country/region, the '+' key
VK_OEM_COMMA: 0xBC, // For any country/region, the ',' key
VK_OEM_MINUS: 0xBD, // For any country/region, the '-' key
VK_OEM_PERIOD: 0xBE, // For any country/region, the '.' key
VK_OEM_2: 0xBF, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key
VK_OEM_3: 0xC0, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key
VK_OEM_4: 0xDB, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key
VK_OEM_5: 0xDC, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key
VK_OEM_6: 0xDD, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key
VK_OEM_7: 0xDE, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key
VK_OEM_8: 0xDF, // Used for miscellaneous characters; it can vary by keyboard.
VK_OEM_102: 0xE2, // Either the angle bracket key or the backslash key on the RT 102-key keyboard
VK_PROCESSKEY: 0xE5, // IME PROCESS key
VK_PACKET: 0xE7, // Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP: -, // 0xE8
VK_ATTN: 0xF6, // Attn key
VK_CRSEL: 0xF7, // CrSel key
VK_EXSEL: 0xF8, // ExSel key
VK_EREOF: 0xF9, // Erase EOF key
VK_PLAY: 0xFA, // Play key
VK_ZOOM: 0xFB, // Zoom key
VK_NONAME: 0xFC, // Reserved
VK_PA1: 0xFD, // PA1 key
VK_OEM_CLEAR: 0xFE // Clear key
},
// https://docs.microsoft.com/windows/win32/api/winuser/ns-winuser-keybdinput
KEYEVENTF_EXTENDEDKEY: 1,
KEYEVENTF_KEYUP: 2,
KEYEVENTF_UNICODE: 4,
KEYEVENTF_SCANCODE: 8,
LLKHF_EXTENDED: 0x01,
LLKHF_INJECTED: 0x10,
LLKHF_ALTDOWN: 0x20,
LLKHF_UP: 0x80,
LLMHF_INJECTED: 0x01,
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registershellhookwindow
HSHELL_WINDOWCREATED: 1,
HSHELL_WINDOWDESTROYED: 2,
HSHELL_WINDOWACTIVATED: 4,
HSHELL_RUDEAPPACTIVATED: 0x8004,
// https://msdn.microsoft.com/library/ms646306
MAPVK_VK_TO_CHAR: 2,
// The AccessibilityTemp values; https://msdn.microsoft.com/library/windows/desktop/bb879984.aspx
disableAT: 2,
enableAT: 3,
MONITOR_DEFAULTTOPRIMARY: 1,
CCHDEVICENAME: 32,
QDC_ONLY_ACTIVE_PATHS: 2,
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554003.aspx
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED: 11,
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED: 13,
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL: 0x80000000,
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getsyscolor
COLOR_DESKTOP: 1,
// https://msdn.microsoft.com/en-us/library/296az74e.aspx
UINT_MAX: 0xffffffff,
// https://msdn.microsoft.com/library/ms724947
SpiFlags: {
SPIF_UPDATEINIFILE: 0x1,
SPIF_SENDCHANGE: 0x2
},
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getsystemmetrics
SM_CXSCREEN: 0,
SM_CYSCREEN: 1,
SM_XVIRTUALSCREEN: 76,
SM_YVIRTUALSCREEN: 77,
SM_CXVIRTUALSCREEN: 78,
SM_CYVIRTUALSCREEN: 79,
SM_CXDOUBLECLK: 36,
SM_CYDOUBLECLK: 37,
SM_SWAPBUTTON: 23,
INVALID_HANDLE_VALUE: 0xffffffff,
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ne-wingdi-displayconfig_topology_id
DISPLAYCONFIG_TOPOLOGY_INTERNAL: 0,
DISPLAYCONFIG_TOPOLOGY_CLONE: 1,
DISPLAYCONFIG_TOPOLOGY_EXTEND: 2,
DISPLAYCONFIG_TOPOLOGY_EXTERNAL: 3,
DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32: 4,
// https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setdisplayconfig
SDC_TOPOLOGY_INTERNAL: 0x00000001,
SDC_TOPOLOGY_CLONE: 0x00000002,
SDC_TOPOLOGY_EXTEND: 0x00000004,
SDC_TOPOLOGY_EXTERNAL: 0x00000008,
SDC_TOPOLOGY_SUPPLIED: 0x00000010,
SDC_VALIDATE: 0x00000040,
SDC_APPLY: 0x00000080,
// https://docs.microsoft.com/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
STARTF_USESHOWWINDOW: 0x1,
// https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-showwindow
SW_HIDE: 0,
SW_SHOWNORMAL: 1,
SW_SHOWMINIMIZED: 2,
SW_SHOWMAXIMIZED: 3,
SW_SHOWNOACTIVATE: 4,
// https://docs.microsoft.com/windows/win32/api/winuser/ns-winuser-rawmouse
RI_MOUSE_LEFT_BUTTON_UP: 0x0002,
RI_MOUSE_MIDDLE_BUTTON_UP: 0x0020,
RI_MOUSE_RIGHT_BUTTON_UP: 0x0008,
RI_MOUSE_WHEEL: 0x0400,
// https://docs.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shappbarmessage
ABE_BOTTOM: 3,
ABN_POSCHANGED: 1,
ABM_NEW: 0x00000000,
ABM_REMOVE: 0x00000001,
ABM_SETPOS: 0x00000003,
ABM_ACTIVATE: 0x00000006,
ABM_WINDOWPOSCHANGED: 0x0000009,
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rawinputdevice
RIDEV_APPKEYS: 0x00000400,
RIDEV_CAPTUREMOUSE: 0x00000200,
RIDEV_DEVNOTIFY: 0x00002000,
RIDEV_EXCLUDE: 0x00000010,
RIDEV_EXINPUTSINK: 0x00001000,
RIDEV_INPUTSINK: 0x00000100,
RIDEV_NOHOTKEYS: 0x00000200,
RIDEV_NOLEGACY: 0x00000030,
RIDEV_PAGEONLY: 0x00000020,
RIDEV_REMOVE: 0x00000001,
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdata
RID_HEADER: 0x10000005,
RID_INPUT: 0x10000003,
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rid_device_info
RIM_TYPEHID: 2,
RIM_TYPEKEYBOARD: 1,
RIM_TYPEMOUSE: 0
};
fluid.each(windows.API_constants.returnCodesLookup, function (value, key) {
windows.API_constants.returnCodes[value] = +key;
});
/*
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx
* TH32CS_SNAPALL
*/
var TH32CS_SNAPHEAPLIST = 0x00000001;
var TH32CS_SNAPMODULE = 0x00000008;
var TH32CS_SNAPPROCESS = 0x00000002;
var TH32CS_SNAPTHREAD = 0x00000004;
var TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE |
TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD;
windows.API_constants.TH32CS_SNAPALL = TH32CS_SNAPALL;
windows.API_constants.TH32CS_SNAPPROCESS = TH32CS_SNAPPROCESS;
var c = windows.API_constants;
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684839%28v=vs.85%29.aspx
windows.PROCESSENTRY32 = new Struct([
[t.DWORD, "dwSize"],
[t.DWORD, "cntUsage"],
[t.DWORD, "th32ProcessID"],
[t.ULONG_PTR, "th32DefaultHeapID"],
[t.DWORD, "th32ModuleID"],
[t.DWORD, "cntThreads"],
[t.DWORD, "th32ParentProcessID"],
[t.LONG, "pcPriClassBase"],
[t.DWORD, "dwFlags"],
// TODO: This needs refactoring to adopt new type t.TCHAR instead of an array of
// chars.
[arrayType("char", c.MAX_PATH), "szExeFile"]
]);
// https://msdn.microsoft.com/library/ms685996
windows.SERVICE_STATUS = new Struct([
[t.DWORD, "dwServiceType"],
[t.DWORD, "dwCurrentState"],
[t.DWORD, "dwControlsAccepted"],
[t.DWORD, "dwWin32ExitCode"],
[t.DWORD, "dwServiceSpecificExitCode"],
[t.DWORD, "dwCheckPoint"],
[t.DWORD, "dwWaitHint"]
]);
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd318112(v=vs.85).aspx
windows.HighContrast = new Struct({
"cbSize": "uint32",
"dwFlags": "int32",
"lpszDefaultScheme": "pointer"
});
windows.highContrastPointer = ref.refType(windows.HighContrast);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa379651(v=vs.85).aspx
windows.AudioDescription = new Struct({
"cbSize": "uint32",
"Enabled": "int32",
"Locale": "uint32"
});
windows.audioDescriptionPointer = ref.refType(windows.AudioDescription);
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
windows.LogFont = new Struct([
["int32", "lfHeight"],
["int32", "lfWidth"],
["int32", "lfEscapement"],
["int32", "lfOrientation"],
["int32", "lfWeight"],
["uchar", "lfItalic"],
["uchar", "lfUnderline"],
["uchar", "lfStrikeOut"],
["uchar", "lfCharSet"],
["uchar", "lfOutPrecision"],
["uchar", "lfClipPrecision"],
["uchar", "lfQuality"],
["uchar", "lfPitchAndFamily"],
[arrayType(t.TCHAR, c.MAX_NAME), "lfFaceName"]
]);
windows.logFontPointer = ref.refType(windows.LogFont);
// http://msdn.microsoft.com/en-us/library/windows/desktop/ff729175(v=vs.85).aspx
windows.NonClientMetrics = new Struct([
["uint32", "cbSize"],
["int32", "iBorderWidth"],
["int32", "iScrollWidth"],
["int32", "iScrollHeight"],
["int32", "iCaptionWidth"],
["int32", "iCaptionHeight"],
[windows.LogFont, "lfCaptionFont"],
["int32", "iSmCaptionWidth"],
["int32", "iSmCaptionHeight"],
[windows.LogFont, "lfSmCaptionFont"],
["int32", "iMenuWidth"],
["int32", "iMenuHeight"],
[windows.LogFont, "lfMenuFont"],
[windows.LogFont, "lfStatusFont"],
[windows.LogFont, "lfMessageFont"],
["int32", "iPaddedBorderWidth"]
]);
windows.nonClientMetricsPointer = ref.refType(windows.NonClientMetrics);
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd373652(v=vs.85).aspx
windows.StickyKeys = new Struct([
["uint32", "cbSize"],