source: trunk/ab5.0/ablib/src/WinNT.ab @ 560

Last change on this file since 560 was 497, checked in by イグトランス (egtra), 15 years ago

インクルードガードとその他不要な前処理定義などの削除

File size: 216.6 KB
Line 
1' winnt.ab
2
3'#include <ctype.h>
4Const ANYSIZE_ARRAY = 1
5
6'#include <specstrings.h>
7
8'RESTRICTED_POINTER
9
10'UNALIGNED
11'UNALIGNED64
12
13#ifdef _WIN64
14Const MAX_NATURAL_ALIGNMENT = SizeOf (QWord)
15Const MEMORY_ALLOCATION_ALIGNMENT = 16
16#else
17Const MAX_NATURAL_ALIGNMENT = SizeOf (DWord)
18Const MEMORY_ALLOCATION_ALIGNMENT = 8
19#endif
20
21'TYPE_ALIGNMENT
22'PROBE_ALIGNMENT
23'PROBE_ALIGNMENT32
24
25'Const C_ASSERT(e) = 0
26
27'#require <basetsd.ab>
28#ifdef _WIN64
29TypeDef LONG_PTR =  Int64
30TypeDef ULONG_PTR = QWord
31TypeDef HALF_PTR = Long
32TypeDef UHALF_PTR = DWord
33#else
34TypeDef LONG_PTR = Long
35TypeDef ULONG_PTR = DWord
36TypeDef HALF_PTR = Integer
37TypeDef UHALF_PTR = Word
38#endif
39TypeDef DWORD_PTR = ULONG_PTR
40
41TypeDef SIZE_T = ULONG_PTR
42TypeDef SSIZE_T = LONG_PTR
43
44Const SYSTEM_CACHE_ALIGNMENT_SIZE = 64
45
46Const DECLSPEC_CACHEALIGN = 4
47/*
48#ifdef DEPRECATE_DDK_FUNCTIONS
49#ifdef _NTDDK_
50#define DECLSPEC_DEPRECATED_DDK DECLSPEC_DEPRECATED
51#ifdef DEPRECATE_SUPPORTED
52#define PRAGMA_DEPRECATED_DDK 1
53#endif
54#else
55#define DECLSPEC_DEPRECATED_DDK
56#define PRAGMA_DEPRECATED_DDK 1
57#endif
58#else
59#define DECLSPEC_DEPRECATED_DDK
60#define PRAGMA_DEPRECATED_DDK 0
61#endif
62*/
63
64TypeDef PVOID = VoidPtr
65#ifdef _WIN64
66TypeDef PVOID64 = VoidPtr
67#else
68TypeDef PVOID64 = QWord
69#endif
70
71TypeDef CHAR = SByte
72TypeDef SHORT = Integer
73TypeDef LONG = Long
74TypeDef INT = Long
75
76TypeDef WCHAR = Word
77
78TypeDef PWCHAR = *WCHAR
79TypeDef LPWCH = *WCHAR
80TypeDef PWCH = *WCHAR
81TypeDef LPCWCH = *WCHAR
82TypeDef NWPSTR = *WCHAR
83TypeDef LPWSTR = *WCHAR
84TypeDef PWSTR = *WCHAR
85TypeDef PZPWSTR = *PWSTR
86TypeDef PCZPWSTR = *PWSTR
87TypeDef LPUWSTR = *WCHAR
88TypeDef PUWSTR = *WCHAR
89TypeDef LPCWSTR = *WCHAR
90TypeDef PCWSTR = *WCHAR
91TypeDef PZPCWSTR = *PCWSTR
92TypeDef LPCUWSTR = *WCHAR
93TypeDef PCUWSTR = *WCHAR
94
95TypeDef LPCWCHAR = *WCHAR
96TypeDef PCWCHAR = *WCHAR
97TypeDef LPCUWCHAR = *WCHAR
98TypeDef PCUWCHAR = *WCHAR
99
100TypeDef UCSCHAR = DWord
101
102Const UCSCHAR_INVALID_CHARACTER = &hffffffff As UCSCHAR
103Const MIN_UCSCHAR = 0 As UCSCHAR
104Const MAX_UCSCHAR = &h0010ffff As UCSCHAR
105
106TypeDef PUCSCHAR = *UCSCHAR
107TypeDef PCUCSCHAR = *UCSCHAR
108
109TypeDef PUCSSTR = *UCSCHAR
110TypeDef PUUCSSTR = *UCSCHAR
111
112TypeDef PCUCSSTR = *UCSCHAR
113TypeDef PCUUCSSTR = *UCSCHAR
114
115TypeDef PUUCSCHAR = *UCSCHAR
116TypeDef PCUUCSCHAR = *UCSCHAR
117
118TypeDef PCHAR = *CHAR
119TypeDef LPCH = *CHAR
120TypeDef PCH = *CHAR
121TypeDef LPCCH = *CHAR
122TypeDef PCCH = *CHAR
123
124TypeDef NPSTR = *CHAR
125TypeDef LPSTR = *CHAR
126TypeDef PSTR = *CHAR
127TypeDef PZPSTR = *PSTR
128TypeDef PCZPSTR = *PSTR
129TypeDef PCSTR = *CHAR
130TypeDef LPCSTR = *CHAR
131TypeDef PZPCSTR = *PCSTR
132
133#ifdef UNICODE
134TypeDef TCHAR = WCHAR
135TypeDef PTCHAR = *WCHAR
136TypeDef TBYTE = WCHAR
137TypeDef PTBYTE = *WCHAR
138
139TypeDef PTCH = PWCH
140TypeDef LPTCH = LPWCH
141TypeDef PTSTR = PWSTR
142TypeDef LPTSTR = LPWSTR
143TypeDef PCTSTR = PCWSTR
144TypeDef LPCTSTR = LPCWSTR
145TypeDef PUTSTR = PUWSTR
146TypeDef LPUTSTR = LPUWSTR
147TypeDef PCUTSTR = PCUWSTR
148TypeDef LPCUTSTR = LPCUWSTR
149'TypeDef LP = LPWSTR
150#else
151TypeDef TCHAR = Char
152TypeDef PTCHAR = *Char
153TypeDef TBYTE = Byte
154TypeDef PTBYTE = *Byte
155
156TypeDef PTCH = PCH
157TypeDef LPTCH = LPCH
158TypeDef PTSTR = PSTR
159TypeDef LPTSTR = LPSTR
160TypeDef PUTSTR = PSTR
161TypeDef LPUTSTR = LPSTR
162TypeDef PCTSTR = PCSTR
163TypeDef LPCTSTR = LPCSTR
164TypeDef PCUTSTR = PCSTR
165TypeDef LPCUTSTR = LPCSTR
166#endif
167
168'TypeDef PSHORT = SHORT
169'TypeDef PLONG = *Long
170
171TypeDef HANDLE = VoidPtr
172TypeDef PHANDLE = *HANDLE
173
174TypeDef FCHAR = Byte
175TypeDef FSHORT = Word
176TypeDef FLONG = DWord
177
178TypeDef HRESULT = Long
179
180TypeDef CCHAR = CHAR
181TypeDef LCID = DWord
182TypeDef PLCID = *DWord
183TypeDef LANGID = Word
184Const APPLICATION_ERROR_MASK = &h20000000
185Const ERROR_SEVERITY_SUCCESS = &h00000000
186Const ERROR_SEVERITY_INFORMATIONAL = &h40000000
187Const ERROR_SEVERITY_WARNING = &h80000000
188Const ERROR_SEVERITY_ERROR = &hC0000000
189
190Type FLOAT128
191    LowPart As Int64
192    HighPart As Int64
193End Type
194TypeDef PFLOAT128 = FLOAT128
195
196TypeDef LONGLONG = Int64
197TypeDef ULONGLONG = QWord
198
199Const MAXLONGLONG = (&h7fffffffffffffff)
200
201TypeDef PLONGLONG = *LONGLONG
202TypeDef PULONGLONG = *ULONGLONG
203
204TypeDef USN = LONGLONG
205
206Type LARGE_INTEGER
207    LowPart As DWord
208    HighPart As Long
209End Type
210TypeDef PLARGE_INTEGER = *LARGE_INTEGER
211
212Type ULARGE_INTEGER
213    LowPart As DWord
214    HighPart As DWord
215End Type
216TypeDef PULARGE_INTEGER = *ULARGE_INTEGER
217
218Type LUID
219    LowPart As DWord
220    HighPart As Long
221End Type
222TypeDef PLUID = *LUID
223
224'TypeDef DWORDLONG = ULONGLONG
225'TypeDef PDWORDLONG = DWORDLONG
226
227Const Int32x32To64(a, b) = (((a) As Long) As Int64 * ((b) As Long) As Int64)
228Const UInt32x32To64(a, b) = (((a) As DWord) As QWord * ((b) As DWord) As QWord)
229Const Int64ShllMod32(a, b) = ((a) As QWord << (b))
230Const Int64ShraMod32(a, b) = ((a) As Int64 >> (b))
231Const Int64ShrlMod32(a, b) = ((a) As QWord >> (b))
232
233Const ANSI_NULL = (0 As CHAR)
234Const UNICODE_NULL = (0 As WCHAR)
235Const UNICODE_STRING_MAX_BYTES = (65534 As Word)
236Const UNICODE_STRING_MAX_CHARS = (32767)
237TypeDef BOOLEAN = BYTE
238TypeDef PBOOLEAN = *BOOLEAN
239
240Type LIST_ENTRY
241    Flink As *LIST_ENTRY
242    Blink As *LIST_ENTRY
243End Type
244TypeDef PLIST_ENTRY = *LIST_ENTRY
245TypeDef PRLIST_ENTRY = *LIST_ENTRY
246
247Type SINGLE_LIST_ENTRY
248    Next As *SINGLE_LIST_ENTRY
249End Type
250TypeDef PSINGLE_LIST_ENTRY = *SINGLE_LIST_ENTRY
251
252Type LIST_ENTRY32
253    Flink As DWord
254    Blink As DWord
255End Type
256TypeDef PLIST_ENTRY32 = *LIST_ENTRY32
257
258Type LIST_ENTRY64
259    Flink As QWord
260    Blink As QWord
261End Type
262TypeDef PLIST_ENTRY64 = *LIST_ENTRY64
263
264#require <guiddef.ab>
265
266Type OBJECTID
267    Lineage As GUID
268    Uniquifier As DWord
269End Type
270
271Const MINCHAR = &h80
272Const MAXCHAR = &h7f
273Const MINSHORT = &h8000
274Const MAXSHORT = &h7fff
275Const MINLONG = &h80000000
276Const MAXLONG = &h7fffffff
277Const MAXBYTE = &hff
278Const MAXWORD = &hffff
279Const MAXDWORD = &hffffffff
280
281'FIELD_OFFSET
282'RTL_FIELD_SIZE
283'RTL_SIZEOF_THROUGH_FIELD
284'RTL_CONTAINS_FIELD
285Const RTL_NUMBER_OF_V1(A) = (Len (A) \ Len(A[0]))
286'RtlpNumberOf
287Const RTL_NUMBER_OF(A) = RTL_NUMBER_OF_V1(A)
288Const ARRAYSIZE(A) = RTL_NUMBER_OF_V1(A) 'RTL_NUMBER_OF_V2(A)
289Const _ARRAYSIZE(A) = RTL_NUMBER_OF_V1(A)
290'RTL_FIELD_TYPE
291'RTL_NUMBER_OF_FIELD
292'RTL_PADDING_BETWEEN_FIELDS
293'RTL_CONST_CAST
294'RTL_BITS_OF
295'RTL_BITS_OF_FIELD
296'CONTAINING_RECORD
297
298Const VER_SERVER_NT = &h80000000
299Const VER_WORKSTATION_NT = &h40000000
300Const VER_SUITE_SMALLBUSINESS = &h00000001
301Const VER_SUITE_ENTERPRISE = &h00000002
302Const VER_SUITE_BACKOFFICE = &h00000004
303Const VER_SUITE_COMMUNICATIONS = &h00000008
304Const VER_SUITE_TERMINAL = &h00000010
305Const VER_SUITE_SMALLBUSINESS_RESTRICTED = &h00000020
306Const VER_SUITE_EMBEDDEDNT = &h00000040
307Const VER_SUITE_DATACENTER = &h00000080
308Const VER_SUITE_SINGLEUSERTS = &h00000100
309Const VER_SUITE_PERSONAL = &h00000200
310Const VER_SUITE_BLADE = &h00000400
311Const VER_SUITE_EMBEDDED_RESTRICTED = &h00000800
312Const VER_SUITE_SECURITY_APPLIANCE = &h00001000
313Const VER_SUITE_STORAGE_SERVER = &h00002000
314Const VER_SUITE_COMPUTE_SERVER = &h00004000
315
316Const PRODUCT_UNDEFINED = &h00000000
317
318Const PRODUCT_ULTIMATE = &h00000001
319Const PRODUCT_HOME_BASIC = &h00000002
320Const PRODUCT_HOME_PREMIUM = &h00000003
321Const PRODUCT_ENTERPRISE = &h00000004
322Const PRODUCT_HOME_BASIC_N = &h00000005
323Const PRODUCT_BUSINESS = &h00000006
324Const PRODUCT_STANDARD_SERVER = &h00000007
325Const PRODUCT_DATACENTER_SERVER = &h00000008
326Const PRODUCT_SMALLBUSINESS_SERVER = &h00000009
327Const PRODUCT_ENTERPRISE_SERVER = &h0000000A
328Const PRODUCT_STARTER = &h0000000B
329Const PRODUCT_DATACENTER_SERVER_CORE = &h0000000C
330Const PRODUCT_STANDARD_SERVER_CORE = &h0000000D
331Const PRODUCT_ENTERPRISE_SERVER_CORE = &h0000000E
332Const PRODUCT_ENTERPRISE_SERVER_IA64 = &h0000000F
333Const PRODUCT_BUSINESS_N = &h00000010
334Const PRODUCT_WEB_SERVER = &h00000011
335Const PRODUCT_CLUSTER_SERVER = &h00000012
336Const PRODUCT_HOME_SERVER = &h00000013
337Const PRODUCT_STORAGE_EXPRESS_SERVER = &h00000014
338Const PRODUCT_STORAGE_STANDARD_SERVER = &h00000015
339Const PRODUCT_STORAGE_WORKGROUP_SERVER = &h00000016
340Const PRODUCT_STORAGE_ENTERPRISE_SERVER = &h00000017
341Const PRODUCT_SERVER_FOR_SMALLBUSINESS = &h00000018
342Const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = &h00000019
343
344Const PRODUCT_UNLICENSED = &hABCDABCD
345
346'#require <sdkddkver.ab>
347
348'  Primary language IDs.
349Const LANG_NEUTRAL = &h00
350Const LANG_INVARIANT = &h7f
351
352Const LANG_AFRIKAANS = &h36
353Const LANG_ALBANIAN = &h1c
354Const LANG_ALSATIAN = &h84
355Const LANG_AMHARIC = &h5e
356Const LANG_ARABIC = &h01
357Const LANG_ARMENIAN = &h2b
358Const LANG_ASSAMESE = &h4d
359Const LANG_AZERI = &h2c
360Const LANG_BASHKIR = &h6d
361Const LANG_BASQUE = &h2d
362Const LANG_BELARUSIAN = &h23
363Const LANG_BENGALI = &h45
364Const LANG_BRETON = &h7e
365Const LANG_BOSNIAN = &h1a
366Const LANG_BOSNIAN_NEUTRAL = &h781a
367Const LANG_BULGARIAN = &h02
368Const LANG_CATALAN = &h03
369Const LANG_CHINESE = &h04
370Const LANG_CHINESE_SIMPLIFIED = &h04
371Const LANG_CHINESE_TRADITIONAL = &h7c04
372Const LANG_CORSICAN = &h83
373Const LANG_CROATIAN = &h1a
374Const LANG_CZECH = &h05
375Const LANG_DANISH = &h06
376Const LANG_DARI = &h8c
377Const LANG_DIVEHI = &h65
378Const LANG_DUTCH = &h13
379Const LANG_ENGLISH = &h09
380Const LANG_ESTONIAN = &h25
381Const LANG_FAEROESE = &h38
382Const LANG_FARSI = &h29
383Const LANG_FILIPINO = &h64
384Const LANG_FINNISH = &h0b
385Const LANG_FRENCH = &h0c
386Const LANG_FRISIAN = &h62
387Const LANG_GALICIAN = &h56
388Const LANG_GEORGIAN = &h37
389Const LANG_GERMAN = &h07
390Const LANG_GREEK = &h08
391Const LANG_GREENLANDIC = &h6f
392Const LANG_GUJARATI = &h47
393Const LANG_HAUSA = &h68
394Const LANG_HEBREW = &h0d
395Const LANG_HINDI = &h39
396Const LANG_HUNGARIAN = &h0e
397Const LANG_ICELANDIC = &h0f
398Const LANG_IGBO = &h70
399Const LANG_INDONESIAN = &h21
400Const LANG_INUKTITUT = &h5d
401Const LANG_IRISH = &h3c
402Const LANG_ITALIAN = &h10
403Const LANG_JAPANESE = &h11
404Const LANG_KANNADA = &h4b
405Const LANG_KASHMIRI = &h60
406Const LANG_KAZAK = &h3f
407Const LANG_KHMER = &h53
408Const LANG_KICHE = &h86
409Const LANG_KINYARWANDA = &h87
410Const LANG_KONKANI = &h57
411Const LANG_KOREAN = &h12
412Const LANG_KYRGYZ = &h40
413Const LANG_LAO = &h54
414Const LANG_LATVIAN = &h26
415Const LANG_LITHUANIAN = &h27
416Const LANG_LOWER_SORBIAN = &h2e
417Const LANG_LUXEMBOURGISH = &h6e
418Const LANG_MACEDONIAN = &h2f
419Const LANG_MALAY = &h3e
420Const LANG_MALAYALAM = &h4c
421Const LANG_MALTESE = &h3a
422Const LANG_MANIPURI = &h58
423Const LANG_MAORI = &h81
424Const LANG_MAPUDUNGUN = &h7a
425Const LANG_MARATHI = &h4e
426Const LANG_MOHAWK = &h7c
427Const LANG_MONGOLIAN = &h50
428Const LANG_NEPALI = &h61
429Const LANG_NORWEGIAN = &h14
430Const LANG_OCCITAN = &h82
431Const LANG_ORIYA = &h48
432Const LANG_PASHTO = &h63
433Const LANG_PERSIAN = &h29
434Const LANG_POLISH = &h15
435Const LANG_PORTUGUESE = &h16
436Const LANG_PUNJABI = &h46
437Const LANG_QUECHUA = &h6b
438Const LANG_ROMANIAN = &h18
439Const LANG_ROMANSH = &h17
440Const LANG_RUSSIAN = &h19
441Const LANG_SAMI = &h3b
442Const LANG_SANSKRIT = &h4f
443Const LANG_SERBIAN = &h1a
444Const LANG_SERBIAN_NEUTRAL = &h7c1a
445Const LANG_SINDHI = &h59
446Const LANG_SINHALESE = &h5b
447Const LANG_SLOVAK = &h1b
448Const LANG_SLOVENIAN = &h24
449Const LANG_SOTHO = &h6c
450Const LANG_SPANISH = &h0a
451Const LANG_SWAHILI = &h41
452Const LANG_SWEDISH = &h1d
453Const LANG_SYRIAC = &h5a
454Const LANG_TAJIK = &h28
455Const LANG_TAMAZIGHT = &h5f
456Const LANG_TAMIL = &h49
457Const LANG_TATAR = &h44
458Const LANG_TELUGU = &h4a
459Const LANG_THAI = &h1e
460Const LANG_TIBETAN = &h51
461Const LANG_TIGRIGNA = &h73
462Const LANG_TSWANA = &h32
463Const LANG_TURKISH = &h1f
464Const LANG_TURKMEN = &h42
465Const LANG_UIGHUR = &h80
466Const LANG_UKRAINIAN = &h22
467Const LANG_UPPER_SORBIAN = &h2e
468Const LANG_URDU = &h20
469Const LANG_UZBEK = &h43
470Const LANG_VIETNAMESE = &h2a
471Const LANG_WELSH = &h52
472Const LANG_WOLOF = &h88
473Const LANG_XHOSA = &h34
474Const LANG_YAKUT = &h85
475Const LANG_YI = &h78
476Const LANG_YORUBA = &h6a
477Const LANG_ZULU = &h35
478
479' Sublanguage IDs.
480Const SUBLANG_NEUTRAL = &h00
481Const SUBLANG_DEFAULT = &h01
482Const SUBLANG_SYS_DEFAULT = &h02
483Const SUBLANG_CUSTOM_DEFAULT = &h03
484Const SUBLANG_CUSTOM_UNSPECIFIED = &h04
485Const SUBLANG_UI_CUSTOM_DEFAULT = &h05
486
487Const SUBLANG_AFRIKAANS_SOUTH_AFRICA = &h01
488Const SUBLANG_ALBANIAN_ALBANIA = &h01
489Const SUBLANG_ALSATIAN_FRANCE = &h01
490Const SUBLANG_AMHARIC_ETHIOPIA = &h01
491Const SUBLANG_ARABIC_SAUDI_ARABIA = &h01
492Const SUBLANG_ARABIC_IRAQ = &h02
493Const SUBLANG_ARABIC_EGYPT = &h03
494Const SUBLANG_ARABIC_LIBYA = &h04
495Const SUBLANG_ARABIC_ALGERIA = &h05
496Const SUBLANG_ARABIC_MOROCCO = &h06
497Const SUBLANG_ARABIC_TUNISIA = &h07
498Const SUBLANG_ARABIC_OMAN = &h08
499Const SUBLANG_ARABIC_YEMEN = &h09
500Const SUBLANG_ARABIC_SYRIA = &h0a
501Const SUBLANG_ARABIC_JORDAN = &h0b
502Const SUBLANG_ARABIC_LEBANON = &h0c
503Const SUBLANG_ARABIC_KUWAIT = &h0d
504Const SUBLANG_ARABIC_UAE = &h0e
505Const SUBLANG_ARABIC_BAHRAIN = &h0f
506Const SUBLANG_ARABIC_QATAR = &h10
507Const SUBLANG_ARMENIAN_ARMENIA = &h01
508Const SUBLANG_ASSAMESE_INDIA = &h01
509Const SUBLANG_AZERI_LATIN = &h01
510Const SUBLANG_AZERI_CYRILLIC = &h02
511Const SUBLANG_BASHKIR_RUSSIA = &h01
512Const SUBLANG_BASQUE_BASQUE = &h01
513Const SUBLANG_BELARUSIAN_BELARUS = &h01
514Const SUBLANG_BENGALI_INDIA = &h01
515Const SUBLANG_BENGALI_BANGLADESH = &h02
516Const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN = &h05
517Const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC = &h08
518Const SUBLANG_BRETON_FRANCE = &h01
519Const SUBLANG_BULGARIAN_BULGARIA = &h01
520Const SUBLANG_CATALAN_CATALAN = &h01
521Const SUBLANG_CHINESE_TRADITIONAL = &h01
522Const SUBLANG_CHINESE_SIMPLIFIED = &h02
523Const SUBLANG_CHINESE_HONGKONG = &h03
524Const SUBLANG_CHINESE_SINGAPORE = &h04
525Const SUBLANG_CHINESE_MACAU = &h05
526Const SUBLANG_CORSICAN_FRANCE = &h01
527Const SUBLANG_CZECH_CZECH_REPUBLIC = &h01
528Const SUBLANG_CROATIAN_CROATIA = &h01
529Const SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN = &h04
530Const SUBLANG_DANISH_DENMARK = &h01
531Const SUBLANG_DARI_AFGHANISTAN = &h01
532Const SUBLANG_DIVEHI_MALDIVES = &h01
533Const SUBLANG_DUTCH = &h01
534Const SUBLANG_DUTCH_BELGIAN = &h02
535Const SUBLANG_ENGLISH_US = &h01
536Const SUBLANG_ENGLISH_UK = &h02
537Const SUBLANG_ENGLISH_AUS = &h03
538Const SUBLANG_ENGLISH_CAN = &h04
539Const SUBLANG_ENGLISH_NZ = &h05
540Const SUBLANG_ENGLISH_EIRE = &h06
541Const SUBLANG_ENGLISH_SOUTH_AFRICA = &h07
542Const SUBLANG_ENGLISH_JAMAICA = &h08
543Const SUBLANG_ENGLISH_CARIBBEAN = &h09
544Const SUBLANG_ENGLISH_BELIZE = &h0a
545Const SUBLANG_ENGLISH_TRINIDAD = &h0b
546Const SUBLANG_ENGLISH_ZIMBABWE = &h0c
547Const SUBLANG_ENGLISH_PHILIPPINES = &h0d
548Const SUBLANG_ENGLISH_INDIA = &h10
549Const SUBLANG_ENGLISH_MALAYSIA = &h11
550Const SUBLANG_ENGLISH_SINGAPORE = &h12
551Const SUBLANG_ESTONIAN_ESTONIA = &h01
552Const SUBLANG_FAEROESE_FAROE_ISLANDS = &h01
553Const SUBLANG_FILIPINO_PHILIPPINES = &h01
554Const SUBLANG_FINNISH_FINLAND = &h01
555Const SUBLANG_FRENCH = &h01
556Const SUBLANG_FRENCH_BELGIAN = &h02
557Const SUBLANG_FRENCH_CANADIAN = &h03
558Const SUBLANG_FRENCH_SWISS = &h04
559Const SUBLANG_FRENCH_LUXEMBOURG = &h05
560Const SUBLANG_FRENCH_MONACO = &h06
561Const SUBLANG_FRISIAN_NETHERLANDS = &h01
562Const SUBLANG_GALICIAN_GALICIAN = &h01
563Const SUBLANG_GEORGIAN_GEORGIA = &h01
564Const SUBLANG_GERMAN = &h01
565Const SUBLANG_GERMAN_SWISS = &h02
566Const SUBLANG_GERMAN_AUSTRIAN = &h03
567Const SUBLANG_GERMAN_LUXEMBOURG = &h04
568Const SUBLANG_GERMAN_LIECHTENSTEIN = &h05
569Const SUBLANG_GREEK_GREECE = &h01
570Const SUBLANG_GREENLANDIC_GREENLAND = &h01
571Const SUBLANG_GUJARATI_INDIA = &h01
572Const SUBLANG_HAUSA_NIGERIA_LATIN = &h01
573Const SUBLANG_HEBREW_ISRAEL = &h01
574Const SUBLANG_HINDI_INDIA = &h01
575Const SUBLANG_HUNGARIAN_HUNGARY = &h01
576Const SUBLANG_ICELANDIC_ICELAND = &h01
577Const SUBLANG_IGBO_NIGERIA = &h01
578Const SUBLANG_INDONESIAN_INDONESIA = &h01
579Const SUBLANG_INUKTITUT_CANADA = &h01
580Const SUBLANG_INUKTITUT_CANADA_LATIN = &h02
581Const SUBLANG_IRISH_IRELAND = &h02
582Const SUBLANG_ITALIAN = &h01
583Const SUBLANG_ITALIAN_SWISS = &h02
584Const SUBLANG_JAPANESE_JAPAN = &h01
585Const SUBLANG_KANNADA_INDIA = &h01
586Const SUBLANG_KASHMIRI_SASIA = &h02
587Const SUBLANG_KASHMIRI_INDIA = &h02
588Const SUBLANG_KAZAK_KAZAKHSTAN = &h01
589Const SUBLANG_KHMER_CAMBODIA = &h01
590Const SUBLANG_KICHE_GUATEMALA = &h01
591Const SUBLANG_KINYARWANDA_RWANDA = &h01
592Const SUBLANG_KONKANI_INDIA = &h01
593Const SUBLANG_KOREAN = &h01
594Const SUBLANG_KYRGYZ_KYRGYZSTAN = &h01
595Const SUBLANG_LAO_LAO = &h01
596Const SUBLANG_LATVIAN_LATVIA = &h01
597Const SUBLANG_LITHUANIAN = &h01
598Const SUBLANG_LOWER_SORBIAN_GERM = &h02
599Const SUBLANG_LUXEMBOURGISH_LUXEMBOURG = &h01
600Const SUBLANG_MACEDONIAN_MACEDONIA = &h01
601Const SUBLANG_MALAY_MALAYSIA = &h01
602Const SUBLANG_MALAY_BRUNEI_DARUSSALAM = &h02
603Const SUBLANG_MALAYALAM_INDIA = &h01
604Const SUBLANG_MALTESE_MALTA = &h01
605Const SUBLANG_MAORI_NEW_ZEALAND = &h01
606Const SUBLANG_MAPUDUNGUN_CHILE = &h01
607Const SUBLANG_MARATHI_INDIA = &h01
608Const SUBLANG_MOHAWK_MOHAWK = &h01
609Const SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA = &h01
610Const SUBLANG_MONGOLIAN_PRC = &h02
611Const SUBLANG_NEPALI_INDIA = &h02
612Const SUBLANG_NEPALI_NEPAL = &h01
613Const SUBLANG_NORWEGIAN_BOKMAL = &h01
614Const SUBLANG_NORWEGIAN_NYNORSK = &h02
615Const SUBLANG_OCCITAN_FRANCE = &h01
616Const SUBLANG_ORIYA_INDIA = &h01
617Const SUBLANG_PASHTO_AFGHANISTAN = &h01
618Const SUBLANG_PERSIAN_IRAN = &h01
619Const SUBLANG_POLISH_POLAND = &h01
620Const SUBLANG_PORTUGUESE = &h02
621Const SUBLANG_PORTUGUESE_BRAZILIAN = &h01
622Const SUBLANG_PUNJABI_INDIA = &h01
623Const SUBLANG_QUECHUA_BOLIVIA = &h01
624Const SUBLANG_QUECHUA_ECUADOR = &h02
625Const SUBLANG_QUECHUA_PERU = &h03
626Const SUBLANG_ROMANIAN_ROMANIA = &h01
627Const SUBLANG_ROMANSH_SWITZERLAND = &h01
628Const SUBLANG_RUSSIAN_RUSSIA = &h01
629Const SUBLANG_SAMI_NORTHERN_NORWAY = &h01
630Const SUBLANG_SAMI_NORTHERN_SWEDEN = &h02
631Const SUBLANG_SAMI_NORTHERN_FINLAND = &h03
632Const SUBLANG_SAMI_LULE_NORWAY = &h04
633Const SUBLANG_SAMI_LULE_SWEDEN = &h05
634Const SUBLANG_SAMI_SOUTHERN_NORWAY = &h06
635Const SUBLANG_SAMI_SOUTHERN_SWEDEN = &h07
636Const SUBLANG_SAMI_SKOLT_FINLAND = &h08
637Const SUBLANG_SAMI_INARI_FINLAND = &h09
638Const SUBLANG_SANSKRIT_INDIA = &h01
639Const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN = &h06
640Const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC = &h07
641Const SUBLANG_SERBIAN_CROATIA = &h01
642Const SUBLANG_SERBIAN_LATIN = &h02
643Const SUBLANG_SERBIAN_CYRILLIC = &h03
644Const SUBLANG_SINDHI_INDIA = &h01
645Const SUBLANG_SINDHI_PAKISTAN = &h02
646Const SUBLANG_SINDHI_AFGHANISTAN = &h02
647Const SUBLANG_SINHALESE_SRI_LANKA = &h01
648Const SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA = &h01
649Const SUBLANG_SLOVAK_SLOVAKIA = &h01
650Const SUBLANG_SLOVENIAN_SLOVENIA = &h01
651Const SUBLANG_SPANISH = &h01
652Const SUBLANG_SPANISH_MEXICAN = &h02
653Const SUBLANG_SPANISH_MODERN = &h03
654Const SUBLANG_SPANISH_GUATEMALA = &h04
655Const SUBLANG_SPANISH_COSTA_RICA = &h05
656Const SUBLANG_SPANISH_PANAMA = &h06
657Const SUBLANG_SPANISH_DOMINICAN_REPUBLIC = &h07
658Const SUBLANG_SPANISH_VENEZUELA = &h08
659Const SUBLANG_SPANISH_COLOMBIA = &h09
660Const SUBLANG_SPANISH_PERU = &h0a
661Const SUBLANG_SPANISH_ARGENTINA = &h0b
662Const SUBLANG_SPANISH_ECUADOR = &h0c
663Const SUBLANG_SPANISH_CHILE = &h0d
664Const SUBLANG_SPANISH_URUGUAY = &h0e
665Const SUBLANG_SPANISH_PARAGUAY = &h0f
666Const SUBLANG_SPANISH_BOLIVIA = &h10
667Const SUBLANG_SPANISH_EL_SALVADOR = &h11
668Const SUBLANG_SPANISH_HONDURAS = &h12
669Const SUBLANG_SPANISH_NICARAGUA = &h13
670Const SUBLANG_SPANISH_PUERTO_RICO = &h14
671Const SUBLANG_SPANISH_US = &h15
672Const SUBLANG_SWAHILI_KENYA = &h01
673Const SUBLANG_SWEDISH = &h01
674Const SUBLANG_SWEDISH_FINLAND = &h02
675Const SUBLANG_SYRIAC_SYRIA = &h01
676Const SUBLANG_TAJIK_TAJIKISTAN = &h01
677Const SUBLANG_TAMAZIGHT_ALGERIA_LATIN = &h02
678Const SUBLANG_TAMIL_INDIA = &h01
679Const SUBLANG_TATAR_RUSSIA = &h01
680Const SUBLANG_TELUGU_INDIA = &h01
681Const SUBLANG_THAI_THAILAND = &h01
682Const SUBLANG_TIBETAN_PRC = &h01
683Const SUBLANG_TIGRIGNA_ERITREA = &h02
684Const SUBLANG_TSWANA_SOUTH_AFRICA = &h01
685Const SUBLANG_TURKISH_TURKEY = &h01
686Const SUBLANG_TURKMEN_TURKMENISTAN = &h01
687Const SUBLANG_UIGHUR_PRC = &h01
688Const SUBLANG_UKRAINIAN_UKRAINE = &h01
689Const SUBLANG_UPPER_SORBIAN_GERMANY = &h01
690Const SUBLANG_URDU_PAKISTAN = &h01
691Const SUBLANG_URDU_INDIA = &h02
692Const SUBLANG_UZBEK_LATIN = &h01
693Const SUBLANG_UZBEK_CYRILLIC = &h02
694Const SUBLANG_VIETNAMESE_VIETNAM = &h01
695Const SUBLANG_WELSH_UNITED_KINGDOM = &h01
696Const SUBLANG_WOLOF_SENEGAL = &h01
697Const SUBLANG_XHOSA_SOUTH_AFRICA = &h01
698Const SUBLANG_YAKUT_RUSSIA = &h01
699Const SUBLANG_YI_PRC = &h01
700Const SUBLANG_YORUBA_NIGERIA = &h01
701Const SUBLANG_ZULU_SOUTH_AFRICA = &h01
702
703' Sorting IDs.
704Const SORT_DEFAULT = &h0
705
706Const SORT_INVARIANT_MATH = &h1
707
708Const SORT_JAPANESE_XJIS = &h0
709Const SORT_JAPANESE_UNICODE = &h1
710Const SORT_JAPANESE_RADICALSTROKE = &h4
711
712Const SORT_CHINESE_BIG5 = &h0
713Const SORT_CHINESE_PRCP = &h0
714Const SORT_CHINESE_UNICODE = &h1
715Const SORT_CHINESE_PRC = &h2
716Const SORT_CHINESE_BOPOMOFO = &h3
717
718Const SORT_KOREAN_KSC = &h0
719Const SORT_KOREAN_UNICODE = &h1
720
721Const SORT_GERMAN_PHONE_BOOK = &h1
722
723Const SORT_HUNGARIAN_DEFAULT = &h0
724Const SORT_HUNGARIAN_TECHNICAL = &h1
725
726Const SORT_GEORGIAN_TRADITIONAL = &h0
727Const SORT_GEORGIAN_MODERN = &h1
728
729Const MAKELANGID(p, s) = ((((s) As Word) << 10) Or (p) As Word)
730Const PRIMARYLANGID(lgid) = ((lgid) As Word And &h3ff)
731Const SUBLANGID(lgid) = ((lgid) As Word >> 10)
732
733Const NLS_VALID_LOCALE_MASK = &h000fffff
734
735Const MAKELCID(lgid, srtid) = ((((((srtid) As Word) As DWord) << 16) Or (((lgid) As Word) As DWord)) As DWord)
736Const MAKESORTLCID(lgid, srtid, ver) = (((MAKELCID(lgid, srtid)) Or ((((ver) As Word)) As DWord << 20)) As DWord)
737Const LANGIDFROMLCID(lcid) = ((lcid) As Word)
738Const SORTIDFROMLCID(lcid) = (((((lcid) As DWord) >> 16) And &hf) As Word)
739Const SORTVERSIONFROMLCID(lcid) = (((((lcid) As DWord) >> 20) And &hf) As Word)
740
741Const LOCALE_NAME_MAX_LENGTH = 85
742
743Const LANG_SYSTEM_DEFAULT = (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
744Const LANG_USER_DEFAULT = (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
745
746Const LOCALE_SYSTEM_DEFAULT = (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
747Const LOCALE_USER_DEFAULT = (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
748
749Const LOCALE_CUSTOM_DEFAULT = (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT))
750Const LOCALE_CUSTOM_UNSPECIFIED = (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT))
751Const LOCALE_CUSTOM_UI_DEFAULT = (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT), SORT_DEFAULT))
752Const LOCALE_NEUTRAL = (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
753Const LOCALE_INVARIANT = (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
754
755' DEFAULT_UNREACHABLE
756
757#ifndef WIN32_NO_STATUS
758Const STATUS_WAIT_0 = (&h00000000 As DWord)
759Const STATUS_ABANDONED_WAIT_0 = (&h00000080 As DWord)
760Const STATUS_USER_APC = (&h000000C0 As DWord)
761Const STATUS_TIMEOUT = (&h00000102 As DWord)
762Const STATUS_PENDING = (&h00000103 As DWord)
763Const DBG_EXCEPTION_HANDLED = (&h00010001 As DWord)
764Const DBG_CONTINUE = (&h00010002 As DWord)
765Const STATUS_SEGMENT_NOTIFICATION = (&h40000005 As DWord)
766Const DBG_TERMINATE_THREAD = (&h40010003 As DWord)
767Const DBG_TERMINATE_PROCESS = (&h40010004 As DWord)
768Const DBG_CONTROL_C = (&h40010005 As DWord)
769Const DBG_CONTROL_BREAK = (&h40010008 As DWord)
770Const DBG_COMMAND_EXCEPTION = (&h40010009 As DWord)
771Const STATUS_GUARD_PAGE_VIOLATION = (&h80000001 As DWord)
772Const STATUS_DATATYPE_MISALIGNMENT = (&h80000002 As DWord)
773Const STATUS_BREAKPOINT = (&h80000003 As DWord)
774Const STATUS_SINGLE_STEP = (&h80000004 As DWord)
775Const DBG_EXCEPTION_NOT_HANDLED = (&h80010001 As DWord)
776Const STATUS_ACCESS_VIOLATION = (&hC0000005 As DWord)
777Const STATUS_IN_PAGE_ERROR = (&hC0000006 As DWord)
778Const STATUS_INVALID_HANDLE = (&hC0000008 As DWord)
779Const STATUS_NO_MEMORY = (&hC0000017 As DWord)
780Const STATUS_ILLEGAL_INSTRUCTION = (&hC000001D As DWord)
781Const STATUS_NONCONTINUABLE_EXCEPTION = (&hC0000025 As DWord)
782Const STATUS_INVALID_DISPOSITION = (&hC0000026 As DWord)
783Const STATUS_ARRAY_BOUNDS_EXCEEDED = (&hC000008C As DWord)
784Const STATUS_FLOAT_DENORMAL_OPERAND = (&hC000008D As DWord)
785Const STATUS_FLOAT_DIVIDE_BY_ZERO = (&hC000008E As DWord)
786Const STATUS_FLOAT_INEXACT_RESULT = (&hC000008F As DWord)
787Const STATUS_FLOAT_INVALID_OPERATION = (&hC0000090 As DWord)
788Const STATUS_FLOAT_OVERFLOW = (&hC0000091 As DWord)
789Const STATUS_FLOAT_STACK_CHECK = (&hC0000092 As DWord)
790Const STATUS_FLOAT_UNDERFLOW = (&hC0000093 As DWord)
791Const STATUS_INTEGER_DIVIDE_BY_ZERO = (&hC0000094 As DWord)
792Const STATUS_INTEGER_OVERFLOW = (&hC0000095 As DWord)
793Const STATUS_PRIVILEGED_INSTRUCTION = (&hC0000096 As DWord)
794Const STATUS_STACK_OVERFLOW = (&hC00000FD As DWord)
795Const STATUS_CONTROL_C_EXIT = (&hC000013A As DWord)
796Const STATUS_FLOAT_MULTIPLE_FAULTS = (&hC00002B4 As DWord)
797Const STATUS_FLOAT_MULTIPLE_TRAPS = (&hC00002B5 As DWord)
798Const STATUS_REG_NAT_CONSUMPTION = (&hC00002C9 As DWord)
799'#if defined(STATUS_SUCCESS) || (_WIN32_WINNT > 0x0500) || (_WIN32_FUSION >= 0x0100)
800Const STATUS_SXS_EARLY_DEACTIVATION = (&hC015000F As DWord)
801Const STATUS_SXS_INVALID_DEACTIVATION = (&hC0150010 As DWord)
802'#endif
803#endif
804
805Const MAXIMUM_WAIT_OBJECTS = 64
806
807Const MAXIMUM_SUSPEND_COUNT = MAXCHAR
808
809TypeDef KSPIN_LOCK = ULONG_PTR
810TypeDef PKSPIN_LOCK = KSPIN_LOCK
811
812#ifdef _WIN64
813
814Const EXCEPTION_READ_FAULT = 0
815Const EXCEPTION_WRITE_FAULT = 1
816Const EXCEPTION_EXECUTE_FAULT = 8
817
818Const CONTEXT_AMD64 = &h100000
819
820Const CONTEXT_CONTROL = (CONTEXT_AMD64 Or &h1)
821Const CONTEXT_INTEGER = (CONTEXT_AMD64 Or &h2)
822Const CONTEXT_SEGMENTS = (CONTEXT_AMD64 Or &h4)
823Const CONTEXT_FLOATING_POINT  = (CONTEXT_AMD64 Or &h8)
824Const CONTEXT_DEBUG_REGISTERS = (CONTEXT_AMD64 Or &h10)
825
826Const CONTEXT_FULL = (CONTEXT_CONTROL Or CONTEXT_INTEGER Or CONTEXT_FLOATING_POINT)
827
828Const CONTEXT_ALL = (CONTEXT_CONTROL Or CONTEXT_INTEGER Or CONTEXT_SEGMENTS Or CONTEXT_FLOATING_POINT Or CONTEXT_DEBUG_REGISTERS)
829
830Const CONTEXT_EXCEPTION_ACTIVE = &h8000000
831Const CONTEXT_SERVICE_ACTIVE = &h10000000
832Const CONTEXT_EXCEPTION_REQUEST = &h40000000
833Const CONTEXT_EXCEPTION_REPORTING = &h80000000
834
835Const INITIAL_MXCSR = &h1f80
836Const INITIAL_FPCSR = &h027f
837
838Type Align(16) M128A
839    Low As QWord
840    High As Int64
841End Type
842TypeDef PM128A = *M128A
843
844Type XMM_SAVE_AREA32
845    ControlWord As Word
846    StatusWord As Word
847    TagWord As Byte
848    Reserved1 As Byte
849    ErrorOpcode As Word
850    ErrorOffset As DWord
851    ErrorSelector As Word
852    Reserved2 As Word
853    DataOffset As DWord
854    DataSelector As Word
855    Reserved3 As Word
856    MxCsr As DWord
857    MxCsr_Mask As DWord
858    FloatRegisters[ELM(8)] As M128A
859    XmmRegisters[ELM(16)] As M128A
860    Reserved4[ELM(96)] As Byte
861End Type
862TypeDef PXMM_SAVE_AREA32 = *XMM_SAVE_AREA32
863
864Const LEGACY_SAVE_AREA_LENGTH = SizeOf (XMM_SAVE_AREA32)
865
866Type Align(16) CONTEXT
867    'Register parameter home addresses.
868    P1Home As QWord
869    P2Home As QWord
870    P3Home As QWord
871    P4Home As QWord
872    P5Home As QWord
873    P6Home As QWord
874    'Control flags.
875    ContextFlags As DWord
876    MxCsr As DWord
877    'Segment Registers and processor flags.
878    SegCs As Word
879    SegDs As Word
880    SegEs As Word
881    SegFs As Word
882    SegGs As Word
883    SegSs As Word
884    EFlags As DWord
885    'Debug registers
886    Dr0 As QWord
887    Dr1 As QWord
888    Dr2 As QWord
889    Dr3 As QWord
890    Dr6 As QWord
891    Dr7 As QWord
892    'Integer registers.
893    Rax As QWord
894    Rcx As QWord
895    Rdx As QWord
896    Rbx As QWord
897    Rsp As QWord
898    Rbp As QWord
899    Rsi As QWord
900    Rdi As QWord
901    R8 As QWord
902    R9 As QWord
903    R10 As QWord
904    R11 As QWord
905    R12 As QWord
906    R13 As QWord
907    R14 As QWord
908    R15 As QWord
909    'Program counter.
910    Rip As QWord
911    'MMX/floating point state.
912    Header[ELM(2)] As M128A
913    Legacy[ELM(8)] As M128A
914    Xmm0 As M128A
915    Xmm1 As M128A
916    Xmm2 As M128A
917    Xmm3 As M128A
918    Xmm4 As M128A
919    Xmm5 As M128A
920    Xmm6 As M128A
921    Xmm7 As M128A
922    Xmm8 As M128A
923    Xmm9 As M128A
924    Xmm10 As M128A
925    Xmm11 As M128A
926    Xmm12 As M128A
927    Xmm13 As M128A
928    Xmm14 As M128A
929    Xmm15 As M128A
930    Reserve[ELM(96)] As Byte
931    'Vector registers
932    VectorRegisters[ELM(26)] As M128A
933    VectorControl As QWord
934    'Special debug control registers.
935    DebugControl As QWord
936    LastBranchToRip As QWord
937    LastBranchFromRip As QWord
938    LastExceptionToRip As QWord
939    LastExceptionFromRip As QWord
940End Type
941TypeDef PCONTEXT = *CONTEXT
942
943Const RUNTIME_FUNCTION_INDIRECT = &h1
944
945Type RUNTIME_FUNCTION
946    BeginAddress As DWord
947    EndAddress As DWord
948    UnwindData As DWord
949End Type
950TypeDef PRUNTIME_FUNCTION = *RUNTIME_FUNCTION
951
952TypeDef PGET_RUNTIME_FUNCTION_CALLBACK = *Function(ControlPc As QWord, Context As PVOID) As PRUNTIME_FUNCTION
953
954TypeDef POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK = *Function(Process As HANDLE, TableAddress As PVOID, Entries As *DWord, ByRef Functions As PRUNTIME_FUNCTION) As DWord
955
956Const OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME = "OutOfProcessFunctionTableCallback"
957
958Declare Sub RtlRestoreContext Lib "kernel32" (ByRef ContextRecord As CONTEXT, ExceptionRecord As *EXCEPTION_RECORD)
959Declare Function RtlAddFunctionTable Lib "kernel32" (FunctionTable As PRUNTIME_FUNCTION, EntryCount As DWord, BaseAddress As QWord) As BOOLEAN
960Declare Function RtlInstallFunctionTableCallback Lib "kernel32" (TableIdentifier As QWord, BaseAddress As QWord, Length As DWord, Callback As PGET_RUNTIME_FUNCTION_CALLBACK, Context As PVOID, OutOfProcessCallbackDll As PCWSTR) As BOOLEAN
961Declare Function RtlDeleteFunctionTable Lib "kernel32" (FunctionTable As PRUNTIME_FUNCTION) As BOOLEAN
962
963'#endif '_WIN64
964#else
965'#ifdef _WIN32
966'InterlockedBitTestAndSet
967'InterlockedBitTestAndReset
968'InterlockedBitTestAndComplement
969
970
971'MemoryBarrier
972'PreFetchCacheLine
973'ReadForWriteAccess
974
975'ReadPMC
976'ReadTimeStampCounter
977
978'DbgRaiseAssertionFailure
979
980'GetFiberData
981'GetCurrentFibe
982
983Const EXCEPTION_READ_FAULT = 0
984Const EXCEPTION_WRITE_FAULT = 1
985Const EXCEPTION_EXECUTE_FAULT = 8
986
987Const SIZE_OF_80387_REGISTERS = 80
988
989Const CONTEXT_i386 = &h00010000
990Const CONTEXT_i486 = &h00010000
991
992Const CONTEXT_CONTROL = (CONTEXT_i386 Or &h00000001) ' SS:SP, CS:IP, FLAGS, BP
993Const CONTEXT_INTEGER = (CONTEXT_i386 Or &h00000002) ' AX, BX, CX, DX, SI, DI
994Const CONTEXT_SEGMENTS = (CONTEXT_i386 Or &h00000004) ' DS, ES, FS, GS
995Const CONTEXT_FLOATING_POINT = (CONTEXT_i386 Or &h00000008) ' 387 state
996Const CONTEXT_DEBUG_REGISTERS = (CONTEXT_i386 Or &h00000010) ' DB 0-3,6,7
997Const CONTEXT_EXTENDED_REGISTERS = (CONTEXT_i386 Or &h00000020) ' cpu specific extensions
998Const CONTEXT_FULL = (CONTEXT_CONTROL Or CONTEXT_INTEGER Or CONTEXT_SEGMENTS)
999Const CONTEXT_ALL = (CONTEXT_CONTROL Or CONTEXT_INTEGER Or CONTEXT_SEGMENTS Or  CONTEXT_FLOATING_POINT Or CONTEXT_DEBUG_REGISTERS Or  CONTEXT_EXTENDED_REGISTERS)
1000
1001Const MAXIMUM_SUPPORTED_EXTENSION = 512
1002
1003Type FLOATING_SAVE_AREA
1004    ControlWord As DWord
1005    StatusWord As DWord
1006    TagWord As DWord
1007    ErrorOffset As DWord
1008    ErrorSelector As DWord
1009    DataOffset As DWord
1010    DataSelector As DWord
1011    RegisterArea[ELM(SIZE_OF_80387_REGISTERS)] As Byte
1012    Cr0NpxState As DWord
1013End Type
1014TypeDef PFLOATING_SAVE_AREA = FLOATING_SAVE_AREA
1015
1016Type CONTEXT
1017    ContextFlags As DWord
1018
1019    Dr0 As DWord
1020    Dr1 As DWord
1021    Dr2 As DWord
1022    Dr3 As DWord
1023    Dr6 As DWord
1024    Dr7 As DWord
1025
1026    FloatSave As FLOATING_SAVE_AREA
1027
1028    SegGs As DWord
1029    SegFs As DWord
1030    SegEs As DWord
1031    SegDs As DWord
1032
1033    Edi As DWord
1034    Esi As DWord
1035    Ebx As DWord
1036    Edx As DWord
1037    Ecx As DWord
1038    Eax As DWord
1039
1040    Ebp As DWord
1041    Eip As DWord
1042    SegCs As DWord
1043    EFlags As DWord
1044    Esp As DWord
1045    SegSs As DWord
1046
1047    ExtendedRegisters[ELM(MAXIMUM_SUPPORTED_EXTENSION)] As Byte
1048End Type
1049
1050TypeDef PCONTEXT = *CONTEXT
1051
1052#endif
1053
1054Type LDT_ENTRY
1055    LimitLow As Word
1056    BaseLow As Word
1057    BaseMid As Byte
1058    Flags1 As Byte
1059    Flags2 As Byte
1060    BaseHi As Byte
1061End Type
1062TypeDef PLDT_ENTRY = *LDT_ENTRY
1063
1064Const WOW64_CONTEXT_i386 = &h00010000
1065Const WOW64_CONTEXT_i486 = &h00010000
1066
1067Const WOW64_CONTEXT_CONTROL = (WOW64_CONTEXT_i386 Or &h00000001) ' SS:SP, CS:IP, FLAGS, BP
1068Const WOW64_CONTEXT_INTEGER = (WOW64_CONTEXT_i386 Or &h00000002) ' AX, BX, CX, DX, SI, DI
1069Const WOW64_CONTEXT_SEGMENTS = (WOW64_CONTEXT_i386 Or &h00000004) ' DS, ES, FS, GS
1070Const WOW64_CONTEXT_FLOATING_POINT = (WOW64_CONTEXT_i386 Or &h00000008) ' 387 state
1071Const WOW64_CONTEXT_DEBUG_REGISTERS = (WOW64_CONTEXT_i386 Or &h00000010) ' DB 0-3,6,7
1072Const WOW64_CONTEXT_EXTENDED_REGISTERS = (WOW64_CONTEXT_i386 Or &h00000020) ' cpu specific extensions
1073Const WOW64_CONTEXT_FULL = (WOW64_CONTEXT_CONTROL Or WOW64_CONTEXT_INTEGER Or WOW64_CONTEXT_SEGMENTS)
1074Const WOW64_CONTEXT_ALL = (WOW64_CONTEXT_CONTROL Or WOW64_CONTEXT_INTEGER Or WOW64_CONTEXT_SEGMENTS Or WOW64_CONTEXT_FLOATING_POINT Or WOW64_CONTEXT_DEBUG_REGISTERS Or WOW64_CONTEXT_EXTENDED_REGISTERS)
1075
1076Const WOW64_SIZE_OF_80387_REGISTERS = 80
1077
1078Const WOW64_MAXIMUM_SUPPORTED_EXTENSION = 512
1079
1080Type WOW64_FLOATING_SAVE_AREA
1081    ControlWord As DWord
1082    StatusWord As DWord
1083    TagWord As DWord
1084    ErrorOffset As DWord
1085    ErrorSelector As DWord
1086    DataOffset As DWord
1087    DataSelector As DWord
1088    RegisterArea[ELM(WOW64_SIZE_OF_80387_REGISTERS)] As Byte
1089    Cr0NpxState As DWord
1090End Type
1091TypeDef PWOW64_FLOATING_SAVE_AREA = *WOW64_FLOATING_SAVE_AREA
1092
1093Type WOW64_CONTEXT
1094    ContextFlags As DWord
1095
1096    Dr0 As DWord
1097    Dr1 As DWord
1098    Dr2 As DWord
1099    Dr3 As DWord
1100    Dr6 As DWord
1101    Dr7 As DWord
1102
1103    FloatSave As WOW64_FLOATING_SAVE_AREA
1104
1105    SegGs As DWord
1106    SegFs As DWord
1107    SegEs As DWord
1108    SegDs As DWord
1109
1110    Edi As DWord
1111    Esi As DWord
1112    Ebx As DWord
1113    Edx As DWord
1114    Ecx As DWord
1115    Eax As DWord
1116
1117    Ebp As DWord
1118    Eip As DWord
1119    SegCs As DWord
1120    EFlags As DWord
1121    Esp As DWord
1122    SegSs As DWord
1123
1124    ExtendedRegisters[ELM(WOW64_MAXIMUM_SUPPORTED_EXTENSION)] As Byte
1125End Type
1126
1127TypeDef PWOW64_CONTEXT = *WOW64_CONTEXT
1128
1129Const EXCEPTION_NONCONTINUABLE = &h1
1130Const EXCEPTION_MAXIMUM_PARAMETERS = 15
1131
1132Type EXCEPTION_RECORD
1133    ExceptionCode As DWord
1134    ExceptionFlags As DWord
1135    ExceptionRecord As *EXCEPTION_RECORD
1136    ExceptionAddress As PVOID
1137    NumberParameters As DWord
1138    ExceptionInformation[ELM(EXCEPTION_MAXIMUM_PARAMETERS)] As ULONG_PTR
1139End Type
1140TypeDef PEXCEPTION_RECORD = *EXCEPTION_RECORD
1141
1142Type EXCEPTION_RECORD32
1143    ExceptionCode As DWord
1144    ExceptionFlags As DWord
1145    ExceptionRecord As DWord
1146    ExceptionAddress As DWord
1147    NumberParameters As DWord
1148    ExceptionInformation[ELM(EXCEPTION_MAXIMUM_PARAMETERS)] As DWord
1149End Type
1150TypeDef PEXCEPTION_RECORD32 = *EXCEPTION_RECORD32
1151
1152Type EXCEPTION_RECORD64
1153    ExceptionCode As DWord
1154    ExceptionFlags As DWord
1155    ExceptionRecord As QWord
1156    ExceptionAddress As QWord
1157    NumberParameters As DWord
1158    __unusedAlignment As DWord
1159    ExceptionInformation[ELM(EXCEPTION_MAXIMUM_PARAMETERS)] As QWord
1160End Type
1161TypeDef PEXCEPTION_RECORD64 = *EXCEPTION_RECORD64
1162
1163Type EXCEPTION_POINTERS
1164    ExceptionRecord As PEXCEPTION_RECORD
1165    ContextRecord As PCONTEXT
1166End Type
1167TypeDef PEXCEPTION_POINTERS = *EXCEPTION_POINTERS
1168
1169TypeDef PACCESS_TOKEN = PVOID
1170'TypeDef PSECURITY_DESCRIPTOR = PVOID
1171'TypeDef PSID = PVOID
1172
1173'ACCESS MASK
1174TypeDef ACCESS_MASK = DWord
1175TypeDef PACCESS_MASK = *ACCESS_MASK
1176
1177'ACCESS TYPES
1178
1179'Const DELETE = (&h00010000)
1180Const READ_CONTROL = (&h00020000)
1181Const WRITE_DAC = (&h00040000)
1182Const WRITE_OWNER = (&h00080000)
1183Const SYNCHRONIZE = (&h00100000)
1184
1185Const STANDARD_RIGHTS_REQUIRED = (&h000F0000)
1186
1187Const STANDARD_RIGHTS_READ = (READ_CONTROL)
1188Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
1189Const STANDARD_RIGHTS_EXECUTE = (READ_CONTROL)
1190
1191Const STANDARD_RIGHTS_ALL = (&h001F0000)
1192
1193Const SPECIFIC_RIGHTS_ALL = (&h0000FFFF)
1194
1195Const ACCESS_SYSTEM_SECURITY = (&h01000000)
1196
1197Const MAXIMUM_ALLOWED = (&h02000000)
1198
1199Const GENERIC_READ = (&h80000000)
1200Const GENERIC_WRITE = (&h40000000)
1201Const GENERIC_EXECUTE = (&h20000000)
1202Const GENERIC_ALL = (&h10000000)
1203
1204Type GENERIC_MAPPING
1205    GenericRead As ACCESS_MASK
1206    GenericWrite As ACCESS_MASK
1207    GenericExecute As ACCESS_MASK
1208    GenericAll As ACCESS_MASK
1209End Type
1210TypeDef PGENERIC_MAPPING = *GENERIC_MAPPING
1211
1212' LUID_AND_ATTRIBUTES
1213Type Align(4) LUID_AND_ATTRIBUTES
1214    Luid As LUID
1215    Attributes As DWord
1216End Type
1217'TypeDef LUID_AND_ATTRIBUTES_ARRAY = LUID_AND_ATTRIBUTES[ANYSIZE_ARRAY]
1218'TypeDef PLUID_AND_ATTRIBUTES_ARRAY = *LUID_AND_ATTRIBUTES_ARRAY
1219
1220' Security Id (SID)
1221
1222Type SID_IDENTIFIER_AUTHORITY
1223    Value[ELM(6)] As Byte
1224End Type
1225TypeDef PSID_IDENTIFIER_AUTHORITY = *SID_IDENTIFIER_AUTHORITY
1226
1227Type SID
1228    Revision As Byte
1229    SubAuthorityCount As Byte
1230    IdentifierAuthority As SID_IDENTIFIER_AUTHORITY
1231    SubAuthority[ELM(ANYSIZE_ARRAY)] As DWord
1232End Type
1233TypeDef PSID = *SID
1234
1235Const SID_REVISION = (1)
1236Const SID_MAX_SUB_AUTHORITIES = (15)
1237Const SID_RECOMMENDED_SUB_AUTHORITIES = (1)
1238
1239Const SECURITY_MAX_SID_SIZE = (SizeOf (SID) - SizeOf (DWord) + (SID_MAX_SUB_AUTHORITIES * SizeOf (DWord)))
1240
1241Enum SID_NAME_USE
1242    SidTypeUser = 1
1243    SidTypeGroup
1244    SidTypeDomain
1245    SidTypeAlias
1246    SidTypeWellKnownGroup
1247    SidTypeDeletedAccount
1248    SidTypeInvalid
1249    SidTypeUnknown
1250    SidTypeComputer
1251    SidTypeLabel
1252End Enum
1253TypeDef PSID_NAME_USE = *SID_NAME_USE
1254
1255Type SID_AND_ATTRIBUTES
1256    Sid As PSID
1257    Attributes As DWord
1258End Type
1259TypeDef PSID_AND_ATTRIBUTES = *SID_AND_ATTRIBUTES
1260
1261'TypeDef SID_AND_ATTRIBUTES_ARRAY = SID_AND_ATTRIBUTES[ANYSIZE_ARRAY]
1262'TypeDef PSID_AND_ATTRIBUTES_ARRAY = *SID_AND_ATTRIBUTES_ARRAY
1263
1264Const SID_HASH_SIZE = 32
1265TypeDef SID_HASH_ENTRY = ULONG_PTR
1266TypeDef PSID_HASH_ENTRY = *SID_HASH_ENTRY
1267
1268Type SID_AND_ATTRIBUTES_HASH
1269    SidCount As DWord
1270    SidAttr As PSID_AND_ATTRIBUTES
1271    Hash[ELM(SID_HASH_SIZE)] As SID_HASH_ENTRY
1272End Type
1273TypeDef PSID_AND_ATTRIBUTES_HASH = *SID_AND_ATTRIBUTES_HASH
1274
1275' Universal well-known SIDs
1276'Const SECURITY_NULL_SID_AUTHORITY = [0, 0, 0, 0, 0, 0] As SID_IDENTIFIER_AUTHORITY
1277'Const SECURITY_WORLD_SID_AUTHORITY = [0, 0, 0, 0, 0, 1] As SID_IDENTIFIER_AUTHORITY
1278'Const SECURITY_LOCAL_SID_AUTHORITY = [0, 0, 0, 0, 0, 2] As SID_IDENTIFIER_AUTHORITY
1279'Const SECURITY_CREATOR_SID_AUTHORITY = [0, 0, 0, 0, 0, 3] As SID_IDENTIFIER_AUTHORITY
1280'Const SECURITY_NON_UNIQUE_AUTHORITY = [0, 0, 0, 0, 0, 4] As SID_IDENTIFIER_AUTHORITY
1281'Const SECURITY_RESOURCE_MANAGER_AUTHORITY = [0, 0, 0, 0, 0, 9] As SID_IDENTIFIER_AUTHORITY
1282
1283Const SECURITY_NULL_RID = (&h00000000)
1284Const SECURITY_WORLD_RID = (&h00000000)
1285Const SECURITY_LOCAL_RID = (&h00000000)
1286
1287Const SECURITY_CREATOR_OWNER_RID = (&h00000000)
1288Const SECURITY_CREATOR_GROUP_RID = (&h00000001)
1289
1290Const SECURITY_CREATOR_OWNER_SERVER_RID = (&h00000002)
1291Const SECURITY_CREATOR_GROUP_SERVER_RID = (&h00000003)
1292
1293Const SECURITY_CREATOR_OWNER_RIGHTS_RID = (&h00000004)
1294
1295' NT well-known SIDs
1296'Const SECURITY_NT_AUTHORITY = [0, 0, 0, 0, 0, 9] As SID_IDENTIFIER_AUTHORITY
1297
1298Const SECURITY_DIALUP_RID = (&h00000001)
1299Const SECURITY_NETWORK_RID = (&h00000002)
1300Const SECURITY_BATCH_RID = (&h00000003)
1301Const SECURITY_INTERACTIVE_RID = (&h00000004)
1302Const SECURITY_LOGON_IDS_RID = (&h00000005)
1303Const SECURITY_LOGON_IDS_RID_COUNT = (3)
1304Const SECURITY_SERVICE_RID = (&h00000006)
1305Const SECURITY_ANONYMOUS_LOGON_RID = (&h00000007)
1306Const SECURITY_PROXY_RID = (&h00000008)
1307Const SECURITY_ENTERPRISE_CONTROLLERS_RID = (&h00000009)
1308Const SECURITY_SERVER_LOGON_RID = SECURITY_ENTERPRISE_CONTROLLERS_RID
1309Const SECURITY_PRINCIPAL_SELF_RID = (&h0000000A)
1310Const SECURITY_AUTHENTICATED_USER_RID = (&h0000000B)
1311Const SECURITY_RESTRICTED_CODE_RID = (&h0000000C)
1312Const SECURITY_TERMINAL_SERVER_RID = (&h0000000D)
1313Const SECURITY_REMOTE_LOGON_RID = (&h0000000E)
1314Const SECURITY_THIS_ORGANIZATION_RID = (&h0000000F)
1315Const SECURITY_IUSER_RID = (&h00000011)
1316Const SECURITY_LOCAL_SYSTEM_RID = (&h00000012)
1317Const SECURITY_LOCAL_SERVICE_RID = (&h00000013)
1318Const SECURITY_NETWORK_SERVICE_RID = (&h00000014)
1319
1320Const SECURITY_NT_NON_UNIQUE = (&h00000015)
1321Const SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT = (3)
1322
1323Const SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID = (&h00000016)
1324
1325Const SECURITY_BUILTIN_DOMAIN_RID = (&h00000020)
1326Const SECURITY_WRITE_RESTRICTED_CODE_RID = (&h00000021)
1327
1328
1329Const SECURITY_PACKAGE_BASE_RID = (&h00000040)
1330Const SECURITY_PACKAGE_RID_COUNT = (2)
1331Const SECURITY_PACKAGE_NTLM_RID = (&h0000000A)
1332Const SECURITY_PACKAGE_SCHANNEL_RID = (&h0000000E)
1333Const SECURITY_PACKAGE_DIGEST_RID = (&h00000015)
1334
1335Const SECURITY_SERVICE_ID_BASE_RID = (&h00000050)
1336Const SECURITY_SERVICE_ID_RID_COUNT = (6)
1337
1338Const SECURITY_RESERVED_ID_BASE_RID = (&h00000051)
1339
1340Const SECURITY_MAX_ALWAYS_FILTERED = (&h000003E7)
1341Const SECURITY_MIN_NEVER_FILTERED = (&h000003E8)
1342
1343Const SECURITY_OTHER_ORGANIZATION_RID = (&h000003E8)
1344
1345' well-known domain relative sub-authority values (RIDs)...
1346' Well-known users ...
1347Const FOREST_USER_RID_MAX = (&h000001F3)
1348
1349Const DOMAIN_USER_RID_ADMIN = (&h000001F4)
1350Const DOMAIN_USER_RID_GUEST = (&h000001F5)
1351Const DOMAIN_USER_RID_KRBTGT = (&h000001F6)
1352
1353Const DOMAIN_USER_RID_MAX = (&h000003E7)
1354
1355' well-known groups ...
1356Const DOMAIN_GROUP_RID_ADMINS = (&h00000200)
1357Const DOMAIN_GROUP_RID_USERS = (&h00000201)
1358Const DOMAIN_GROUP_RID_GUESTS = (&h00000202)
1359Const DOMAIN_GROUP_RID_COMPUTERS = (&h00000203)
1360Const DOMAIN_GROUP_RID_CONTROLLERS = (&h00000204)
1361Const DOMAIN_GROUP_RID_CERT_ADMINS = (&h00000205)
1362Const DOMAIN_GROUP_RID_SCHEMA_ADMINS = (&h00000206)
1363Const DOMAIN_GROUP_RID_ENTERPRISE_ADMINS = (&h00000207)
1364Const DOMAIN_GROUP_RID_POLICY_ADMINS = (&h00000208)
1365Const DOMAIN_GROUP_RID_READONLY_CONTROLLERS = (&h00000209)
1366
1367' well-known aliases ...
1368Const DOMAIN_ALIAS_RID_ADMINS = (&h00000220)
1369Const DOMAIN_ALIAS_RID_USERS = (&h00000221)
1370Const DOMAIN_ALIAS_RID_GUESTS = (&h00000222)
1371Const DOMAIN_ALIAS_RID_POWER_USERS = (&h00000223)
1372
1373Const DOMAIN_ALIAS_RID_ACCOUNT_OPS = (&h00000224)
1374Const DOMAIN_ALIAS_RID_SYSTEM_OPS = (&h00000225)
1375Const DOMAIN_ALIAS_RID_PRINT_OPS = (&h00000226)
1376Const DOMAIN_ALIAS_RID_BACKUP_OPS = (&h00000227)
1377
1378Const DOMAIN_ALIAS_RID_REPLICATOR = (&h00000228)
1379Const DOMAIN_ALIAS_RID_RAS_SERVERS = (&h00000229)
1380Const DOMAIN_ALIAS_RID_PREW2KCOMPACCESS = (&h0000022A)
1381Const DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS = (&h0000022B)
1382Const DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS = (&h0000022C)
1383Const DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS = (&h0000022D)
1384
1385Const DOMAIN_ALIAS_RID_MONITORING_USERS = (&h0000022E)
1386Const DOMAIN_ALIAS_RID_LOGGING_USERS = (&h0000022F)
1387Const DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS = (&h00000230)
1388Const DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS = (&h00000231)
1389Const DOMAIN_ALIAS_RID_DCOM_USERS = (&h00000232)
1390Const DOMAIN_ALIAS_RID_IUSERS = (&h00000238)
1391Const DOMAIN_ALIAS_RID_CRYPTO_OPERATORS = (&h00000239)
1392Const DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP = (&h0000023B)
1393Const DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP = (&h0000023C)
1394Const DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP = (&h0000023D)
1395
1396'Const SECURITY_MANDATORY_LABEL_AUTHORITY = [0, 0, 0, 0 ,0, 16] As SID_IDENTIFIER_AUTHORITY
1397Const SECURITY_MANDATORY_UNTRUSTED_RID = (&h00000000)
1398Const SECURITY_MANDATORY_LOW_RID = (&h00001000)
1399Const SECURITY_MANDATORY_MEDIUM_RID = (&h00002000)
1400Const SECURITY_MANDATORY_HIGH_RID = (&h00003000)
1401Const SECURITY_MANDATORY_SYSTEM_RID = (&h00004000)
1402Const SECURITY_MANDATORY_PROTECTED_PROCESS_RID = (&h00005000)
1403
1404
1405Const SECURITY_MANDATORY_MAXIMUM_USER_RID = SECURITY_MANDATORY_SYSTEM_RID
1406
1407Const MANDATORY_LEVEL_TO_MANDATORY_RID(I) = (I * &h1000)
1408
1409' Well known SID definitions for lookup.
1410Const Enum WELL_KNOWN_SID_TYPE
1411    WinNullSid = 0
1412    WinWorldSid = 1
1413    WinLocalSid = 2
1414    WinCreatorOwnerSid = 3
1415    WinCreatorGroupSid = 4
1416    WinCreatorOwnerServerSid = 5
1417    WinCreatorGroupServerSid = 6
1418    WinNtAuthoritySid = 7
1419    WinDialupSid = 8
1420    WinNetworkSid = 9
1421    WinBatchSid = 10
1422    WinInteractiveSid = 11
1423    WinServiceSid = 12
1424    WinAnonymousSid = 13
1425    WinProxySid = 14
1426    WinEnterpriseControllersSid = 15
1427    WinSelfSid = 16
1428    WinAuthenticatedUserSid = 17
1429    WinRestrictedCodeSid = 18
1430    WinTerminalServerSid = 19
1431    WinRemoteLogonIdSid = 20
1432    WinLogonIdsSid = 21
1433    WinLocalSystemSid = 22
1434    WinLocalServiceSid = 23
1435    WinNetworkServiceSid = 24
1436    WinBuiltinDomainSid = 25
1437    WinBuiltinAdministratorsSid = 26
1438    WinBuiltinUsersSid = 27
1439    WinBuiltinGuestsSid = 28
1440    WinBuiltinPowerUsersSid = 29
1441    WinBuiltinAccountOperatorsSid = 30
1442    WinBuiltinSystemOperatorsSid = 31
1443    WinBuiltinPrintOperatorsSid = 32
1444    WinBuiltinBackupOperatorsSid = 33
1445    WinBuiltinReplicatorSid = 34
1446    WinBuiltinPreWindows2000CompatibleAccessSid = 35
1447    WinBuiltinRemoteDesktopUsersSid = 36
1448    WinBuiltinNetworkConfigurationOperatorsSid = 37
1449    WinAccountAdministratorSid = 38
1450    WinAccountGuestSid = 39
1451    WinAccountKrbtgtSid = 40
1452    WinAccountDomainAdminsSid = 41
1453    WinAccountDomainUsersSid = 42
1454    WinAccountDomainGuestsSid = 43
1455    WinAccountComputersSid = 44
1456    WinAccountControllersSid = 45
1457    WinAccountCertAdminsSid = 46
1458    WinAccountSchemaAdminsSid = 47
1459    WinAccountEnterpriseAdminsSid = 48
1460    WinAccountPolicyAdminsSid = 49
1461    WinAccountRasAndIasServersSid = 50
1462    WinNTLMAuthenticationSid = 51
1463    WinDigestAuthenticationSid = 52
1464    WinSChannelAuthenticationSid = 53
1465    WinThisOrganizationSid = 54
1466    WinOtherOrganizationSid = 55
1467    WinBuiltinIncomingForestTrustBuildersSid = 56
1468    WinBuiltinPerfMonitoringUsersSid = 57
1469    WinBuiltinPerfLoggingUsersSid = 58
1470    WinBuiltinAuthorizationAccessSid = 59
1471    WinBuiltinTerminalServerLicenseServersSid = 60
1472    WinBuiltinDCOMUsersSid = 61
1473    WinBuiltinIUsersSid = 62
1474    WinIUserSid = 63
1475    WinBuiltinCryptoOperatorsSid = 64
1476    WinUntrustedLabelSid = 65
1477    WinLowLabelSid = 66
1478    WinMediumLabelSid = 67
1479    WinHighLabelSid = 68
1480    WinSystemLabelSid = 69
1481    WinWriteRestrictedCodeSid = 70
1482    WinCreatorOwnerRightsSid = 71
1483    WinCacheablePrincipalsGroupSid = 72
1484    WinNonCacheablePrincipalsGroupSid = 73
1485    WinEnterpriseReadonlyControllersSid = 74
1486    WinAccountReadonlyControllersSid = 75
1487    WinBuiltinEventLogReadersGroup = 76
1488End Enum
1489
1490'Const SYSTEM_LUID = [&h3e7, &h0] As LUID
1491'Const ANONYMOUS_LOGON_LUID = [&h3e6, &h0] As LUID
1492'Const LOCALSERVICE_LUID = [&h3e5, &h0] As LUID
1493'Const NETWORKSERVICE_LUID = [&h3e4, &h0] As LUID
1494'Const IUSER_LUID = [&h3e3, &h0] As LUID
1495
1496' User and Group related SID attributes
1497
1498' Group attributes
1499Const SE_GROUP_MANDATORY = (&h00000001)
1500Const SE_GROUP_ENABLED_BY_DEFAULT = (&h00000002)
1501Const SE_GROUP_ENABLED = (&h00000004)
1502Const SE_GROUP_OWNER = (&h00000008)
1503Const SE_GROUP_USE_FOR_DENY_ONLY = (&h00000010)
1504Const SE_GROUP_INTEGRITY = (&h00000020)
1505Const SE_GROUP_INTEGRITY_ENABLED = (&h00000040)
1506Const SE_GROUP_LOGON_ID = (&hC0000000)
1507Const SE_GROUP_RESOURCE = (&h20000000)
1508
1509Const SE_GROUP_VALID_ATTRIBUTES = (SE_GROUP_MANDATORY Or SE_GROUP_ENABLED_BY_DEFAULT Or SE_GROUP_ENABLED Or SE_GROUP_OWNER Or SE_GROUP_USE_FOR_DENY_ONLY Or SE_GROUP_LOGON_ID  Or SE_GROUP_RESOURCE Or SE_GROUP_INTEGRITY Or SE_GROUP_INTEGRITY_ENABLED)
1510
1511' ACL  and  ACE
1512Const ACL_REVISION = (2)
1513Const ACL_REVISION_DS = (4)
1514
1515Const ACL_REVISION1 = (1)
1516Const MIN_ACL_REVISION = ACL_REVISION2
1517Const ACL_REVISION2 = (2)
1518Const ACL_REVISION3 = (3)
1519Const ACL_REVISION4 = (4)
1520Const MAX_ACL_REVISION = ACL_REVISION4
1521
1522Type ACL
1523    AclRevision As Byte
1524    Sbz1 As Byte
1525    AclSize As Word
1526    AceCount As Word
1527    Sbz2 As Word
1528End Type
1529TypeDef PACL = ACL
1530
1531Type ACE_HEADER
1532    AceType As Byte
1533    AceFlags As Byte
1534    AceSize As Word
1535End Type
1536TypeDef PACE_HEADER = *ACE_HEADER
1537
1538Const ACCESS_MIN_MS_ACE_TYPE = (&h0)
1539Const ACCESS_ALLOWED_ACE_TYPE = (&h0)
1540Const ACCESS_DENIED_ACE_TYPE = (&h1)
1541Const SYSTEM_AUDIT_ACE_TYPE = (&h2)
1542Const SYSTEM_ALARM_ACE_TYPE = (&h3)
1543Const ACCESS_MAX_MS_V2_ACE_TYPE = (&h3)
1544
1545Const ACCESS_ALLOWED_COMPOUND_ACE_TYPE = (&h4)
1546Const ACCESS_MAX_MS_V3_ACE_TYPE = (&h4)
1547
1548Const ACCESS_MIN_MS_OBJECT_ACE_TYPE = (&h5)
1549Const ACCESS_ALLOWED_OBJECT_ACE_TYPE = (&h5)
1550Const ACCESS_DENIED_OBJECT_ACE_TYPE = (&h6)
1551Const SYSTEM_AUDIT_OBJECT_ACE_TYPE = (&h7)
1552Const SYSTEM_ALARM_OBJECT_ACE_TYPE = (&h8)
1553Const ACCESS_MAX_MS_OBJECT_ACE_TYPE = (&h8)
1554
1555Const ACCESS_MAX_MS_V4_ACE_TYPE = (&h8)
1556Const ACCESS_MAX_MS_ACE_TYPE = (&h8)
1557
1558Const ACCESS_ALLOWED_CALLBACK_ACE_TYPE = (&h9)
1559Const ACCESS_DENIED_CALLBACK_ACE_TYPE = (&hA)
1560Const ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE = (&hB)
1561Const ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE = (&hC)
1562Const SYSTEM_AUDIT_CALLBACK_ACE_TYPE = (&hD)
1563Const SYSTEM_ALARM_CALLBACK_ACE_TYPE = (&hE)
1564Const SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE = (&hF)
1565Const SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE = (&h10)
1566
1567Const SYSTEM_MANDATORY_LABEL_ACE_TYPE = (&h11)
1568Const ACCESS_MAX_MS_V5_ACE_TYPE = (&h11)
1569
1570Const OBJECT_INHERIT_ACE = (&h1)
1571Const CONTAINER_INHERIT_ACE = (&h2)
1572Const NO_PROPAGATE_INHERIT_ACE = (&h4)
1573Const INHERIT_ONLY_ACE = (&h8)
1574Const INHERITED_ACE = (&h10)
1575Const VALID_INHERIT_FLAGS = (&h1F)
1576
1577Const SUCCESSFUL_ACCESS_ACE_FLAG = (&h40)
1578Const FAILED_ACCESS_ACE_FLAG = (&h80)
1579
1580Type ACCESS_ALLOWED_ACE
1581    Header As ACE_HEADER
1582    Mask As ACCESS_MASK
1583    SidStart As DWord
1584End Type
1585TypeDef PACCESS_ALLOWED_ACE = *ACCESS_ALLOWED_ACE
1586
1587Type ACCESS_DENIED_ACE
1588    Header As ACE_HEADER
1589    Mask As ACCESS_MASK
1590    SidStart As DWord
1591End Type
1592TypeDef PACCESS_DENIED_ACE = *ACCESS_DENIED_ACE
1593
1594Type SYSTEM_AUDIT_ACE
1595    Header As ACE_HEADER
1596    Mask As ACCESS_MASK
1597    SidStart As DWord
1598End Type
1599TypeDef PSYSTEM_AUDIT_ACE = *SYSTEM_AUDIT_ACE
1600
1601Type SYSTEM_ALARM_ACE
1602    Header As ACE_HEADER
1603    Mask As ACCESS_MASK
1604    SidStart As DWord
1605End Type
1606TypeDef PSYSTEM_ALARM_ACE = *SYSTEM_ALARM_ACE
1607
1608Type SYSTEM_MANDATORY_LABEL_ACE
1609    Header As ACE_HEADER
1610    Mask As ACCESS_MASK
1611    SidStart As DWord
1612End Type
1613TypeDef PSYSTEM_MANDATORY_LABEL_ACE = *SYSTEM_MANDATORY_LABEL_ACE
1614
1615Const SYSTEM_MANDATORY_LABEL_NO_WRITE_UP = &h1
1616Const SYSTEM_MANDATORY_LABEL_NO_READ_UP = &h2
1617Const SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP = &h4
1618
1619Const SYSTEM_MANDATORY_LABEL_VALID_MASK = (SYSTEM_MANDATORY_LABEL_NO_WRITE_UP Or SYSTEM_MANDATORY_LABEL_NO_READ_UP Or SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP)
1620
1621Type ACCESS_ALLOWED_OBJECT_ACE
1622    Header As ACE_HEADER
1623    Mask As ACCESS_MASK
1624    Flags As DWord
1625    ObjectType As GUID
1626    InheritedObjectType As GUID
1627    SidStart As DWord
1628End Type
1629TypeDef PACCESS_ALLOWED_OBJECT_ACE = *ACCESS_ALLOWED_OBJECT_ACE
1630
1631Type ACCESS_DENIED_OBJECT_ACE
1632    Header As ACE_HEADER
1633    Mask As ACCESS_MASK
1634    Flags As DWord
1635    ObjectType As GUID
1636    InheritedObjectType As GUID
1637    SidStart As DWord
1638End Type
1639TypeDef PACCESS_DENIED_OBJECT_ACE = *ACCESS_DENIED_OBJECT_ACE
1640
1641Type SYSTEM_AUDIT_OBJECT_ACE
1642    Header As ACE_HEADER
1643    Mask As ACCESS_MASK
1644    Flags As DWord
1645    ObjectType As GUID
1646    InheritedObjectType As GUID
1647    SidStart As DWord
1648End Type
1649TypeDef PSYSTEM_AUDIT_OBJECT_ACE = *SYSTEM_AUDIT_OBJECT_ACE
1650
1651Type SYSTEM_ALARM_OBJECT_ACE
1652    Header As ACE_HEADER
1653    Mask As ACCESS_MASK
1654    Flags As DWord
1655    ObjectType As GUID
1656    InheritedObjectType As GUID
1657    SidStart As DWord
1658End Type
1659TypeDef PSYSTEM_ALARM_OBJECT_ACE = *SYSTEM_ALARM_OBJECT_ACE
1660
1661Type ACCESS_ALLOWED_CALLBACK_ACE
1662    Header As ACE_HEADER
1663    Mask As ACCESS_MASK
1664    SidStart As DWord
1665End Type
1666TypeDef PACCESS_ALLOWED_CALLBACK_ACE = *ACCESS_ALLOWED_CALLBACK_ACE
1667
1668Type ACCESS_DENIED_CALLBACK_ACE
1669    Header As ACE_HEADER
1670    Mask As ACCESS_MASK
1671    SidStart As DWord
1672End Type
1673TypeDef PACCESS_DENIED_CALLBACK_ACE = *ACCESS_DENIED_CALLBACK_ACE
1674
1675Type SYSTEM_AUDIT_CALLBACK_ACE
1676    Header As ACE_HEADER
1677    Mask As ACCESS_MASK
1678    SidStart As DWord
1679End Type
1680TypeDef PSYSTEM_AUDIT_CALLBACK_ACE = *SYSTEM_AUDIT_CALLBACK_ACE
1681
1682Type SYSTEM_ALARM_CALLBACK_ACE
1683    Header As ACE_HEADER
1684    Mask As ACCESS_MASK
1685    SidStart As DWord
1686End Type
1687TypeDef PSYSTEM_ALARM_CALLBACK_ACE = *SYSTEM_ALARM_CALLBACK_ACE
1688
1689Type ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
1690    Header As ACE_HEADER
1691    Mask As ACCESS_MASK
1692    Flags As DWord
1693    ObjectType As GUID
1694    InheritedObjectType As GUID
1695    SidStart As DWord
1696End Type
1697TypeDef PACCESS_ALLOWED_CALLBACK_OBJECT_ACE = *ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
1698
1699Type ACCESS_DENIED_CALLBACK_OBJECT_ACE
1700    Header As ACE_HEADER
1701    Mask As ACCESS_MASK
1702    Flags As DWord
1703    ObjectType As GUID
1704    InheritedObjectType As GUID
1705    SidStart As DWord
1706End Type
1707TypeDef PACCESS_DENIED_CALLBACK_OBJECT_ACE = *ACCESS_DENIED_CALLBACK_OBJECT_ACE
1708
1709Type SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
1710    Header As ACE_HEADER
1711    Mask As ACCESS_MASK
1712    Flags As DWord
1713    ObjectType As GUID
1714    InheritedObjectType As GUID
1715    SidStart As DWord
1716End Type
1717TypeDef PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE = *SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
1718
1719Type SYSTEM_ALARM_CALLBACK_OBJECT_ACE
1720    Header As ACE_HEADER
1721    Mask As ACCESS_MASK
1722    Flags As DWord
1723    ObjectType As GUID
1724    InheritedObjectType As GUID
1725    SidStart As DWord
1726End Type
1727TypeDef PSYSTEM_ALARM_CALLBACK_OBJECT_ACE = *SYSTEM_ALARM_CALLBACK_OBJECT_ACE
1728
1729Const ACE_OBJECT_TYPE_PRESENT = &h1
1730Const ACE_INHERITED_OBJECT_TYPE_PRESENT = &h2
1731
1732Enum ACL_INFORMATION_CLASS
1733    AclRevisionInformation = 1
1734    AclSizeInformation
1735End Enum
1736
1737Type ACL_REVISION_INFORMATION
1738    AclRevision As DWord
1739End Type
1740TypeDef PACL_REVISION_INFORMATION = *ACL_REVISION_INFORMATION
1741
1742Type ACL_SIZE_INFORMATION
1743AceCount As DWord
1744AclBytesInUse As DWord
1745AclBytesFree As DWord
1746End Type
1747TypeDef PACL_SIZE_INFORMATION = *ACL_SIZE_INFORMATION
1748
1749' SECURITY_DESCRIPTOR
1750Const SECURITY_DESCRIPTOR_REVISION = (1)
1751Const SECURITY_DESCRIPTOR_REVISION1 = (1)
1752
1753Const SECURITY_DESCRIPTOR_MIN_LENGTH = (SizeOf (SECURITY_DESCRIPTOR))
1754
1755TypeDef SECURITY_DESCRIPTOR_CONTROL = Word
1756TypeDef PSECURITY_DESCRIPTOR_CONTROL = *SECURITY_DESCRIPTOR_CONTROL
1757
1758Const SE_OWNER_DEFAULTED = (&h0001)
1759Const SE_GROUP_DEFAULTED = (&h0002)
1760Const SE_DACL_PRESENT = (&h0004)
1761Const SE_DACL_DEFAULTED = (&h0008)
1762Const SE_SACL_PRESENT = (&h0010)
1763Const SE_SACL_DEFAULTED = (&h0020)
1764Const SE_DACL_AUTO_INHERIT_REQ = (&h0100)
1765Const SE_SACL_AUTO_INHERIT_REQ = (&h0200)
1766Const SE_DACL_AUTO_INHERITED = (&h0400)
1767Const SE_SACL_AUTO_INHERITED = (&h0800)
1768Const SE_DACL_PROTECTED = (&h1000)
1769Const SE_SACL_PROTECTED = (&h2000)
1770Const SE_RM_CONTROL_VALID = (&h4000)
1771Const SE_SELF_RELATIVE = (&h8000)
1772
1773Type SECURITY_DESCRIPTOR_RELATIVE
1774    Revision As Byte
1775    Sbz1 As Byte
1776    Control As SECURITY_DESCRIPTOR_CONTROL
1777    Owner As DWord
1778    Group As DWord
1779    Sacl As DWord
1780    Dacl As DWord
1781End Type
1782TypeDef PSECURITY_DESCRIPTOR_RELATIVE = *SECURITY_DESCRIPTOR_RELATIVE
1783
1784Type SECURITY_DESCRIPTOR
1785    Revision As Byte
1786    Sbz1 As Byte
1787    Control As SECURITY_DESCRIPTOR_CONTROL
1788    Owner As PSID
1789    Group As PSID
1790    Sacl As PACL
1791    Dacl As PACL
1792End Type
1793TypeDef PSECURITY_DESCRIPTOR = *SECURITY_DESCRIPTOR
1794
1795Type OBJECT_TYPE_LIST
1796    Level As Word
1797    Sbz As Word
1798    ObjectType As *GUID
1799End Type
1800TypeDef POBJECT_TYPE_LIST = *OBJECT_TYPE_LIST
1801
1802Const ACCESS_OBJECT_GUID = 0
1803Const ACCESS_PROPERTY_SET_GUID = 1
1804Const ACCESS_PROPERTY_GUID = 2
1805
1806Const ACCESS_MAX_LEVEL = 4
1807
1808Const Enum AUDIT_EVENT_TYPE
1809    AuditEventObjectAccess,
1810    AuditEventDirectoryServiceAccess
1811End Enum
1812TypeDef PAUDIT_EVENT_TYPE = *AUDIT_EVENT_TYPE
1813
1814Const AUDIT_ALLOW_NO_PRIVILEGE = &h1
1815
1816'Const ACCESS_DS_SOURCE_A = "DS"
1817'Const ACCESS_DS_SOURCE_W = L"DS"
1818'Const ACCESS_DS_OBJECT_TYPE_NAME_A = "Directory Service Object"
1819'Const ACCESS_DS_OBJECT_TYPE_NAME_W = L"Directory Service Object"
1820Const ACCESS_DS_SOURCE = "DS"
1821Const ACCESS_DS_OBJECT_TYPE_NAME = "Directory Service Object"
1822
1823Const SE_PRIVILEGE_ENABLED_BY_DEFAULT = (&h00000001)
1824Const SE_PRIVILEGE_ENABLED = (&h00000002)
1825Const SE_PRIVILEGE_REMOVED = (&h00000004)
1826Const SE_PRIVILEGE_USED_FOR_ACCESS = (&h80000000)
1827
1828Const SE_PRIVILEGE_VALID_ATTRIBUTES = (SE_PRIVILEGE_ENABLED_BY_DEFAULT Or SE_PRIVILEGE_ENABLED  Or SE_PRIVILEGE_REMOVED  Or SE_PRIVILEGE_USED_FOR_ACCESS)
1829
1830Const PRIVILEGE_SET_ALL_NECESSARY = (1)
1831
1832Type PRIVILEGE_SET
1833    PrivilegeCount As DWord
1834    Control As DWord
1835    Privilege[ELM(ANYSIZE_ARRAY)] As LUID_AND_ATTRIBUTES
1836End Type
1837TypeDef PPRIVILEGE_SET = *PRIVILEGE_SET
1838
1839' NT Defined Privileges
1840Const SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
1841Const SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
1842Const SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
1843Const SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
1844Const SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
1845Const SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
1846Const SE_TCB_NAME = "SeTcbPrivilege"
1847Const SE_SECURITY_NAME = "SeSecurityPrivilege"
1848Const SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
1849Const SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
1850Const SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
1851Const SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
1852Const SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
1853Const SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
1854Const SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
1855Const SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
1856Const SE_BACKUP_NAME = "SeBackupPrivilege"
1857Const SE_RESTORE_NAME = "SeRestorePrivilege"
1858Const SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
1859Const SE_DEBUG_NAME = "SeDebugPrivilege"
1860Const SE_AUDIT_NAME = "SeAuditPrivilege"
1861Const SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
1862Const SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
1863Const SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
1864Const SE_UNDOCK_NAME = "SeUndockPrivilege"
1865Const SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege"
1866Const SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege"
1867Const SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege"
1868Const SE_IMPERSONATE_NAME = "SeImpersonatePrivilege"
1869Const SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege"
1870Const SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege"
1871Const SE_RELABEL_NAME = "SeRelabelPrivilege"
1872Const SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege"
1873Const SE_TIME_ZONE_NAME = "SeTimeZonePrivilege"
1874Const SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"
1875
1876' Security Quality Of Service
1877Const Enum SECURITY_IMPERSONATION_LEVEL
1878    SecurityAnonymous
1879    SecurityIdentification
1880    SecurityImpersonation
1881    SecurityDelegation
1882End Enum
1883TypeDef PSECURITY_IMPERSONATION_LEVEL = *SECURITY_IMPERSONATION_LEVEL
1884
1885Const SECURITY_MAX_IMPERSONATION_LEVEL = SecurityDelegation
1886Const SECURITY_MIN_IMPERSONATION_LEVEL = SecurityAnonymous
1887Const DEFAULT_IMPERSONATION_LEVEL = SecurityImpersonation
1888Const VALID_IMPERSONATION_LEVEL(L) = (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) And ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
1889
1890' Token Object Definitions
1891
1892' Token Specific Access Rights.
1893Const TOKEN_ASSIGN_PRIMARY = (&h0001)
1894Const TOKEN_DUPLICATE = (&h0002)
1895Const TOKEN_IMPERSONATE = (&h0004)
1896Const TOKEN_QUERY = (&h0008)
1897Const TOKEN_QUERY_SOURCE = (&h0010)
1898Const TOKEN_ADJUST_PRIVILEGES = (&h0020)
1899Const TOKEN_ADJUST_GROUPS = (&h0040)
1900Const TOKEN_ADJUST_DEFAULT = (&h0080)
1901Const TOKEN_ADJUST_SESSIONID = (&h0100)
1902
1903Const TOKEN_ALL_ACCESS_P = (STANDARD_RIGHTS_REQUIRED Or TOKEN_ASSIGN_PRIMARY Or TOKEN_DUPLICATE  Or TOKEN_IMPERSONATE Or TOKEN_QUERY  Or TOKEN_QUERY_SOURCE Or TOKEN_ADJUST_PRIVILEGES Or TOKEN_ADJUST_GROUPS Or TOKEN_ADJUST_DEFAULT)
1904'#if ((defined(_WIN32_WINNT) And (_WIN32_WINNT > &h0400)) Or (!defined(_WIN32_WINNT)))
1905Const TOKEN_ALL_ACCESS = (TOKEN_ALL_ACCESS_P Or TOKEN_ADJUST_SESSIONID)
1906'#else
1907'Const TOKEN_ALL_ACCESS = (TOKEN_ALL_ACCESS_P)
1908'#endif
1909Const TOKEN_READ = (STANDARD_RIGHTS_READ Or TOKEN_QUERY)
1910Const TOKEN_WRITE = (STANDARD_RIGHTS_WRITE Or TOKEN_ADJUST_PRIVILEGES Or TOKEN_ADJUST_GROUPS Or TOKEN_ADJUST_DEFAULT)
1911Const TOKEN_EXECUTE = (STANDARD_RIGHTS_EXECUTE)
1912
1913' Token Types
1914Const Enum TOKEN_TYPE
1915    TokenPrimary = 1
1916    TokenImpersonation
1917End Enum
1918TypeDef PTOKEN_TYPE = *TOKEN_TYPE
1919
1920Const Enum TOKEN_ELEVATION_TYPE
1921    TokenElevationTypeDefault = 1
1922    TokenElevationTypeFull
1923    TokenElevationTypeLimited
1924End Enum
1925TypeDef PTOKEN_ELEVATION_TYPE = TOKEN_ELEVATION_TYPE
1926
1927' Token Information Classes.
1928Const Enum TOKEN_INFORMATION_CLASS
1929    TokenUser = 1
1930    TokenGroups
1931    TokenPrivileges
1932    TokenOwner
1933    TokenPrimaryGroup
1934    TokenDefaultDacl
1935    TokenSource
1936    TokenType
1937    TokenImpersonationLevel
1938    TokenStatistics
1939    TokenRestrictedSids
1940    TokenSessionId
1941    TokenGroupsAndPrivileges
1942    TokenSessionReference
1943    TokenSandBoxInert
1944    TokenAuditPolicy
1945    TokenOrigin
1946    TokenElevationType
1947    TokenLinkedToken
1948    TokenElevation
1949    TokenHasRestrictions
1950    TokenAccessInformation
1951    TokenVirtualizationAllowed
1952    TokenVirtualizationEnabled
1953    TokenIntegrityLevel
1954    TokenUIAccess
1955    TokenMandatoryPolicy
1956    TokenLogonSid
1957    MaxTokenInfoClass
1958End Enum
1959TypeDef PTOKEN_INFORMATION_CLASS = TOKEN_INFORMATION_CLASS
1960
1961Type TOKEN_USER
1962    User As SID_AND_ATTRIBUTES
1963End Type
1964TypeDef PTOKEN_USER = *TOKEN_USER
1965
1966Type TOKEN_GROUPS
1967    GroupCount As DWord
1968    Groups[ELM(ANYSIZE_ARRAY)] As SID_AND_ATTRIBUTES
1969End Type
1970TypeDef PTOKEN_GROUPS = *TOKEN_GROUPS
1971
1972Type TOKEN_PRIVILEGES
1973    PrivilegeCount As DWord
1974    Privileges[ELM(ANYSIZE_ARRAY)] As LUID_AND_ATTRIBUTES
1975End Type
1976TypeDef PTOKEN_PRIVILEGES = *TOKEN_PRIVILEGES
1977
1978Type TOKEN_OWNER
1979    Owner As PSID
1980End Type
1981TypeDef PTOKEN_OWNER = TOKEN_OWNER
1982
1983Type TOKEN_PRIMARY_GROUP
1984    PrimaryGroup As PSID
1985End Type
1986TypeDef PTOKEN_PRIMARY_GROUP = TOKEN_PRIMARY_GROUP
1987
1988Type TOKEN_DEFAULT_DACL
1989    DefaultDacl As PACL
1990End Type
1991TypeDef PTOKEN_DEFAULT_DACL = *TOKEN_DEFAULT_DACL
1992
1993Type TOKEN_GROUPS_AND_PRIVILEGES
1994    SidCount As DWord
1995    SidLength As DWord
1996    Sids As PSID_AND_ATTRIBUTES
1997    RestrictedSidCount As DWord
1998    RestrictedSidLength As DWord
1999    RestrictedSids As PSID_AND_ATTRIBUTES
2000    PrivilegeCount As DWord
2001    PrivilegeLength As DWord
2002    Privileges As VoidPtr 'PLUID_AND_ATTRIBUTES
2003    AuthenticationId As LUID
2004End Type
2005TypeDef PTOKEN_GROUPS_AND_PRIVILEGES = *TOKEN_GROUPS_AND_PRIVILEGES
2006
2007Type TOKEN_LINKED_TOKEN
2008    LinkedToken As HANDLE
2009End Type
2010TypeDef PTOKEN_LINKED_TOKEN = *TOKEN_LINKED_TOKEN
2011
2012Type TOKEN_ELEVATION
2013    TokenIsElevated As DWord
2014End Type
2015TypeDef PTOKEN_ELEVATION = *TOKEN_ELEVATION
2016
2017Type TOKEN_MANDATORY_LABEL
2018    Label As SID_AND_ATTRIBUTES
2019End Type
2020TypeDef PTOKEN_MANDATORY_LABEL = *TOKEN_MANDATORY_LABEL
2021
2022Const TOKEN_MANDATORY_POLICY_OFF = &h0
2023Const TOKEN_MANDATORY_POLICY_NO_WRITE_UP = &h1
2024Const TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN = &h2
2025
2026Const TOKEN_MANDATORY_POLICY_VALID_MASK = (TOKEN_MANDATORY_POLICY_NO_WRITE_UP Or TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN)
2027
2028Type TOKEN_MANDATORY_POLICY
2029    Policy As DWord
2030End Type
2031TypeDef PTOKEN_MANDATORY_POLICY = *TOKEN_MANDATORY_POLICY
2032
2033Type TOKEN_ACCESS_INFORMATION
2034    SidHash As PSID_AND_ATTRIBUTES_HASH
2035    RestrictedSidHash As PSID_AND_ATTRIBUTES_HASH
2036    Privileges As PTOKEN_PRIVILEGES
2037    AuthenticationId As LUID
2038    TokenType As TOKEN_TYPE
2039    ImpersonationLevel As SECURITY_IMPERSONATION_LEVEL
2040    MandatoryPolicy As TOKEN_MANDATORY_POLICY
2041    Flags As DWord
2042End Type
2043TypeDef PTOKEN_ACCESS_INFORMATION = *TOKEN_ACCESS_INFORMATION
2044
2045Const POLICY_AUDIT_SUBCATEGORY_COUNT = (50)
2046
2047Type TOKEN_AUDIT_POLICY
2048    PerUserPolicy[ELM(((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1)] As Byte
2049End Type
2050TypeDef PTOKEN_AUDIT_POLICY = TOKEN_AUDIT_POLICY
2051
2052Const TOKEN_SOURCE_LENGTH = 8
2053
2054Type TOKEN_SOURCE
2055    SourceName[ELM(TOKEN_SOURCE_LENGTH)] As CHAR
2056    SourceIdentifier As LUID
2057End Type
2058TypeDef PTOKEN_SOURCE = *TOKEN_SOURCE
2059
2060Type TOKEN_STATISTICS
2061    TokenId As LUID
2062    AuthenticationId As LUID
2063    ExpirationTime As LARGE_INTEGER
2064    TokenType As TOKEN_TYPE
2065    ImpersonationLevel As SECURITY_IMPERSONATION_LEVEL
2066    DynamicCharged As DWord
2067    DynamicAvailable As DWord
2068    GroupCount As DWord
2069    PrivilegeCount As DWord
2070    ModifiedId As LUID
2071End Type
2072TypeDef PTOKEN_STATISTICS = *TOKEN_STATISTICS
2073
2074Type TOKEN_CONTROL
2075    TokenId As LUID
2076    AuthenticationId As LUID
2077    ModifiedId As LUID
2078    TokenSource As TOKEN_SOURCE
2079End Type
2080TypeDef PTOKEN_CONTROL = *TOKEN_CONTROL
2081
2082Type TOKEN_ORIGIN
2083    OriginatingLogonSession As LUID
2084End Type
2085TypeDef PTOKEN_ORIGIN = *TOKEN_ORIGIN
2086
2087Const Enum MANDATORY_LEVEL
2088    MandatoryLevelUntrusted = 0
2089    MandatoryLevelLow
2090    MandatoryLevelMedium
2091    MandatoryLevelHigh
2092    MandatoryLevelSystem
2093    MandatoryLevelSecureProcess
2094    MandatoryLevelCount
2095End Enum
2096TypeDef PMANDATORY_LEVEL = *MANDATORY_LEVEL
2097
2098Const SECURITY_DYNAMIC_TRACKING = (TRUE)
2099Const SECURITY_STATIC_TRACKING = (FALSE)
2100
2101TypeDef SECURITY_CONTEXT_TRACKING_MODE = BOOLEAN
2102TypeDef PSECURITY_CONTEXT_TRACKING_MODE = *BOOLEAN
2103
2104Type SECURITY_QUALITY_OF_SERVICE
2105    Length As DWord
2106    ImpersonationLevel As SECURITY_IMPERSONATION_LEVEL
2107    ContextTrackingMode As SECURITY_CONTEXT_TRACKING_MODE
2108    EffectiveOnly As BOOLEAN
2109End Type
2110TypeDef PSECURITY_QUALITY_OF_SERVICE = *SECURITY_QUALITY_OF_SERVICE
2111
2112Type SE_IMPERSONATION_STATE
2113    Token As PACCESS_TOKEN
2114    CopyOnOpen As BOOLEAN
2115    EffectiveOnly As BOOLEAN
2116    Level As SECURITY_IMPERSONATION_LEVEL
2117End Type
2118TypeDef PSE_IMPERSONATION_STATE = *SE_IMPERSONATION_STATE
2119
2120Const DISABLE_MAX_PRIVILEGE = &h1
2121Const SANDBOX_INERT = &h2
2122Const LUA_TOKEN = &h4
2123Const WRITE_RESTRICTED = &h8
2124
2125TypeDef SECURITY_INFORMATION = DWord
2126TypeDef PSECURITY_INFORMATION = *DWord
2127
2128Const OWNER_SECURITY_INFORMATION = (&h00000001)
2129Const GROUP_SECURITY_INFORMATION = (&h00000002)
2130Const DACL_SECURITY_INFORMATION = (&h00000004)
2131Const SACL_SECURITY_INFORMATION = (&h00000008)
2132Const LABEL_SECURITY_INFORMATION = (&h00000010)
2133
2134Const PROTECTED_DACL_SECURITY_INFORMATION = (&h80000000)
2135Const PROTECTED_SACL_SECURITY_INFORMATION = (&h40000000)
2136Const UNPROTECTED_DACL_SECURITY_INFORMATION = (&h20000000)
2137Const UNPROTECTED_SACL_SECURITY_INFORMATION = (&h10000000)
2138
2139Const PROCESS_TERMINATE = (&h0001)
2140Const PROCESS_CREATE_THREAD = (&h0002)
2141Const PROCESS_SET_SESSIONID = (&h0004)
2142Const PROCESS_VM_OPERATION = (&h0008)
2143Const PROCESS_VM_READ = (&h0010)
2144Const PROCESS_VM_WRITE = (&h0020)
2145Const PROCESS_DUP_HANDLE = (&h0040)
2146Const PROCESS_CREATE_PROCESS = (&h0080)
2147Const PROCESS_SET_QUOTA = (&h0100)
2148Const PROCESS_SET_INFORMATION = (&h0200)
2149Const PROCESS_QUERY_INFORMATION = (&h0400)
2150Const PROCESS_SUSPEND_RESUME = (&h0800)
2151Const PROCESS_QUERY_LIMITED_INFORMATION = (&h1000)
2152'#if (NTDDI_VERSION >= NTDDI_LONGHORN)
2153'Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &hFFFF)
2154'#else
2155Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &hFFF)
2156'#endif
2157
2158#ifdef _WIN64
2159Const MAXIMUM_PROCESSORS = 64
2160#else
2161Const MAXIMUM_PROCESSORS = 32
2162#endif
2163
2164Const THREAD_TERMINATE = (&h0001)
2165Const THREAD_SUSPEND_RESUME = (&h0002)
2166Const THREAD_GET_CONTEXT = (&h0008)
2167Const THREAD_SET_CONTEXT = (&h0010)
2168Const THREAD_QUERY_INFORMATION = (&h0040)
2169Const THREAD_SET_INFORMATION = (&h0020)
2170Const THREAD_SET_THREAD_TOKEN = (&h0080)
2171Const THREAD_IMPERSONATE = (&h0100)
2172Const THREAD_DIRECT_IMPERSONATION = (&h0200)
2173Const THREAD_SET_LIMITED_INFORMATION = (&h0400)
2174Const THREAD_QUERY_LIMITED_INFORMATION = (&h0800)
2175'#if (NTDDI_VERSION >= NTDDI_LONGHORN)
2176'Const THREAD_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &hFFFF)
2177'#else
2178Const THREAD_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h3FF)
2179'#endif
2180Const JOB_OBJECT_ASSIGN_PROCESS = (&h0001)
2181Const JOB_OBJECT_SET_ATTRIBUTES = (&h0002)
2182Const JOB_OBJECT_QUERY = (&h0004)
2183Const JOB_OBJECT_TERMINATE = (&h0008)
2184Const JOB_OBJECT_SET_SECURITY_ATTRIBUTES = (&h0010)
2185Const JOB_OBJECT_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h1F)
2186
2187Type JOB_SET_ARRAY
2188    JobHandle As HANDLE
2189    MemberLevel As DWord
2190    Flags As DWord
2191End Type
2192TypeDef PJOB_SET_ARRAY = *JOB_SET_ARRAY
2193
2194Const FLS_MAXIMUM_AVAILABLE = 128
2195Const TLS_MINIMUM_AVAILABLE = 64
2196
2197Type NT_TIB
2198    ExceptionList As VoidPtr '*EXCEPTION_REGISTRATION_RECORD
2199    StackBase As PVOID
2200    StackLimit As PVOID
2201    SubSystemTib As PVOID
2202'   Union
2203        FiberData As PVOID
2204'       Version As DWord
2205'   End Union
2206    PVOID ArbitraryUserPointer As PVOID
2207    Self As *NT_TIB
2208End Type
2209TypeDef PNT_TIB = *NT_TIB
2210
2211Type NT_TIB32
2212    ExceptionList As DWord
2213    StackBase As DWord
2214    StackLimit As DWord
2215    SubSystemTib As DWord
2216'   Union
2217        FiberData As DWord
2218'       Version As DWord
2219'   End Union
2220    ArbitraryUserPointer As DWord
2221    Self As DWord
2222End Type
2223TypeDef PNT_TIB32 = *NT_TIB32
2224
2225Type NT_TIB64
2226    ExceptionList As QWord
2227    StackBase As QWord
2228    StackLimit As QWord
2229    SubSystemTib As QWord
2230'   Union
2231        FiberData As QWord
2232'       Version As QWord
2233'   End Union
2234    ArbitraryUserPointer As QWord
2235    Self As QWord
2236End Type
2237TypeDef PNT_TIB64 = *NT_TIB64
2238
2239Const THREAD_BASE_PRIORITY_LOWRT = 15
2240Const THREAD_BASE_PRIORITY_MAX = 2
2241Const THREAD_BASE_PRIORITY_MIN = (-2)
2242Const THREAD_BASE_PRIORITY_IDLE = (-15)
2243
2244Type QUOTA_LIMITS
2245    PagedPoolLimit As SIZE_T
2246    NonPagedPoolLimit As SIZE_T
2247    MinimumWorkingSetSize As SIZE_T
2248    MaximumWorkingSetSize As SIZE_T
2249    PagefileLimit As SIZE_T
2250    TimeLimit As LARGE_INTEGER
2251End Type
2252TypeDef PQUOTA_LIMITS = *QUOTA_LIMITS
2253
2254Const QUOTA_LIMITS_HARDWS_MIN_ENABLE = &h00000001
2255Const QUOTA_LIMITS_HARDWS_MIN_DISABLE = &h00000002
2256Const QUOTA_LIMITS_HARDWS_MAX_ENABLE = &h00000004
2257Const QUOTA_LIMITS_HARDWS_MAX_DISABLE = &h00000008
2258Const QUOTA_LIMITS_USE_DEFAULT_LIMITS = &h00000010
2259
2260Const PS_RATE_PHASE_BITS = 4
2261Const PS_RATE_PHASE_MASK = ((1 As DWord << PS_RATE_PHASE_BITS) - 1)
2262
2263Const Enum PS_RATE_PHASE
2264    PsRateOneSecond = 0
2265    PsRateTwoSecond
2266    PsRateThreeSecond
2267    PsRateMaxPhase
2268End Enum
2269
2270Type RATE_QUOTA_LIMIT
2271    RateData As DWord
2272    dummy As DWord
2273'   Type
2274'       DWORD RatePhase     : PS_RATE_PHASE_BITS;
2275'       DWORD RatePercent   : 28;
2276'   End Type
2277End Type
2278TypeDef PRATE_QUOTA_LIMIT = *RATE_QUOTA_LIMIT
2279
2280'#if !defined(SORTPP_PASS) && !defined(MIDL_PASS) && !defined(RC_INVOKED) && defined(_WIN64) && !defined(_X86AMD64_)
2281'C_ASSERT (sizeof (DWORD) * 8 - PS_RATE_PHASE_BITS == 28);
2282'#endif
2283
2284Type QUOTA_LIMITS_EX
2285    PagedPoolLimit As SIZE_T
2286    NonPagedPoolLimit As SIZE_T
2287    MinimumWorkingSetSize As SIZE_T
2288    MaximumWorkingSetSize As SIZE_T
2289    PagefileLimit As SIZE_T
2290    TimeLimit As LARGE_INTEGER
2291    WorkingSetLimit As SIZE_T
2292    Reserved2 As SIZE_T
2293    Reserved3 As SIZE_T
2294    Reserved4 As SIZE_T
2295    Flags As DWord
2296    CpuRateLimit As RATE_QUOTA_LIMIT
2297End Type
2298TypeDef PQUOTA_LIMITS_EX = *QUOTA_LIMITS_EX
2299
2300Type IO_COUNTERS
2301    ReadOperationCount As QWord
2302    WriteOperationCount As QWord
2303    OtherOperationCount As QWord
2304    ReadTransferCount As QWord
2305    WriteTransferCount As QWord
2306    OtherTransferCount As QWord
2307End Type
2308TypeDef PIO_COUNTERS = IO_COUNTERS
2309
2310Type JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
2311    TotalUserTime As LARGE_INTEGER
2312    TotalKernelTime As LARGE_INTEGER
2313    ThisPeriodTotalUserTime As LARGE_INTEGER
2314    ThisPeriodTotalKernelTime As LARGE_INTEGER
2315    TotalPageFaultCount As DWord
2316    TotalProcesses As DWord
2317    ActiveProcesses As DWord
2318    TotalTerminatedProcesses As DWord
2319End Type
2320TypeDef PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION = *JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
2321
2322Type JOBOBJECT_BASIC_LIMIT_INFORMATION
2323    PerProcessUserTimeLimit As LARGE_INTEGER
2324    PerJobUserTimeLimit As LARGE_INTEGER
2325    LimitFlags As DWord
2326    MinimumWorkingSetSize As SIZE_T
2327    MaximumWorkingSetSize As SIZE_T
2328    ActiveProcessLimit As DWord
2329    Affinity As ULONG_PTR
2330    PriorityClass As DWord
2331    SchedulingClass As DWord
2332End Type
2333TypeDef PJOBOBJECT_BASIC_LIMIT_INFORMATION = *JOBOBJECT_BASIC_LIMIT_INFORMATION
2334
2335Type JOBOBJECT_EXTENDED_LIMIT_INFORMATION
2336    BasicLimitInformation As JOBOBJECT_BASIC_LIMIT_INFORMATION
2337    IoInfo As IO_COUNTERS
2338    ProcessMemoryLimit As SIZE_T
2339    JobMemoryLimitt As SIZE_T
2340    PeakProcessMemoryUsedt As SIZE_T
2341    PeakJobMemoryUsedt As SIZE_T
2342End Type
2343TypeDef PJOBOBJECT_EXTENDED_LIMIT_INFORMATION = *JOBOBJECT_EXTENDED_LIMIT_INFORMATION
2344
2345Type JOBOBJECT_BASIC_PROCESS_ID_LIST
2346    NumberOfAssignedProcesses As DWord
2347    NumberOfProcessIdsInList As DWord
2348    ProcessIdList[1] As ULONG_PTR
2349End Type
2350TypeDef PJOBOBJECT_BASIC_PROCESS_ID_LIST = *JOBOBJECT_BASIC_PROCESS_ID_LIST
2351
2352Type JOBOBJECT_BASIC_UI_RESTRICTIONS
2353    UIRestrictionsClass As DWord
2354End Type
2355TypeDef PJOBOBJECT_BASIC_UI_RESTRICTIONS = *JOBOBJECT_BASIC_UI_RESTRICTIONS
2356
2357Type JOBOBJECT_SECURITY_LIMIT_INFORMATION
2358    SecurityLimitFlags As DWord
2359    JobToken As HANDLE
2360    SidsToDisable As PTOKEN_GROUPS
2361    PrivilegesToDelete As PTOKEN_PRIVILEGES
2362    RestrictedSids As PTOKEN_GROUPS
2363End Type
2364TypeDef PJOBOBJECT_SECURITY_LIMIT_INFORMATION = *JOBOBJECT_SECURITY_LIMIT_INFORMATION
2365
2366Type JOBOBJECT_END_OF_JOB_TIME_INFORMATION
2367    EndOfJobTimeAction As DWord
2368End Type
2369TypeDef PJOBOBJECT_END_OF_JOB_TIME_INFORMATION = *JOBOBJECT_END_OF_JOB_TIME_INFORMATION
2370
2371Type JOBOBJECT_ASSOCIATE_COMPLETION_PORT
2372    CompletionKey As PVOID
2373    CompletionPort As HANDLE
2374End Type
2375TypeDef PJOBOBJECT_ASSOCIATE_COMPLETION_PORT = *JOBOBJECT_ASSOCIATE_COMPLETION_PORT
2376
2377Type JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
2378    BasicInfo As JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
2379    IoInfo As IO_COUNTERS
2380End Type
2381TypeDef PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION = *JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
2382
2383Type JOBOBJECT_JOBSET_INFORMATION
2384    MemberLevel As DWord
2385End Type
2386TypeDef PJOBOBJECT_JOBSET_INFORMATION = *JOBOBJECT_JOBSET_INFORMATION
2387
2388Const JOB_OBJECT_TERMINATE_AT_END_OF_JOB = 0
2389Const JOB_OBJECT_POST_AT_END_OF_JOB = 1
2390
2391' Completion Port Messages for job objects
2392Const JOB_OBJECT_MSG_END_OF_JOB_TIME = 1
2393Const JOB_OBJECT_MSG_END_OF_PROCESS_TIME = 2
2394Const JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT = 3
2395Const JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO = 4
2396Const JOB_OBJECT_MSG_NEW_PROCESS = 6
2397Const JOB_OBJECT_MSG_EXIT_PROCESS = 7
2398Const JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS = 8
2399Const JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT = 9
2400Const JOB_OBJECT_MSG_JOB_MEMORY_LIMIT = 10
2401
2402' Basic Limits
2403Const JOB_OBJECT_LIMIT_WORKINGSET = &h00000001
2404Const JOB_OBJECT_LIMIT_PROCESS_TIME = &h00000002
2405Const JOB_OBJECT_LIMIT_JOB_TIME = &h00000004
2406Const JOB_OBJECT_LIMIT_ACTIVE_PROCESS = &h00000008
2407Const JOB_OBJECT_LIMIT_AFFINITY = &h00000010
2408Const JOB_OBJECT_LIMIT_PRIORITY_CLASS = &h00000020
2409Const JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = &h00000040
2410Const JOB_OBJECT_LIMIT_SCHEDULING_CLASS = &h00000080
2411
2412' Extended Limits
2413Const JOB_OBJECT_LIMIT_PROCESS_MEMORY = &h00000100
2414Const JOB_OBJECT_LIMIT_JOB_MEMORY = &h00000200
2415Const JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = &h00000400
2416Const JOB_OBJECT_LIMIT_BREAKAWAY_OK = &h00000800
2417Const JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = &h00001000
2418Const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = &h00002000
2419
2420Const JOB_OBJECT_LIMIT_RESERVED2 = &h00004000
2421Const JOB_OBJECT_LIMIT_RESERVED3 = &h00008000
2422Const JOB_OBJECT_LIMIT_RESERVED4 = &h00010000
2423Const JOB_OBJECT_LIMIT_RESERVED5 = &h00020000
2424Const JOB_OBJECT_LIMIT_RESERVED6 = &h00040000
2425
2426
2427Const JOB_OBJECT_LIMIT_VALID_FLAGS = &h0007ffff
2428
2429Const JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS = &h000000ff
2430Const JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS = &h00003fff
2431Const JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS = &h0007ffff
2432
2433' UI restrictions for jobs
2434Const JOB_OBJECT_UILIMIT_NONE = &h00000000
2435
2436Const JOB_OBJECT_UILIMIT_HANDLES = &h00000001
2437Const JOB_OBJECT_UILIMIT_READCLIPBOARD = &h00000002
2438Const JOB_OBJECT_UILIMIT_WRITECLIPBOARD = &h00000004
2439Const JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = &h00000008
2440Const JOB_OBJECT_UILIMIT_DISPLAYSETTINGS = &h00000010
2441Const JOB_OBJECT_UILIMIT_GLOBALATOMS = &h00000020
2442Const JOB_OBJECT_UILIMIT_DESKTOP = &h00000040
2443Const JOB_OBJECT_UILIMIT_EXITWINDOWS = &h00000080
2444
2445Const JOB_OBJECT_UILIMIT_ALL = &h000000FF
2446
2447Const JOB_OBJECT_UI_VALID_FLAGS = &h000000FF
2448
2449Const JOB_OBJECT_SECURITY_NO_ADMIN = &h00000001
2450Const JOB_OBJECT_SECURITY_RESTRICTED_TOKEN = &h00000002
2451Const JOB_OBJECT_SECURITY_ONLY_TOKEN = &h00000004
2452Const JOB_OBJECT_SECURITY_FILTER_TOKENS = &h00000008
2453
2454Const JOB_OBJECT_SECURITY_VALID_FLAGS = &h0000000f
2455
2456Enum JOBOBJECTINFOCLASS
2457    JobObjectBasicAccountingInformation = 1
2458    JobObjectBasicLimitInformation
2459    JobObjectBasicProcessIdList
2460    JobObjectBasicUIRestrictions
2461    JobObjectSecurityLimitInformation
2462    JobObjectEndOfJobTimeInformation
2463    JobObjectAssociateCompletionPortInformation
2464    JobObjectBasicAndIoAccountingInformation
2465    JobObjectExtendedLimitInformation
2466    JobObjectJobSetInformation
2467    MaxJobObjectInfoClass
2468End Enum
2469
2470Const EVENT_MODIFY_STATE = &h0002
2471Const EVENT_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h3)
2472Const MUTANT_QUERY_STATE = &h0001
2473
2474Const MUTANT_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or MUTANT_QUERY_STATE)
2475Const SEMAPHORE_MODIFY_STATE = &h0002
2476Const SEMAPHORE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h3)
2477
2478' Timer Specific Access Rights.
2479Const TIMER_QUERY_STATE = &h0001
2480Const TIMER_MODIFY_STATE = &h0002
2481
2482Const TIMER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or TIMER_QUERY_STATE Or TIMER_MODIFY_STATE)
2483
2484Const TIME_ZONE_ID_UNKNOWN = 0
2485Const TIME_ZONE_ID_STANDARD = 1
2486Const TIME_ZONE_ID_DAYLIGHT = 2
2487
2488Enum LOGICAL_PROCESSOR_RELATIONSHIP
2489    RelationProcessorCore
2490    RelationNumaNode
2491    RelationCache
2492    RelationProcessorPackage
2493End Enum
2494
2495Const LTP_PC_SMT = 1
2496
2497Enum PROCESSOR_CACHE_TYPE
2498    CacheUnified
2499    CacheInstruction
2500    CacheData
2501    CacheTrace
2502End Enum
2503
2504Const CACHE_FULLY_ASSOCIATIVE = &hFF
2505
2506Type CACHE_DESCRIPTOR
2507    Level As Byte
2508    Associativity As Byte
2509    LineSize As Word
2510    Size As DWord
2511    Type_ As PROCESSOR_CACHE_TYPE
2512End Type
2513TypeDef PCACHE_DESCRIPTOR = *CACHE_DESCRIPTOR
2514
2515Type SYSTEM_LOGICAL_PROCESSOR_INFORMATION
2516    ProcessorMask As ULONG_PTR
2517    Relationship As LOGICAL_PROCESSOR_RELATIONSHIP
2518'   Union
2519'       struct {
2520'           Flags As Byte
2521'       } ProcessorCore;
2522'       struct {
2523'           NodeNumber As DWord
2524'       } NumaNode;
2525        Cache As CACHE_DESCRIPTOR
2526'       Reserved[ELM(2)] As ULONGLONG
2527'   End Union
2528End Type
2529TypeDef PSYSTEM_LOGICAL_PROCESSOR_INFORMATION = *SYSTEM_LOGICAL_PROCESSOR_INFORMATION
2530
2531Const PROCESSOR_INTEL_386 = 386
2532Const PROCESSOR_INTEL_486 = 486
2533Const PROCESSOR_INTEL_PENTIUM = 586
2534Const PROCESSOR_INTEL_IA64 = 2200
2535Const PROCESSOR_AMD_X8664 = 8664
2536Const PROCESSOR_MIPS_R4000 = 4000    ' incl R4101 & R3910 for Windows CE
2537Const PROCESSOR_ALPHA_21064 = 21064
2538Const PROCESSOR_PPC_601 = 601
2539Const PROCESSOR_PPC_603 = 603
2540Const PROCESSOR_PPC_604 = 604
2541Const PROCESSOR_PPC_620 = 620
2542Const PROCESSOR_HITACHI_SH3 = 10003   ' Windows CE
2543Const PROCESSOR_HITACHI_SH3E = 10004  ' Windows CE
2544Const PROCESSOR_HITACHI_SH4 = 10005   ' Windows CE
2545Const PROCESSOR_MOTOROLA_821 = 821    ' Windows CE
2546Const PROCESSOR_SHx_SH3 = 103         ' Windows CE
2547Const PROCESSOR_SHx_SH4 = 104         ' Windows CE
2548Const PROCESSOR_STRONGARM = 2577      ' Windows CE - 0xA11
2549Const PROCESSOR_ARM720 = 1824         ' Windows CE - 0x720
2550Const PROCESSOR_ARM820 = 2080         ' Windows CE - 0x820
2551Const PROCESSOR_ARM920 = 2336         ' Windows CE - 0x920
2552Const PROCESSOR_ARM_7TDMI = 70001     ' Windows CE
2553Const PROCESSOR_OPTIL = &h494f        ' MSIL
2554
2555Const PROCESSOR_ARCHITECTURE_INTEL = 0
2556Const PROCESSOR_ARCHITECTURE_MIPS = 1
2557Const PROCESSOR_ARCHITECTURE_ALPHA = 2
2558Const PROCESSOR_ARCHITECTURE_PPC = 3
2559Const PROCESSOR_ARCHITECTURE_SHX = 4
2560Const PROCESSOR_ARCHITECTURE_ARM = 5
2561Const PROCESSOR_ARCHITECTURE_IA64 = 6
2562Const PROCESSOR_ARCHITECTURE_ALPHA64 = 7
2563Const PROCESSOR_ARCHITECTURE_MSIL = 8
2564Const PROCESSOR_ARCHITECTURE_AMD64 = 9
2565Const PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10
2566
2567Const PROCESSOR_ARCHITECTURE_UNKNOWN = &hFFFF
2568
2569Const PF_FLOATING_POINT_PRECISION_ERRATA = 0
2570Const PF_FLOATING_POINT_EMULATED = 1
2571Const PF_COMPARE_EXCHANGE_DOUBLE = 2
2572Const PF_MMX_INSTRUCTIONS_AVAILABLE = 3
2573Const PF_PPC_MOVEMEM_64BIT_OK = 4
2574Const PF_ALPHA_BYTE_INSTRUCTIONS = 5
2575Const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6
2576Const PF_3DNOW_INSTRUCTIONS_AVAILABLE = 7
2577Const PF_RDTSC_INSTRUCTION_AVAILABLE = 8
2578Const PF_PAE_ENABLED = 9
2579Const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10
2580Const PF_SSE_DAZ_MODE_AVAILABLE = 11
2581Const PF_NX_ENABLED = 12
2582Const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13
2583Const PF_COMPARE_EXCHANGE128 = 14
2584Const PF_COMPARE64_EXCHANGE128 = 15
2585Const PF_CHANNELS_ENABLED = 16
2586
2587Type MEMORY_BASIC_INFORMATION
2588    BaseAddress As VoidPtr
2589    AllocationBase As VoidPtr
2590    AllocationProtect As DWord
2591    RegionSize As SIZE_T
2592    State As DWord
2593    Protect As DWord
2594    MBIType As DWord
2595End Type
2596TypeDef PMEMORY_BASIC_INFORMATION = *MEMORY_BASIC_INFORMATION
2597
2598Type MEMORY_BASIC_INFORMATION32
2599    BaseAddress As DWord
2600    AllocationBase As DWord
2601    AllocationProtect As DWord
2602    RegionSize As DWord
2603    State As DWord
2604    Protect As DWord
2605    Type_ As DWord
2606End Type
2607TypeDef PMEMORY_BASIC_INFORMATION32 = *MEMORY_BASIC_INFORMATION32
2608
2609Type Align(16) MEMORY_BASIC_INFORMATION64
2610    BaseAddress As QWord
2611    AllocationBase As QWord
2612    AllocationProtect As DWord
2613    __alignment1 As DWord
2614    RegionSize As QWord
2615    State As DWord
2616    Protect As DWord
2617    Type_ As DWord
2618    __alignment2 As DWord
2619End Type
2620TypeDef PMEMORY_BASIC_INFORMATION64 = *MEMORY_BASIC_INFORMATION64
2621
2622Const SECTION_QUERY = &h0001
2623Const SECTION_MAP_WRITE = &h0002
2624Const SECTION_MAP_READ = &h0004
2625Const SECTION_MAP_EXECUTE = &h0008
2626Const SECTION_EXTEND_SIZE = &h0010
2627Const SECTION_MAP_EXECUTE_EXPLICIT = &h0020
2628
2629Const SECTION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SECTION_QUERY Or SECTION_MAP_WRITE Or SECTION_MAP_READ Or SECTION_MAP_EXECUTE Or SECTION_EXTEND_SIZE)
2630
2631Const SESSION_QUERY_ACCESS = &h0001
2632Const SESSION_MODIFY_ACCESS = &h0002
2633
2634Const SESSION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SESSION_QUERY_ACCESS Or SESSION_MODIFY_ACCESS)
2635
2636Const PAGE_NOACCESS = &h01
2637Const PAGE_READONLY = &h02
2638Const PAGE_READWRITE = &h04
2639Const PAGE_WRITECOPY = &h08
2640Const PAGE_EXECUTE = &h10
2641Const PAGE_EXECUTE_READ = &h20
2642Const PAGE_EXECUTE_READWRITE = &h40
2643Const PAGE_EXECUTE_WRITECOPY = &h80
2644Const PAGE_GUARD = &h100
2645Const PAGE_NOCACHE = &h200
2646Const PAGE_WRITECOMBINE = &h400
2647Const MEM_COMMIT = &h1000
2648Const MEM_RESERVE = &h2000
2649Const MEM_DECOMMIT = &h4000
2650Const MEM_RELEASE = &h8000
2651Const MEM_FREE = &h10000
2652Const MEM_PRIVATE = &h20000
2653Const MEM_MAPPED = &h40000
2654Const MEM_RESET = &h80000
2655Const MEM_TOP_DOWN = &h100000
2656Const MEM_WRITE_WATCH = &h200000
2657Const MEM_PHYSICAL = &h400000
2658Const MEM_ROTATE = &h800000
2659Const MEM_LARGE_PAGES = &h20000000
2660Const MEM_4MB_PAGES = &h80000000
2661Const SEC_FILE = &h800000
2662Const SEC_IMAGE = &h1000000
2663Const SEC_PROTECTED_IMAGE = &h2000000
2664Const SEC_RESERVE = &h4000000
2665Const SEC_COMMIT = &h8000000
2666Const SEC_NOCACHE = &h10000000
2667Const SEC_WRITECOMBINE = &h40000000
2668Const SEC_LARGE_PAGES = &h80000000
2669Const MEM_IMAGE = SEC_IMAGE
2670Const WRITE_WATCH_FLAG_RESET = &h01
2671
2672' Define access rights to files and directories
2673Const FILE_READ_DATA = &h0001                 ' file & pipe
2674Const FILE_LIST_DIRECTORY = &h0001            ' directory
2675
2676Const FILE_WRITE_DATA = &h0002                ' file & pipe
2677Const FILE_ADD_FILE = &h0002                  ' directory
2678
2679Const FILE_APPEND_DATA = &h0004               ' file
2680Const FILE_ADD_SUBDIRECTORY = &h0004          ' directory
2681Const FILE_CREATE_PIPE_INSTANCE = &h0004      ' named pipe
2682
2683
2684Const FILE_READ_EA = &h0008                   ' file & directory
2685
2686Const FILE_WRITE_EA = &h0010                  ' file & directory
2687
2688Const FILE_EXECUTE = &h0020                   ' file
2689Const FILE_TRAVERSE = &h0020                  ' directory
2690
2691Const FILE_DELETE_CHILD = &h0040              ' directory
2692
2693Const FILE_READ_ATTRIBUTES = &h0080           ' all
2694
2695Const FILE_WRITE_ATTRIBUTES = &h0100          ' all
2696
2697Const FILE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h1FF)
2698Const FILE_GENERIC_READ = (STANDARD_RIGHTS_READ Or FILE_READ_DATA Or FILE_READ_ATTRIBUTES Or FILE_READ_EA Or SYNCHRONIZE)
2699Const FILE_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE Or FILE_WRITE_DATA Or FILE_WRITE_ATTRIBUTES Or FILE_WRITE_EA Or FILE_APPEND_DATA Or SYNCHRONIZE)
2700Const FILE_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE Or FILE_READ_ATTRIBUTES Or FILE_EXECUTE Or SYNCHRONIZE)
2701
2702Const FILE_SHARE_READ = &h00000001
2703Const FILE_SHARE_WRITE = &h00000002
2704Const FILE_SHARE_DELETE = &h00000004
2705Const FILE_ATTRIBUTE_READONLY = &h00000001
2706Const FILE_ATTRIBUTE_HIDDEN = &h00000002
2707Const FILE_ATTRIBUTE_SYSTEM = &h00000004
2708Const FILE_ATTRIBUTE_DIRECTORY = &h00000010
2709Const FILE_ATTRIBUTE_ARCHIVE = &h00000020
2710Const FILE_ATTRIBUTE_DEVICE = &h00000040
2711Const FILE_ATTRIBUTE_NORMAL = &h00000080
2712Const FILE_ATTRIBUTE_TEMPORARY = &h00000100
2713Const FILE_ATTRIBUTE_SPARSE_FILE = &h00000200
2714Const FILE_ATTRIBUTE_REPARSE_POINT = &h00000400
2715Const FILE_ATTRIBUTE_COMPRESSED = &h00000800
2716Const FILE_ATTRIBUTE_OFFLINE = &h00001000
2717Const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = &h00002000
2718Const FILE_ATTRIBUTE_ENCRYPTED = &h00004000
2719Const FILE_ATTRIBUTE_VIRTUAL = &h00010000
2720Const FILE_NOTIFY_CHANGE_FILE_NAME = &h00000001
2721Const FILE_NOTIFY_CHANGE_DIR_NAME = &h00000002
2722Const FILE_NOTIFY_CHANGE_ATTRIBUTES = &h00000004
2723Const FILE_NOTIFY_CHANGE_SIZE = &h00000008
2724Const FILE_NOTIFY_CHANGE_LAST_WRITE = &h00000010
2725Const FILE_NOTIFY_CHANGE_LAST_ACCESS = &h00000020
2726Const FILE_NOTIFY_CHANGE_CREATION = &h00000040
2727Const FILE_NOTIFY_CHANGE_SECURITY = &h00000100
2728Const FILE_ACTION_ADDED = &h00000001
2729Const FILE_ACTION_REMOVED = &h00000002
2730Const FILE_ACTION_MODIFIED = &h00000003
2731Const FILE_ACTION_RENAMED_OLD_NAME = &h00000004
2732Const FILE_ACTION_RENAMED_NEW_NAME = &h00000005
2733Const MAILSLOT_NO_MESSAGE = (-1 As DWord)
2734Const MAILSLOT_WAIT_FOREVER = (-1 As DWord)
2735Const FILE_CASE_SENSITIVE_SEARCH = &h00000001
2736Const FILE_CASE_PRESERVED_NAMES = &h00000002
2737Const FILE_UNICODE_ON_DISK = &h00000004
2738Const FILE_PERSISTENT_ACLS = &h00000008
2739Const FILE_FILE_COMPRESSION = &h00000010
2740Const FILE_VOLUME_QUOTAS = &h00000020
2741Const FILE_SUPPORTS_SPARSE_FILES = &h00000040
2742Const FILE_SUPPORTS_REPARSE_POINTS = &h00000080
2743Const FILE_SUPPORTS_REMOTE_STORAGE = &h00000100
2744Const FILE_VOLUME_IS_COMPRESSED = &h00008000
2745Const FILE_SUPPORTS_OBJECT_IDS = &h00010000
2746Const FILE_SUPPORTS_ENCRYPTION = &h00020000
2747Const FILE_NAMED_STREAMS = &h00040000
2748Const FILE_READ_ONLY_VOLUME = &h00080000
2749Const FILE_SEQUENTIAL_WRITE_ONCE = &h00100000
2750Const FILE_SUPPORTS_TRANSACTIONS = &h00200000
2751
2752Type FILE_NOTIFY_INFORMATION
2753    NextEntryOffset As DWord
2754    Action As DWord
2755    FileNameLength As DWord
2756    FileName[ELM(1)] As WCHAR
2757End Type
2758TypeDef PFILE_NOTIFY_INFORMATION = *FILE_NOTIFY_INFORMATION
2759
2760Type /*Union*/ FILE_SEGMENT_ELEMENT
2761    Buffer As PVOID64
2762'   Alignment As QWord
2763End Type 'Union
2764TypeDef PFILE_SEGMENT_ELEMENT = *FILE_SEGMENT_ELEMENT
2765
2766Type REPARSE_GUID_DATA_BUFFER
2767    ReparseTag As DWord
2768    ReparseDataLength As Word
2769    Reserved As Word
2770    ReparseGuid As GUID
2771'   struct {
2772        DataBuffer[ELM(1)] As Byte
2773'   } GenericReparseBuffer;
2774End Type
2775TypeDef PREPARSE_GUID_DATA_BUFFER = *REPARSE_GUID_DATA_BUFFER
2776
2777'Const REPARSE_GUID_DATA_BUFFER_HEADER_SIZE = FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
2778
2779' Maximum allowed size of the reparse data.
2780Const MAXIMUM_REPARSE_DATA_BUFFER_SIZE = (16 * 1024)
2781
2782' Predefined reparse tags.
2783Const IO_REPARSE_TAG_RESERVED_ZERO = 0
2784Const IO_REPARSE_TAG_RESERVED_ONE = 1
2785
2786Const IO_REPARSE_TAG_RESERVED_RANGE = IO_REPARSE_TAG_RESERVED_ONE
2787
2788
2789Const IsReparseTagMicrosoft(_tag) = ((_tag) And &h80000000)
2790Const IsReparseTagNameSurrogate(_tag) = ((_tag) And &h0000000)
2791
2792Const IO_REPARSE_TAG_MOUNT_POINT = &hA0000003
2793Const IO_REPARSE_TAG_HSM = &hC0000004
2794Const IO_REPARSE_TAG_SIS = &h80000007
2795Const IO_REPARSE_TAG_DFS = &h8000000A
2796Const IO_REPARSE_TAG_SYMLINK = &hA000000C
2797Const IO_REPARSE_TAG_DFSR = &h80000012
2798
2799Const IO_COMPLETION_MODIFY_STATE = &h0002
2800Const IO_COMPLETION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &h3)
2801
2802Const DUPLICATE_CLOSE_SOURCE = &h00000001
2803Const DUPLICATE_SAME_ACCESS = &h00000002
2804/*
2805' Define GUIDs which represent well-known power schemes
2806
2807DEFINE_GUID( GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A );
2808DEFINE_GUID( GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C );
2809DEFINE_GUID( GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E );
2810DEFINE_GUID( NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 );
2811DEFINE_GUID( ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 );
2812DEFINE_GUID( GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 );
2813DEFINE_GUID( GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 );
2814
2815' Define GUIDs which represent well-known power settings
2816
2817' Video settings
2818
2819DEFINE_GUID( GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 );
2820DEFINE_GUID( GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E );
2821DEFINE_GUID( GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B );
2822DEFINE_GUID( GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA );
2823
2824' Harddisk settings
2825DEFINE_GUID( GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 );
2826DEFINE_GUID( GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E );
2827DEFINE_GUID( GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 );
2828
2829' System sleep settings
2830DEFINE_GUID( GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 );
2831DEFINE_GUID( GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 );
2832DEFINE_GUID( GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA );
2833DEFINE_GUID( GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 );
2834DEFINE_GUID( GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E );
2835DEFINE_GUID( GUID_CRITICAL_POWER_TRANSITION,  0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
2836DEFINE_GUID( GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 );
2837DEFINE_GUID( GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 );
2838DEFINE_GUID( GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab );
2839DEFINE_GUID( GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D );
2840
2841' System button actions
2842DEFINE_GUID( GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 );
2843DEFINE_GUID( GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 );
2844DEFINE_GUID( GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 );
2845DEFINE_GUID( GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB );
2846DEFINE_GUID( GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 );
2847DEFINE_GUID( GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 );
2848DEFINE_GUID( GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 );
2849DEFINE_GUID( GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B );
2850DEFINE_GUID( GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 );
2851
2852' Battery Discharge Settings
2853DEFINE_GUID( GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F );
2854' 4 battery discharge alarm settings.
2855DEFINE_GUID( GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 );
2856DEFINE_GUID( GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 );
2857DEFINE_GUID( GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f );
2858
2859DEFINE_GUID( GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 );
2860DEFINE_GUID( GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A );
2861DEFINE_GUID( GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 );
2862
2863DEFINE_GUID( GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 );
2864DEFINE_GUID( GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA );
2865DEFINE_GUID( GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 );
2866
2867DEFINE_GUID( GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 );
2868DEFINE_GUID( GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 );
2869DEFINE_GUID( GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 );
2870
2871' Processor power settings
2872DEFINE_GUID( GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 );
2873DEFINE_GUID( GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 );
2874DEFINE_GUID( GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC );
2875DEFINE_GUID( GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C );
2876DEFINE_GUID( GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
2877DEFINE_GUID( GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
2878DEFINE_GUID( GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
2879
2880' Lock Console on Wake
2881DEFINE_GUID( GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 );
2882
2883' AC/DC power source
2884DEFINE_GUID( GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 );
2885
2886' Lid state changes
2887DEFINE_GUID( GUID_LIDSWITCH_STATE_CHANGE,  0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 );
2888
2889' Battery life remaining
2890DEFINE_GUID( GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 );
2891DEFINE_GUID( GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 );
2892DEFINE_GUID( GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E );
2893DEFINE_GUID( GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA );
2894DEFINE_GUID( GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 );
2895DEFINE_GUID( GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 );
2896*/
2897Enum SYSTEM_POWER_STATE
2898    PowerSystemUnspecified = 0
2899    PowerSystemWorking = 1
2900    PowerSystemSleeping1 = 2
2901    PowerSystemSleeping2 = 3
2902    PowerSystemSleeping3 = 4
2903    PowerSystemHibernate = 5
2904    PowerSystemShutdown = 6
2905    PowerSystemMaximum = 7
2906End Enum
2907TypeDef PSYSTEM_POWER_STATE = *SYSTEM_POWER_STATE
2908
2909Const POWER_SYSTEM_MAXIMUM = 7
2910
2911Enum POWER_ACTION
2912    PowerActionNone = 0
2913    PowerActionReserved
2914    PowerActionSleep
2915    PowerActionHibernate
2916    PowerActionShutdown
2917    PowerActionShutdownReset
2918    PowerActionShutdownOff
2919    PowerActionWarmEject
2920End Enum
2921TypeDef PPOWER_ACTION = *POWER_ACTION
2922
2923Enum DEVICE_POWER_STATE
2924    PowerDeviceUnspecified = 0
2925    PowerDeviceD0
2926    PowerDeviceD1
2927    PowerDeviceD2
2928    PowerDeviceD3
2929    PowerDeviceMaximum
2930End Enum
2931TypeDef PDEVICE_POWER_STATE = *DEVICE_POWER_STATE
2932
2933Const ES_SYSTEM_REQUIRED = (&h00000001 As DWord)
2934Const ES_DISPLAY_REQUIRED = (&h00000002 As DWord)
2935Const ES_USER_PRESENT = (&h00000004 As DWord)
2936Const ES_AWAYMODE_REQUIRED = (&h00000040 As DWord)
2937Const ES_CONTINUOUS = (&h80000000 As DWord)
2938
2939TypeDef EXECUTION_STATE = DWord
2940
2941Enum LATENCY_TIME
2942    LT_DONT_CARE
2943    LT_LOWEST_LATENCY
2944End Enum
2945
2946'#if (NTDDI_VERSION >= NTDDI_WINXP)
2947
2948' Device Power Information
2949Const PDCAP_D0_SUPPORTED = &h00000001
2950Const PDCAP_D1_SUPPORTED = &h00000002
2951Const PDCAP_D2_SUPPORTED = &h00000004
2952Const PDCAP_D3_SUPPORTED = &h00000008
2953Const PDCAP_WAKE_FROM_D0_SUPPORTED = &h00000010
2954Const PDCAP_WAKE_FROM_D1_SUPPORTED = &h00000020
2955Const PDCAP_WAKE_FROM_D2_SUPPORTED = &h00000040
2956Const PDCAP_WAKE_FROM_D3_SUPPORTED = &h00000080
2957Const PDCAP_WARM_EJECT_SUPPORTED = &h00000100
2958
2959Type CM_POWER_DATA
2960    PD_Size As DWord
2961    PD_MostRecentPowerState As DEVICE_POWER_STATE
2962    PD_Capabilities As DWord
2963    PD_D1Latency As DWord
2964    PD_D2Latency As DWord
2965    PD_D3Latency As DWord
2966    PD_PowerStateMapping[POWER_SYSTEM_MAXIMUM] As DEVICE_POWER_STATE
2967    PD_DeepestSystemWake As SYSTEM_POWER_STATE
2968End Type
2969TypeDef PCM_POWER_DATA = *CM_POWER_DATA
2970
2971'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
2972
2973Enum POWER_INFORMATION_LEVEL
2974    SystemPowerPolicyAc
2975    SystemPowerPolicyDc
2976    VerifySystemPolicyAc
2977    VerifySystemPolicyDc
2978    SystemPowerCapabilities
2979    SystemBatteryState
2980    SystemPowerStateHandler
2981    ProcessorStateHandler
2982    SystemPowerPolicyCurrent
2983    AdministratorPowerPolicy
2984    SystemReserveHiberFile
2985    ProcessorInformation
2986    SystemPowerInformation
2987    ProcessorStateHandler2
2988    LastWakeTime                        ' Compare with KeQueryInterruptTime()
2989    LastSleepTime                       ' Compare with KeQueryInterruptTime()
2990    SystemExecutionState
2991    SystemPowerStateNotifyHandler
2992    ProcessorPowerPolicyAc
2993    ProcessorPowerPolicyDc
2994    VerifyProcessorPowerPolicyAc
2995    VerifyProcessorPowerPolicyDc
2996    ProcessorPowerPolicyCurrent
2997    SystemPowerStateLogging
2998    SystemPowerLoggingEntry
2999    SetPowerSettingValue
3000    NotifyUserPowerSetting
3001    GetPowerTransitionVetoes
3002    SetPowerTransitionVeto
3003    SystemVideoState
3004    TraceApplicationPowerMessage
3005    TraceApplicationPowerMessageEnd
3006    ProcessorPerfStates
3007    ProcessorIdleStates
3008    ProcessorThrottleStates
3009    SystemWakeSource
3010    SystemHiberFileInformation
3011    TraceServicePowerMessage
3012    ProcessorLoad
3013    PowerShutdownNotification
3014End Enum
3015
3016' Power Transition Vetos
3017Const PO_TRANSITION_VETO_TYPE_WINDOW = &h00000001
3018Const PO_TRANSITION_VETO_TYPE_SERVICE = &h00000002
3019'Const PO_TRANSITION_VETO_TYPE_DRIVER = &h00000004
3020
3021Const PO_TRANSITION_VETO_TYPE_ALL = (PO_TRANSITION_VETO_TYPE_WINDOW Or PO_TRANSITION_VETO_TYPE_SERVICE)
3022
3023Type PO_TRANSITION_VETO_REASON
3024    ResourceId As DWord
3025    ModuleNameOffset As DWord
3026End Type
3027TypeDef PPO_TRANSITION_VETO_REASON = *PO_TRANSITION_VETO_REASON
3028
3029Type PO_TRANSITION_VETO_WINDOW
3030    Handle As HANDLE
3031End Type
3032TypeDef PPO_TRANSITION_VETO_WINDOW = *PO_TRANSITION_VETO_WINDOW
3033
3034Type PO_TRANSITION_VETO_SERVICE
3035    ServiceNameOffset As DWord
3036End Type
3037TypeDef PPO_TRANSITION_VETO_SERVICE = *PO_TRANSITION_VETO_SERVICE
3038
3039/*
3040Type PO_TRANSITION_VETO_DRIVER
3041    InstancePathOffset As DWord
3042    DriverNameOffset As DWord
3043End Type
3044TypeDef PPO_TRANSITION_VETO_DRIVER = *PO_TRANSITION_VETO_DRIVER
3045*/
3046
3047Type PO_TRANSITION_VETO
3048    Type_ As DWord
3049    Reason As PO_TRANSITION_VETO_REASON
3050    ProcessId As DWord
3051'   Union
3052        Window_ As PO_TRANSITION_VETO_WINDOW
3053'       Service As PO_TRANSITION_VETO_SERVICE
3054'       ' Driver As PO_TRANSITION_VETO_DRIVER
3055'   End Union
3056End Type
3057TypeDef PPO_TRANSITION_VETO = *PO_TRANSITION_VETO
3058
3059Type PO_TRANSITION_VETOES
3060    Count As DWord
3061    Vetoes[ELM(ANYSIZE_ARRAY)] As PO_TRANSITION_VETO
3062End Type
3063TypeDef PPO_TRANSITION_VETOES = *PO_TRANSITION_VETOES
3064
3065Enum SYSTEM_POWER_CONDITION
3066    PoAc
3067    PoDc
3068    PoHot
3069    PoConditionMaximum
3070End Enum
3071
3072Type SET_POWER_SETTING_VALUE
3073    Version As DWord
3074    Guid As GUID
3075    PowerCondition As SYSTEM_POWER_CONDITION
3076    DataLength As DWord
3077    Data[ELM(ANYSIZE_ARRAY)] As Byte
3078End Type
3079TypeDef PSET_POWER_SETTING_VALUE = *SET_POWER_SETTING_VALUE
3080
3081Const POWER_SETTING_VALUE_VERSION = &h1
3082
3083Type NOTIFY_USER_POWER_SETTING
3084    Guid As GUID
3085End Type
3086TypeDef PNOTIFY_USER_POWER_SETTING = *NOTIFY_USER_POWER_SETTING
3087
3088Type APPLICATIONLAUNCH_SETTING_VALUE
3089    ActivationTime As LARGE_INTEGER
3090    Flags As DWord
3091    ButtonInstanceID As DWord
3092End Type
3093TypeDef PAPPLICATIONLAUNCH_SETTING_VALUE = *APPLICATIONLAUNCH_SETTING_VALUE
3094
3095Enum POWER_PLATFORM_ROLE
3096    PlatformRoleUnspecified = 0
3097    PlatformRoleDesktop
3098    PlatformRoleMobile
3099    PlatformRoleWorkstation
3100    PlatformRoleEnterpriseServer
3101    PlatformRoleSOHOServer
3102    PlatformRoleAppliancePC
3103    PlatformRolePerformanceServer
3104    PlatformRoleMaximum
3105End Enum
3106
3107Enum PO_WAKE_SOURCE_TYPE
3108    DeviceWakeSourceType
3109    FixedWakeSourceType
3110End Enum
3111TypeDef PPO_WAKE_SOURCE_TYPE = *PO_WAKE_SOURCE_TYPE
3112
3113Enum PO_FIXED_WAKE_SOURCE_TYPE
3114    FixedWakeSourcePowerButton
3115    FixedWakeSourceSleepButton
3116    FixedWakeSourceRtc
3117End Enum
3118TypeDef PPO_FIXED_WAKE_SOURCE_TYPE = *PO_FIXED_WAKE_SOURCE_TYPE
3119
3120Type PO_WAKE_SOURCE_HEADER
3121    Type_ As PO_WAKE_SOURCE_TYPE
3122    Size As DWord
3123End Type
3124TypeDef PPO_WAKE_SOURCE_HEADER = *PO_WAKE_SOURCE_HEADER
3125
3126Type PO_WAKE_SOURCE_DEVICE
3127    Header As PO_WAKE_SOURCE_HEADER
3128    InstancePath[ELM(ANYSIZE_ARRAY)] As WCHAR
3129End Type
3130TypeDef PPO_WAKE_SOURCE_DEVICE = *PO_WAKE_SOURCE_DEVICE
3131
3132Type PO_WAKE_SOURCE_FIXED
3133    Header As PO_WAKE_SOURCE_HEADER
3134    FixedWakeSourceType As PO_FIXED_WAKE_SOURCE_TYPE
3135End Type
3136TypeDef PPO_WAKE_SOURCE_FIXED = *PO_WAKE_SOURCE_FIXED
3137
3138Type PO_WAKE_SOURCE_INFO
3139    Count As DWord
3140    Offsets[ELM(ANYSIZE_ARRAY)] As DWord
3141End Type
3142TypeDef PPO_WAKE_SOURCE_INFO = *PO_WAKE_SOURCE_INFO
3143
3144Type PO_WAKE_SOURCE_HISTORY
3145    Count As DWord
3146    Offsets[ELM(ANYSIZE_ARRAY)] As DWord
3147End Type
3148TypeDef PPO_WAKE_SOURCE_HISTORY = *PO_WAKE_SOURCE_HISTORY
3149
3150'#if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
3151Type BATTERY_REPORTING_SCALE
3152    Granularity As DWord
3153    Capacity As DWord
3154End Type
3155TypeDef PBATTERY_REPORTING_SCALE = *BATTERY_REPORTING_SCALE
3156'#endif
3157
3158Type PPM_SIMULATED_PROCESSOR_LOAD
3159    Enabled As BOOLEAN
3160    PercentBusy[ELM(MAXIMUM_PROCESSORS)] As Byte
3161End Type
3162TypeDef PPPM_SIMULATED_PROCESSOR_LOAD = *PPM_SIMULATED_PROCESSOR_LOAD
3163
3164Type PPM_WMI_LEGACY_PERFSTATE
3165    Frequency As DWord
3166    Flags As DWord
3167    PercentFrequency As DWord
3168End Type
3169TypeDef PPPM_WMI_LEGACY_PERFSTATE = *PPM_WMI_LEGACY_PERFSTATE
3170
3171Type PPM_WMI_IDLE_STATE
3172    Latency As DWord
3173    Power As DWord
3174    TimeCheck As DWord
3175    PromotePercent As Byte
3176    DemotePercent As Byte
3177    StateType As Byte
3178    Reserved As Byte
3179    StateFlags As DWord
3180    Context As DWord
3181    IdleHandler As DWord
3182    Reserved1 As DWord
3183End Type
3184TypeDef PPPM_WMI_IDLE_STATE = *PPM_WMI_IDLE_STATE
3185
3186Type PPM_WMI_IDLE_STATES
3187    Type_ As DWord
3188    Count As DWord
3189    TargetState As DWord
3190    OldState As DWord
3191    TargetProcessors As QWord
3192    State[ELM(ANYSIZE_ARRAY)] As PPM_WMI_IDLE_STATE
3193End Type
3194TypeDef PPPM_WMI_IDLE_STATES = *PPM_WMI_IDLE_STATES
3195
3196Type PPM_WMI_PERF_STATE
3197    Frequency As DWord
3198    Power As DWord
3199    PercentFrequency As Byte
3200    IncreaseLevel As Byte
3201    DecreaseLevel As Byte
3202    Type_  As Byte
3203    IncreaseTime As DWord
3204    DecreaseTime As DWord
3205    Control As QWord
3206    Status As QWord
3207    HitCount As DWord
3208    Reserved1 As DWord
3209    Reserved2 As QWord
3210    Reserved3 As QWord
3211End Type
3212TypeDef PPPM_WMI_PERF_STATE = *PPM_WMI_PERF_STATE
3213
3214Type PPM_WMI_PERF_STATES
3215    Count As DWord
3216    MaxFrequency As DWord
3217    CurrentState As DWord
3218    MaxPerfState As DWord
3219    MinPerfState As DWord
3220    LowestPerfState As DWord
3221    ThermalConstraint As DWord
3222    BusyAdjThreshold As Byte
3223    PolicyType As Byte
3224    Type_ As Byte
3225    Reserved As Byte
3226    TimerInterval As DWord
3227    TargetProcessors As QWord
3228    PStateHandler As DWord
3229    PStateContext As DWord
3230    TStateHandler As DWord
3231    TStateContext As DWord
3232    FeedbackHandler As DWord
3233    Reserved1 As DWord
3234    Reserved2 As QWord
3235    State[ELM(ANYSIZE_ARRAY)] As PPM_WMI_PERF_STATE
3236End Type
3237TypeDef PPPM_WMI_PERF_STATES = *PPM_WMI_PERF_STATES
3238
3239Const PROC_IDLE_BUCKET_COUNT = 6
3240
3241Type PPM_IDLE_STATE_ACCOUNTING
3242    IdleTransitions As DWord
3243    FailedTransitions As DWord
3244    InvalidBucketIndex As DWord
3245    TotalTime As QWord
3246    IdleTimeBuckets[ELM(PROC_IDLE_BUCKET_COUNT)] As DWord
3247End Type
3248TypeDef PPPM_IDLE_STATE_ACCOUNTING = *PPM_IDLE_STATE_ACCOUNTING
3249
3250Type PPM_IDLE_ACCOUNTING
3251    StateCount As DWord
3252    TotalTransitions As DWord
3253    ResetCount As DWord
3254    StartTime As QWord
3255    State[ELM(ANYSIZE_ARRAY)] As PPM_IDLE_STATE_ACCOUNTING
3256End Type
3257TypeDef PPPM_IDLE_ACCOUNTING = *PPM_IDLE_ACCOUNTING
3258
3259Const ACPI_PPM_SOFTWARE_ALL = &hFC
3260Const ACPI_PPM_SOFTWARE_ANY = &hFD
3261Const ACPI_PPM_HARDWARE_ALL = &hFE
3262
3263Const MS_PPM_SOFTWARE_ALL = &h1
3264
3265' Processor Power Management WMI interface.
3266/*
3267// {A5B32DDD-7F39-4abc-B892-900E43B59EBB}
3268DEFINE_GUID(PPM_PERFSTATE_CHANGE_GUID,
32690xa5b32ddd, 0x7f39, 0x4abc, 0xb8, 0x92, 0x90, 0xe, 0x43, 0xb5, 0x9e, 0xbb);
3270
3271// {995e6b7f-d653-497a-b978-36a30c29bf01}
3272DEFINE_GUID(PPM_PERFSTATE_DOMAIN_CHANGE_GUID,
32730x995e6b7f, 0xd653, 0x497a, 0xb9, 0x78, 0x36, 0xa3, 0xc, 0x29, 0xbf, 0x1);
3274
3275// {4838fe4f-f71c-4e51-9ecc-8430a7ac4c6c}
3276DEFINE_GUID(PPM_IDLESTATE_CHANGE_GUID,
32770x4838fe4f, 0xf71c, 0x4e51, 0x9e, 0xcc, 0x84, 0x30, 0xa7, 0xac, 0x4c, 0x6c);
3278
3279// {5708cc20-7d40-4bf4-b4aa-2b01338d0126}
3280DEFINE_GUID(PPM_PERFSTATES_DATA_GUID,
32810x5708cc20, 0x7d40, 0x4bf4, 0xb4, 0xaa, 0x2b, 0x01, 0x33, 0x8d, 0x01, 0x26);
3282
3283// {ba138e10-e250-4ad7-8616-cf1a7ad410e7}
3284DEFINE_GUID(PPM_IDLESTATES_DATA_GUID,
32850xba138e10, 0xe250, 0x4ad7, 0x86, 0x16, 0xcf, 0x1a, 0x7a, 0xd4, 0x10, 0xe7);
3286
3287// {e2a26f78-ae07-4ee0-a30f-ce354f5a94cd}
3288DEFINE_GUID(PPM_IDLE_ACCOUNTING_GUID,
32890xe2a26f78, 0xae07, 0x4ee0, 0xa3, 0x0f, 0xce, 0x54, 0xf5, 0x5a, 0x94, 0xcd);
3290
3291// {a852c2c8-1a4c-423b-8c2c-f30d82931a88}
3292DEFINE_GUID(PPM_THERMALCONSTRAINT_GUID,
32930xa852c2c8, 0x1a4c, 0x423b, 0x8c, 0x2c, 0xf3, 0x0d, 0x82, 0x93, 0x1a, 0x88);
3294
3295// {7fd18652-0cfe-40d2-b0a1-0b066a87759e}
3296DEFINE_GUID(PPM_PERFMON_PERFSTATE_GUID,
32970x7fd18652, 0xcfe, 0x40d2, 0xb0, 0xa1, 0xb, 0x6, 0x6a, 0x87, 0x75, 0x9e);
3298
3299// {48f377b8-6880-4c7b-8bdc-380176c6654d}
3300DEFINE_GUID(PPM_THERMAL_POLICY_CHANGE_GUID,
33010x48f377b8, 0x6880, 0x4c7b, 0x8b, 0xdc, 0x38, 0x1, 0x76, 0xc6, 0x65, 0x4d);
3302*/
3303Type PPM_PERFSTATE_EVENT
3304    State As DWord
3305    Status As DWord
3306    Latency As DWord
3307    Speed As DWord
3308    Processor As DWord
3309End Type
3310TypeDef PPPM_PERFSTATE_EVENT = *PPM_PERFSTATE_EVENT
3311
3312Type PPM_PERFSTATE_DOMAIN_EVENT
3313    State As DWord
3314    Latency As DWord
3315    Speed As DWord
3316    Processors As QWord
3317End Type
3318TypeDef PPPM_PERFSTATE_DOMAIN_EVENT = *PPM_PERFSTATE_DOMAIN_EVENT
3319
3320Type PPM_IDLESTATE_EVENT
3321    NewState As DWord
3322    OldState As DWord
3323    Processors As QWord
3324End Type
3325TypeDef PPPM_IDLESTATE_EVENT = *PPM_IDLESTATE_EVENT
3326
3327Type PPM_THERMALCHANGE_EVENT
3328    ThermalConstraint As DWord
3329    Processors As QWord
3330End Type
3331TypeDef PPPM_THERMALCHANGE_EVENT = *PPM_THERMALCHANGE_EVENT
3332
3333Type PPM_THERMAL_POLICY_EVENT
3334    Mode As Byte
3335    Processors As QWord
3336End Type
3337TypeDef PPPM_THERMAL_POLICY_EVENT = *PPM_THERMAL_POLICY_EVENT
3338
3339Type POWER_ACTION_POLICY
3340    Action As POWER_ACTION
3341    Flags As DWord
3342    EventCode As DWord
3343End Type
3344TypeDef PPOWER_ACTION_POLICY = *POWER_ACTION_POLICY
3345
3346' POWER_ACTION_POLICY->Flags:
3347Const POWER_ACTION_QUERY_ALLOWED = &h00000001
3348Const POWER_ACTION_UI_ALLOWED = &h00000002
3349Const POWER_ACTION_OVERRIDE_APPS = &h00000004
3350Const POWER_ACTION_LIGHTEST_FIRST = &h10000000
3351Const POWER_ACTION_LOCK_CONSOLE = &h20000000
3352Const POWER_ACTION_DISABLE_WAKES = &h40000000
3353Const POWER_ACTION_CRITICAL = &h80000000
3354
3355' POWER_ACTION_POLICY->EventCode flags
3356Const POWER_LEVEL_USER_NOTIFY_TEXT = &h00000001
3357Const POWER_LEVEL_USER_NOTIFY_SOUND = &h00000002
3358Const POWER_LEVEL_USER_NOTIFY_EXEC = &h00000004
3359Const POWER_USER_NOTIFY_BUTTON = &h00000008
3360Const POWER_USER_NOTIFY_SHUTDOWN = &h00000010
3361Const POWER_FORCE_TRIGGER_RESET = &h80000000
3362
3363Const BATTERY_DISCHARGE_FLAGS_EVENTCODE_MASK = &h00000007
3364Const BATTERY_DISCHARGE_FLAGS_ENABLE = &h80000000
3365
3366Type SYSTEM_POWER_LEVEL
3367    Enable As BOOLEAN
3368    Spare[ELM(3)] As Byte
3369    BatteryLevel As DWord
3370    PowerPolicy As POWER_ACTION_POLICY
3371    MinSystemState As POWER_ACTION_POLICY
3372End Type
3373TypeDef PSYSTEM_POWER_LEVEL = *SYSTEM_POWER_LEVEL
3374
3375Const NUM_DISCHARGE_POLICIES = 4
3376Const DISCHARGE_POLICY_CRITICAL= 0
3377Const DISCHARGE_POLICY_LOW = 1
3378
3379Type SYSTEM_POWER_POLICY
3380    Revision As DWord
3381
3382    PowerButton As POWER_ACTION_POLICY
3383    SleepButton As POWER_ACTION_POLICY
3384    LidClose As POWER_ACTION_POLICY
3385    LidOpenWake As SYSTEM_POWER_STATE
3386    Reserved As DWord
3387
3388    Idle As POWER_ACTION_POLICY
3389    IdleTimeout As DWord
3390    IdleSensitivity As Byte
3391
3392    DynamicThrottle As Byte
3393    Spare2[ELM(2)] As Byte
3394
3395    MinSleep As SYSTEM_POWER_STATE
3396    MaxSleep As SYSTEM_POWER_STATE
3397    ReducedLatencySleep As SYSTEM_POWER_STATE
3398    WinLogonFlags As DWord
3399
3400    Spare3 As DWord
3401
3402    DozeS4Timeout As DWord
3403
3404    BroadcastCapacityResolution; As DWord
3405    DischargePolicy[ELM(NUM_DISCHARGE_POLICIES)] As SYSTEM_POWER_LEVEL
3406
3407    VideoTimeout As DWord
3408    VideoDimDisplay As BOOLEAN
3409    VideoReserved[ELM(3)] As DWord
3410
3411    SpindownTimeout As DWord
3412
3413    OptimizeForPower As BOOLEAN
3414    FanThrottleTolerance As Byte
3415    ForcedThrottle As Byte
3416    MinThrottle As Byte
3417    OverThrottled As POWER_ACTION_POLICY
3418End Type
3419TypeDef PSYSTEM_POWER_POLICY = *SYSTEM_POWER_POLICY
3420
3421' processor power policy state
3422
3423Const PROCESSOR_IDLESTATE_POLICY_COUNT = &h3
3424
3425Type PROCESSOR_IDLESTATE_INFO
3426    TimeCheck As DWord
3427    DemotePercent As Byte
3428    PromotePercent As Byte
3429    Spare[ELM(2)] As Byte
3430End Type
3431TypeDef PPROCESSOR_IDLESTATE_INFO = *PROCESSOR_IDLESTATE_INFO
3432
3433Type PROCESSOR_IDLESTATE_POLICY
3434    Revision As Word
3435    FlagsAsWRORD As Word
3436'   Union
3437'       AsWORD As Word
3438'       struct {
3439'           WORD   AllowScaling : 1;
3440'           WORD   Disabled : 1;
3441'           WORD   Reserved : 14;
3442'       };
3443'   } Flags;
3444
3445    PolicyCount As DWord
3446    Policy[ELM(PROCESSOR_IDLESTATE_POLICY_COUNT)] As PROCESSOR_IDLESTATE_INFO
3447End Type
3448TypeDef PPROCESSOR_IDLESTATE_POLICY = *PROCESSOR_IDLESTATE_POLICY
3449
3450Const PO_THROTTLE_NONE = 0
3451Const PO_THROTTLE_CONSTANT = 1
3452Const PO_THROTTLE_DEGRADE = 2
3453Const PO_THROTTLE_ADAPTIVE = 3
3454Const PO_THROTTLE_MAXIMUM = 4
3455
3456Type PROCESSOR_POWER_POLICY_INFO
3457    TimeCheck As DWord
3458    DemoteLimit As DWord
3459    PromoteLimit As DWord
3460
3461    DemotePercent As Byte
3462    PromotePercent As Byte
3463    Spare[ELM(2)] As Byte
3464    Allow As DWord
3465'   AllowDemotion:1 As DWord
3466'   AllowPromotion:1 As DWord
3467'   Reserved:30 As DWord
3468End Type
3469TypeDef PPROCESSOR_POWER_POLICY_INFO = *PROCESSOR_POWER_POLICY_INFO
3470
3471Type PROCESSOR_POWER_POLICY
3472    Revision As DWord
3473
3474    DynamicThrottle As Byte
3475    Spare[ELM(3)] As Byte
3476
3477    DisableCStates/*:1*/ As DWord
3478'   Reserved:31 As DWord
3479
3480    PolicyCount As DWord
3481    Policy[ELM(3)] As PROCESSOR_POWER_POLICY_INFO
3482End Type
3483TypeDef PPROCESSOR_POWER_POLICY = *PROCESSOR_POWER_POLICY
3484
3485' Processor Perf State Policy.
3486Const PERFSTATE_POLICY_CHANGE_IDEAL = &h00
3487Const PERFSTATE_POLICY_CHANGE_SINGLE = &h01
3488Const PERFSTATE_POLICY_CHANGE_ROCKET = &h02
3489Const PERFSTATE_POLICY_CHANGE_MAX = PERFSTATE_POLICY_CHANGE_ROCKET
3490
3491Type PROCESSOR_PERFSTATE_POLICY 'アラインメント平気か?
3492    Revision As DWord
3493    MaxThrottle As Byte
3494    MinThrottle As Byte
3495    BusyAdjThreshold As Byte
3496    FlagsAsBYTE As Byte '下の共用体メンバの部分
3497'   Union
3498'       Spare As Byte
3499'       Union
3500'           AsBYTE As Byte
3501'           Type
3502'               NoDomainAccounting : 1 As Byte
3503'               IncreasePolicy: 2 As Byte
3504'               DecreasePolicy: 2 As Byte
3505'               Reserved : 3 As Byte
3506'           End Type
3507'       } Flags;
3508'   };
3509    TimeCheck As DWord
3510    IncreaseTime As DWord
3511    DecreaseTime As DWord
3512    IncreasePercent As DWord
3513    DecreasePercent As DWord
3514End Type
3515TypeDef PPROCESSOR_PERFSTATE_POLICY = *PROCESSOR_PERFSTATE_POLICY
3516
3517Type ADMINISTRATOR_POWER_POLICY
3518    MinSleep As SYSTEM_POWER_STATE
3519    MaxSleep As SYSTEM_POWER_STATE
3520
3521    MinVideoTimeout As DWord
3522    MaxVideoTimeout As DWord
3523
3524    MinSpindownTimeout As DWord
3525    MaxSpindownTimeout As DWord
3526End Type
3527TypeDef PADMINISTRATOR_POWER_POLICY = *ADMINISTRATOR_POWER_POLICY
3528
3529Type SYSTEM_POWER_CAPABILITIES
3530    PowerButtonPresent As BOOLEAN
3531    SleepButtonPresent As BOOLEAN
3532    LidPresent As BOOLEAN
3533    SystemS1 As BOOLEAN
3534    SystemS2 As BOOLEAN
3535    SystemS3 As BOOLEAN
3536    SystemS4 As BOOLEAN
3537    SystemS5 As BOOLEAN
3538    HiberFilePresent As BOOLEAN
3539    FullWake As BOOLEAN
3540    VideoDimPresent As BOOLEAN
3541    ApmPresent As BOOLEAN
3542    UpsPresent As BOOLEAN
3543
3544    ThermalControl As BOOLEAN
3545    ProcessorThrottle As BOOLEAN
3546    ProcessorMinThrottle As Byte
3547
3548'#if (NTDDI_VERSION < NTDDI_WINXP)
3549'   ProcessorThrottleScale As Byte
3550'   spare2[ELM(4)] As Byte
3551'#else
3552    ProcessorMaxThrottle As Byte
3553    FastSystemS4 As BOOLEAN
3554    spare2[(3)] As Byte
3555'#endif // (NTDDI_VERSION < NTDDI_WINXP)
3556
3557    DiskSpinDown As BOOLEAN
3558    spare3[ELM(8)] As Byte
3559
3560    SystemBatteriesPresent As BOOLEAN
3561    BatteriesAreShortTerm As BOOLEAN
3562    BatteryScale[ELM(3)] As BATTERY_REPORTING_SCALE
3563
3564    AcOnLineWake As SYSTEM_POWER_STATE
3565    SoftLidWake As SYSTEM_POWER_STATE
3566    RtcWake As SYSTEM_POWER_STATE
3567    MinDeviceWakeState As SYSTEM_POWER_STATE
3568    DefaultLowLatencyWake As SYSTEM_POWER_STATE
3569End Type
3570TypeDef PSYSTEM_POWER_CAPABILITIES = *SYSTEM_POWER_CAPABILITIES
3571
3572Type SYSTEM_BATTERY_STATE
3573    AcOnLine As BOOLEAN
3574    BatteryPresent As BOOLEAN
3575    Charging As BOOLEAN
3576    Discharging As BOOLEAN
3577    Spare1[ELM(4)] As BOOLEAN
3578
3579    MaxCapacity As DWord
3580    RemainingCapacity As DWord
3581    Rate As DWord
3582    EstimatedTime As DWord
3583
3584    DefaultAlert1 As DWord
3585    DefaultAlert2 As DWord
3586End Type
3587TypeDef PSYSTEM_BATTERY_STATE = *SYSTEM_BATTERY_STATE
3588
3589Const IMAGE_DOS_SIGNATURE = &h5A4D    ' MZ
3590Const IMAGE_OS2_SIGNATURE = &h454E    ' NE
3591Const IMAGE_OS2_SIGNATURE_LE = &h454C ' LE
3592Const IMAGE_VXD_SIGNATURE = &h454C    ' LE
3593Const IMAGE_NT_SIGNATURE = &h00004550 ' PE00
3594
3595Type Align(2) IMAGE_DOS_HEADER          ' DOS .EXE header
3596    e_magic As Word                     ' Magic number
3597    e_cblp As Word                      ' Bytes on last page of file
3598    e_cp As Word                        ' Pages in file
3599    e_crlc As Word                      ' Relocations
3600    e_cparhdr As Word                   ' Size of header in paragraphs
3601    e_minalloc As Word                  ' Minimum extra paragraphs needed
3602    e_maxalloc As Word                  ' Maximum extra paragraphs needed
3603    e_ss As Word                        ' Initial (relative) SS value
3604    e_sp As Word                        ' Initial SP value
3605    e_csum As Word                      ' Checksum
3606    e_ip As Word                        ' Initial IP value
3607    e_cs As Word                        ' Initial (relative) CS value
3608    e_lfarlc As Word                    ' File address of relocation table
3609    e_ovno As Word                      ' Overlay number
3610    e_res[ELM(4)] As Word               ' Reserved words
3611    e_oemid As Word                     ' OEM identifier (for e_oeminfo)
3612    e_oeminfo As Word                   ' OEM information; e_oemid specific
3613    e_res2[ELM(10)] As Word             ' Reserved words
3614    e_lfanew As Long                    ' File address of new exe header
3615End Type
3616TypeDef PIMAGE_DOS_HEADER = *IMAGE_DOS_HEADER
3617
3618Type Align(2) IMAGE_OS2_HEADER          ' OS/2 .EXE header
3619    ne_magic As Word                    ' Magic number
3620    ne_ver As CHAR                      ' Version number
3621    ne_rev As CHAR                      ' Revision number
3622    ne_enttab As Word                   ' Offset of Entry Table
3623    ne_cbenttab As Word                 ' Number of bytes in Entry Table
3624    ne_crc As Long                      ' Checksum of whole file
3625    ne_flags As Word                    ' Flag word
3626    ne_autodata As Word                 ' Automatic data segment number
3627    ne_heap As Word                     ' Initial heap allocation
3628    ne_stack As Word                    ' Initial stack allocation
3629    ne_csip As Long                     ' Initial CS:IP setting
3630    ne_sssp As Long                     ' Initial SS:SP setting
3631    ne_cseg As Word                     ' Count of file segments
3632    ne_cmod As Word                     ' Entries in Module Reference Table
3633    ne_cbnrestab As Word                ' Size of non-resident name table
3634    ne_segtab As Word                   ' Offset of Segment Table
3635    ne_rsrctab As Word                  ' Offset of Resource Table
3636    ne_restab As Word                   ' Offset of resident name table
3637    ne_modtab As Word                   ' Offset of Module Reference Table
3638    ne_imptab As Word                   ' Offset of Imported Names Table
3639    ne_nrestab As Long                  ' Offset of Non-resident Names Table
3640    ne_cmovent As Word                  ' Count of movable entries
3641    ne_align As Word                    ' Segment alignment shift count
3642    ne_cres As Word                     ' Count of resource segments
3643    ne_exetyp As Byte                   ' Target Operating system
3644    ne_flagsothers As Byte              ' Other .EXE flags
3645    ne_pretthunks As Word               ' offset to return thunks
3646    ne_psegrefbytes As Word             ' offset to segment ref. bytes
3647    ne_swaparea As Word                 ' Minimum code swap area size
3648    ne_expver As Word                   ' Expected Windows version number
3649End Type
3650TypeDef PIMAGE_OS2_HEADER = *IMAGE_OS2_HEADER
3651
3652Type Align(2) IMAGE_VXD_HEADER          ' Windows VXD header
3653    e32_magic As Word                   ' Magic number
3654    e32_border As Byte                  ' The byte ordering for the VXD
3655    e32_worder As Byte                  ' The word ordering for the VXD
3656    e32_level As DWord                  ' The EXE format level for now = 0
3657    e32_cpu As Word                     ' The CPU type
3658    e32_os As Word                      ' The OS type
3659    e32_ver As DWord                    ' Module version
3660    e32_mflags As DWord                 ' Module flags
3661    e32_mpages As DWord                 ' Module # pages
3662    e32_startobj As DWord               ' Object # for instruction pointer
3663    e32_eip As DWord                    ' Extended instruction pointer
3664    e32_stackobj As DWord               ' Object # for stack pointer
3665    e32_esp As DWord                    ' Extended stack pointer
3666    e32_pagesize As DWord               ' VXD page size
3667    e32_lastpagesize As DWord           ' Last page size in VXD
3668    e32_fixupsize As DWord              ' Fixup section size
3669    e32_fixupsum As DWord               ' Fixup section checksum
3670    e32_ldrsize As DWord                ' Loader section size
3671    e32_ldrsum As DWord                 ' Loader section checksum
3672    e32_objtab As DWord                 ' Object table offset
3673    e32_objcnt As DWord                 ' Number of objects in module
3674    e32_objmap As DWord                 ' Object page map offset
3675    e32_itermap As DWord                ' Object iterated data map offset
3676    e32_rsrctab As DWord                ' Offset of Resource Table
3677    e32_rsrccnt As DWord                ' Number of resource entries
3678    e32_restab As DWord                 ' Offset of resident name table
3679    e32_enttab As DWord                 ' Offset of Entry Table
3680    e32_dirtab As DWord                 ' Offset of Module Directive Table
3681    e32_dircnt As DWord                 ' Number of module directives
3682    e32_fpagetab As DWord               ' Offset of Fixup Page Table
3683    e32_frectab As DWord                ' Offset of Fixup Record Table
3684    e32_impmod As DWord                 ' Offset of Import Module Name Table
3685    e32_impmodcnt As DWord              ' Number of entries in Import Module Name Table
3686    e32_impproc As DWord                ' Offset of Import Procedure Name Table
3687    e32_pagesum As DWord                ' Offset of Per-Page Checksum Table
3688    e32_datapage As DWord               ' Offset of Enumerated Data Pages
3689    e32_preload As DWord                ' Number of preload pages
3690    e32_nrestab As DWord                ' Offset of Non-resident Names Table
3691    e32_cbnrestab As DWord              ' Size of Non-resident Name Table
3692    e32_nressum As DWord                ' Non-resident Name Table Checksum
3693    e32_autodata As DWord               ' Object # for automatic data object
3694    e32_debuginfo As DWord              ' Offset of the debugging information
3695    e32_debuglen As DWord               ' The length of the debugging info. in bytes
3696    e32_instpreload As DWord            ' Number of instance pages in preload section of VXD file
3697    e32_instdemand As DWord             ' Number of instance pages in demand load section of VXD file
3698    e32_heapsize As DWord               ' Size of heap - for 16-bit apps
3699    e32_res3[ELM(12)] As Byte           ' Reserved words
3700    e32_winresoff As DWord
3701    e32_winreslen As DWord
3702    e32_devid As Word                   ' Device ID for VxD
3703    e32_ddkver As Word                  ' DDK version for VxD
3704End Type
3705TypeDef PIMAGE_VXD_HEADER = *IMAGE_VXD_HEADER
3706
3707' File header format.
3708Type Align(4) IMAGE_FILE_HEADER
3709    Machine As Word
3710    NumberOfSections As Word
3711    TimeDateStamp As DWord
3712    PointerToSymbolTable As DWord
3713    NumberOfSymbols As DWord
3714    SizeOfOptionalHeader As Word
3715    Characteristics As Word
3716End Type
3717TypeDef PIMAGE_FILE_HEADER = *IMAGE_FILE_HEADER
3718
3719Const IMAGE_SIZEOF_FILE_HEADER = 20
3720
3721Const IMAGE_FILE_RELOCS_STRIPPED         = &h0001  ' Relocation info stripped from file.
3722Const IMAGE_FILE_EXECUTABLE_IMAGE        = &h0002  ' File is executable  (i.e. no unresolved externel references).
3723Const IMAGE_FILE_LINE_NUMS_STRIPPED      = &h0004  ' Line nunbers stripped from file.
3724Const IMAGE_FILE_LOCAL_SYMS_STRIPPED     = &h0008  ' Local symbols stripped from file.
3725Const IMAGE_FILE_AGGRESIVE_WS_TRIM       = &h0010  ' Agressively trim working set
3726Const IMAGE_FILE_LARGE_ADDRESS_AWARE     = &h0020  ' App can handle >2gb addresses
3727Const IMAGE_FILE_BYTES_REVERSED_LO       = &h0080  ' Bytes of machine word are reversed.
3728Const IMAGE_FILE_32BIT_MACHINE           = &h0100  ' 32 bit word machine.
3729Const IMAGE_FILE_DEBUG_STRIPPED          = &h0200  ' Debugging info stripped from file in .DBG file
3730Const IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = &h0400  ' If Image is on removable media, copy and run from the swap file.
3731Const IMAGE_FILE_NET_RUN_FROM_SWAP       = &h0800  ' If Image is on Net, copy and run from the swap file.
3732Const IMAGE_FILE_SYSTEM                  = &h1000  ' System File.
3733Const IMAGE_FILE_DLL                     = &h2000  ' File is a DLL.
3734Const IMAGE_FILE_UP_SYSTEM_ONLY          = &h4000  ' File should only be run on a UP machine
3735Const IMAGE_FILE_BYTES_REVERSED_HI       = &h8000  ' Bytes of machine word are reversed.
3736
3737Const IMAGE_FILE_MACHINE_UNKNOWN         = 0
3738Const IMAGE_FILE_MACHINE_I386            = &h014c  ' Intel 386.
3739Const IMAGE_FILE_MACHINE_R3000           = &h0162  ' MIPS little-endian, 0x160 big-endian
3740Const IMAGE_FILE_MACHINE_R4000           = &h0166  ' MIPS little-endian
3741Const IMAGE_FILE_MACHINE_R10000          = &h0168  ' MIPS little-endian
3742Const IMAGE_FILE_MACHINE_WCEMIPSV2       = &h0169  ' MIPS little-endian WCE v2
3743Const IMAGE_FILE_MACHINE_ALPHA           = &h0184  ' Alpha_AXP
3744Const IMAGE_FILE_MACHINE_SH3             = &h01a2  ' SH3 little-endian
3745Const IMAGE_FILE_MACHINE_SH3DSP          = &h01a3
3746Const IMAGE_FILE_MACHINE_SH3E            = &h01a4  ' SH3E little-endian
3747Const IMAGE_FILE_MACHINE_SH4             = &h01a6  ' SH4 little-endian
3748Const IMAGE_FILE_MACHINE_SH5             = &h01a8  ' SH5
3749Const IMAGE_FILE_MACHINE_ARM             = &h01c0  ' ARM Little-Endian
3750Const IMAGE_FILE_MACHINE_THUMB           = &h01c2
3751Const IMAGE_FILE_MACHINE_AM33            = &h01d3
3752Const IMAGE_FILE_MACHINE_POWERPC         = &h01F0  ' IBM PowerPC Little-Endian
3753Const IMAGE_FILE_MACHINE_POWERPCFP       = &h01f1
3754Const IMAGE_FILE_MACHINE_IA64            = &h0200  ' Intel 64
3755Const IMAGE_FILE_MACHINE_MIPS16          = &h0266  ' MIPS
3756Const IMAGE_FILE_MACHINE_ALPHA64         = &h0284  ' ALPHA64
3757Const IMAGE_FILE_MACHINE_MIPSFPU         = &h0366  ' MIPS
3758Const IMAGE_FILE_MACHINE_MIPSFPU16       = &h0466  ' MIPS
3759Const IMAGE_FILE_MACHINE_AXP64           = IMAGE_FILE_MACHINE_ALPHA64
3760Const IMAGE_FILE_MACHINE_TRICORE         = &h0520  ' Infineon
3761Const IMAGE_FILE_MACHINE_CEF             = &h0CEF
3762Const IMAGE_FILE_MACHINE_EBC             = &h0EBC  ' EFI Byte Code
3763Const IMAGE_FILE_MACHINE_AMD64           = &h8664  ' AMD64 (K8)
3764Const IMAGE_FILE_MACHINE_M32R            = &h9041  ' M32R little-endian
3765Const IMAGE_FILE_MACHINE_CEE             = &hC0EE
3766
3767' Directory format.
3768Type IMAGE_DATA_DIRECTORY
3769    VirtualAddress As DWord
3770    Size As DWord
3771End Type
3772TypeDef PIMAGE_DATA_DIRECTORY = *IMAGE_DATA_DIRECTORY
3773
3774Const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16
3775
3776' Optional header format.
3777Type IMAGE_OPTIONAL_HEADER32
3778    Magic As Word
3779    MajorLinkerVersion As Byte
3780    MinorLinkerVersion As Byte
3781    SizeOfCode As DWord
3782    SizeOfInitializedData As DWord
3783    SizeOfUninitializedData As DWord
3784    AddressOfEntryPoint As DWord
3785    BaseOfCode As DWord
3786    BaseOfData As DWord
3787
3788    ImageBase As DWord
3789    SectionAlignment As DWord
3790    FileAlignment As DWord
3791    MajorOperatingSystemVersion As Word
3792    MinorOperatingSystemVersion As Word
3793    MajorImageVersion As Word
3794    MinorImageVersion As Word
3795    MajorSubsystemVersion As Word
3796    MinorSubsystemVersion As Word
3797    Win32VersionValue As Word
3798    SizeOfImage As DWord
3799    SizeOfHeaders As DWord
3800    CheckSum As DWord
3801    Subsystem As Word
3802    DllCharacteristics As Word
3803    SizeOfStackReserve As DWord
3804    SizeOfStackCommit As DWord
3805    SizeOfHeapReserve As DWord
3806    SizeOfHeapCommit As DWord
3807    LoaderFlags As DWord
3808    NumberOfRvaAndSizes As DWord
3809    DataDirectory[ELM(IMAGE_NUMBEROF_DIRECTORY_ENTRIES)] As IMAGE_DATA_DIRECTORY
3810End Type
3811TypeDef PIMAGE_OPTIONAL_HEADER32 = *IMAGE_OPTIONAL_HEADER32
3812
3813Type IMAGE_ROM_OPTIONAL_HEADER
3814    Magic As Word
3815    MajorLinkerVersion As Byte
3816    MinorLinkerVersion As Byte
3817    SizeOfCode As DWord
3818    SizeOfInitializedData As DWord
3819    SizeOfUninitializedData As DWord
3820    AddressOfEntryPoint As DWord
3821    BaseOfCode As DWord
3822    BaseOfData As DWord
3823    BaseOfBss As DWord
3824    GprMask As DWord
3825    CprMask[ELM(4)] As DWord
3826    GpValue As DWord
3827End Type
3828TypeDef PIMAGE_ROM_OPTIONAL_HEADER = *IMAGE_ROM_OPTIONAL_HEADER
3829
3830Type IMAGE_OPTIONAL_HEADER64
3831    Magic As Word
3832    MajorLinkerVersion As Byte
3833    MinorLinkerVersion As Byte
3834    SizeOfCode As DWord
3835    SizeOfInitializedData As DWord
3836    SizeOfUninitializedData As DWord
3837    AddressOfEntryPoint As DWord
3838    BaseOfCode As DWord
3839    ImageBase As QWord
3840    SectionAlignment As DWord
3841    FileAlignment As DWord
3842    MajorOperatingSystemVersion As Word
3843    MinorOperatingSystemVersion As Word
3844    MajorImageVersion As Word
3845    MinorImageVersion As Word
3846    MajorSubsystemVersion As Word
3847    MinorSubsystemVersion As Word
3848    Win32VersionValue As DWord
3849    SizeOfImage As DWord
3850    SizeOfHeaders As DWord
3851    CheckSum As DWord
3852    Subsystem As Word
3853    DllCharacteristics As Word
3854    SizeOfStackReserve As QWord
3855    SizeOfStackCommit As QWord
3856    SizeOfHeapReserve As QWord
3857    SizeOfHeapCommit As QWord
3858    LoaderFlags As DWord
3859    NumberOfRvaAndSizes As DWord
3860    DataDirectory[ELM(IMAGE_NUMBEROF_DIRECTORY_ENTRIES)] As IMAGE_DATA_DIRECTORY
3861End Type
3862TypeDef PIMAGE_OPTIONAL_HEADER64 = *IMAGE_OPTIONAL_HEADER64
3863
3864Const IMAGE_NT_OPTIONAL_HDR32_MAGIC = &h10b
3865Const IMAGE_NT_OPTIONAL_HDR64_MAGIC = &h20b
3866Const IMAGE_ROM_OPTIONAL_HDR_MAGIC = &h107
3867
3868#ifdef _WIN64
3869TypeDef IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER64
3870TypeDef PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER64
3871Const IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR64_MAGIC
3872#else
3873TypeDef IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32
3874TypeDef PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER32
3875Const IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR32_MAGIC
3876#endif
3877
3878Type IMAGE_NT_HEADERS64
3879    Signature As DWord
3880    FileHeader As IMAGE_FILE_HEADER
3881    OptionalHeader As IMAGE_OPTIONAL_HEADER64
3882End Type
3883TypeDef PIMAGE_NT_HEADERS64 = *IMAGE_NT_HEADERS64
3884
3885Type IMAGE_NT_HEADERS32
3886    Signature As DWord
3887    FileHeader As IMAGE_FILE_HEADER
3888    OptionalHeader As IMAGE_OPTIONAL_HEADER32
3889End Type
3890TypeDef PIMAGE_NT_HEADERS32 = *IMAGE_NT_HEADERS32
3891
3892Type IMAGE_ROM_HEADERS
3893    FileHeader As IMAGE_FILE_HEADER
3894    OptionalHeader As IMAGE_ROM_OPTIONAL_HEADER
3895End Type
3896TypeDef PIMAGE_ROM_HEADERS = *IMAGE_ROM_HEADERS
3897
3898#ifdef _WIN64
3899TypeDef IMAGE_NT_HEADERS = IMAGE_NT_HEADERS64
3900TypeDef PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS64
3901#else
3902TypeDef IMAGE_NT_HEADERS = IMAGE_NT_HEADERS32
3903TypeDef PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS32
3904#endif
3905/*
3906Const IMAGE_FIRST_SECTION( ntheader ) (        \_
3907    ((ntheader) As ULONG_PTR +                                              _
3908     FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) +                 _
3909     ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader   _
3910    ) As PIMAGE_SECTION_HEADER)
3911*/
3912Const IMAGE_SUBSYSTEM_UNKNOWN             = 0   ' Unknown subsystem.
3913Const IMAGE_SUBSYSTEM_NATIVE              = 1   ' Image doesn't require a subsystem.
3914Const IMAGE_SUBSYSTEM_WINDOWS_GUI         = 2   ' Image runs in the Windows GUI subsystem.
3915Const IMAGE_SUBSYSTEM_WINDOWS_CUI         = 3   ' Image runs in the Windows character subsystem.
3916Const IMAGE_SUBSYSTEM_OS2_CUI             = 5   ' image runs in the OS/2 character subsystem.
3917Const IMAGE_SUBSYSTEM_POSIX_CUI           = 7   ' image runs in the Posix character subsystem.
3918Const IMAGE_SUBSYSTEM_NATIVE_WINDOWS      = 8   ' image is a native Win9x driver.
3919Const IMAGE_SUBSYSTEM_WINDOWS_CE_GUI      = 9   ' Image runs in the Windows CE subsystem.
3920Const IMAGE_SUBSYSTEM_EFI_APPLICATION     = 10  '
3921Const IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11   '
3922Const IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER  = 12  '
3923Const IMAGE_SUBSYSTEM_EFI_ROM             = 13
3924Const IMAGE_SUBSYSTEM_XBOX                = 14
3925Const IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16
3926
3927'      IMAGE_LIBRARY_PROCESS_INIT           = &h0001    ' Reserved.
3928'      IMAGE_LIBRARY_PROCESS_TERM           = &h0002    ' Reserved.
3929'      IMAGE_LIBRARY_THREAD_INIT            = &h0004    ' Reserved.
3930'      IMAGE_LIBRARY_THREAD_TERM            = &h0008    ' Reserved.
3931Const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = &h0040     ' DLL can move.
3932Const IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY   = &h0080     ' Code Integrity Image
3933Const IMAGE_DLLCHARACTERISTICS_NX_COMPAT    = &h0100     ' Image is NX compatible
3934Const IMAGE_DLLCHARACTERISTICS_NO_ISOLATION = &h0200     ' Image understands isolation and doesn't want it
3935Const IMAGE_DLLCHARACTERISTICS_NO_SEH       = &h0400     ' Image does not use SEH.  No SE handler may reside in this image
3936Const IMAGE_DLLCHARACTERISTICS_NO_BIND      = &h0800     ' Do not bind this image.
3937'                                            = &h1000    ' Reserved.
3938Const IMAGE_DLLCHARACTERISTICS_WDM_DRIVER   = &h2000     ' Driver uses WDM model
3939'                                           = &h4000    ' Reserved.
3940Const IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE    = &h8000
3941
3942Const IMAGE_DIRECTORY_ENTRY_EXPORT         = 0   ' Export Directory
3943Const IMAGE_DIRECTORY_ENTRY_IMPORT         = 1   ' Import Directory
3944Const IMAGE_DIRECTORY_ENTRY_RESOURCE       = 2   ' Resource Directory
3945Const IMAGE_DIRECTORY_ENTRY_EXCEPTION      = 3   ' Exception Directory
3946Const IMAGE_DIRECTORY_ENTRY_SECURITY       = 4   ' Security Directory
3947Const IMAGE_DIRECTORY_ENTRY_BASERELOC      = 5   ' Base Relocation Table
3948Const IMAGE_DIRECTORY_ENTRY_DEBUG          = 6   ' Debug Directory
3949'      IMAGE_DIRECTORY_ENTRY_COPYRIGHT      = 7  ' (X86 usage)
3950Const IMAGE_DIRECTORY_ENTRY_ARCHITECTURE   = 7   ' Architecture Specific Data
3951Const IMAGE_DIRECTORY_ENTRY_GLOBALPTR      = 8   ' RVA of GP
3952Const IMAGE_DIRECTORY_ENTRY_TLS            = 9   ' TLS Directory
3953Const IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG   = 10   ' Load Configuration Directory
3954Const IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT  = 11   ' Bound Import Directory in headers
3955Const IMAGE_DIRECTORY_ENTRY_IAT           = 12   ' Import Address Table
3956Const IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT  = 13   ' Delay Load Import Descriptors
3957Const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR = 14  ' COM Runtime descriptor
3958
3959' Non-COFF Object file header
3960Type ANON_OBJECT_HEADER
3961    Sig1 As Word             ' Must be IMAGE_FILE_MACHINE_UNKNOWN
3962    Sig2 As Word             ' Must be 0xffff
3963    Version As Word  ' >= 1 (implies the CLSID field is present)
3964    Machine As Word
3965    TimeDateStamp As DWord
3966    ClassID As CLSID       ' Used to invoke CoCreateInstance
3967    SizeOfData As DWord    ' Size of data that follows the header
3968End Type
3969
3970Type ANON_OBJECT_HEADER_V2
3971    Sig1 As Word            ' Must be IMAGE_FILE_MACHINE_UNKNOWN
3972    Sig2 As Word            ' Must be 0xffff
3973    Version As Word         ' >= 2 (implies the Flags field is present - otherwise V1)
3974    Machine As Word
3975    TimeDateStamp As DWord
3976    ClassID As CLSID         ' Used to invoke CoCreateInstance
3977    SizeOfData As DWord      ' Size of data that follows the header
3978    Flags As DWord           ' 0x1 -> contains metadata
3979    MetaDataSize As DWord    ' Size of CLR metadata
3980    MetaDataOffset As DWord  ' Offset of CLR metadata
3981End Type
3982
3983Const IMAGE_SIZEOF_SHORT_NAME = 8
3984
3985Type IMAGE_SECTION_HEADER
3986    Name[ELM(IMAGE_SIZEOF_SHORT_NAME)] As Byte
3987    'Union
3988        PhysicalAddress As DWord
3989'       VirtualSize As DWord
3990'   } Misc
3991    VirtualAddress As DWord
3992    SizeOfRawData As DWord
3993    PointerToRawData As DWord
3994    PointerToRelocations As DWord
3995    PointerToLinenumbers As DWord
3996    NumberOfRelocations As Word
3997    NumberOfLinenumbers As Word
3998    Characteristics As DWord
3999End Type
4000TypeDef PIMAGE_SECTION_HEADER = *IMAGE_SECTION_HEADER
4001
4002Const IMAGE_SIZEOF_SECTION_HEADER = 40
4003
4004' Section characteristics.
4005'      IMAGE_SCN_TYPE_REG                 = &h00000000 ' Reserved.
4006'      IMAGE_SCN_TYPE_DSECT               = &h00000001 ' Reserved.
4007'      IMAGE_SCN_TYPE_NOLOAD              = &h00000002 ' Reserved.
4008'      IMAGE_SCN_TYPE_GROUP               = &h00000004 ' Reserved.
4009Const IMAGE_SCN_TYPE_NO_PAD              = &h00000008  ' Reserved.
4010'      IMAGE_SCN_TYPE_COPY                = &h00000010 ' Reserved.
4011
4012Const IMAGE_SCN_CNT_CODE                 = &h00000020  ' Section contains code.
4013Const IMAGE_SCN_CNT_INITIALIZED_DATA     = &h00000040  ' Section contains initialized data.
4014Const IMAGE_SCN_CNT_UNINITIALIZED_DATA   = &h00000080  ' Section contains uninitialized data.
4015
4016Const IMAGE_SCN_LNK_OTHER                = &h00000100  ' Reserved.
4017Const IMAGE_SCN_LNK_INFO                 = &h00000200  ' Section contains comments or some other type of information.
4018'      IMAGE_SCN_TYPE_OVER                = &h00000400 ' Reserved.
4019Const IMAGE_SCN_LNK_REMOVE               = &h00000800  ' Section contents will not become part of image.
4020Const IMAGE_SCN_LNK_COMDAT               = &h00001000  ' Section contents comdat.
4021'                                         = &h00002000 ' Reserved.
4022'      IMAGE_SCN_MEM_PROTECTED - Obsolete = &h00004000
4023Const IMAGE_SCN_NO_DEFER_SPEC_EXC        = &h00004000  ' Reset speculative exceptions handling bits in the TLB entries for this section.
4024Const IMAGE_SCN_GPREL                    = &h00008000  ' Section content can be accessed relative to GP
4025Const IMAGE_SCN_MEM_FARDATA              = &h00008000
4026'      IMAGE_SCN_MEM_SYSHEAP  - Obsolete  = &h00010000
4027Const IMAGE_SCN_MEM_PURGEABLE            = &h00020000
4028Const IMAGE_SCN_MEM_16BIT                = &h00020000
4029Const IMAGE_SCN_MEM_LOCKED               = &h00040000
4030Const IMAGE_SCN_MEM_PRELOAD              = &h00080000
4031
4032Const IMAGE_SCN_ALIGN_1BYTES             = &h00100000  '
4033Const IMAGE_SCN_ALIGN_2BYTES             = &h00200000  '
4034Const IMAGE_SCN_ALIGN_4BYTES             = &h00300000  '
4035Const IMAGE_SCN_ALIGN_8BYTES             = &h00400000  '
4036Const IMAGE_SCN_ALIGN_16BYTES            = &h00500000  ' Default alignment if no others are specified.
4037Const IMAGE_SCN_ALIGN_32BYTES            = &h00600000  '
4038Const IMAGE_SCN_ALIGN_64BYTES            = &h00700000  '
4039Const IMAGE_SCN_ALIGN_128BYTES           = &h00800000  '
4040Const IMAGE_SCN_ALIGN_256BYTES           = &h00900000  '
4041Const IMAGE_SCN_ALIGN_512BYTES           = &h00A00000  '
4042Const IMAGE_SCN_ALIGN_1024BYTES          = &h00B00000  '
4043Const IMAGE_SCN_ALIGN_2048BYTES          = &h00C00000  '
4044Const IMAGE_SCN_ALIGN_4096BYTES          = &h00D00000  '
4045Const IMAGE_SCN_ALIGN_8192BYTES          = &h00E00000  '
4046' Unused                                  = &h00F00000
4047Const IMAGE_SCN_ALIGN_MASK               = &h00F00000
4048
4049Const IMAGE_SCN_LNK_NRELOC_OVFL          = &h01000000  ' Section contains extended relocations.
4050Const IMAGE_SCN_MEM_DISCARDABLE          = &h02000000  ' Section can be discarded.
4051Const IMAGE_SCN_MEM_NOT_CACHED           = &h04000000  ' Section is not cachable.
4052Const IMAGE_SCN_MEM_NOT_PAGED            = &h08000000  ' Section is not pageable.
4053Const IMAGE_SCN_MEM_SHARED               = &h10000000  ' Section is shareable.
4054Const IMAGE_SCN_MEM_EXECUTE              = &h20000000  ' Section is executable.
4055Const IMAGE_SCN_MEM_READ                 = &h40000000  ' Section is readable.
4056Const IMAGE_SCN_MEM_WRITE                = &h80000000  ' Section is writeable.
4057
4058' TLS Chaacteristic Flags
4059Const IMAGE_SCN_SCALE_INDEX              = &h00000001  ' Tls index is scaled
4060
4061' Symbol format.
4062Type Align(2) IMAGE_SYMBOL
4063'   Union
4064        ShortName[ELM(8)] As Byte
4065'       Type
4066'           Short As DWord
4067'           Long As DWord
4068'       } Name
4069'       LongName[ELM(2)] As DWord ' PBYTE [ELM(2)]
4070'   } N
4071    Value AS DWord
4072    SectionNumber As Integer
4073    Type_ As Word
4074    StorageClass As Byte
4075    NumberOfAuxSymbols As Byte
4076End Type
4077TypeDef PIMAGE_SYMBOL = * /*UNALIGNED*/ IMAGE_SYMBOL
4078
4079Const IMAGE_SIZEOF_SYMBOL  = 18
4080
4081' Section values.
4082Const IMAGE_SYM_UNDEFINED   = 0 As Integer         ' Symbol is undefined or is common.
4083Const IMAGE_SYM_ABSOLUTE    = -1 As Integer        ' Symbol is an absolute value.
4084Const IMAGE_SYM_DEBUG       = -2 As Integer        ' Symbol is a special debug item.
4085Const IMAGE_SYM_SECTION_MAX = &hFEFF               ' Values 0xFF00-0xFFFF are special
4086
4087' Type (fundamental) values.
4088
4089Const IMAGE_SYM_TYPE_NULL               = &h0000  ' no type.
4090Const IMAGE_SYM_TYPE_VOID               = &h0001  '
4091Const IMAGE_SYM_TYPE_CHAR               = &h0002  ' type character.
4092Const IMAGE_SYM_TYPE_SHORT              = &h0003  ' type short integer.
4093Const IMAGE_SYM_TYPE_INT                = &h0004  '
4094Const IMAGE_SYM_TYPE_LONG               = &h0005  '
4095Const IMAGE_SYM_TYPE_FLOAT              = &h0006  '
4096Const IMAGE_SYM_TYPE_DOUBLE             = &h0007  '
4097Const IMAGE_SYM_TYPE_STRUCT             = &h0008  '
4098Const IMAGE_SYM_TYPE_UNION              = &h0009  '
4099Const IMAGE_SYM_TYPE_ENUM               = &h000A  ' enumeration.
4100Const IMAGE_SYM_TYPE_MOE                = &h000B  ' member of enumeration.
4101Const IMAGE_SYM_TYPE_BYTE               = &h000C  '
4102Const IMAGE_SYM_TYPE_WORD               = &h000D  '
4103Const IMAGE_SYM_TYPE_UINT               = &h000E  '
4104Const IMAGE_SYM_TYPE_DWORD              = &h000F  '
4105Const IMAGE_SYM_TYPE_PCODE              = &h8000  '
4106
4107'Type (derived) values.
4108
4109Const IMAGE_SYM_DTYPE_NULL              = 0       ' no derived type.
4110Const IMAGE_SYM_DTYPE_POINTER           = 1       ' pointer.
4111Const IMAGE_SYM_DTYPE_FUNCTION          = 2       ' function.
4112Const IMAGE_SYM_DTYPE_ARRAY             = 3       ' array.
4113
4114' Storage classes.
4115Const IMAGE_SYM_CLASS_END_OF_FUNCTION = -1 As Byte
4116Const IMAGE_SYM_CLASS_NULL = &h0000
4117Const IMAGE_SYM_CLASS_AUTOMATIC = &h0001
4118Const IMAGE_SYM_CLASS_EXTERNAL = &h0002
4119Const IMAGE_SYM_CLASS_STATIC = &h0003
4120Const IMAGE_SYM_CLASS_REGISTER = &h0004
4121Const IMAGE_SYM_CLASS_EXTERNAL_DEF = &h0005
4122Const IMAGE_SYM_CLASS_LABEL = &h0006
4123Const IMAGE_SYM_CLASS_UNDEFINED_LABEL = &h0007
4124Const IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = &h0008
4125Const IMAGE_SYM_CLASS_ARGUMENT = &h0009
4126Const IMAGE_SYM_CLASS_STRUCT_TAG = &h000A
4127Const IMAGE_SYM_CLASS_MEMBER_OF_UNION = &h000B
4128Const IMAGE_SYM_CLASS_UNION_TAG = &h000C
4129Const IMAGE_SYM_CLASS_TYPE_DEFINITION = &h000D
4130Const IMAGE_SYM_CLASS_UNDEFINED_STATIC = &h000E
4131Const IMAGE_SYM_CLASS_ENUM_TAG = &h000F
4132Const IMAGE_SYM_CLASS_MEMBER_OF_ENUM = &h0010
4133Const IMAGE_SYM_CLASS_REGISTER_PARAM = &h0011
4134Const IMAGE_SYM_CLASS_BIT_FIELD = &h0012
4135
4136Const IMAGE_SYM_CLASS_FAR_EXTERNAL = &h0044
4137
4138Const IMAGE_SYM_CLASS_BLOCK = &h0064
4139Const IMAGE_SYM_CLASS_FUNCTION = &h0065
4140Const IMAGE_SYM_CLASS_END_OF_STRUCT = &h0066
4141Const IMAGE_SYM_CLASS_FILE = &h0067
4142' new
4143Const IMAGE_SYM_CLASS_SECTION = &h0068
4144Const IMAGE_SYM_CLASS_WEAK_EXTERNAL = &h0069
4145
4146Const IMAGE_SYM_CLASS_CLR_TOKEN = &h006B
4147
4148' type packing constants
4149Const N_BTMASK = &h000F
4150Const N_TMASK = &h0030
4151Const N_TMASK1 = &h00C0
4152Const N_TMASK2 = &h00F0
4153Const N_BTSHFT = 4
4154Const N_TSHIFT = 2
4155
4156Const BTYPE(x) = ((x) And N_BTMASK)
4157Const ISPTR(x) = (((x) And N_TMASK) = (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
4158Const ISFCN(x) = (((x) And N_TMASK) = (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
4159Const ISARY(x) = (((x) And N_TMASK) = (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
4160Const ISTAG(x) = ((x) = IMAGE_SYM_CLASS_STRUCT_TAG Or (x) = IMAGE_SYM_CLASS_UNION_TAG Or (x) = IMAGE_SYM_CLASS_ENUM_TAG)
4161Const INCREF(x) = ((((x) And (Not N_BTMASK)) << N_TSHIFT) Or (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) Or ((x) And N_BTMASK))
4162Const DECREF(x) = ((((x) >> N_TSHIFT) And (Not N_BTMASK)) Or ((x) And N_BTMASK))
4163
4164' Auxiliary entry format.
4165Type /*Union*/ Align(2) IMAGE_AUX_SYMBOL
4166'   Type
4167'       TagIndex As DWord                     ' struct, union, or enum tag index
4168'       Union
4169'           Type
4170'               Linenumber As Word            ' declaration line number
4171'               Size As Word                  ' size of struct, union, or enum
4172'           } LnSz
4173'           TotalSize As DWord
4174'       } Misc
4175'       Union
4176'           Type                              ' if ISFCN, tag, or .bb
4177'           PointerToLinenumber As DWord
4178'               PointerToNextFunction As DWord
4179'           } Function
4180'           Type                              ' if ISARY, up to 4 dimen.
4181'               Dimension[ELM(4)] As Word
4182'           } Array
4183'       } FcnAry
4184'       TvIndex As Word                       ' tv index
4185'   } Sym
4186'   Type
4187'       Name[ELM(IMAGE_SIZEOF_SYMBOL)] As Byte
4188'   } File
4189'   Type
4190        Length As DWord                 ' section length
4191        NumberOfRelocations As Word     ' number of relocation entries
4192        NumberOfLinenumbers As Word     ' number of line numbers
4193        CheckSum As DWord               ' checksum for communal
4194        Number As Integer               ' section number to associate with
4195        Selection As Byte               ' communal selection type
4196'   } Section
4197End Type 'Union
4198TypeDef PIMAGE_AUX_SYMBOL = * /*UNALIGNED*/ IMAGE_AUX_SYMBOL
4199
4200Enum IMAGE_AUX_SYMBOL_TYPE
4201    IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1
4202End Enum
4203
4204Type Align(2) IMAGE_AUX_SYMBOL_TOKEN_DEF
4205    bAuxType As Byte
4206    bReserved As Byte
4207    SymbolTableIndex As DWord
4208    rgbReserved[ELM(12)] As Byte
4209End Type
4210TypeDef PIMAGE_AUX_SYMBOL_TOKEN_DEF = * /*UNALIGNED*/ IMAGE_AUX_SYMBOL_TOKEN_DEF
4211
4212' Communal selection types.
4213Const IMAGE_COMDAT_SELECT_NODUPLICATES = 1
4214Const IMAGE_COMDAT_SELECT_ANY = 2
4215Const IMAGE_COMDAT_SELECT_SAME_SIZE = 3
4216Const IMAGE_COMDAT_SELECT_EXACT_MATCH = 4
4217Const IMAGE_COMDAT_SELECT_ASSOCIATIVE = 5
4218Const IMAGE_COMDAT_SELECT_LARGEST = 6
4219Const IMAGE_COMDAT_SELECT_NEWEST = 7
4220
4221Const IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1
4222Const IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2
4223Const IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
4224
4225' Relocation format.
4226Type Align(2) IMAGE_RELOCATION
4227'   Union
4228'       VirtualAddress As DWord
4229        RelocCount As DWord
4230'   End Union
4231    SymbolTableIndex As DWord
4232    Type_ As Word
4233End Type
4234TypeDef PIMAGE_RELOCATION = * /*UNALIGNED*/ IMAGE_RELOCATION
4235
4236' I386 relocation types.
4237Const IMAGE_REL_I386_ABSOLUTE       = &h0000  ' Reference is absolute, no relocation is necessary
4238Const IMAGE_REL_I386_DIR16          = &h0001  ' Direct 16-bit reference to the symbols virtual address
4239Const IMAGE_REL_I386_REL16          = &h0002  ' PC-relative 16-bit reference to the symbols virtual address
4240Const IMAGE_REL_I386_DIR32          = &h0006  ' Direct 32-bit reference to the symbols virtual address
4241Const IMAGE_REL_I386_DIR32NB        = &h0007  ' Direct 32-bit reference to the symbols virtual address, base not included
4242Const IMAGE_REL_I386_SEG12          = &h0009  ' Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
4243Const IMAGE_REL_I386_SECTION        = &h000A
4244Const IMAGE_REL_I386_SECREL         = &h000B
4245Const IMAGE_REL_I386_TOKEN          = &h000C  ' clr token
4246Const IMAGE_REL_I386_SECREL7        = &h000D  ' 7 bit offset from base of section containing target
4247Const IMAGE_REL_I386_REL32          = &h0014  ' PC-relative 32-bit reference to the symbols virtual address
4248
4249' MIPS relocation types.
4250Const IMAGE_REL_MIPS_ABSOLUTE       = &h0000  ' Reference is absolute, no relocation is necessary
4251Const IMAGE_REL_MIPS_REFHALF        = &h0001
4252Const IMAGE_REL_MIPS_REFWORD        = &h0002
4253Const IMAGE_REL_MIPS_JMPADDR        = &h0003
4254Const IMAGE_REL_MIPS_REFHI          = &h0004
4255Const IMAGE_REL_MIPS_REFLO          = &h0005
4256Const IMAGE_REL_MIPS_GPREL          = &h0006
4257Const IMAGE_REL_MIPS_LITERAL        = &h0007
4258Const IMAGE_REL_MIPS_SECTION        = &h000A
4259Const IMAGE_REL_MIPS_SECREL         = &h000B
4260Const IMAGE_REL_MIPS_SECRELLO       = &h000C  ' Low 16-bit section relative referemce (used for >32k TLS)
4261Const IMAGE_REL_MIPS_SECRELHI       = &h000D  ' High 16-bit section relative reference (used for >32k TLS)
4262Const IMAGE_REL_MIPS_TOKEN          = &h000E  ' clr token
4263Const IMAGE_REL_MIPS_JMPADDR16      = &h0010
4264Const IMAGE_REL_MIPS_REFWORDNB      = &h0022
4265Const IMAGE_REL_MIPS_PAIR           = &h0025
4266
4267' Alpha Relocation types.
4268Const IMAGE_REL_ALPHA_ABSOLUTE      = &h0000
4269Const IMAGE_REL_ALPHA_REFLONG       = &h0001
4270Const IMAGE_REL_ALPHA_REFQUAD       = &h0002
4271Const IMAGE_REL_ALPHA_GPREL32       = &h0003
4272Const IMAGE_REL_ALPHA_LITERAL       = &h0004
4273Const IMAGE_REL_ALPHA_LITUSE        = &h0005
4274Const IMAGE_REL_ALPHA_GPDISP        = &h0006
4275Const IMAGE_REL_ALPHA_BRADDR        = &h0007
4276Const IMAGE_REL_ALPHA_HINT          = &h0008
4277Const IMAGE_REL_ALPHA_INLINE_REFLONG= &h0009
4278Const IMAGE_REL_ALPHA_REFHI         = &h000A
4279Const IMAGE_REL_ALPHA_REFLO         = &h000B
4280Const IMAGE_REL_ALPHA_PAIR          = &h000C
4281Const IMAGE_REL_ALPHA_MATCH         = &h000D
4282Const IMAGE_REL_ALPHA_SECTION       = &h000E
4283Const IMAGE_REL_ALPHA_SECREL        = &h000F
4284Const IMAGE_REL_ALPHA_REFLONGNB     = &h0010
4285Const IMAGE_REL_ALPHA_SECRELLO      = &h0011  ' Low 16-bit section relative reference
4286Const IMAGE_REL_ALPHA_SECRELHI      = &h0012  ' High 16-bit section relative reference
4287Const IMAGE_REL_ALPHA_REFQ3         = &h0013  ' High 16 bits of 48 bit reference
4288Const IMAGE_REL_ALPHA_REFQ2         = &h0014  ' Middle 16 bits of 48 bit reference
4289Const IMAGE_REL_ALPHA_REFQ1         = &h0015  ' Low 16 bits of 48 bit reference
4290Const IMAGE_REL_ALPHA_GPRELLO       = &h0016  ' Low 16-bit GP relative reference
4291Const IMAGE_REL_ALPHA_GPRELHI       = &h0017  ' High 16-bit GP relative reference
4292
4293' IBM PowerPC relocation types.
4294Const IMAGE_REL_PPC_ABSOLUTE        = &h0000  ' NOP
4295Const IMAGE_REL_PPC_ADDR64          = &h0001  ' 64-bit address
4296Const IMAGE_REL_PPC_ADDR32          = &h0002  ' 32-bit address
4297Const IMAGE_REL_PPC_ADDR24          = &h0003  ' 26-bit address, shifted left 2 (branch absolute)
4298Const IMAGE_REL_PPC_ADDR16          = &h0004  ' 16-bit address
4299Const IMAGE_REL_PPC_ADDR14          = &h0005  ' 16-bit address, shifted left 2 (load doubleword)
4300Const IMAGE_REL_PPC_REL24           = &h0006  ' 26-bit PC-relative offset, shifted left 2 (branch relative)
4301Const IMAGE_REL_PPC_REL14           = &h0007  ' 16-bit PC-relative offset, shifted left 2 (br cond relative)
4302Const IMAGE_REL_PPC_TOCREL16        = &h0008  ' 16-bit offset from TOC base
4303Const IMAGE_REL_PPC_TOCREL14        = &h0009  ' 16-bit offset from TOC base, shifted left 2 (load doubleword)
4304
4305Const IMAGE_REL_PPC_ADDR32NB        = &h000A  ' 32-bit addr w/o image base
4306Const IMAGE_REL_PPC_SECREL          = &h000B  ' va of containing section (as in an image sectionhdr)
4307Const IMAGE_REL_PPC_SECTION         = &h000C  ' sectionheader number
4308Const IMAGE_REL_PPC_IFGLUE          = &h000D  ' substitute TOC restore instruction iff symbol is glue code
4309Const IMAGE_REL_PPC_IMGLUE          = &h000E  ' symbol is glue code; virtual address is TOC restore instruction
4310Const IMAGE_REL_PPC_SECREL16        = &h000F  ' va of containing section (limited to 16 bits)
4311Const IMAGE_REL_PPC_REFHI           = &h0010
4312Const IMAGE_REL_PPC_REFLO           = &h0011
4313Const IMAGE_REL_PPC_PAIR            = &h0012
4314Const IMAGE_REL_PPC_SECRELLO        = &h0013  ' Low 16-bit section relative reference (used for >32k TLS)
4315Const IMAGE_REL_PPC_SECRELHI        = &h0014  ' High 16-bit section relative reference (used for >32k TLS)
4316Const IMAGE_REL_PPC_GPREL           = &h0015
4317Const IMAGE_REL_PPC_TOKEN           = &h0016  ' clr token
4318
4319Const IMAGE_REL_PPC_TYPEMASK        = &h00FF  ' mask to isolate above values in IMAGE_RELOCATION.Type
4320
4321' Flag bits in IMAGE_RELOCATION.TYPE
4322
4323Const IMAGE_REL_PPC_NEG             = &h0100  ' subtract reloc value rather than adding it
4324Const IMAGE_REL_PPC_BRTAKEN         = &h0200  ' fix branch prediction bit to predict branch taken
4325Const IMAGE_REL_PPC_BRNTAKEN        = &h0400  ' fix branch prediction bit to predict branch not taken
4326Const IMAGE_REL_PPC_TOCDEFN         = &h0800  ' toc slot defined in file (or, data in toc)
4327
4328' Hitachi SH3 relocation types.
4329Const IMAGE_REL_SH3_ABSOLUTE        = &h0000  ' No relocation
4330Const IMAGE_REL_SH3_DIRECT16        = &h0001  ' 16 bit direct
4331Const IMAGE_REL_SH3_DIRECT32        = &h0002  ' 32 bit direct
4332Const IMAGE_REL_SH3_DIRECT8         = &h0003  ' 8 bit direct, -128..255
4333Const IMAGE_REL_SH3_DIRECT8_WORD    = &h0004  ' 8 bit direct .W (0 ext.)
4334Const IMAGE_REL_SH3_DIRECT8_LONG    = &h0005  ' 8 bit direct .L (0 ext.)
4335Const IMAGE_REL_SH3_DIRECT4         = &h0006  ' 4 bit direct (0 ext.)
4336Const IMAGE_REL_SH3_DIRECT4_WORD    = &h0007  ' 4 bit direct .W (0 ext.)
4337Const IMAGE_REL_SH3_DIRECT4_LONG    = &h0008  ' 4 bit direct .L (0 ext.)
4338Const IMAGE_REL_SH3_PCREL8_WORD     = &h0009  ' 8 bit PC relative .W
4339Const IMAGE_REL_SH3_PCREL8_LONG     = &h000A  ' 8 bit PC relative .L
4340Const IMAGE_REL_SH3_PCREL12_WORD    = &h000B  ' 12 LSB PC relative .W
4341Const IMAGE_REL_SH3_STARTOF_SECTION = &h000C  ' Start of EXE section
4342Const IMAGE_REL_SH3_SIZEOF_SECTION  = &h000D  ' Size of EXE section
4343Const IMAGE_REL_SH3_SECTION         = &h000E  ' Section table index
4344Const IMAGE_REL_SH3_SECREL          = &h000F  ' Offset within section
4345Const IMAGE_REL_SH3_DIRECT32_NB     = &h0010  ' 32 bit direct not based
4346Const IMAGE_REL_SH3_GPREL4_LONG     = &h0011  ' GP-relative addressing
4347Const IMAGE_REL_SH3_TOKEN           = &h0012  ' clr token
4348Const IMAGE_REL_SHM_PCRELPT         = &h0013  ' Offset from current
4349                                                '  instruction in longwords
4350                                                '  if not NOMODE, insert the
4351                                                '  inverse of the low bit at
4352                                                '  bit 32 to select PTA/PTB
4353Const IMAGE_REL_SHM_REFLO           = &h0014  ' Low bits of 32-bit address
4354Const IMAGE_REL_SHM_REFHALF         = &h0015  ' High bits of 32-bit address
4355Const IMAGE_REL_SHM_RELLO           = &h0016  ' Low bits of relative reference
4356Const IMAGE_REL_SHM_RELHALF         = &h0017  ' High bits of relative reference
4357Const IMAGE_REL_SHM_PAIR            = &h0018  ' offset operand for relocation
4358
4359Const IMAGE_REL_SH_NOMODE           = &h8000  ' relocation ignores section mode
4360
4361
4362Const IMAGE_REL_ARM_ABSOLUTE        = &h0000  ' No relocation required
4363Const IMAGE_REL_ARM_ADDR32          = &h0001  ' 32 bit address
4364Const IMAGE_REL_ARM_ADDR32NB        = &h0002  ' 32 bit address w/o image base
4365Const IMAGE_REL_ARM_BRANCH24        = &h0003  ' 24 bit offset << 2 & sign ext.
4366Const IMAGE_REL_ARM_BRANCH11        = &h0004  ' Thumb: 2 11 bit offsets
4367Const IMAGE_REL_ARM_TOKEN           = &h0005  ' clr token
4368Const IMAGE_REL_ARM_GPREL12         = &h0006  ' GP-relative addressing (ARM)
4369Const IMAGE_REL_ARM_GPREL7          = &h0007  ' GP-relative addressing (Thumb)
4370Const IMAGE_REL_ARM_BLX24           = &h0008
4371Const IMAGE_REL_ARM_BLX11           = &h0009
4372Const IMAGE_REL_ARM_SECTION         = &h000E  ' Section table index
4373Const IMAGE_REL_ARM_SECREL          = &h000F  ' Offset within section
4374
4375Const IMAGE_REL_AM_ABSOLUTE         = &h0000
4376Const IMAGE_REL_AM_ADDR32           = &h0001
4377Const IMAGE_REL_AM_ADDR32NB         = &h0002
4378Const IMAGE_REL_AM_CALL32           = &h0003
4379Const IMAGE_REL_AM_FUNCINFO         = &h0004
4380Const IMAGE_REL_AM_REL32_1          = &h0005
4381Const IMAGE_REL_AM_REL32_2          = &h0006
4382Const IMAGE_REL_AM_SECREL           = &h0007
4383Const IMAGE_REL_AM_SECTION          = &h0008
4384Const IMAGE_REL_AM_TOKEN            = &h0009
4385
4386' x64 relocations
4387Const IMAGE_REL_AMD64_ABSOLUTE      = &h0000  ' Reference is absolute, no relocation is necessary
4388Const IMAGE_REL_AMD64_ADDR64        = &h0001  ' 64-bit address (VA).
4389Const IMAGE_REL_AMD64_ADDR32        = &h0002  ' 32-bit address (VA).
4390Const IMAGE_REL_AMD64_ADDR32NB      = &h0003  ' 32-bit address w/o image base (RVA).
4391Const IMAGE_REL_AMD64_REL32         = &h0004  ' 32-bit relative address from byte following reloc
4392Const IMAGE_REL_AMD64_REL32_1       = &h0005  ' 32-bit relative address from byte distance 1 from reloc
4393Const IMAGE_REL_AMD64_REL32_2       = &h0006  ' 32-bit relative address from byte distance 2 from reloc
4394Const IMAGE_REL_AMD64_REL32_3       = &h0007  ' 32-bit relative address from byte distance 3 from reloc
4395Const IMAGE_REL_AMD64_REL32_4       = &h0008  ' 32-bit relative address from byte distance 4 from reloc
4396Const IMAGE_REL_AMD64_REL32_5       = &h0009  ' 32-bit relative address from byte distance 5 from reloc
4397Const IMAGE_REL_AMD64_SECTION       = &h000A  ' Section index
4398Const IMAGE_REL_AMD64_SECREL        = &h000B  ' 32 bit offset from base of section containing target
4399Const IMAGE_REL_AMD64_SECREL7       = &h000C  ' 7 bit unsigned offset from base of section containing target
4400Const IMAGE_REL_AMD64_TOKEN         = &h000D  ' 32 bit metadata token
4401Const IMAGE_REL_AMD64_SREL32        = &h000E  ' 32 bit signed span-dependent value emitted into object
4402Const IMAGE_REL_AMD64_PAIR          = &h000F
4403Const IMAGE_REL_AMD64_SSPAN32       = &h0010  ' 32 bit signed span-dependent value applied at link time
4404
4405' IA64 relocation types.
4406
4407Const IMAGE_REL_IA64_ABSOLUTE       = &h0000
4408Const IMAGE_REL_IA64_IMM14          = &h0001
4409Const IMAGE_REL_IA64_IMM22          = &h0002
4410Const IMAGE_REL_IA64_IMM64          = &h0003
4411Const IMAGE_REL_IA64_DIR32          = &h0004
4412Const IMAGE_REL_IA64_DIR64          = &h0005
4413Const IMAGE_REL_IA64_PCREL21B       = &h0006
4414Const IMAGE_REL_IA64_PCREL21M       = &h0007
4415Const IMAGE_REL_IA64_PCREL21F       = &h0008
4416Const IMAGE_REL_IA64_GPREL22        = &h0009
4417Const IMAGE_REL_IA64_LTOFF22        = &h000A
4418Const IMAGE_REL_IA64_SECTION        = &h000B
4419Const IMAGE_REL_IA64_SECREL22       = &h000C
4420Const IMAGE_REL_IA64_SECREL64I      = &h000D
4421Const IMAGE_REL_IA64_SECREL32       = &h000E
4422'
4423Const IMAGE_REL_IA64_DIR32NB        = &h0010
4424Const IMAGE_REL_IA64_SREL14         = &h0011
4425Const IMAGE_REL_IA64_SREL22         = &h0012
4426Const IMAGE_REL_IA64_SREL32         = &h0013
4427Const IMAGE_REL_IA64_UREL32         = &h0014
4428Const IMAGE_REL_IA64_PCREL60X       = &h0015  ' This is always a BRL and never converted
4429Const IMAGE_REL_IA64_PCREL60B       = &h0016  ' If possible, convert to MBB bundle with NOP.B in slot 1
4430Const IMAGE_REL_IA64_PCREL60F       = &h0017  ' If possible, convert to MFB bundle with NOP.F in slot 1
4431Const IMAGE_REL_IA64_PCREL60I       = &h0018  ' If possible, convert to MIB bundle with NOP.I in slot 1
4432Const IMAGE_REL_IA64_PCREL60M       = &h0019  ' If possible, convert to MMB bundle with NOP.M in slot 1
4433Const IMAGE_REL_IA64_IMMGPREL64     = &h001A
4434Const IMAGE_REL_IA64_TOKEN          = &h001B  ' clr token
4435Const IMAGE_REL_IA64_GPREL32        = &h001C
4436Const IMAGE_REL_IA64_ADDEND         = &h001F
4437
4438' CEF relocation types.
4439Const IMAGE_REL_CEF_ABSOLUTE        = &h0000  ' Reference is absolute, no relocation is necessary
4440Const IMAGE_REL_CEF_ADDR32          = &h0001  ' 32-bit address (VA).
4441Const IMAGE_REL_CEF_ADDR64          = &h0002  ' 64-bit address (VA).
4442Const IMAGE_REL_CEF_ADDR32NB        = &h0003  ' 32-bit address w/o image base (RVA).
4443Const IMAGE_REL_CEF_SECTION         = &h0004  ' Section index
4444Const IMAGE_REL_CEF_SECREL          = &h0005  ' 32 bit offset from base of section containing target
4445Const IMAGE_REL_CEF_TOKEN           = &h0006  ' 32 bit metadata token
4446
4447' clr relocation types.
4448Const IMAGE_REL_CEE_ABSOLUTE        = &h0000  ' Reference is absolute, no relocation is necessary
4449Const IMAGE_REL_CEE_ADDR32          = &h0001  ' 32-bit address (VA).
4450Const IMAGE_REL_CEE_ADDR64          = &h0002  ' 64-bit address (VA).
4451Const IMAGE_REL_CEE_ADDR32NB        = &h0003  ' 32-bit address w/o image base (RVA).
4452Const IMAGE_REL_CEE_SECTION         = &h0004  ' Section index
4453Const IMAGE_REL_CEE_SECREL          = &h0005  ' 32 bit offset from base of section containing target
4454Const IMAGE_REL_CEE_TOKEN           = &h0006  ' 32 bit metadata token
4455
4456
4457Const IMAGE_REL_M32R_ABSOLUTE       = &h0000  ' No relocation required
4458Const IMAGE_REL_M32R_ADDR32         = &h0001  ' 32 bit address
4459Const IMAGE_REL_M32R_ADDR32NB       = &h0002  ' 32 bit address w/o image base
4460Const IMAGE_REL_M32R_ADDR24         = &h0003  ' 24 bit address
4461Const IMAGE_REL_M32R_GPREL16        = &h0004  ' GP relative addressing
4462Const IMAGE_REL_M32R_PCREL24        = &h0005  ' 24 bit offset << 2 & sign ext.
4463Const IMAGE_REL_M32R_PCREL16        = &h0006  ' 16 bit offset << 2 & sign ext.
4464Const IMAGE_REL_M32R_PCREL8         = &h0007  ' 8 bit offset << 2 & sign ext.
4465Const IMAGE_REL_M32R_REFHALF        = &h0008  ' 16 MSBs
4466Const IMAGE_REL_M32R_REFHI          = &h0009  ' 16 MSBs; adj for LSB sign ext.
4467Const IMAGE_REL_M32R_REFLO          = &h000A  ' 16 LSBs
4468Const IMAGE_REL_M32R_PAIR           = &h000B  ' Link HI and LO
4469Const IMAGE_REL_M32R_SECTION        = &h000C  ' Section table index
4470Const IMAGE_REL_M32R_SECREL32       = &h000D  ' 32 bit section relative reference
4471Const IMAGE_REL_M32R_TOKEN          = &h000E  ' clr token
4472
4473Const IMAGE_REL_EBC_ABSOLUTE        = &h0000  ' No relocation required
4474Const IMAGE_REL_EBC_ADDR32NB        = &h0001  ' 32 bit address w/o image base
4475Const IMAGE_REL_EBC_REL32           = &h0002  ' 32-bit relative address from byte following reloc
4476Const IMAGE_REL_EBC_SECTION         = &h0003  ' Section table index
4477Const IMAGE_REL_EBC_SECREL          = &h0004  ' Offset within section
4478
4479'Const EXT_IMM64(Value, Address, Size, InstPos, ValPos)  /* Intel-IA64-Filler * /           \
4480'    Value |= (((ULONGLONG)((*(Address) >> InstPos) & (((ULONGLONG)1 << Size) - 1))) << ValPos)  // Intel-IA64-Filler
4481
4482'Const INS_IMM64(Value, Address, Size, InstPos, ValPos)  /* Intel-IA64-Filler * /\
4483'    *(PDWORD)Address = (*(PDWORD)Address & ~(((1 << Size) - 1) << InstPos)) | /* Intel-IA64-Filler * /\
4484'          ((DWORD)((((ULONGLONG)Value >> ValPos) & (((ULONGLONG)1 << Size) - 1))) << InstPos)  // Intel-IA64-Filler
4485
4486Const EMARCH_ENC_I17_IMM7B_INST_WORD_X       = 3  ' Intel-IA64-Filler
4487Const EMARCH_ENC_I17_IMM7B_SIZE_X            = 7  ' Intel-IA64-Filler
4488Const EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X   = 4  ' Intel-IA64-Filler
4489Const EMARCH_ENC_I17_IMM7B_VAL_POS_X         = 0  ' Intel-IA64-Filler
4490
4491Const EMARCH_ENC_I17_IMM9D_INST_WORD_X       = 3  ' Intel-IA64-Filler
4492Const EMARCH_ENC_I17_IMM9D_SIZE_X            = 9  ' Intel-IA64-Filler
4493Const EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X   = 18 ' Intel-IA64-Filler
4494Const EMARCH_ENC_I17_IMM9D_VAL_POS_X         = 7  ' Intel-IA64-Filler
4495
4496Const EMARCH_ENC_I17_IMM5C_INST_WORD_X       = 3  ' Intel-IA64-Filler
4497Const EMARCH_ENC_I17_IMM5C_SIZE_X            = 5  ' Intel-IA64-Filler
4498Const EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X   = 13 ' Intel-IA64-Filler
4499Const EMARCH_ENC_I17_IMM5C_VAL_POS_X         = 16 ' Intel-IA64-Filler
4500
4501Const EMARCH_ENC_I17_IC_INST_WORD_X          = 3  ' Intel-IA64-Filler
4502Const EMARCH_ENC_I17_IC_SIZE_X               = 1  ' Intel-IA64-Filler
4503Const EMARCH_ENC_I17_IC_INST_WORD_POS_X      = 12 ' Intel-IA64-Filler
4504Const EMARCH_ENC_I17_IC_VAL_POS_X            = 21 ' Intel-IA64-Filler
4505
4506Const EMARCH_ENC_I17_IMM41a_INST_WORD_X      = 1  ' Intel-IA64-Filler
4507Const EMARCH_ENC_I17_IMM41a_SIZE_X           = 10 ' Intel-IA64-Filler
4508Const EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X  = 14 ' Intel-IA64-Filler
4509Const EMARCH_ENC_I17_IMM41a_VAL_POS_X        = 22 ' Intel-IA64-Filler
4510
4511Const EMARCH_ENC_I17_IMM41b_INST_WORD_X      = 1  ' Intel-IA64-Filler
4512Const EMARCH_ENC_I17_IMM41b_SIZE_X           = 8  ' Intel-IA64-Filler
4513Const EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X  = 24 ' Intel-IA64-Filler
4514Const EMARCH_ENC_I17_IMM41b_VAL_POS_X        = 32 ' Intel-IA64-Filler
4515
4516Const EMARCH_ENC_I17_IMM41c_INST_WORD_X      = 2  ' Intel-IA64-Filler
4517Const EMARCH_ENC_I17_IMM41c_SIZE_X           = 23 ' Intel-IA64-Filler
4518Const EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X  = 0  ' Intel-IA64-Filler
4519Const EMARCH_ENC_I17_IMM41c_VAL_POS_X        = 40 ' Intel-IA64-Filler
4520
4521Const EMARCH_ENC_I17_SIGN_INST_WORD_X        = 3  ' Intel-IA64-Filler
4522Const EMARCH_ENC_I17_SIGN_SIZE_X             = 1  ' Intel-IA64-Filler
4523Const EMARCH_ENC_I17_SIGN_INST_WORD_POS_X    = 27 ' Intel-IA64-Filler
4524Const EMARCH_ENC_I17_SIGN_VAL_POS_X          = 63 ' Intel-IA64-Filler
4525
4526Const X3_OPCODE_INST_WORD_X                  = 3  ' Intel-IA64-Filler
4527Const X3_OPCODE_SIZE_X                       = 4  ' Intel-IA64-Filler
4528Const X3_OPCODE_INST_WORD_POS_X              = 28 ' Intel-IA64-Filler
4529Const X3_OPCODE_SIGN_VAL_POS_X               = 0  ' Intel-IA64-Filler
4530
4531Const X3_I_INST_WORD_X                       = 3  ' Intel-IA64-Filler
4532Const X3_I_SIZE_X                            = 1  ' Intel-IA64-Filler
4533Const X3_I_INST_WORD_POS_X                   = 27 ' Intel-IA64-Filler
4534Const X3_I_SIGN_VAL_POS_X                    = 59 ' Intel-IA64-Filler
4535
4536Const X3_D_WH_INST_WORD_X                    = 3  ' Intel-IA64-Filler
4537Const X3_D_WH_SIZE_X                         = 3  ' Intel-IA64-Filler
4538Const X3_D_WH_INST_WORD_POS_X                = 24 ' Intel-IA64-Filler
4539Const X3_D_WH_SIGN_VAL_POS_X                 = 0  ' Intel-IA64-Filler
4540
4541Const X3_IMM20_INST_WORD_X                   = 3  ' Intel-IA64-Filler
4542Const X3_IMM20_SIZE_X                        = 20 ' Intel-IA64-Filler
4543Const X3_IMM20_INST_WORD_POS_X               = 4  ' Intel-IA64-Filler
4544Const X3_IMM20_SIGN_VAL_POS_X                = 0  ' Intel-IA64-Filler
4545
4546Const X3_IMM39_1_INST_WORD_X                 = 2  ' Intel-IA64-Filler
4547Const X3_IMM39_1_SIZE_X                      = 23 ' Intel-IA64-Filler
4548Const X3_IMM39_1_INST_WORD_POS_X             = 0  ' Intel-IA64-Filler
4549Const X3_IMM39_1_SIGN_VAL_POS_X              = 36 ' Intel-IA64-Filler
4550
4551Const X3_IMM39_2_INST_WORD_X                 = 1  ' Intel-IA64-Filler
4552Const X3_IMM39_2_SIZE_X                      = 16 ' Intel-IA64-Filler
4553Const X3_IMM39_2_INST_WORD_POS_X             = 16 ' Intel-IA64-Filler
4554Const X3_IMM39_2_SIGN_VAL_POS_X              = 20 ' Intel-IA64-Filler
4555
4556Const X3_P_INST_WORD_X                       = 3  ' Intel-IA64-Filler
4557Const X3_P_SIZE_X                            = 4  ' Intel-IA64-Filler
4558Const X3_P_INST_WORD_POS_X                   = 0  ' Intel-IA64-Filler
4559Const X3_P_SIGN_VAL_POS_X                    = 0  ' Intel-IA64-Filler
4560
4561Const X3_TMPLT_INST_WORD_X                   = 0  ' Intel-IA64-Filler
4562Const X3_TMPLT_SIZE_X                        = 4  ' Intel-IA64-Filler
4563Const X3_TMPLT_INST_WORD_POS_X               = 0  ' Intel-IA64-Filler
4564Const X3_TMPLT_SIGN_VAL_POS_X                = 0  ' Intel-IA64-Filler
4565
4566Const X3_BTYPE_QP_INST_WORD_X                = 2  ' Intel-IA64-Filler
4567Const X3_BTYPE_QP_SIZE_X                     = 9  ' Intel-IA64-Filler
4568Const X3_BTYPE_QP_INST_WORD_POS_X            = 23 ' Intel-IA64-Filler
4569Const X3_BTYPE_QP_INST_VAL_POS_X             = 0  ' Intel-IA64-Filler
4570
4571Const X3_EMPTY_INST_WORD_X                   = 1  ' Intel-IA64-Filler
4572Const X3_EMPTY_SIZE_X                        = 2  ' Intel-IA64-Filler
4573Const X3_EMPTY_INST_WORD_POS_X               = 14 ' Intel-IA64-Filler
4574Const X3_EMPTY_INST_VAL_POS_X                = 0  ' Intel-IA64-Filler
4575
4576' Line number format.
4577Type Align(2) IMAGE_LINENUMBER
4578'   Union
4579        SymbolTableIndex As DWord
4580'       VirtualAddress As DWord
4581'   End Union
4582    Linenumber As Word
4583End Type
4584TypeDef PIMAGE_LINENUMBER = * /*UNALIGNED*/ IMAGE_LINENUMBER
4585
4586' Based relocation format.
4587Type IMAGE_BASE_RELOCATION
4588    VirtualAddress As DWord
4589    SizeOfBlock As DWord
4590'   TypeOffset[ELM(1)] As Word
4591End Type
4592TypeDef PIMAGE_BASE_RELOCATION = * /*UNALIGNED*/ IMAGE_BASE_RELOCATION
4593
4594' Based relocation types.
4595Const IMAGE_REL_BASED_ABSOLUTE = 0
4596Const IMAGE_REL_BASED_HIGH = 1
4597Const IMAGE_REL_BASED_LOW = 2
4598Const IMAGE_REL_BASED_HIGHLOW = 3
4599Const IMAGE_REL_BASED_HIGHADJ = 4
4600Const IMAGE_REL_BASED_MIPS_JMPADDR = 5
4601Const IMAGE_REL_BASED_MIPS_JMPADDR16 = 9
4602Const IMAGE_REL_BASED_IA64_IMM64 = 9
4603Const IMAGE_REL_BASED_DIR64 = 10
4604
4605' Archive format.
4606Const IMAGE_ARCHIVE_START_SIZE = 8
4607Const IMAGE_ARCHIVE_START = Ex"!<arch>\n"
4608Const IMAGE_ARCHIVE_END = Ex"`\n"
4609Const IMAGE_ARCHIVE_PAD = Ex"\n"
4610Const IMAGE_ARCHIVE_LINKER_MEMBER = Ex"/               "
4611Const IMAGE_ARCHIVE_LONGNAMES_MEMBER = Ex"//              "
4612
4613Type IMAGE_ARCHIVE_MEMBER_HEADER
4614    Name[ELM(16)] As Byte
4615    Date[ELM(12)] As Byte
4616    UserID[ELM(6)] As Byte
4617    GroupID[ELM(6)] As Byte
4618    Mode[ELM(8)] As Byte
4619    Size[ELM(10)] As Byte
4620    EndHeader[ELM(2)] As Byte
4621End Type
4622TypeDef PIMAGE_ARCHIVE_MEMBER_HEADER = *IMAGE_ARCHIVE_MEMBER_HEADER
4623
4624Const IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR = 60
4625
4626' DLL support.
4627
4628' Export Format
4629Type IMAGE_EXPORT_DIRECTORY
4630    Characteristics As DWord
4631    TimeDateStamp As DWord
4632    MajorVersion As DWord
4633    MinorVersion As DWord
4634    Name As Word
4635    Base As Word
4636    NumberOfFunctions As DWord
4637    NumberOfNames As DWord
4638    AddressOfFunctions As DWord
4639    AddressOfNames As DWord
4640    AddressOfNameOrdinals As DWord
4641End Type
4642TypeDef PIMAGE_EXPORT_DIRECTORY = *IMAGE_EXPORT_DIRECTORY
4643
4644' Import Format
4645Type IMAGE_IMPORT_BY_NAME
4646    Hint As Word
4647    Name[ELM(1)] As Byte
4648End Type
4649TypeDef PIMAGE_IMPORT_BY_NAME = *IMAGE_IMPORT_BY_NAME
4650
4651Type Align(8) IMAGE_THUNK_DATA64
4652'   Union
4653        ForwarderString As QWord 'PBYTE
4654'       Function_ As QWord 'PDWORD
4655'       Ordinal As QWord
4656'       AddressOfData As QWord 'PIMAGE_IMPORT_BY_NAME
4657'   } u1
4658End Type
4659TypeDef PIMAGE_THUNK_DATA64 = *IMAGE_THUNK_DATA64
4660
4661Type IMAGE_THUNK_DATA32
4662'   Union
4663        ForwarderString As DWORD 'PBYTE
4664'       Function_ As DWORD 'PDWORD
4665'       Ordinal As DWORD
4666'       AddressOfData As DWORD 'PIMAGE_IMPORT_BY_NAME
4667'   } u1
4668End Type
4669TypeDef PIMAGE_THUNK_DATA32 = *IMAGE_THUNK_DATA32
4670
4671Const IMAGE_ORDINAL_FLAG64 = &h8000000000000000
4672Const IMAGE_ORDINAL_FLAG32 = &h80000000
4673Const IMAGE_ORDINAL64(Ordinal) = (Ordinal And &hffff)
4674Const IMAGE_ORDINAL32(Ordinal) = (Ordinal And &hffff)
4675Const IMAGE_SNAP_BY_ORDINAL64(Ordinal) = ((Ordinal And IMAGE_ORDINAL_FLAG64) <> 0)
4676Const IMAGE_SNAP_BY_ORDINAL32(Ordinal) = ((Ordinal And IMAGE_ORDINAL_FLAG32) <> 0)
4677
4678' Thread Local Storage
4679TypeDef PIMAGE_TLS_CALLBACK = *Sub(DllHandle As PVOID, Reason As DWord, Reserved As PVOID)
4680
4681Type IMAGE_TLS_DIRECTORY64
4682    StartAddressOfRawData As QWord
4683    EndAddressOfRawData As QWord
4684    AddressOfIndex As QWord 'PDWORD
4685    AddressOfCallBacks As QWord 'PIMAGE_TLS_CALLBACK *
4686    SizeOfZeroFill As DWord
4687    Characteristics As DWord
4688End Type
4689TypeDef PIMAGE_TLS_DIRECTORY64 = *IMAGE_TLS_DIRECTORY64
4690
4691Type IMAGE_TLS_DIRECTORY32
4692    StartAddressOfRawData As DWord
4693    EndAddressOfRawData As DWord
4694    AddressOfIndex As DWord 'PDWORD
4695    AddressOfCallBacks As DWord 'PIMAGE_TLS_CALLBACK *
4696    SizeOfZeroFill As DWord
4697    Characteristics As DWord
4698End Type
4699TypeDef PIMAGE_TLS_DIRECTORY32 = *IMAGE_TLS_DIRECTORY32
4700
4701#ifdef _WIN64
4702Const IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG64
4703Const IMAGE_ORDINAL(Ordinal) = IMAGE_ORDINAL64(Ordinal)
4704TypeDef IMAGE_THUNK_DATA = IMAGE_THUNK_DATA64
4705TypeDef PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA64
4706Const IMAGE_SNAP_BY_ORDINAL(Ordinal) = IMAGE_SNAP_BY_ORDINAL64(Ordinal)
4707TypeDef IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY64
4708TypeDef PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY64
4709#else
4710Const IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG32
4711Const IMAGE_ORDINAL(Ordinal) = IMAGE_ORDINAL32(Ordinal)
4712TypeDef IMAGE_THUNK_DATA = IMAGE_THUNK_DATA32
4713TypeDef PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA32
4714Const IMAGE_SNAP_BY_ORDINAL(Ordinal) = IMAGE_SNAP_BY_ORDINAL32(Ordinal)
4715TypeDef IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY32
4716TypeDef PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY32
4717#endif
4718
4719Type IMAGE_IMPORT_DESCRIPTOR
4720'   Union
4721        Characteristics As DWord
4722'       OriginalFirstThunk As DWord
4723'   End Union
4724    TimeDateStamp As DWord
4725    ForwarderChain As DWord
4726    Name As DWord
4727    FirstThunk As DWord
4728End Type
4729TypeDef PIMAGE_IMPORT_DESCRIPTOR = * /*UNALIGNED*/ IMAGE_IMPORT_DESCRIPTOR
4730
4731' New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ]
4732Type IMAGE_BOUND_IMPORT_DESCRIPTOR
4733    TimeDateStamp As DWord
4734    OffsetModuleName As Word
4735    NumberOfModuleForwarderRefs As Word
4736End Type
4737TypeDef PIMAGE_BOUND_IMPORT_DESCRIPTOR = IMAGE_BOUND_IMPORT_DESCRIPTOR
4738
4739Type IMAGE_BOUND_FORWARDER_REF
4740    TimeDateStamp As DWord
4741    OffsetModuleName As Word
4742    Reserved As Word
4743End Type
4744TypeDef PIMAGE_BOUND_FORWARDER_REF = *IMAGE_BOUND_FORWARDER_REF
4745
4746' Resource Format.
4747Type IMAGE_RESOURCE_DIRECTORY
4748    Characteristics As DWord
4749    TimeDateStamp As DWord
4750    MajorVersion As Word
4751    MinorVersion As Word
4752    NumberOfNamedEntries As Word
4753    NumberOfIdEntries As Word
4754End Type
4755TypeDef PIMAGE_RESOURCE_DIRECTORY = *IMAGE_RESOURCE_DIRECTORY
4756
4757Const IMAGE_RESOURCE_NAME_IS_STRING = &h80000000
4758Const IMAGE_RESOURCE_DATA_IS_DIRECTORY = &h80000000
4759
4760Type IMAGE_RESOURCE_DIRECTORY_ENTRY
4761'   Union
4762'       Type
4763'           NameOffset : 31 As DWord
4764'           NameIsString :  As DWord
4765'       End Type
4766        Name As DWord
4767'       Id As DWord
4768'   End Union
4769'   Union
4770        OffsetToData As DWord
4771'       Type
4772'           OffsetToDirectory : 31 As DWord
4773'           DataIsDirectory : 1 As DWord
4774'       End Type
4775'   End Union
4776End Type
4777TypeDef PIMAGE_RESOURCE_DIRECTORY_ENTRY = *IMAGE_RESOURCE_DIRECTORY_ENTRY
4778
4779Type IMAGE_RESOURCE_DIRECTORY_STRING
4780    Length As Word
4781    NameString[ELM(1)] As CHAR
4782End Type
4783TypeDef PIMAGE_RESOURCE_DIRECTORY_STRING = *IMAGE_RESOURCE_DIRECTORY_STRING
4784
4785Type IMAGE_RESOURCE_DIR_STRING_U
4786    Length As Word
4787    NameString[ELM(1)] As WCHAR
4788End Type
4789TypeDef PIMAGE_RESOURCE_DIR_STRING_U = *IMAGE_RESOURCE_DIR_STRING_U
4790
4791Type IMAGE_RESOURCE_DATA_ENTRY
4792    OffsetToData As DWord
4793    Size As DWord
4794    CodePage As DWord
4795    Reserved As DWord
4796End Type
4797TypeDef PIMAGE_RESOURCE_DATA_ENTRY = *IMAGE_RESOURCE_DATA_ENTRY
4798
4799' Load Configuration Directory Entry
4800
4801Type IMAGE_LOAD_CONFIG_DIRECTORY32
4802    Size As DWord
4803    TimeDateStamp As DWord
4804    MajorVersion As Word
4805    MinorVersion As Word
4806    GlobalFlagsClear As DWord
4807    GlobalFlagsSet As DWord
4808    CriticalSectionDefaultTimeout As DWord
4809    DeCommitFreeBlockThreshold As DWord
4810    DeCommitTotalFreeThreshold As DWord
4811    LockPrefixTable As DWord
4812    MaximumAllocationSize As DWord
4813    VirtualMemoryThreshold As DWord
4814    ProcessHeapFlags As DWord
4815    ProcessAffinityMask As DWord
4816    CSDVersion As Word
4817    Reserved1 As Word
4818    EditList As DWord
4819    SecurityCookie As DWord
4820    SEHandlerTable As DWord
4821    SEHandlerCount As DWord
4822End Type
4823TypeDef PIMAGE_LOAD_CONFIG_DIRECTORY32 = *IMAGE_LOAD_CONFIG_DIRECTORY32
4824
4825Type IMAGE_LOAD_CONFIG_DIRECTORY64
4826    Size As DWord
4827    TimeDateStamp As DWord
4828    MajorVersion As Word
4829    MinorVersion As Word
4830    GlobalFlagsClear As DWord
4831    GlobalFlagsSet As DWord
4832    CriticalSectionDefaultTimeout As DWord
4833    DeCommitFreeBlockThreshold As QWord
4834    DeCommitTotalFreeThreshold As QWord
4835    LockPrefixTable As QWord
4836    MaximumAllocationSize As QWord
4837    VirtualMemoryThreshold As QWord
4838    ProcessAffinityMask As QWord
4839    ProcessHeapFlags As DWord
4840    CSDVersion As Word
4841    Reserved1 As Word
4842    EditList As QWord
4843    SecurityCookie As QWord
4844    SEHandlerTable As QWord
4845    SEHandlerCount As QWord
4846End Type
4847TypeDef PIMAGE_LOAD_CONFIG_DIRECTORY64 = *IMAGE_LOAD_CONFIG_DIRECTORY64
4848
4849#ifdef _WIN64
4850TypeDef IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY64
4851TypeDef PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY64
4852#else
4853TypeDef IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY32
4854TypeDef PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY32
4855#endif
4856
4857' WIN CE Exception table format
4858
4859' Function table entry format
4860
4861Type IMAGE_CE_RUNTIME_FUNCTION_ENTRY
4862    FuncStart As DWord
4863    dummy As DWord
4864'   PrologLen : 8 As DWord
4865'   FuncLen : 22 As DWord
4866'   ThirtyTwoBit : 1 As DWord
4867'   ExceptionFlag : 1 As DWord
4868End Type
4869TypeDef PIMAGE_CE_RUNTIME_FUNCTION_ENTRY = *IMAGE_CE_RUNTIME_FUNCTION_ENTRY
4870
4871Type IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY
4872    BeginAddress As QWord
4873    EndAddress As QWord
4874    ExceptionHandler As QWord
4875    HandlerData As QWord
4876    PrologEndAddress As QWord
4877End Type
4878TypeDef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY = *IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY
4879
4880Type IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY
4881    BeginAddress As DWord
4882    EndAddress As DWord
4883    ExceptionHandler As DWord
4884    HandlerData As DWord
4885    PrologEndAddress As DWord
4886End Type
4887TypeDef PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY = *IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY
4888
4889Type _IMAGE_RUNTIME_FUNCTION_ENTRY
4890    BeginAddress As DWord
4891    EndAddress As DWord
4892    UnwindInfoAddress As DWord
4893End Type
4894TypeDef _PIMAGE_RUNTIME_FUNCTION_ENTRY = *_IMAGE_RUNTIME_FUNCTION_ENTRY
4895
4896TypeDef IMAGE_IA64_RUNTIME_FUNCTION_ENTRY = _IMAGE_RUNTIME_FUNCTION_ENTRY
4897TypeDef PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY = _PIMAGE_RUNTIME_FUNCTION_ENTRY
4898
4899TypeDef IMAGE_RUNTIME_FUNCTION_ENTRY = _IMAGE_RUNTIME_FUNCTION_ENTRY
4900TypeDef PIMAGE_RUNTIME_FUNCTION_ENTRY = _PIMAGE_RUNTIME_FUNCTION_ENTRY
4901
4902' Debug Format
4903Type IMAGE_DEBUG_DIRECTORY
4904    Characteristics As DWord
4905    TimeDateStamp As DWord
4906    MajorVersion As Word
4907    MinorVersion As Word
4908    Type_ As DWord
4909    SizeOfData As DWord
4910    AddressOfRawData As DWord
4911    PointerToRawData As DWord
4912End Type
4913TypeDef PIMAGE_DEBUG_DIRECTORY = *IMAGE_DEBUG_DIRECTORY
4914
4915Const IMAGE_DEBUG_TYPE_UNKNOWN = 0
4916Const IMAGE_DEBUG_TYPE_COFF = 1
4917Const IMAGE_DEBUG_TYPE_CODEVIEW = 2
4918Const IMAGE_DEBUG_TYPE_FPO = 3
4919Const IMAGE_DEBUG_TYPE_MISC = 4
4920Const IMAGE_DEBUG_TYPE_EXCEPTION = 5
4921Const IMAGE_DEBUG_TYPE_FIXUP = 6
4922Const IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7
4923Const IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8
4924Const IMAGE_DEBUG_TYPE_BORLAND = 9
4925Const IMAGE_DEBUG_TYPE_RESERVED10 = 10
4926Const IMAGE_DEBUG_TYPE_CLSID = 11
4927
4928Type IMAGE_COFF_SYMBOLS_HEADER
4929    NumberOfSymbols As DWord
4930    LvaToFirstSymbol As DWord
4931    NumberOfLinenumbers As DWord
4932    LvaToFirstLinenumber As DWord
4933    RvaToFirstByteOfCode As DWord
4934    RvaToLastByteOfCode As DWord
4935    RvaToFirstByteOfData As DWord
4936    RvaToLastByteOfData As DWord
4937End Type
4938TypeDef PIMAGE_COFF_SYMBOLS_HEADER = *IMAGE_COFF_SYMBOLS_HEADER
4939
4940Const FRAME_FPO = 0
4941Const FRAME_TRAP = 1
4942Const FRAME_TSS = 2
4943Const FRAME_NONFPO = 3
4944
4945Type FPO_DATA
4946    ulOffStart As DWord
4947    cbProcSize As DWord
4948    cdwLocals As DWord
4949    cdwParams As Word
4950    dummy As Word
4951'   cbProlog : 8 As Word
4952'   cbRegs   : 3 As Word
4953'   fHasSEH  : 1 As Word
4954'   fUseBP   : 1 As Word
4955'   reserved : 1 As Word
4956'   cbFrame  : 2 As Word
4957End Type
4958TypeDef PFPO_DATA = *FPO_DATA
4959Const SIZEOF_RFPO_DATA = 16
4960
4961Const IMAGE_DEBUG_MISC_EXENAME = 1
4962
4963Type IMAGE_DEBUG_MISC
4964    DataType As DWord
4965    Length As DWord
4966    Unicode As BOOLEAN
4967    Reserved[ELM(3)] As Byte
4968    Data[ELM(1)] As Byte
4969End Type
4970TypeDef PIMAGE_DEBUG_MISC = *IMAGE_DEBUG_MISC
4971
4972Type IMAGE_FUNCTION_ENTRY
4973    StartingAddress As DWord
4974    EndingAddress As DWord
4975    EndOfPrologue As DWord
4976End Type
4977TypeDef PIMAGE_FUNCTION_ENTRY = *IMAGE_FUNCTION_ENTRY
4978
4979Type IMAGE_FUNCTION_ENTRY64
4980    StartingAddress As QWord
4981    EndingAddress As QWord
4982'   Union
4983        EndOfPrologue As QWord
4984'       UnwindInfoAddress As QWord
4985'End Union
4986End Type
4987TypeDef PIMAGE_FUNCTION_ENTRY64 = *IMAGE_FUNCTION_ENTRY64
4988
4989Type IMAGE_SEPARATE_DEBUG_HEADER
4990    Signature As Word
4991    Flags As Word
4992    Machine As Word
4993    Characteristics As Word
4994    TimeDateStamp As DWord
4995    CheckSum As DWord
4996    ImageBase As DWord
4997    SizeOfImage As DWord
4998    NumberOfSections As DWord
4999    ExportedNamesSize As DWord
5000    DebugDirectorySize As DWord
5001    SectionAlignment As DWord
5002    Reserved[ELM(2)] As DWord
5003End Type
5004TypeDef PIMAGE_SEPARATE_DEBUG_HEADER = *IMAGE_SEPARATE_DEBUG_HEADER
5005
5006Type NON_PAGED_DEBUG_INFO
5007    Signature As Word
5008    Flags As Word
5009    Size As DWord
5010    Machine As Word
5011    Characteristics As Word
5012    TimeDateStamp As DWord
5013    CheckSum As DWord
5014    SizeOfImage As DWord
5015    ImageBase As QWord
5016End Type
5017TypeDef PNON_PAGED_DEBUG_INFO = *NON_PAGED_DEBUG_INFO
5018
5019Const IMAGE_SEPARATE_DEBUG_SIGNATURE = &h4449 'DI
5020Const NON_PAGED_DEBUG_SIGNATURE = &h4E49 ' NI
5021
5022Const IMAGE_SEPARATE_DEBUG_FLAGS_MASK = &h8000
5023Const IMAGE_SEPARATE_DEBUG_MISMATCH = &h8000
5024
5025Type IMAGE_ARCHITECTURE_HEADER
5026    AmaskValue As Byte
5027'   AmaskValue: 1 As DWord
5028'   : 7 As Long
5029    AmaskShift As Byte
5030'   AmaskShift: 8 As DWord
5031    dummy As Word
5032'   : 16 As Long
5033    FirstEntryRVA As DWord
5034End Type
5035TypeDef PIMAGE_ARCHITECTURE_HEADER = *IMAGE_ARCHITECTURE_HEADER
5036
5037Type IMAGE_ARCHITECTURE_ENTRY
5038    FixupInstRVA As DWord
5039    NewInst As DWord
5040End Type
5041TypeDef PIMAGE_ARCHITECTURE_ENTRY = *IMAGE_ARCHITECTURE_ENTRY
5042
5043Const IMPORT_OBJECT_HDR_SIG2 = &hffff
5044
5045Type IMPORT_OBJECT_HEADER
5046    Sig1 As Word
5047    Sig2 As Word
5048    Version As Word
5049    Machine As Word
5050    TimeDateStamp As DWord
5051    SizeOfData As DWord
5052
5053'   Union
5054        Ordinal As Word
5055'       Hint As Word
5056'   End Union
5057
5058    Reserved As Word
5059'   Type : 2 As Word
5060'   NameType : 3 As Word
5061'   Reserved : 11 As Word
5062End Type
5063
5064Enum IMPORT_OBJECT_TYPE
5065    IMPORT_OBJECT_CODE = 0
5066    IMPORT_OBJECT_DATA = 1
5067    IMPORT_OBJECT_CONST = 2
5068End Enum
5069
5070Enum IMPORT_OBJECT_NAME_TYPE
5071    IMPORT_OBJECT_ORDINAL = 0
5072    IMPORT_OBJECT_NAME = 1
5073    IMPORT_OBJECT_NAME_NO_PREFIX = 2
5074    IMPORT_OBJECT_NAME_UNDECORATE = 3
5075End Enum
5076
5077#ifndef __IMAGE_COR20_HEADER_DEFINED__
5078#define __IMAGE_COR20_HEADER_DEFINED__
5079
5080Enum ReplacesCorHdrNumericDefines
5081' COM+ Header entry point flags.
5082    COMIMAGE_FLAGS_ILONLY               = &h00000001
5083    COMIMAGE_FLAGS_32BITREQUIRED        = &h00000002
5084    COMIMAGE_FLAGS_IL_LIBRARY           = &h00000004
5085    COMIMAGE_FLAGS_STRONGNAMESIGNED     = &h00000008
5086    COMIMAGE_FLAGS_TRACKDEBUGDATA       = &h00010000
5087' Version flags for image.
5088    COR_VERSION_MAJOR_V2                = 2
5089    COR_VERSION_MAJOR                   = COR_VERSION_MAJOR_V2
5090    COR_VERSION_MINOR                   = 0
5091    COR_DELETED_NAME_LENGTH             = 8
5092    COR_VTABLEGAP_NAME_LENGTH           = 8
5093' Maximum size of a NativeType descriptor.
5094    NATIVE_TYPE_MAX_CB                  = 1
5095    COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE= &hFF
5096' Consts for the MIH FLAGS
5097    IMAGE_COR_MIH_METHODRVA             = &h01
5098    IMAGE_COR_MIH_EHRVA                 = &h02
5099    IMAGE_COR_MIH_BASICBLOCK            = &h08
5100' V-table constants
5101    COR_VTABLE_32BIT                    = &h01          ' V-table slots are 32-bits in size.
5102    COR_VTABLE_64BIT                    = &h02          ' V-table slots are 64-bits in size.
5103    COR_VTABLE_FROM_UNMANAGED           = &h04          ' If set, transition from unmanaged.
5104    COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN  = &h08  ' If set, transition from unmanaged with keeping the current appdomain.
5105    COR_VTABLE_CALL_MOST_DERIVED        = &h10          ' Call most derived method described by
5106' EATJ constants
5107    IMAGE_COR_EATJ_THUNK_SIZE           = 32            ' Size of a jump thunk reserved range.
5108' Max name lengths
5109    '@todo: Change to unlimited name lengths.
5110    MAX_CLASS_NAME                      = 1024
5111    MAX_PACKAGE_NAME                    = 1024
5112End Enum
5113
5114' CLR 2.0 header structure.
5115Type IMAGE_COR20_HEADER
5116    ' Header versioning
5117    cb As DWord
5118    MajorRuntimeVersion As Word
5119    MinorRuntimeVersion As Word
5120    ' Symbol table and startup information
5121    MetaData As IMAGE_DATA_DIRECTORY
5122    Flags As DWord
5123    EntryPointToken As DWord
5124    ' Binding information
5125    Resources As IMAGE_DATA_DIRECTORY
5126    StrongNameSignature As IMAGE_DATA_DIRECTORY
5127    ' Regular fixup and binding information
5128    CodeManagerTable As IMAGE_DATA_DIRECTORY
5129    VTableFixups As IMAGE_DATA_DIRECTORY
5130    ExportAddressTableJumps As IMAGE_DATA_DIRECTORY
5131    ' Precompiled image info (internal use only - set to zero)
5132    ManagedNativeHeader As IMAGE_DATA_DIRECTORY
5133End Type
5134TypeDef PIMAGE_COR20_HEADER = *IMAGE_COR20_HEADER
5135
5136#endif
5137
5138#ifdef _WIN64
5139Type Align(16) SLIST_ENTRY
5140    Next_ As *SLIST_ENTRY
5141End Type
5142TypeDef PSLIST_ENTRY = *SLIST_ENTRY
5143#else
5144TypeDef SLIST_ENTRY = SINGLE_LIST_ENTRY
5145'TypeDef _SLIST_ENTRY = _SINGLE_LIST_ENTRY
5146TypeDef PSLIST_ENTRY = PSINGLE_LIST_ENTRY
5147#endif
5148
5149#ifdef _WIN64
5150
5151Type /*Union*/ Align(16) SLIST_HEADER
5152'   Type ' original struct
5153        Alignment As QWord
5154        Region As QWord
5155'   End Type
5156'   Type ' 8-byte header
5157'       Depth:16 As QWord
5158'       Sequence:9 As QWord
5159'       NextEntry:39 As QWord
5160'       HeaderType:1 As QWord ' 0: 8-byte As QWord 1: 16-byte
5161'       Init:1 As QWord       ' 0: uninitialized As QWord 1: initialized
5162'       Reserved:59 As QWord
5163'       Region:3 As QWord
5164'   } Header8
5165'   Type ' 16-byte header
5166'       Depth:16 As QWord
5167'       Sequence:48 As QWord
5168'       HeaderType:1 As QWord ' 0: 8-byte As QWord 1: 16-byte
5169'       Init:1 As QWord       ' 0: uninitialized As QWord 1: initialized
5170'       Reserved:2 As QWord
5171'       NextEntry:60 As QWord ' last 4 bits are always 0's
5172'   } Header16
5173End Type 'Union
5174TypeDef PSLIST_HEADER = *SLIST_HEADER
5175
5176#else
5177
5178Type /*Union*/ SLIST_HEADER
5179'   Alignment As QWord
5180'   Type
5181        Next_ As SLIST_ENTRY
5182        Depth As Word
5183        Sequence As Word
5184'   End Type
5185End Type 'Union
5186TypeDef PSLIST_HEADER = *SLIST_HEADER
5187
5188#endif
5189
5190
5191Declare Sub RtlInitializeSListHead Lib "kernel32" (/*IN*/ ByRef ListHead As SLIST_HEADER)
5192Declare Function RtlFirstEntrySList Lib "kernel32" (/*IN*/ ByRef ListHead As /*Const*/ SLIST_HEADER) As PSLIST_ENTRY
5193Declare Function RtlInterlockedPopEntrySList Lib "kernel32" (/*IN*/ ByRef ListHead As SLIST_HEADER) As PSLIST_ENTRY
5194Declare Function RtlInterlockedPushEntrySList Lib "kernel32" (/*IN*/ ByRef ListHead As SLIST_HEADER, /*IN*/ ListEntry As PSLIST_ENTRY) As PSLIST_ENTRY
5195Declare Function RtlInterlockedFlushSList Lib "kernel32" (/*IN*/ ByRef ListHead As SLIST_HEADER) As PSLIST_ENTRY
5196Declare Function RtlQueryDepthSList Lib "kernel32" (/*IN*/ ByRef ListHead As SLIST_HEADER) As Word
5197
5198'Const RTL_RUN_ONCE_INIT {0} 'Static initializer
5199
5200Const RTL_RUN_ONCE_CHECK_ONLY = &h00000001
5201Const RTL_RUN_ONCE_ASYNC = &h00000002
5202Const RTL_RUN_ONCE_INIT_FAILED = &h00000004
5203
5204Const RTL_RUN_ONCE_CTX_RESERVED_BITS = 2
5205
5206Type /*Union*/ RTL_RUN_ONCE
5207    Ptr As VoidPtr
5208End Type 'Union
5209TypeDef PRTL_RUN_ONCE = *RTL_RUN_ONCE
5210
5211TypeDef PRTL_RUN_ONCE_INIT_FN = *Function(ByRef RunOnce As RTL_RUN_ONCE, Parameter As VoidPtr, ByRef Context As VoidPtr) As DWord'LOGICAL
5212
5213Declare Sub RtlRunOnceInitialize Lib "kernel32" (ByRef RunOnce As RTL_RUN_ONCE)
5214Declare Function RtlRunOnceExecuteOnce Lib "kernel32" (ByRef RunOnce As RTL_RUN_ONCE, InitFn As PRTL_RUN_ONCE_INIT_FN, Parameter As PVOID, ByRef Context As PVOID) As DWord
5215Declare Function RtlRunOnceBeginInitialize Lib "kernel32" (ByRef RunOnce As RTL_RUN_ONCE, Flags As DWord, ByRef Context As PVOID) As DWord
5216Declare Function RtlRunOnceComplete Lib "kernel32" (ByRef RunOnce As RTL_RUN_ONCE, Flags As DWord, Context As PVOID) As DWord
5217
5218Const HEAP_NO_SERIALIZE = &h00000001
5219Const HEAP_GROWABLE = &h00000002
5220Const HEAP_GENERATE_EXCEPTIONS = &h00000004
5221Const HEAP_ZERO_MEMORY = &h00000008
5222Const HEAP_REALLOC_IN_PLACE_ONLY = &h00000010
5223Const HEAP_TAIL_CHECKING_ENABLED = &h00000020
5224Const HEAP_FREE_CHECKING_ENABLED = &h00000040
5225Const HEAP_DISABLE_COALESCE_ON_FREE = &h00000080
5226Const HEAP_CREATE_ALIGN_16 = &h00010000
5227Const HEAP_CREATE_ENABLE_TRACING = &h00020000
5228Const HEAP_CREATE_ENABLE_EXECUTE = &h00040000
5229Const HEAP_MAXIMUM_TAG = &h0FFF
5230Const HEAP_PSEUDO_TAG_FLAG = &h8000
5231Const HEAP_TAG_SHIFT = 18
5232
5233Const HEAP_MAKE_TAG_FLAGS (TagBase /*As DWord*/, Tag /*As DWord*/) /*As DWord*/ = (((TagBase) + ((Tag) << HEAP_TAG_SHIFT)) As DWord)
5234
5235'#if (NTDDI_VERSION > NTDDI_WINXP)
5236'Declare Function RtlCaptureStackBackTrace Lib "kernel32" (FramesToSkip As DWord, FramesToCapture A sDWord, ByRef BackTrace As PVOID, BackTraceHash As *DWord) As Word
5237'#endif
5238
5239'#if (NTDDI_VERSION > NTDDI_WIN2K)
5240'Declare Sub RtlCaptureContext Lib "kernel32" (ByRef ContextRecord As CONTEXT)
5241'#endif
5242
5243Const IS_TEXT_UNICODE_ASCII16 = &h0001
5244Const IS_TEXT_UNICODE_REVERSE_ASCII16 = &h0010
5245
5246Const IS_TEXT_UNICODE_STATISTICS = &h0002
5247Const IS_TEXT_UNICODE_REVERSE_STATISTICS = &h0020
5248
5249Const IS_TEXT_UNICODE_CONTROLS = &h0004
5250Const IS_TEXT_UNICODE_REVERSE_CONTROLS = &h0040
5251
5252Const IS_TEXT_UNICODE_SIGNATURE = &h0008
5253Const IS_TEXT_UNICODE_REVERSE_SIGNATURE = &h0080
5254
5255Const IS_TEXT_UNICODE_ILLEGAL_CHARS = &h0100
5256Const IS_TEXT_UNICODE_ODD_LENGTH = &h0200
5257Const IS_TEXT_UNICODE_DBCS_LEADBYTE = &h0400
5258Const IS_TEXT_UNICODE_NULL_BYTES = &h1000
5259
5260Const IS_TEXT_UNICODE_UNICODE_MASK = &h000F
5261Const IS_TEXT_UNICODE_REVERSE_MASK = &h00F0
5262Const IS_TEXT_UNICODE_NOT_UNICODE_MASK = &h0F00
5263Const IS_TEXT_UNICODE_NOT_ASCII_MASK = &hF000
5264
5265Const COMPRESSION_FORMAT_NONE = &h0000
5266Const COMPRESSION_FORMAT_DEFAULT = &h0001
5267Const COMPRESSION_FORMAT_LZNT1 = &h0002
5268Const COMPRESSION_ENGINE_STANDARD = &h0000
5269Const COMPRESSION_ENGINE_MAXIMUM = &h0100
5270Const COMPRESSION_ENGINE_HIBER = &h0200
5271
5272'#if _DBG_MEMCPY_INLINE_ && !defined(MIDL_PASS) && !defined(_MEMCPY_INLINE_) && !defined(_CRTBLD)
5273'#define _MEMCPY_INLINE_
5274/*
5275FORCEINLINE
5276PVOID
5277__cdecl
5278memcpy_inline (
5279    void *dst,
5280    const void *src,
5281    size_t size
5282    )
5283{
5284    if (((char *)dst > (char *)src) &&
5285        ((char *)dst < ((char *)src + size))) {
5286        __debugbreak();
5287    }
5288    return memcpy(dst, src, size);
5289}
5290Const memcpy memcpy_inline
5291*/
5292'#endif
5293
5294'#if (NTDDI_VERSION >= NTDDI_WIN2K)
5295'Declare Function RtlCompareMemory Lib "kernel32" (Source1 As VoidPtr, Source2 As VoidPtr, Length As SIZE_T) As SIZE_T
5296'#endif
5297/*
5298Const RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
5299Const RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
5300Const RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
5301Const RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
5302Const RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
5303*/
5304Function RtlSecureZeroMemory(ptr As VoidPtr, cnt As SIZE_T) As VoidPtr
5305    Dim vptr = ptr As * /*Volatile*/ Byte
5306#ifdef _WIN64
5307    FillMemory(vptr, cnt, 0)
5308#else
5309
5310    While (cnt > 0)
5311        vptr = 0
5312        vptr++
5313        cnt--
5314    Wend
5315#endif
5316    RtlSecureZeroMemory = ptr
5317End Function
5318
5319Const SEF_DACL_AUTO_INHERIT = &h01
5320Const SEF_SACL_AUTO_INHERIT = &h02
5321Const SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT = &h04
5322Const SEF_AVOID_PRIVILEGE_CHECK = &h08
5323Const SEF_AVOID_OWNER_CHECK = &h10
5324Const SEF_DEFAULT_OWNER_FROM_PARENT = &h20
5325Const SEF_DEFAULT_GROUP_FROM_PARENT = &h40
5326Const SEF_MACL_NO_WRITE_UP = &h100
5327Const SEF_MACL_NO_READ_UP = &h200
5328Const SEF_MACL_NO_EXECUTE_UP = &h400
5329Const SEF_AVOID_OWNER_RESTRICTION = &h1000
5330
5331Const SEF_MACL_VALID_FLAGS = (SEF_MACL_NO_WRITE_UP OR SEF_MACL_NO_READ_UP Or SEF_MACL_NO_EXECUTE_UP)
5332
5333Type MESSAGE_RESOURCE_ENTRY
5334    Length As Word
5335    Flags As Word
5336    Text[ELM(1)] As Byte
5337End Type
5338TypeDef PMESSAGE_RESOURCE_ENTRY = *MESSAGE_RESOURCE_ENTRY
5339
5340Const MESSAGE_RESOURCE_UNICODE = &h0001
5341
5342Type MESSAGE_RESOURCE_BLOCK
5343    LowId As DWord
5344    HighId As DWord
5345    OffsetToEntries As DWord
5346End Type
5347TypeDef PMESSAGE_RESOURCE_BLOCK = *MESSAGE_RESOURCE_BLOCK
5348
5349Type MESSAGE_RESOURCE_DATA
5350    NumberOfBlocks As DWord
5351    Blocks[ELM(1)] As MESSAGE_RESOURCE_BLOCK
5352End Type
5353TypeDef PMESSAGE_RESOURCE_DATA = *MESSAGE_RESOURCE_DATA
5354
5355Type OSVERSIONINFOA
5356    dwOSVersionInfoSize As DWord
5357    dwMajorVersion As DWord
5358    dwMinorVersion As DWord
5359    dwBuildNumber As DWord
5360    dwPlatformId As DWord
5361    szCSDVersion[ELM(128)] As CHAR
5362End Type
5363TypeDef POSVERSIONINFOA = *OSVERSIONINFOA
5364TypeDef LPOSVERSIONINFOA = *OSVERSIONINFOA
5365Type OSVERSIONINFOW
5366    dwOSVersionInfoSize As DWord
5367    dwMajorVersion As DWord
5368    dwMinorVersion As DWord
5369    dwBuildNumber As DWord
5370    dwPlatformId As DWord
5371    szCSDVersion[ELM(128)] As WCHAR
5372End Type
5373TypeDef POSVERSIONINFOW = *OSVERSIONINFOW
5374TypeDef LPOSVERSIONINFOW = *OSVERSIONINFOW
5375TypeDef RTL_OSVERSIONINFOW = OSVERSIONINFOW
5376TypeDef PRTL_OSVERSIONINFOW = *OSVERSIONINFOW
5377#ifdef UNICODE
5378TypeDef OSVERSIONINFO = OSVERSIONINFOW
5379TypeDef POSVERSIONINFO = POSVERSIONINFOW
5380TypeDef LPOSVERSIONINFO = LPOSVERSIONINFOW
5381#else
5382TypeDef OSVERSIONINFO = OSVERSIONINFOA
5383TypeDef POSVERSIONINFO = POSVERSIONINFOA
5384TypeDef LPOSVERSIONINFO = LPOSVERSIONINFOA
5385#endif
5386Type OSVERSIONINFOEXA
5387    dwOSVersionInfoSize As DWord
5388    dwMajorVersion As DWord
5389    dwMinorVersion As DWord
5390    dwBuildNumber As DWord
5391    dwPlatformId As DWord
5392    szCSDVersion[ELM(128)] As CHAR
5393    wServicePackMajor As Word
5394    wServicePackMinor As Word
5395    wSuiteMask As Word
5396    wProductType As Byte
5397    wReserved As Byte
5398End Type
5399TypeDef POSVERSIONINFOEXA = *OSVERSIONINFOEXA
5400TypeDef LPOSVERSIONINFOEXA = *OSVERSIONINFOEXA
5401Type OSVERSIONINFOEXW
5402    dwOSVersionInfoSize As DWord
5403    dwMajorVersion As DWord
5404    dwMinorVersion As DWord
5405    dwBuildNumber As DWord
5406    dwPlatformId As DWord
5407    szCSDVersion[ELM(128)] As WCHAR
5408    wServicePackMajor As Word
5409    wServicePackMinor As Word
5410    wSuiteMask As Word
5411    wProductType As Byte
5412    wReserved As Byte
5413End Type
5414TypeDef POSVERSIONINFOEXW = *OSVERSIONINFOEXW
5415TypeDef LPOSVERSIONINFOEXW = *OSVERSIONINFOEXW
5416TypeDef RTL_OSVERSIONINFOEXW = OSVERSIONINFOEXW
5417TypeDef PRTL_OSVERSIONINFOEXW = *OSVERSIONINFOEXW
5418#ifdef UNICODE
5419TypeDef OSVERSIONINFOEX = OSVERSIONINFOEXW
5420TypeDef POSVERSIONINFOEX = POSVERSIONINFOEXW
5421TypeDef LPOSVERSIONINFOEX = LPOSVERSIONINFOEXW
5422#else
5423TypeDef OSVERSIONINFOEX = OSVERSIONINFOEXA
5424TypeDef POSVERSIONINFOEX = POSVERSIONINFOEXA
5425TypeDef LPOSVERSIONINFOEX = LPOSVERSIONINFOEXA
5426#endif
5427
5428' RtlVerifyVersionInfo() conditions
5429Const VER_EQUAL = 1
5430Const VER_GREATER = 2
5431Const VER_GREATER_EQUAL = 3
5432Const VER_LESS = 4
5433Const VER_LESS_EQUAL = 5
5434Const VER_AND = 6
5435Const VER_OR = 7
5436
5437Const VER_CONDITION_MASK = 7
5438Const VER_NUM_BITS_PER_CONDITION_MASK = 3
5439
5440' RtlVerifyVersionInfo() type mask bits
5441Const VER_MINORVERSION = 0000001
5442Const VER_MAJORVERSION = 0000002
5443Const VER_BUILDNUMBER = 0000004
5444Const VER_PLATFORMID = 0000008
5445Const VER_SERVICEPACKMINOR = 0000010
5446Const VER_SERVICEPACKMAJOR = 0000020
5447Const VER_SUITENAME = 0000040
5448Const VER_PRODUCT_TYPE = 0000080
5449
5450' RtlVerifyVersionInfo() os product type values
5451Const VER_NT_WORKSTATION = 0000001
5452Const VER_NT_DOMAIN_CONTROLLER = 0000002
5453Const VER_NT_SERVER = 0000003
5454
5455' dwPlatformId defines:
5456Const VER_PLATFORM_WIN32s        = 0
5457Const VER_PLATFORM_WIN32_WINDOWS = 1
5458Const VER_PLATFORM_WIN32_NT      = 2
5459Const VER_PLATFORM_WIN32_CE      = 3
5460
5461' VerifyVersionInfo() macro to set the condition mask
5462' VER_SET_CONDITION
5463
5464'#if (NTDDI_VERSION >= NTDDI_WIN2K)
5465'Declare Function VerSetConditionMask Lib "kernel32" (ConditionMask As QWord, TypeMask As DWord, Condition As Byte) As QWord
5466'#endif
5467
5468'#if (NTDDI_VERSION >= NTDDI_LONGHORN)
5469'Declare Function RtlGetProductInfo Lib "kernel32" (OSMajorVersion As DWord, OSMinorVersion As DWord, SpMajorVersion As DWord, SpMinorVersion As DWord, ByRef ReturnedProductType As DWord) As BOOLEAN
5470'#endif
5471
5472Type RTL_CRITICAL_SECTION_DEBUG
5473    Type_ As Word
5474    CreatorBackTraceIndex As Word
5475    CriticalSection As VoidPtr '!*RTL_CRITICAL_SECTION
5476    ProcessLocksList As LIST_ENTRY
5477    EntryCount As DWord
5478    ContentionCount As DWord
5479    Flags As DWord
5480    CreatorBackTraceIndexHigh As Word
5481    SpareWORD As Word
5482End Type
5483TypeDef PRTL_CRITICAL_SECTION_DEBUG = *RTL_CRITICAL_SECTION_DEBUG
5484TypeDef RTL_RESOURCE_DEBUG = RTL_CRITICAL_SECTION_DEBUG
5485TypeDef PRTL_RESOURCE_DEBUG = *RTL_RESOURCE_DEBUG
5486
5487Const RTL_CRITSECT_TYPE = 0
5488Const RTL_RESOURCE_TYPE = 1
5489
5490Const RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO = &h01000000
5491Const RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN = &h02000000
5492Const RTL_CRITICAL_SECTION_FLAG_STATIC_INIT = &h04000000
5493Const RTL_CRITICAL_SECTION_ALL_FLAG_BITS = &hFF000000
5494Const RTL_CRITICAL_SECTION_FLAG_RESERVED = (RTL_CRITICAL_SECTION_ALL_FLAG_BITS And (Not (RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO Or RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN Or RTL_CRITICAL_SECTION_FLAG_STATIC_INIT)))
5495
5496Const RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT = &h00000001
5497
5498Type Align(8) RTL_CRITICAL_SECTION
5499     DebugInfo As PRTL_CRITICAL_SECTION_DEBUG
5500    LockCount As Long
5501    RecursionCount As Long
5502    OwningThread As HANDLE
5503    LockSemaphore As HANDLE
5504    SpinCount As ULONG_PTR
5505End Type
5506TypeDef PRTL_CRITICAL_SECTION = *RTL_CRITICAL_SECTION
5507
5508Type RTL_SRWLOCK
5509    Ptr As VoidPtr
5510End Type
5511TypeDef PRTL_SRWLOCK = *RTL_SRWLOCK
5512'Const RTL_SRWLOCK_INIT {0}
5513Type RTL_CONDITION_VARIABLE
5514    Ptr As VoidPtr
5515End Type
5516TypeDef PRTL_CONDITION_VARIABLE = *RTL_CONDITION_VARIABLE
5517'Const RTL_CONDITION_VARIABLE_INIT {0}
5518Const RTL_CONDITION_VARIABLE_LOCKMODE_SHARED = &h1
5519TypeDef PVECTORED_EXCEPTION_HANDLER = *Function(ByRef ExceptionInfo As EXCEPTION_POINTERS) As Long
5520
5521Enum HEAP_INFORMATION_CLASS
5522    HeapCompatibilityInformation
5523    HeapEnableTerminationOnCorruption
5524End Enum
5525
5526Const WT_EXECUTEDEFAULT = &h00000000
5527Const WT_EXECUTEINIOTHREAD = &h00000001
5528Const WT_EXECUTEINUITHREAD = &h00000002
5529Const WT_EXECUTEINWAITTHREAD = &h00000004
5530Const WT_EXECUTEONLYONCE = &h00000008
5531Const WT_EXECUTEINTIMERTHREAD = &h00000020
5532Const WT_EXECUTELONGFUNCTION = &h00000010
5533Const WT_EXECUTEINPERSISTENTIOTHREAD = &h00000040
5534Const WT_EXECUTEINPERSISTENTTHREAD = &h00000080
5535Const WT_TRANSFER_IMPERSONATION = &h00000100
5536'Const WT_SET_MAX_THREADPOOL_THREADS(Flags, Limit)  ((Flags) Or= (Limit)<<16)
5537TypeDef WAITORTIMERCALLBACKFUNC = *Sub(p As VoidPtr, b As Boolean)
5538TypeDef WORKERCALLBACKFUNC = *Sub(p As VoidPtr)
5539TypeDef APC_CALLBACK_FUNCTION = *Sub(dw AS DWord, p1 As VoidPtr, p2 As VoidPtr)
5540TypeDef PFLS_CALLBACK_FUNCTION = *Sub(lpFlsData As VoidPtr)
5541Const WT_EXECUTEINLONGTHREAD = &h00000010
5542Const WT_EXECUTEDELETEWAIT = &h00000008
5543
5544Enum ACTIVATION_CONTEXT_INFO_CLASS
5545    ActivationContextBasicInformation = 1
5546    ActivationContextDetailedInformation = 2
5547    AssemblyDetailedInformationInActivationContext = 3
5548    FileInformationInAssemblyOfAssemblyInActivationContext = 4
5549    RunlevelInformationInActivationContext = 5
5550    MaxActivationContextInfoClass
5551    ' compatibility with old names
5552    AssemblyDetailedInformationInActivationContxt = 3
5553    FileInformationInAssemblyOfAssemblyInActivationContxt = 4
5554End Enum
5555
5556TypeDef ACTIVATIONCONTEXTINFOCLASS = ACTIVATION_CONTEXT_INFO_CLASS
5557
5558Type ACTIVATION_CONTEXT_QUERY_INDEX
5559    ulAssemblyIndex As DWord
5560    ulFileIndexInAssembly; As DWord
5561End Type
5562TypeDef PACTIVATION_CONTEXT_QUERY_INDEX = *ACTIVATION_CONTEXT_QUERY_INDEX
5563
5564TypeDef PCACTIVATION_CONTEXT_QUERY_INDEX = * /*Const*/ ACTIVATION_CONTEXT_QUERY_INDEX
5565
5566Const ACTIVATION_CONTEXT_PATH_TYPE_NONE = 1
5567Const ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE = 2
5568Const ACTIVATION_CONTEXT_PATH_TYPE_URL = 3
5569Const ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF = 4
5570
5571Type ASSEMBLY_FILE_DETAILED_INFORMATION
5572    ulFlags As DWord
5573    ulFilenameLength As PCWSTR
5574    ulPathLength As PCWSTR
5575    lpFileName As PCWSTR
5576    lpFilePath As PCWSTR
5577End Type
5578TypeDef PASSEMBLY_FILE_DETAILED_INFORMATION = *ASSEMBLY_FILE_DETAILED_INFORMATION
5579TypeDef PCASSEMBLY_FILE_DETAILED_INFORMATION = * /*Const*/ ASSEMBLY_FILE_DETAILED_INFORMATION
5580
5581' compatibility with old names
5582TypeDef  _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION =  ASSEMBLY_FILE_DETAILED_INFORMATION
5583TypeDef   ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION =  ASSEMBLY_FILE_DETAILED_INFORMATION
5584TypeDef  PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION =  PASSEMBLY_FILE_DETAILED_INFORMATION
5585TypeDef PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = PCASSEMBLY_FILE_DETAILED_INFORMATION
5586
5587Type ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
5588    ulFlags As DWord
5589    ulEncodedAssemblyIdentityLength As DWord
5590    ulManifestPathType As DWord
5591    liManifestLastWriteTime As LARGE_INTEGER
5592    ulPolicyPathType As DWord
5593    ulPolicyPathLength As DWord
5594    liPolicyLastWriteTime As LARGE_INTEGER
5595    ulMetadataSatelliteRosterIndex As DWord
5596    ulManifestVersionMajor As DWord
5597    ulManifestVersionMinor As DWord
5598    ulPolicyVersionMajor As DWord
5599    ulPolicyVersionMinor As DWord
5600    ulAssemblyDirectoryNameLength As DWord
5601    lpAssemblyEncodedAssemblyIdentity As PCWSTR
5602    lpAssemblyManifestPath As PCWSTR
5603    lpAssemblyPolicyPath As PCWSTR
5604    lpAssemblyDirectoryName As PCWSTR
5605    ulFileCount As DWord
5606End Type
5607TypeDef PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = *ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
5608TypeDef PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = * /*Const*/ ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
5609
5610Enum ACTCTX_REQUESTED_RUN_LEVEL
5611    ACTCTX_RUN_LEVEL_UNSPECIFIED = 0
5612    ACTCTX_RUN_LEVEL_AS_INVOKER
5613    ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE
5614    ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
5615    ACTCTX_RUN_LEVEL_NUMBERS
5616End Enum
5617
5618Type ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
5619    ulFlags As DWord
5620    RunLevel As ACTCTX_REQUESTED_RUN_LEVEL
5621    UiAccess As DWord
5622End Type
5623TypeDef PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION = ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
5624TypeDef PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION = * /*Const*/ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
5625
5626Type ACTIVATION_CONTEXT_DETAILED_INFORMATION
5627    dwFlags As DWord
5628    ulFormatVersion As DWord
5629    ulAssemblyCount As DWord
5630    ulRootManifestPathType As DWord
5631    ulRootManifestPathChars As DWord
5632    ulRootConfigurationPathType As DWord
5633    ulRootConfigurationPathChars As DWord
5634    ulAppDirPathType As DWord
5635    ulAppDirPathChars As DWord
5636    lpRootManifestPath As PCWSTR
5637    lpRootConfigurationPath As PCWSTR
5638    lpAppDirPath As PCWSTR
5639End Type
5640TypeDef PACTIVATION_CONTEXT_DETAILED_INFORMATION = *ACTIVATION_CONTEXT_DETAILED_INFORMATION
5641TypeDef PCACTIVATION_CONTEXT_DETAILED_INFORMATION = * /*Const*/ ACTIVATION_CONTEXT_DETAILED_INFORMATION
5642
5643Const DLL_PROCESS_ATTACH = 1
5644Const DLL_THREAD_ATTACH = 2
5645Const DLL_THREAD_DETACH = 3
5646Const DLL_PROCESS_DETACH = 0
5647
5648Const EVENTLOG_SEQUENTIAL_READ = &h0001
5649Const EVENTLOG_SEEK_READ = &h0002
5650Const EVENTLOG_FORWARDS_READ = &h0004
5651Const EVENTLOG_BACKWARDS_READ = &h0008
5652
5653Const EVENTLOG_SUCCESS = &h0000
5654Const EVENTLOG_ERROR_TYPE = &h0001
5655Const EVENTLOG_WARNING_TYPE = &h0002
5656Const EVENTLOG_INFORMATION_TYPE = &h0004
5657Const EVENTLOG_AUDIT_SUCCESS = &h0008
5658Const EVENTLOG_AUDIT_FAILURE = &h0010
5659
5660Const EVENTLOG_START_PAIRED_EVENT = &h0001
5661Const EVENTLOG_END_PAIRED_EVENT = &h0002
5662Const EVENTLOG_END_ALL_PAIRED_EVENTS = &h0004
5663Const EVENTLOG_PAIRED_EVENT_ACTIVE = &h0008
5664Const EVENTLOG_PAIRED_EVENT_INACTIVE = &h0010
5665
5666Type EVENTLOGRECORD
5667    Length As DWord
5668    Reserved As DWord
5669    RecordNumber As DWord
5670    TimeGenerated As DWord
5671    TimeWritten As DWord
5672    EventID As DWord
5673    EventType As Word
5674    NumStrings As Word
5675    EventCategory As Word
5676    ReservedFlags As Word
5677    ClosingRecordNumber As DWord
5678    StringOffset As DWord
5679    UserSidLength As DWord
5680    UserSidOffset As DWord
5681    DataLength As DWord
5682    DataOffset As DWord
5683    ' Then follow:
5684    ' WCHAR SourceName[]
5685    ' WCHAR Computername[]
5686    ' SID   UserSid
5687    ' WCHAR Strings[]
5688    ' BYTE  Data[]
5689    ' CHAR  Pad[]
5690    ' DWORD Length;
5691End Type
5692TypeDef PEVENTLOGRECORD = *EVENTLOGRECORD
5693
5694Const MAXLOGICALLOGNAMESIZE = 256
5695
5696Type EVENTSFORLOGFILE
5697    ulSize As DWord
5698    szLogicalLogFile[ELM(MAXLOGICALLOGNAMESIZE)] As WCHAR
5699    ulNumRecords As DWord
5700    pEventLogRecords[ELM(ANYSIZE_ARRAY)] As EVENTLOGRECORD 'pEventLogRecords[] As EVENTLOGRECORD
5701End Type
5702TypeDef PEVENTSFORLOGFILE = *EVENTSFORLOGFILE
5703
5704Type PACKEDEVENTINFO
5705    ulSize As DWord
5706    ulNumEventsForLogFile As DWord
5707    ulOffsets[ELM(ANYSIZE_ARRAY)] As DWord 'ulOffsets[] As DWord
5708End Type
5709TypeDef PPACKEDEVENTINFO = *PACKEDEVENTINFO
5710
5711Const KEY_QUERY_VALUE = &h0001
5712Const KEY_SET_VALUE = &h0002
5713Const KEY_CREATE_SUB_KEY = &h0004
5714Const KEY_ENUMERATE_SUB_KEYS = &h0008
5715Const KEY_NOTIFY = &h0010
5716Const KEY_CREATE_LINK = &h0020
5717Const KEY_WOW64_32KEY = &h0200
5718Const KEY_WOW64_64KEY = &h0100
5719Const KEY_WOW64_RES = &h0300
5720Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
5721Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
5722Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))
5723Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
5724Const REG_OPTION_RESERVED = &h00000000
5725Const REG_OPTION_NON_VOLATILE = &h00000000
5726Const REG_OPTION_VOLATILE = &h00000001
5727Const REG_OPTION_CREATE_LINK = &h00000002
5728Const REG_OPTION_BACKUP_RESTORE = &h00000004
5729Const REG_OPTION_OPEN_LINK = &h00000008
5730Const REG_LEGAL_OPTION = (REG_OPTION_RESERVED Or REG_OPTION_NON_VOLATILE Or REG_OPTION_VOLATILE Or REG_OPTION_CREATE_LINK Or REG_OPTION_BACKUP_RESTORE Or REG_OPTION_OPEN_LINK)
5731Const REG_CREATED_NEW_KEY = &h00000001
5732Const REG_OPENED_EXISTING_KEY = &h00000002
5733
5734Const REG_STANDARD_FORMAT = 1
5735Const REG_LATEST_FORMAT = 2
5736Const REG_NO_COMPRESSION = 4
5737
5738Const REG_WHOLE_HIVE_VOLATILE = &h00000001
5739Const REG_REFRESH_HIVE = &h00000002
5740Const REG_NO_LAZY_FLUSH = &h00000004
5741Const REG_FORCE_RESTORE = &h00000008
5742Const REG_APP_HIVE = &h00000010
5743Const REG_PROCESS_PRIVATE = &h00000020
5744Const REG_START_JOURNAL = &h00000040
5745Const REG_HIVE_EXACT_FILE_GROWTH = &h00000080
5746Const REG_HIVE_NO_RM = &h00000100
5747Const REG_HIVE_SINGLE_LOG = &h00000200
5748
5749Const REG_FORCE_UNLOAD = 1
5750
5751Const REG_NOTIFY_CHANGE_NAME = &h00000001
5752Const REG_NOTIFY_CHANGE_ATTRIBUTES = &h00000002
5753Const REG_NOTIFY_CHANGE_LAST_SET = &h00000004
5754Const REG_NOTIFY_CHANGE_SECURITY = &h00000008
5755
5756Const REG_LEGAL_CHANGE_FILTER = (REG_NOTIFY_CHANGE_NAME Or REG_NOTIFY_CHANGE_ATTRIBUTES Or REG_NOTIFY_CHANGE_LAST_SET Or REG_NOTIFY_CHANGE_SECURITY)
5757
5758Const REG_NONE = 0
5759Const REG_SZ = 1
5760Const REG_EXPAND_SZ = 2
5761
5762Const REG_BINARY = 3
5763Const REG_DWORD = 4
5764Const REG_DWORD_LITTLE_ENDIAN = 4
5765Const REG_DWORD_BIG_ENDIAN = 5
5766Const REG_LINK = 6
5767Const REG_MULTI_SZ = 7
5768Const REG_RESOURCE_LIST = 8
5769Const REG_FULL_RESOURCE_DESCRIPTOR = 9
5770Const REG_RESOURCE_REQUIREMENTS_LIST = 10
5771Const REG_QWORD = 11
5772Const REG_QWORD_LITTLE_ENDIAN = 11
5773
5774Const SERVICE_KERNEL_DRIVER = &h00000001
5775Const SERVICE_FILE_SYSTEM_DRIVER = &h00000002
5776Const SERVICE_ADAPTER = &h00000004
5777Const SERVICE_RECOGNIZER_DRIVER = &h00000008
5778
5779Const SERVICE_DRIVER = (SERVICE_KERNEL_DRIVER Or SERVICE_FILE_SYSTEM_DRIVER Or SERVICE_RECOGNIZER_DRIVER)
5780
5781Const SERVICE_WIN32_OWN_PROCESS = &h00000010
5782Const SERVICE_WIN32_SHARE_PROCESS = &h00000020
5783Const SERVICE_WIN32 = (SERVICE_WIN32_OWN_PROCESS Or SERVICE_WIN32_SHARE_PROCESS)
5784
5785Const SERVICE_INTERACTIVE_PROCESS = &h00000100
5786
5787Const SERVICE_TYPE_ALL = (SERVICE_WIN32 Or SERVICE_ADAPTER Or SERVICE_DRIVER Or SERVICE_INTERACTIVE_PROCESS)
5788
5789Const SERVICE_BOOT_START = &h00000000
5790Const SERVICE_SYSTEM_START = &h00000001
5791Const SERVICE_AUTO_START = &h00000002
5792Const SERVICE_DEMAND_START = &h00000003
5793Const SERVICE_DISABLED = &h00000004
5794
5795Const SERVICE_ERROR_IGNORE = &h00000000
5796Const SERVICE_ERROR_NORMAL = &h00000001
5797Const SERVICE_ERROR_SEVERE = &h00000002
5798Const SERVICE_ERROR_CRITICAL = &h00000003
5799
5800Enum _SERVICE_NODE_TYPE
5801    DriverType = SERVICE_KERNEL_DRIVER
5802    FileSystemType = SERVICE_FILE_SYSTEM_DRIVER
5803    Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS
5804    Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS
5805    AdapterType = SERVICE_ADAPTER
5806    RecognizerType = SERVICE_RECOGNIZER_DRIVER
5807End Enum
5808
5809Enum SERVICE_LOAD_TYPE
5810    BootLoad = SERVICE_BOOT_START
5811    SystemLoad = SERVICE_SYSTEM_START
5812    AutoLoad = SERVICE_AUTO_START
5813    DemandLoad = SERVICE_DEMAND_START
5814    DisableLoad = SERVICE_DISABLED
5815End Enum
5816
5817Enum SERVICE_ERROR_TYPE
5818    IgnoreError = SERVICE_ERROR_IGNORE
5819    NormalError = SERVICE_ERROR_NORMAL
5820    SevereError = SERVICE_ERROR_SEVERE
5821    CriticalError = SERVICE_ERROR_CRITICAL
5822End Enum
5823
5824Const TAPE_ERASE_SHORT = 0
5825Const TAPE_ERASE_LONG = 1
5826
5827Type TAPE_ERASE
5828    Type_ As DWord
5829    Immediate As BOOLEAN
5830End Type
5831TypeDef PTAPE_ERASE = *TAPE_ERASE
5832
5833Const TAPE_LOAD = 0
5834Const TAPE_UNLOAD = 1
5835Const TAPE_TENSION = 2
5836Const TAPE_LOCK = 3
5837Const TAPE_UNLOCK = 4
5838Const TAPE_FORMAT = 5
5839
5840Type TAPE_PREPARE
5841    Operation As DWord
5842    Immediate As BOOLEAN
5843End Type
5844TypeDef PTAPE_PREPARE = *TAPE_PREPARE
5845
5846Const TAPE_SETMARKS = 0
5847Const TAPE_FILEMARKS = 1
5848Const TAPE_SHORT_FILEMARKS = 2
5849Const TAPE_LONG_FILEMARKS = 3
5850
5851Type TAPE_WRITE_MARKS
5852    Type_ As DWord
5853    Count As DWord
5854    Immediate As BOOLEAN
5855End Type
5856TypeDef PTAPE_WRITE_MARKS = *TAPE_WRITE_MARKS
5857
5858Const TAPE_ABSOLUTE_POSITION = 0
5859Const TAPE_LOGICAL_POSITION = 1
5860Const TAPE_PSEUDO_LOGICAL_POSITION = 2
5861
5862Type TAPE_GET_POSITION
5863    Type_ As DWord
5864    Partition As DWord
5865    Offset As LARGE_INTEGER
5866End Type
5867TypeDef PTAPE_GET_POSITION = *TAPE_GET_POSITION
5868
5869Const TAPE_REWIND = 0
5870Const TAPE_ABSOLUTE_BLOCK = 1
5871Const TAPE_LOGICAL_BLOCK = 2
5872Const TAPE_PSEUDO_LOGICAL_BLOCK = 3
5873Const TAPE_SPACE_END_OF_DATA = 4
5874Const TAPE_SPACE_RELATIVE_BLOCKS = 5
5875Const TAPE_SPACE_FILEMARKS = 6
5876Const TAPE_SPACE_SEQUENTIAL_FMKS = 7
5877Const TAPE_SPACE_SETMARKS = 8
5878Const TAPE_SPACE_SEQUENTIAL_SMKS = 9
5879
5880Type TAPE_SET_POSITION
5881    Method As DWord
5882    Partition As DWord
5883    Offset As LARGE_INTEGER
5884    Immediate As BOOLEAN
5885End Type
5886TypeDef PTAPE_SET_POSITION = *TAPE_SET_POSITION
5887
5888Const TAPE_DRIVE_FIXED = &h00000001
5889Const TAPE_DRIVE_SELECT = &h00000002
5890Const TAPE_DRIVE_INITIATOR = &h00000004
5891
5892Const TAPE_DRIVE_ERASE_SHORT = &h00000010
5893Const TAPE_DRIVE_ERASE_LONG = &h00000020
5894Const TAPE_DRIVE_ERASE_BOP_ONLY = &h00000040
5895Const TAPE_DRIVE_ERASE_IMMEDIATE = &h00000080
5896
5897Const TAPE_DRIVE_TAPE_CAPACITY = &h00000100
5898Const TAPE_DRIVE_TAPE_REMAINING = &h00000200
5899Const TAPE_DRIVE_FIXED_BLOCK = &h00000400
5900Const TAPE_DRIVE_VARIABLE_BLOCK = &h00000800
5901
5902Const TAPE_DRIVE_WRITE_PROTECT = &h00001000
5903Const TAPE_DRIVE_EOT_WZ_SIZE = &h00002000
5904
5905Const TAPE_DRIVE_ECC = &h00010000
5906Const TAPE_DRIVE_COMPRESSION = &h00020000
5907Const TAPE_DRIVE_PADDING = &h00040000
5908Const TAPE_DRIVE_REPORT_SMKS = &h00080000
5909
5910Const TAPE_DRIVE_GET_ABSOLUTE_BLK = &h00100000
5911Const TAPE_DRIVE_GET_LOGICAL_BLK = &h00200000
5912Const TAPE_DRIVE_SET_EOT_WZ_SIZE = &h00400000
5913
5914Const TAPE_DRIVE_EJECT_MEDIA = &h01000000
5915Const TAPE_DRIVE_CLEAN_REQUESTS = &h02000000
5916Const TAPE_DRIVE_SET_CMP_BOP_ONLY = &h04000000
5917
5918Const TAPE_DRIVE_RESERVED_BIT = &h80000000
5919
5920Const TAPE_DRIVE_LOAD_UNLOAD = &h80000001
5921Const TAPE_DRIVE_TENSION = &h80000002
5922Const TAPE_DRIVE_LOCK_UNLOCK = &h80000004
5923Const TAPE_DRIVE_REWIND_IMMEDIATE = &h80000008
5924
5925Const TAPE_DRIVE_SET_BLOCK_SIZE = &h80000010
5926Const TAPE_DRIVE_LOAD_UNLD_IMMED = &h80000020
5927Const TAPE_DRIVE_TENSION_IMMED = &h80000040
5928Const TAPE_DRIVE_LOCK_UNLK_IMMED = &h80000080
5929
5930Const TAPE_DRIVE_SET_ECC = &h80000100
5931Const TAPE_DRIVE_SET_COMPRESSION = &h80000200
5932Const TAPE_DRIVE_SET_PADDING = &h80000400
5933Const TAPE_DRIVE_SET_REPORT_SMKS = &h80000800
5934
5935Const TAPE_DRIVE_ABSOLUTE_BLK = &h80001000
5936Const TAPE_DRIVE_ABS_BLK_IMMED = &h80002000
5937Const TAPE_DRIVE_LOGICAL_BLK = &h80004000
5938Const TAPE_DRIVE_LOG_BLK_IMMED = &h80008000
5939
5940Const TAPE_DRIVE_END_OF_DATA = &h80010000
5941Const TAPE_DRIVE_RELATIVE_BLKS = &h80020000
5942Const TAPE_DRIVE_FILEMARKS = &h80040000
5943Const TAPE_DRIVE_SEQUENTIAL_FMKS = &h80080000
5944
5945Const TAPE_DRIVE_SETMARKS = &h80100000
5946Const TAPE_DRIVE_SEQUENTIAL_SMKS = &h80200000
5947Const TAPE_DRIVE_REVERSE_POSITION = &h80400000
5948Const TAPE_DRIVE_SPACE_IMMEDIATE = &h80800000
5949
5950Const TAPE_DRIVE_WRITE_SETMARKS = &h81000000
5951Const TAPE_DRIVE_WRITE_FILEMARKS = &h82000000
5952Const TAPE_DRIVE_WRITE_SHORT_FMKS = &h84000000
5953Const TAPE_DRIVE_WRITE_LONG_FMKS = &h88000000
5954
5955Const TAPE_DRIVE_WRITE_MARK_IMMED = &h90000000
5956Const TAPE_DRIVE_FORMAT = &hA0000000
5957Const TAPE_DRIVE_FORMAT_IMMEDIATE = &hC0000000
5958Const TAPE_DRIVE_HIGH_FEATURES = &h80000000
5959
5960Type TAPE_GET_DRIVE_PARAMETERS
5961    ECC As BOOLEAN
5962    Compression As BOOLEAN
5963    DataPadding As BOOLEAN
5964    ReportSetmarks As BOOLEAN
5965    DefaultBlockSize As DWord
5966    MaximumBlockSize As DWord
5967    MinimumBlockSize As DWord
5968    MaximumPartitionCount As DWord
5969    FeaturesLow As DWord
5970    FeaturesHigh As DWord
5971    EOTWarningZoneSize As DWord
5972End Type
5973TypeDef PTAPE_GET_DRIVE_PARAMETERS = *TAPE_GET_DRIVE_PARAMETERS
5974
5975Type TAPE_SET_DRIVE_PARAMETERS
5976    ECC As BOOLEAN
5977    Compression As BOOLEAN
5978    DataPadding As BOOLEAN
5979    ReportSetmarks As BOOLEAN
5980    EOTWarningZoneSize As DWord
5981End Type
5982TypeDef PTAPE_SET_DRIVE_PARAMETERS = *TAPE_SET_DRIVE_PARAMETERS
5983
5984Type TAPE_GET_MEDIA_PARAMETERS
5985    Capacity As LARGE_INTEGER
5986    Remaining As LARGE_INTEGER
5987    BlockSize As DWord
5988    PartitionCount As DWord
5989    WriteProtected As BOOLEAN
5990End Type
5991TypeDef PTAPE_GET_MEDIA_PARAMETERS = *TAPE_GET_MEDIA_PARAMETERS
5992
5993Type TAPE_SET_MEDIA_PARAMETERS
5994    BlockSize As DWord
5995End Type
5996TypeDef PTAPE_SET_MEDIA_PARAMETERS = *TAPE_SET_MEDIA_PARAMETERS
5997
5998Const TAPE_FIXED_PARTITIONS = 0
5999Const TAPE_SELECT_PARTITIONS = 1
6000Const TAPE_INITIATOR_PARTITIONS = 2
6001
6002Type TAPE_CREATE_PARTITION
6003    Method As DWord
6004    Count As DWord
6005    Size As DWord
6006End Type
6007TypeDef PTAPE_CREATE_PARTITION = *TAPE_CREATE_PARTITION
6008
6009Const TAPE_QUERY_DRIVE_PARAMETERS = 0
6010Const TAPE_QUERY_MEDIA_CAPACITY = 1
6011Const TAPE_CHECK_FOR_DRIVE_PROBLEM = 2
6012Const TAPE_QUERY_IO_ERROR_DATA = 3
6013Const TAPE_QUERY_DEVICE_ERROR_DATA = 4
6014
6015Type TAPE_WMI_OPERATIONS
6016    Method As DWord
6017    DataBufferSize As DWord
6018    DataBuffer As VoidPtr
6019End Type
6020TypeDef PTAPE_WMI_OPERATIONS = *TAPE_WMI_OPERATIONS
6021
6022Enum TAPE_DRIVE_PROBLEM_TYPE
6023    TapeDriveProblemNone
6024    TapeDriveReadWriteWarning
6025    TapeDriveReadWriteError
6026    TapeDriveReadWarning
6027    TapeDriveWriteWarning
6028    TapeDriveReadError
6029    TapeDriveWriteError
6030    TapeDriveHardwareError
6031    TapeDriveUnsupportedMedia
6032    TapeDriveScsiConnectionError
6033    TapeDriveTimetoClean
6034    TapeDriveCleanDriveNow
6035    TapeDriveMediaLifeExpired
6036    TapeDriveSnappedTape
6037End Enum
6038
6039'#ifndef _NTTMAPI_
6040'#define _NTTMAPI_
6041
6042'#include <ktmtypes.ab>
6043
6044' Types for Nt level TM calls
6045Const TRANSACTIONMANAGER_QUERY_INFORMATION = &h0001
6046Const TRANSACTIONMANAGER_SET_INFORMATION = &h0002
6047Const TRANSACTIONMANAGER_RECOVER = &h0004
6048Const TRANSACTIONMANAGER_RENAME = &h0008
6049Const TRANSACTIONMANAGER_CREATE_RM = &h0010
6050Const TRANSACTIONMANAGER_BIND_TRANSACTION = &h0020
6051Const TRANSACTIONMANAGER_GENERIC_READ = (STANDARD_RIGHTS_READ Or TRANSACTIONMANAGER_QUERY_INFORMATION)
6052Const TRANSACTIONMANAGER_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE Or TRANSACTIONMANAGER_SET_INFORMATION Or TRANSACTIONMANAGER_RECOVER Or TRANSACTIONMANAGER_RENAME Or TRANSACTIONMANAGER_CREATE_RM)
6053Const TRANSACTIONMANAGER_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE)
6054Const TRANSACTIONMANAGER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or TRANSACTIONMANAGER_GENERIC_READ Or TRANSACTIONMANAGER_GENERIC_WRITE Or TRANSACTIONMANAGER_GENERIC_EXECUTE Or TRANSACTIONMANAGER_BIND_TRANSACTION)
6055
6056Const TRANSACTION_QUERY_INFORMATION = &h0001
6057Const TRANSACTION_SET_INFORMATION = &h0002
6058Const TRANSACTION_ENLIST = &h0004
6059Const TRANSACTION_COMMIT = &h0008
6060Const TRANSACTION_ROLLBACK = &h0010
6061Const TRANSACTION_PROPAGATE = &h0020
6062Const TRANSACTION_SAVEPOINT = &h0040
6063Const TRANSACTION_MARSHALL = ( TRANSACTION_QUERY_INFORMATION )
6064Const TRANSACTION_GENERIC_READ = (STANDARD_RIGHTS_READ Or TRANSACTION_QUERY_INFORMATION Or SYNCHRONIZE)
6065Const TRANSACTION_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE Or TRANSACTION_SET_INFORMATION Or TRANSACTION_COMMIT Or TRANSACTION_ENLIST Or TRANSACTION_ROLLBACK Or TRANSACTION_PROPAGATE Or TRANSACTION_SAVEPOINT Or SYNCHRONIZE)
6066Const TRANSACTION_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE Or TRANSACTION_COMMIT Or TRANSACTION_ROLLBACK Or SYNCHRONIZE)
6067Const TRANSACTION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or TRANSACTION_GENERIC_READ Or TRANSACTION_GENERIC_WRITE Or TRANSACTION_GENERIC_EXECUTE)
6068Const TRANSACTION_RESOURCE_MANAGER_RIGHTS = (TRANSACTION_GENERIC_READ Or STANDARD_RIGHTS_WRITE Or TRANSACTION_SET_INFORMATION Or TRANSACTION_ENLIST Or TRANSACTION_ROLLBACK Or TRANSACTION_PROPAGATE Or SYNCHRONIZE)
6069
6070Const RESOURCEMANAGER_QUERY_INFORMATION = &h0001
6071Const RESOURCEMANAGER_SET_INFORMATION = &h0002
6072Const RESOURCEMANAGER_RECOVER = &h0004
6073Const RESOURCEMANAGER_ENLIST = &h0008
6074Const RESOURCEMANAGER_GET_NOTIFICATION = &h0010
6075Const RESOURCEMANAGER_REGISTER_PROTOCOL = &h0020
6076Const RESOURCEMANAGER_COMPLETE_PROPAGATION = &h0040
6077Const RESOURCEMANAGER_GENERIC_READ = (STANDARD_RIGHTS_READ Or RESOURCEMANAGER_QUERY_INFORMATION Or SYNCHRONIZE)
6078Const RESOURCEMANAGER_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE Or RESOURCEMANAGER_SET_INFORMATION Or RESOURCEMANAGER_RECOVER Or RESOURCEMANAGER_ENLIST Or RESOURCEMANAGER_GET_NOTIFICATION Or RESOURCEMANAGER_REGISTER_PROTOCOL Or RESOURCEMANAGER_COMPLETE_PROPAGATION Or SYNCHRONIZE)
6079Const RESOURCEMANAGER_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE Or RESOURCEMANAGER_RECOVER Or RESOURCEMANAGER_ENLIST Or RESOURCEMANAGER_GET_NOTIFICATION Or RESOURCEMANAGER_COMPLETE_PROPAGATION Or SYNCHRONIZE)
6080Const RESOURCEMANAGER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or RESOURCEMANAGER_GENERIC_READ Or RESOURCEMANAGER_GENERIC_WRITE Or RESOURCEMANAGER_GENERIC_EXECUTE)
6081
6082
6083Const ENLISTMENT_QUERY_INFORMATION = &h0001
6084Const ENLISTMENT_SET_INFORMATION = &h0002
6085Const ENLISTMENT_RECOVER = &h0004
6086Const ENLISTMENT_SUBORDINATE_RIGHTS = &h0008
6087Const ENLISTMENT_SUPERIOR_RIGHTS = &h0010
6088Const ENLISTMENT_GENERIC_READ = (STANDARD_RIGHTS_READ Or ENLISTMENT_QUERY_INFORMATION)
6089Const ENLISTMENT_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE Or ENLISTMENT_SET_INFORMATION Or ENLISTMENT_RECOVER Or ENLISTMENT_SUBORDINATE_RIGHTS Or ENLISTMENT_SUPERIOR_RIGHTS)
6090Const ENLISTMENT_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE Or ENLISTMENT_RECOVER Or ENLISTMENT_SUBORDINATE_RIGHTS Or ENLISTMENT_SUPERIOR_RIGHTS)
6091Const ENLISTMENT_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or ENLISTMENT_GENERIC_READ Or ENLISTMENT_GENERIC_WRITE Or ENLISTMENT_GENERIC_EXECUTE)
6092
6093' Transaction outcomes.
6094
6095Enum TRANSACTION_OUTCOME
6096    TransactionOutcomeUndetermined = 1
6097    TransactionOutcomeCommitted
6098    TransactionOutcomeAborted
6099End Enum
6100
6101Enum TRANSACTION_STATE
6102    TransactionStateNormal = 1
6103    TransactionStateIndoubt
6104    TransactionStateCommittedNotify
6105End Enum
6106
6107Type TRANSACTION_BASIC_INFORMATION
6108    TransactionId As GUID
6109    State As DWord
6110    Outcome As DWord
6111End Type
6112TypeDef PTRANSACTION_BASIC_INFORMATION = *TRANSACTION_BASIC_INFORMATION
6113
6114Type TRANSACTIONMANAGER_BASIC_INFORMATION
6115    TmIdentity As GUID
6116    VirtualClock As LARGE_INTEGER
6117End Type
6118TypeDef PTRANSACTIONMANAGER_BASIC_INFORMATION = *TRANSACTIONMANAGER_BASIC_INFORMATION
6119
6120Type TRANSACTIONMANAGER_LOG_INFORMATION
6121    LogIdentity As GUID
6122End Type
6123TypeDef PTRANSACTIONMANAGER_LOG_INFORMATION = *TRANSACTIONMANAGER_LOG_INFORMATION
6124
6125Type TRANSACTIONMANAGER_LOGPATH_INFORMATION
6126    LogPathLength As DWord
6127    /*__field_ecount(LogPathLength)*/ LogPath[ELM(1)] As WCHAR 'Variable size
6128'   Data[ELM(1)] 'Variable size data not declared
6129End Type
6130TypeDef PTRANSACTIONMANAGER_LOGPATH_INFORMATION = *TRANSACTIONMANAGER_LOGPATH_INFORMATION
6131
6132Type TRANSACTION_PROPERTIES_INFORMATION
6133    IsolationLevel As DWord
6134    IsolationFlags As DWord
6135    Timeout As LARGE_INTEGER
6136    Outcome As DWord
6137    DescriptionLength As DWord
6138    Description[ELM(1)] As WCHAR 'Variable size
6139'   Data[ELM(1)] 'Variable size data not declared
6140End Type
6141TypeDef PTRANSACTION_PROPERTIES_INFORMATION = *TRANSACTION_PROPERTIES_INFORMATION
6142
6143Type TRANSACTION_BIND_INFORMATION
6144    TmHandle As HANDLE
6145End Type
6146TypeDef PTRANSACTION_BIND_INFORMATION = *TRANSACTION_BIND_INFORMATION
6147
6148Type TRANSACTION_ENLISTMENT_PAIR
6149    EnlistmentId As GUID
6150    ResourceManagerId As GUID
6151End Type
6152TypeDef PTRANSACTION_ENLISTMENT_PAIR = *TRANSACTION_ENLISTMENT_PAIR
6153
6154Type TRANSACTION_ENLISTMENTS_INFORMATION
6155    NumberOfEnlistments As DWord
6156    EnlistmentPair[ELM(1)] As TRANSACTION_ENLISTMENT_PAIR 'Variable size
6157End Type
6158TypeDef PTRANSACTION_ENLISTMENTS_INFORMATION = *TRANSACTION_ENLISTMENTS_INFORMATION
6159
6160Type TRANSACTION_FULL_INFORMATION
6161    NameLength As DWord
6162End Type
6163TypeDef PTRANSACTION_FULL_INFORMATION = *TRANSACTION_FULL_INFORMATION
6164
6165Type RESOURCEMANAGER_BASIC_INFORMATION
6166    ResourceManagerId As GUID
6167    DescriptionLength As DWord
6168    Description[ELM(1)] As WCHAR 'Variable size
6169End Type
6170TypeDef PRESOURCEMANAGER_BASIC_INFORMATION = *RESOURCEMANAGER_BASIC_INFORMATION
6171
6172Type RESOURCEMANAGER_COMPLETION_INFORMATION
6173    IoCompletionPortHandle As HANDLE
6174    CompletionKey As ULONG_PTR
6175End Type
6176TypeDef PRESOURCEMANAGER_COMPLETION_INFORMATION = *RESOURCEMANAGER_COMPLETION_INFORMATION
6177
6178Type TRANSACTION_NAME_INFORMATION
6179    NameLength As DWord
6180    Name[ELM(1)] As WCHAR 'Variable length string
6181End Type
6182TypeDef PTRANSACTION_NAME_INFORMATION = *TRANSACTION_NAME_INFORMATION
6183
6184Enum TRANSACTION_INFORMATION_CLASS
6185    TransactionBasicInformation
6186    TransactionPropertiesInformation
6187    TransactionEnlistmentInformation
6188    TransactionFullInformation
6189    TransactionBindInformation
6190'   TransactionNameInformation
6191End Enum
6192
6193Enum TRANSACTIONMANAGER_INFORMATION_CLASS
6194    TransactionManagerBasicInformation
6195    TransactionManagerLogInformation
6196    TransactionManagerLogPathInformation
6197    TransactionManagerOnlineProbeInformation
6198End Enum
6199
6200Enum RESOURCEMANAGER_INFORMATION_CLASS
6201    ResourceManagerBasicInformation
6202    ResourceManagerCompletionInformation
6203    ResourceManagerFullInformation
6204    ResourceManagerNameInformation
6205End Enum
6206
6207Type ENLISTMENT_BASIC_INFORMATION
6208    EnlistmentId As GUID
6209    TransactionId As GUID
6210    ResourceManagerId As GUID
6211End Type
6212TypeDef PENLISTMENT_BASIC_INFORMATION = *ENLISTMENT_BASIC_INFORMATION
6213
6214Enum ENLISTMENT_INFORMATION_CLASS
6215    EnlistmentBasicInformation
6216    EnlistmentRecoveryInformation
6217    EnlistmentFullInformation
6218    EnlistmentNameInformation
6219End Enum
6220
6221Type TRANSACTION_LIST_ENTRY
6222'   UOW As UOW
6223End Type
6224
6225TypeDef PTRANSACTION_LIST_ENTRY = *TRANSACTION_LIST_ENTRY
6226
6227Type TRANSACTION_LIST_INFORMATION
6228    NumberOfTransactions As DWord
6229    TransactionInformation[ELM(1)] As TRANSACTION_LIST_ENTRY
6230End Type
6231TypeDef PTRANSACTION_LIST_INFORMATION = *TRANSACTION_LIST_INFORMATION
6232
6233' Types of objects known to the kernel transaction manager.
6234Enum KTMOBJECT_TYPE
6235    KTMOBJECT_TRANSACTION
6236    KTMOBJECT_TRANSACTION_MANAGER
6237    KTMOBJECT_RESOURCE_MANAGER
6238    KTMOBJECT_ENLISTMENT
6239    KTMOBJECT_INVALID
6240End Enum
6241TypeDef PKTMOBJECT_TYPE = *KTMOBJECT_TYPE
6242
6243' KTMOBJECT_CURSOR
6244Type KTMOBJECT_CURSOR
6245    LastQuery As GUID
6246    ObjectIdCount As DWord
6247    ObjectIds[ELM(1)] As GUID
6248End Type
6249TypeDef PKTMOBJECT_CURSOR = *KTMOBJECT_CURSOR
6250
6251'#endif
6252
6253TypeDef TP_VERSION = DWord
6254TypeDef PTP_VERSION = *TP_VERSION
6255
6256TypeDef PTP_CALLBACK_INSTANCE = VoidPtr
6257'typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE, *PTP_CALLBACK_INSTANCE;
6258
6259TypeDef PTP_SIMPLE_CALLBACK = *Sub(Instance As PTP_CALLBACK_INSTANCE, Context As VoidPtr)
6260TypeDef PTP_POOL = VoidPtr
6261'typedef struct _TP_POOL TP_POOL, *PTP_POOL;
6262TypeDef PTP_CLEANUP_GROUP = VoidPtr
6263'typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP, *PTP_CLEANUP_GROUP;
6264TypeDef PTP_CLEANUP_GROUP_CANCEL_CALLBACK = *Sub(ObjectContext As VoidPtr, CleanupContext As VoidPtr)
6265
6266TypeDef PACTIVATION_CONTEXT = VoidPtr
6267
6268Type TP_CALLBACK_ENVIRON
6269    Version As TP_VERSION
6270    Pool As PTP_POOL
6271    CleanupGroup As PTP_CLEANUP_GROUP
6272    CleanupGroupCancelCallback As PTP_CLEANUP_GROUP_CANCEL_CALLBACK
6273    RaceDll As VoidPtr
6274    ActivationContext As PACTIVATION_CONTEXT
6275    FinalizationCallback As PTP_SIMPLE_CALLBACK
6276'   Union
6277        Flags As DWord
6278'       Type
6279'           LongFunction :  1 As DWord
6280'           Private_     : 31 As DWord
6281'       } s;
6282'   End Union
6283End Type
6284TypeDef PTP_CALLBACK_ENVIRON = *TP_CALLBACK_ENVIRON
6285
6286Sub /*FORCEINLINE*/ TpInitializeCallbackEnviron(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON)
6287    With CallbackEnviron
6288        .Version = 1
6289        .Pool = NULL
6290        .CleanupGroup = NULL
6291        .CleanupGroupCancelCallback = NULL
6292        .RaceDll = NULL
6293        .ActivationContext = NULL
6294        .FinalizationCallback = NULL
6295        .Flags = 0
6296    End With
6297End Sub
6298
6299Sub /*FORCEINLINE*/ TpSetCallbackThreadpool(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON, Pool As PTP_POOL)
6300    CallbackEnviron.Pool = Pool
6301End Sub
6302
6303Sub /*FORCEINLINE*/ TpSetCallbackCleanupGroup(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON, CleanupGroup As PTP_CLEANUP_GROUP, CleanupGroupCancelCallback As PTP_CLEANUP_GROUP_CANCEL_CALLBACK)
6304    CallbackEnviron.CleanupGroup = CleanupGroup
6305    CallbackEnviron.CleanupGroupCancelCallback = CleanupGroupCancelCallback
6306End Sub
6307
6308Sub /*FORCEINLINE*/ TpSetCallbackActivationContext(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON, ActivationContext As PACTIVATION_CONTEXT)
6309    CallbackEnviron.ActivationContext = ActivationContext
6310End Sub
6311
6312Sub /*FORCEINLINE*/ TpSetCallbackNoActivationContext(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON)
6313    CallbackEnviron.ActivationContext = (-1 As LONG_PTR) As PACTIVATION_CONTEXT
6314End Sub
6315
6316Sub /*FORCEINLINE*/ TpSetCallbackLongFunction(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON)
6317    CallbackEnviron.Flags = 1 'u.s.LongFunction = 1
6318End Sub
6319
6320Sub /*FORCEINLINE*/ TpSetCallbackRaceWithDll(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON, DllHandle As VoidPtr)
6321    CallbackEnviron.RaceDll = DllHandle
6322End Sub
6323
6324Sub /*FORCEINLINE*/ TpSetCallbackFinalizationCallback(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON, FinalizationCallback As PTP_SIMPLE_CALLBACK)
6325    CallbackEnviron.FinalizationCallback = FinalizationCallback
6326End Sub
6327
6328Sub /*FORCEINLINE*/ TpDestroyCallbackEnviron(ByRef CallbackEnviron As TP_CALLBACK_ENVIRON)
6329'   UNREFERENCED_PARAMETER(CallbackEnviron)
6330End Sub
6331
6332TypeDef PTP_WORK = VoidPtr
6333'typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6334
6335TypeDef PTP_WORK_CALLBACK = *Sub(Instance As PTP_CALLBACK_INSTANCE, Context As VoidPtr, Work As PTP_WORK)
6336
6337TypeDef PTP_TIMER = *VoidPtr
6338'typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6339
6340TypeDef PTP_TIMER_CALLBACK = *Sub(Instance As PTP_CALLBACK_INSTANCE, Context As VoidPtr, Timer As PTP_TIMER)
6341
6342TypeDef TP_WAIT_RESULT = DWord
6343
6344TypeDef PTP_WAIT = VoidPtr
6345'typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6346
6347TypeDef PTP_WAIT_CALLBACK = *Sub(Instance As PTP_CALLBACK_INSTANCE, Context As VoidPtr, Wait As PTP_WAIT, WaitResult As TP_WAIT_RESULT)
6348
6349TypeDef PTP_IO = VoidPtr
6350'typedef struct _TP_IO TP_IO, *PTP_IO;
6351
6352'NtCurrentTeb()
6353'GetCurrentFiber()
6354'GetFiberData ()
6355
6356'#if (_WIN32_WINNT > 0x0500) Or (_WIN32_FUSION >= 0x0100) Or ISOLATION_AWARE_ENABLED
6357Const ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION = 1
6358Const ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION = 2
6359Const ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION = 3
6360Const ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION = 4
6361Const ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION = 5
6362Const ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION = 6
6363Const ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION = 7
6364Const ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE = 8
6365Const ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES = 9
6366Const ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS = 10
6367'#endif // winnt_only
6368
Note: See TracBrowser for help on using the repository browser.