[XDK]
[reactos.git] / include / xdk / rtltypes.h
1 /******************************************************************************
2 * Runtime Library Types *
3 ******************************************************************************/
4
5 $if (_WDMDDK_)
6 #define RTL_REGISTRY_ABSOLUTE 0
7 #define RTL_REGISTRY_SERVICES 1
8 #define RTL_REGISTRY_CONTROL 2
9 #define RTL_REGISTRY_WINDOWS_NT 3
10 #define RTL_REGISTRY_DEVICEMAP 4
11 #define RTL_REGISTRY_USER 5
12 #define RTL_REGISTRY_MAXIMUM 6
13 #define RTL_REGISTRY_HANDLE 0x40000000
14 #define RTL_REGISTRY_OPTIONAL 0x80000000
15
16 /* RTL_QUERY_REGISTRY_TABLE.Flags */
17 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001
18 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002
19 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004
20 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008
21 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010
22 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020
23 #define RTL_QUERY_REGISTRY_DELETE 0x00000040
24
25 #define HASH_STRING_ALGORITHM_DEFAULT 0
26 #define HASH_STRING_ALGORITHM_X65599 1
27 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
28
29 typedef struct _RTL_BITMAP {
30 ULONG SizeOfBitMap;
31 PULONG Buffer;
32 } RTL_BITMAP, *PRTL_BITMAP;
33
34 typedef struct _RTL_BITMAP_RUN {
35 ULONG StartingIndex;
36 ULONG NumberOfBits;
37 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
38
39 typedef NTSTATUS
40 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
41 IN PWSTR ValueName,
42 IN ULONG ValueType,
43 IN PVOID ValueData,
44 IN ULONG ValueLength,
45 IN PVOID Context,
46 IN PVOID EntryContext);
47
48 typedef struct _RTL_QUERY_REGISTRY_TABLE {
49 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
50 ULONG Flags;
51 PCWSTR Name;
52 PVOID EntryContext;
53 ULONG DefaultType;
54 PVOID DefaultData;
55 ULONG DefaultLength;
56 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
57
58 typedef struct _TIME_FIELDS {
59 CSHORT Year;
60 CSHORT Month;
61 CSHORT Day;
62 CSHORT Hour;
63 CSHORT Minute;
64 CSHORT Second;
65 CSHORT Milliseconds;
66 CSHORT Weekday;
67 } TIME_FIELDS, *PTIME_FIELDS;
68
69 /* Slist Header */
70 #ifndef _SLIST_HEADER_
71 #define _SLIST_HEADER_
72
73 #if defined(_WIN64)
74
75 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
76 struct _SLIST_ENTRY *Next;
77 } SLIST_ENTRY, *PSLIST_ENTRY;
78
79 typedef struct _SLIST_ENTRY32 {
80 ULONG Next;
81 } SLIST_ENTRY32, *PSLIST_ENTRY32;
82
83 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
84 struct {
85 ULONGLONG Alignment;
86 ULONGLONG Region;
87 } DUMMYSTRUCTNAME;
88 struct {
89 ULONGLONG Depth:16;
90 ULONGLONG Sequence:9;
91 ULONGLONG NextEntry:39;
92 ULONGLONG HeaderType:1;
93 ULONGLONG Init:1;
94 ULONGLONG Reserved:59;
95 ULONGLONG Region:3;
96 } Header8;
97 struct {
98 ULONGLONG Depth:16;
99 ULONGLONG Sequence:48;
100 ULONGLONG HeaderType:1;
101 ULONGLONG Init:1;
102 ULONGLONG Reserved:2;
103 ULONGLONG NextEntry:60;
104 } Header16;
105 struct {
106 ULONGLONG Depth:16;
107 ULONGLONG Sequence:48;
108 ULONGLONG HeaderType:1;
109 ULONGLONG Reserved:3;
110 ULONGLONG NextEntry:60;
111 } HeaderX64;
112 } SLIST_HEADER, *PSLIST_HEADER;
113
114 typedef union _SLIST_HEADER32 {
115 ULONGLONG Alignment;
116 struct {
117 SLIST_ENTRY32 Next;
118 USHORT Depth;
119 USHORT Sequence;
120 } DUMMYSTRUCTNAME;
121 } SLIST_HEADER32, *PSLIST_HEADER32;
122
123 #else
124
125 #define SLIST_ENTRY SINGLE_LIST_ENTRY
126 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
127 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
128
129 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
130
131 typedef union _SLIST_HEADER {
132 ULONGLONG Alignment;
133 struct {
134 SLIST_ENTRY Next;
135 USHORT Depth;
136 USHORT Sequence;
137 } DUMMYSTRUCTNAME;
138 } SLIST_HEADER, *PSLIST_HEADER;
139
140 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
141
142 #endif /* defined(_WIN64) */
143
144 #endif /* _SLIST_HEADER_ */
145
146 /* MS definition is broken! */
147 extern BOOLEAN NTSYSAPI NlsMbCodePageTag;
148 extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag;
149 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
150 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
151
152 #define SHORT_LEAST_SIGNIFICANT_BIT 0
153 #define SHORT_MOST_SIGNIFICANT_BIT 1
154
155 #define LONG_LEAST_SIGNIFICANT_BIT 0
156 #define LONG_3RD_MOST_SIGNIFICANT_BIT 1
157 #define LONG_2ND_MOST_SIGNIFICANT_BIT 2
158 #define LONG_MOST_SIGNIFICANT_BIT 3
159
160 #define RTLVERLIB_DDI(x) Wdmlib##x
161
162 typedef BOOLEAN
163 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
164 IN ULONG Version);
165
166 typedef BOOLEAN
167 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
168 IN ULONG Version);
169
170 $endif
171
172 $if (_NTDDK_)
173
174 #ifndef _RTL_RUN_ONCE_DEF
175 #define _RTL_RUN_ONCE_DEF
176
177 #define RTL_RUN_ONCE_INIT {0}
178
179 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL
180 #define RTL_RUN_ONCE_ASYNC 0x00000002UL
181 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL
182
183 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
184
185 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
186
187 #define RTL_HASH_RESERVED_SIGNATURE 0
188
189 /* RtlVerifyVersionInfo() ComparisonType */
190
191 #define VER_EQUAL 1
192 #define VER_GREATER 2
193 #define VER_GREATER_EQUAL 3
194 #define VER_LESS 4
195 #define VER_LESS_EQUAL 5
196 #define VER_AND 6
197 #define VER_OR 7
198
199 #define VER_CONDITION_MASK 7
200 #define VER_NUM_BITS_PER_CONDITION_MASK 3
201
202 /* RtlVerifyVersionInfo() TypeMask */
203
204 #define VER_MINORVERSION 0x0000001
205 #define VER_MAJORVERSION 0x0000002
206 #define VER_BUILDNUMBER 0x0000004
207 #define VER_PLATFORMID 0x0000008
208 #define VER_SERVICEPACKMINOR 0x0000010
209 #define VER_SERVICEPACKMAJOR 0x0000020
210 #define VER_SUITENAME 0x0000040
211 #define VER_PRODUCT_TYPE 0x0000080
212
213 #define VER_NT_WORKSTATION 0x0000001
214 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
215 #define VER_NT_SERVER 0x0000003
216
217 #define VER_PLATFORM_WIN32s 0
218 #define VER_PLATFORM_WIN32_WINDOWS 1
219 #define VER_PLATFORM_WIN32_NT 2
220
221 typedef union _RTL_RUN_ONCE {
222 PVOID Ptr;
223 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
224
225 typedef ULONG /* LOGICAL */
226 (NTAPI *PRTL_RUN_ONCE_INIT_FN) (
227 IN OUT PRTL_RUN_ONCE RunOnce,
228 IN OUT PVOID Parameter OPTIONAL,
229 IN OUT PVOID *Context OPTIONAL);
230
231 #endif /* _RTL_RUN_ONCE_DEF */
232
233 typedef enum _TABLE_SEARCH_RESULT {
234 TableEmptyTree,
235 TableFoundNode,
236 TableInsertAsLeft,
237 TableInsertAsRight
238 } TABLE_SEARCH_RESULT;
239
240 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
241 GenericLessThan,
242 GenericGreaterThan,
243 GenericEqual
244 } RTL_GENERIC_COMPARE_RESULTS;
245
246 // Forwarder
247 struct _RTL_AVL_TABLE;
248
249 typedef RTL_GENERIC_COMPARE_RESULTS
250 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
251 IN struct _RTL_AVL_TABLE *Table,
252 IN PVOID FirstStruct,
253 IN PVOID SecondStruct);
254
255 typedef PVOID
256 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
257 IN struct _RTL_AVL_TABLE *Table,
258 IN CLONG ByteSize);
259
260 typedef VOID
261 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
262 IN struct _RTL_AVL_TABLE *Table,
263 IN PVOID Buffer);
264
265 typedef NTSTATUS
266 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
267 IN struct _RTL_AVL_TABLE *Table,
268 IN PVOID UserData,
269 IN PVOID MatchData);
270
271 typedef struct _RTL_BALANCED_LINKS {
272 struct _RTL_BALANCED_LINKS *Parent;
273 struct _RTL_BALANCED_LINKS *LeftChild;
274 struct _RTL_BALANCED_LINKS *RightChild;
275 CHAR Balance;
276 UCHAR Reserved[3];
277 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
278
279 typedef struct _RTL_AVL_TABLE {
280 RTL_BALANCED_LINKS BalancedRoot;
281 PVOID OrderedPointer;
282 ULONG WhichOrderedElement;
283 ULONG NumberGenericTableElements;
284 ULONG DepthOfTree;
285 PRTL_BALANCED_LINKS RestartKey;
286 ULONG DeleteCount;
287 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
288 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
289 PRTL_AVL_FREE_ROUTINE FreeRoutine;
290 PVOID TableContext;
291 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
292
293 #ifndef RTL_USE_AVL_TABLES
294
295 struct _RTL_GENERIC_TABLE;
296
297 typedef RTL_GENERIC_COMPARE_RESULTS
298 (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
299 IN struct _RTL_GENERIC_TABLE *Table,
300 IN PVOID FirstStruct,
301 IN PVOID SecondStruct);
302
303 typedef PVOID
304 (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
305 IN struct _RTL_GENERIC_TABLE *Table,
306 IN CLONG ByteSize);
307
308 typedef VOID
309 (NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
310 IN struct _RTL_GENERIC_TABLE *Table,
311 IN PVOID Buffer);
312
313 typedef struct _RTL_SPLAY_LINKS {
314 struct _RTL_SPLAY_LINKS *Parent;
315 struct _RTL_SPLAY_LINKS *LeftChild;
316 struct _RTL_SPLAY_LINKS *RightChild;
317 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
318
319 typedef struct _RTL_GENERIC_TABLE {
320 PRTL_SPLAY_LINKS TableRoot;
321 LIST_ENTRY InsertOrderList;
322 PLIST_ENTRY OrderedPointer;
323 ULONG WhichOrderedElement;
324 ULONG NumberGenericTableElements;
325 PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
326 PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
327 PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
328 PVOID TableContext;
329 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
330
331 #endif /* !RTL_USE_AVL_TABLES */
332
333 #ifdef RTL_USE_AVL_TABLES
334
335 #undef PRTL_GENERIC_COMPARE_ROUTINE
336 #undef RTL_GENERIC_COMPARE_ROUTINE
337 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
338 #undef RTL_GENERIC_ALLOCATE_ROUTINE
339 #undef PRTL_GENERIC_FREE_ROUTINE
340 #undef RTL_GENERIC_FREE_ROUTINE
341 #undef RTL_GENERIC_TABLE
342 #undef PRTL_GENERIC_TABLE
343
344 #define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE
345 #define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE
346 #define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE
347 #define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE
348 #define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE
349 #define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE
350 #define RTL_GENERIC_TABLE RTL_AVL_TABLE
351 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
352
353 #endif /* RTL_USE_AVL_TABLES */
354
355 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY {
356 LIST_ENTRY Linkage;
357 ULONG_PTR Signature;
358 } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY;
359
360 typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT {
361 PLIST_ENTRY ChainHead;
362 PLIST_ENTRY PrevLinkage;
363 ULONG_PTR Signature;
364 } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT;
365
366 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR {
367 RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry;
368 PLIST_ENTRY ChainHead;
369 ULONG BucketIndex;
370 } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR;
371
372 typedef struct _RTL_DYNAMIC_HASH_TABLE {
373 ULONG Flags;
374 ULONG Shift;
375 ULONG TableSize;
376 ULONG Pivot;
377 ULONG DivisorMask;
378 ULONG NumEntries;
379 ULONG NonEmptyBuckets;
380 ULONG NumEnumerators;
381 PVOID Directory;
382 } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE;
383
384 typedef struct _OSVERSIONINFOA {
385 ULONG dwOSVersionInfoSize;
386 ULONG dwMajorVersion;
387 ULONG dwMinorVersion;
388 ULONG dwBuildNumber;
389 ULONG dwPlatformId;
390 CHAR szCSDVersion[128];
391 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
392
393 typedef struct _OSVERSIONINFOW {
394 ULONG dwOSVersionInfoSize;
395 ULONG dwMajorVersion;
396 ULONG dwMinorVersion;
397 ULONG dwBuildNumber;
398 ULONG dwPlatformId;
399 WCHAR szCSDVersion[128];
400 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
401
402 typedef struct _OSVERSIONINFOEXA {
403 ULONG dwOSVersionInfoSize;
404 ULONG dwMajorVersion;
405 ULONG dwMinorVersion;
406 ULONG dwBuildNumber;
407 ULONG dwPlatformId;
408 CHAR szCSDVersion[128];
409 USHORT wServicePackMajor;
410 USHORT wServicePackMinor;
411 USHORT wSuiteMask;
412 UCHAR wProductType;
413 UCHAR wReserved;
414 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
415
416 typedef struct _OSVERSIONINFOEXW {
417 ULONG dwOSVersionInfoSize;
418 ULONG dwMajorVersion;
419 ULONG dwMinorVersion;
420 ULONG dwBuildNumber;
421 ULONG dwPlatformId;
422 WCHAR szCSDVersion[128];
423 USHORT wServicePackMajor;
424 USHORT wServicePackMinor;
425 USHORT wSuiteMask;
426 UCHAR wProductType;
427 UCHAR wReserved;
428 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
429
430 #ifdef UNICODE
431 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
432 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
433 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
434 typedef OSVERSIONINFOW OSVERSIONINFO;
435 typedef POSVERSIONINFOW POSVERSIONINFO;
436 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
437 #else
438 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
439 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
440 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
441 typedef OSVERSIONINFOA OSVERSIONINFO;
442 typedef POSVERSIONINFOA POSVERSIONINFO;
443 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
444 #endif /* UNICODE */
445
446 #define HASH_ENTRY_KEY(x) ((x)->Signature)
447
448 $endif