xref: /reactos/sdk/include/xdk/rtltypes.h (revision bc6c731d)
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 #define RTL_QUERY_REGISTRY_TYPECHECK      0x00000100
25 
26 #define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT 24
27 
28 #define HASH_STRING_ALGORITHM_DEFAULT     0
29 #define HASH_STRING_ALGORITHM_X65599      1
30 #define HASH_STRING_ALGORITHM_INVALID     0xffffffff
31 
32 typedef struct _RTL_BITMAP {
33   ULONG SizeOfBitMap;
34   PULONG Buffer;
35 } RTL_BITMAP, *PRTL_BITMAP;
36 
37 typedef struct _RTL_BITMAP_RUN {
38   ULONG StartingIndex;
39   ULONG NumberOfBits;
40 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
41 
42 _Function_class_(RTL_QUERY_REGISTRY_ROUTINE)
43 _IRQL_requires_max_(PASSIVE_LEVEL)
44 _IRQL_requires_same_
45 typedef NTSTATUS
46 (NTAPI RTL_QUERY_REGISTRY_ROUTINE)(
47   _In_z_ PWSTR ValueName,
48   _In_ ULONG ValueType,
49   _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
50   _In_ ULONG ValueLength,
51   _In_opt_ PVOID Context,
52   _In_opt_ PVOID EntryContext);
53 typedef RTL_QUERY_REGISTRY_ROUTINE *PRTL_QUERY_REGISTRY_ROUTINE;
54 
55 typedef struct _RTL_QUERY_REGISTRY_TABLE {
56   PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
57   ULONG Flags;
58   PCWSTR Name;
59   PVOID EntryContext;
60   ULONG DefaultType;
61   PVOID DefaultData;
62   ULONG DefaultLength;
63 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
64 
65 typedef struct _TIME_FIELDS {
66   CSHORT Year;
67   CSHORT Month;
68   CSHORT Day;
69   CSHORT Hour;
70   CSHORT Minute;
71   CSHORT Second;
72   CSHORT Milliseconds;
73   CSHORT Weekday;
74 } TIME_FIELDS, *PTIME_FIELDS;
75 
76 /* Slist Header */
77 #ifndef _SLIST_HEADER_
78 #define _SLIST_HEADER_
79 
80 #if defined(_WIN64)
81 
82 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
83   struct _SLIST_ENTRY *Next;
84 } SLIST_ENTRY, *PSLIST_ENTRY;
85 
86 typedef struct _SLIST_ENTRY32 {
87   ULONG Next;
88 } SLIST_ENTRY32, *PSLIST_ENTRY32;
89 
90 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
91   _ANONYMOUS_STRUCT struct {
92     ULONGLONG Alignment;
93     ULONGLONG Region;
94   } DUMMYSTRUCTNAME;
95   struct {
96     ULONGLONG Depth:16;
97     ULONGLONG Sequence:9;
98     ULONGLONG NextEntry:39;
99     ULONGLONG HeaderType:1;
100     ULONGLONG Init:1;
101     ULONGLONG Reserved:59;
102     ULONGLONG Region:3;
103   } Header8;
104   struct {
105     ULONGLONG Depth:16;
106     ULONGLONG Sequence:48;
107     ULONGLONG HeaderType:1;
108     ULONGLONG Init:1;
109     ULONGLONG Reserved:2;
110     ULONGLONG NextEntry:60;
111   } Header16;
112   struct {
113     ULONGLONG Depth:16;
114     ULONGLONG Sequence:48;
115     ULONGLONG HeaderType:1;
116     ULONGLONG Reserved:3;
117     ULONGLONG NextEntry:60;
118   } HeaderX64;
119 } SLIST_HEADER, *PSLIST_HEADER;
120 
121 typedef union _SLIST_HEADER32 {
122   ULONGLONG Alignment;
123   _ANONYMOUS_STRUCT struct {
124     SLIST_ENTRY32 Next;
125     USHORT Depth;
126     USHORT Sequence;
127   } DUMMYSTRUCTNAME;
128 } SLIST_HEADER32, *PSLIST_HEADER32;
129 
130 #else
131 
132 #define SLIST_ENTRY SINGLE_LIST_ENTRY
133 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
134 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
135 
136 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
137 
138 typedef union _SLIST_HEADER {
139   ULONGLONG Alignment;
140   _ANONYMOUS_STRUCT struct {
141     SLIST_ENTRY Next;
142     USHORT Depth;
143     USHORT Sequence;
144   } DUMMYSTRUCTNAME;
145 } SLIST_HEADER, *PSLIST_HEADER;
146 
147 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
148 
149 #endif /* defined(_WIN64) */
150 
151 #endif /* _SLIST_HEADER_ */
152 
153 /* Exception record flags */
154 #define EXCEPTION_NONCONTINUABLE  0x01
155 #define EXCEPTION_UNWINDING       0x02
156 #define EXCEPTION_EXIT_UNWIND     0x04
157 #define EXCEPTION_STACK_INVALID   0x08
158 #define EXCEPTION_NESTED_CALL     0x10
159 #define EXCEPTION_TARGET_UNWIND   0x20
160 #define EXCEPTION_COLLIDED_UNWIND 0x40
161 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
162                           EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
163 
164 #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
165 #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
166 #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
167 
168 #define EXCEPTION_MAXIMUM_PARAMETERS 15
169 
170 /* Exception records */
171 typedef struct _EXCEPTION_RECORD {
172   NTSTATUS ExceptionCode;
173   ULONG ExceptionFlags;
174   struct _EXCEPTION_RECORD *ExceptionRecord;
175   PVOID ExceptionAddress;
176   ULONG NumberParameters;
177   ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
178 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
179 
180 typedef struct _EXCEPTION_RECORD32 {
181   NTSTATUS ExceptionCode;
182   ULONG ExceptionFlags;
183   ULONG ExceptionRecord;
184   ULONG ExceptionAddress;
185   ULONG NumberParameters;
186   ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
187 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
188 
189 typedef struct _EXCEPTION_RECORD64 {
190   NTSTATUS ExceptionCode;
191   ULONG ExceptionFlags;
192   ULONG64 ExceptionRecord;
193   ULONG64 ExceptionAddress;
194   ULONG NumberParameters;
195   ULONG __unusedAlignment;
196   ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
197 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
198 
199 typedef struct _EXCEPTION_POINTERS {
200   PEXCEPTION_RECORD ExceptionRecord;
201   PCONTEXT ContextRecord;
202 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
203 
204 #ifdef _NTSYSTEM_
205 extern BOOLEAN NlsMbCodePageTag;
206 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
207 extern BOOLEAN NlsMbOemCodePageTag;
208 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
209 #else
210 __CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbCodePageTag)
211 extern BOOLEAN *NlsMbCodePageTag;
212 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
213 __CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbOemCodePageTag)
214 extern BOOLEAN *NlsMbOemCodePageTag;
215 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
216 #endif
217 
218 #define SHORT_LEAST_SIGNIFICANT_BIT       0
219 #define SHORT_MOST_SIGNIFICANT_BIT        1
220 
221 #define LONG_LEAST_SIGNIFICANT_BIT        0
222 #define LONG_3RD_MOST_SIGNIFICANT_BIT     1
223 #define LONG_2ND_MOST_SIGNIFICANT_BIT     2
224 #define LONG_MOST_SIGNIFICANT_BIT         3
225 
226 #define RTLVERLIB_DDI(x) Wdmlib##x
227 
228 typedef BOOLEAN
229 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
230   _In_ ULONG Version);
231 
232 typedef BOOLEAN
233 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
234   _In_ ULONG Version);
235 
236 typedef struct _OSVERSIONINFOA {
237   ULONG dwOSVersionInfoSize;
238   ULONG dwMajorVersion;
239   ULONG dwMinorVersion;
240   ULONG dwBuildNumber;
241   ULONG dwPlatformId;
242   CHAR szCSDVersion[128];
243 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
244 
245 typedef struct _OSVERSIONINFOW {
246   ULONG dwOSVersionInfoSize;
247   ULONG dwMajorVersion;
248   ULONG dwMinorVersion;
249   ULONG dwBuildNumber;
250   ULONG dwPlatformId;
251   WCHAR szCSDVersion[128];
252 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
253 
254 typedef struct _OSVERSIONINFOEXA {
255   ULONG dwOSVersionInfoSize;
256   ULONG dwMajorVersion;
257   ULONG dwMinorVersion;
258   ULONG dwBuildNumber;
259   ULONG dwPlatformId;
260   CHAR szCSDVersion[128];
261   USHORT wServicePackMajor;
262   USHORT wServicePackMinor;
263   USHORT wSuiteMask;
264   UCHAR wProductType;
265   UCHAR wReserved;
266 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
267 
268 typedef struct _OSVERSIONINFOEXW {
269   ULONG dwOSVersionInfoSize;
270   ULONG dwMajorVersion;
271   ULONG dwMinorVersion;
272   ULONG dwBuildNumber;
273   ULONG dwPlatformId;
274   WCHAR szCSDVersion[128];
275   USHORT wServicePackMajor;
276   USHORT wServicePackMinor;
277   USHORT wSuiteMask;
278   UCHAR wProductType;
279   UCHAR wReserved;
280 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
281 
282 #define RTL_CONDITION_VARIABLE_INIT {0}
283 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
284 
285 typedef struct _RTL_CONDITION_VARIABLE {
286   PVOID Ptr;
287 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
288 
289 #define RTL_SRWLOCK_INIT {0}
290 
291 typedef struct _RTL_SRWLOCK {
292   PVOID Ptr;
293 } RTL_SRWLOCK, *PRTL_SRWLOCK;
294 
295 #ifdef UNICODE
296 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
297 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
298 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
299 typedef OSVERSIONINFOW OSVERSIONINFO;
300 typedef POSVERSIONINFOW POSVERSIONINFO;
301 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
302 #else
303 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
304 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
305 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
306 typedef OSVERSIONINFOA OSVERSIONINFO;
307 typedef POSVERSIONINFOA POSVERSIONINFO;
308 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
309 #endif /* UNICODE */
310 
311 $endif (_WDMDDK_)
312 $if (_NTDDK_ || _WINNT_)
313 
314 #ifndef _RTL_RUN_ONCE_DEF
315 #define _RTL_RUN_ONCE_DEF
316 
317 #define RTL_RUN_ONCE_INIT {0}
318 
319 #define RTL_RUN_ONCE_CHECK_ONLY     0x00000001UL
320 #define RTL_RUN_ONCE_ASYNC          0x00000002UL
321 #define RTL_RUN_ONCE_INIT_FAILED    0x00000004UL
322 
323 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
324 
325 typedef union _RTL_RUN_ONCE {
326   PVOID Ptr;
327 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
328 
329 typedef
330 _Function_class_(RTL_RUN_ONCE_INIT_FN)
331 _IRQL_requires_same_
332 ULONG
333 NTAPI
334 RTL_RUN_ONCE_INIT_FN(
335     _Inout_ PRTL_RUN_ONCE RunOnce,
336     _Inout_opt_ PVOID Parameter,
337     _Inout_opt_ PVOID* Context);
338 typedef RTL_RUN_ONCE_INIT_FN* PRTL_RUN_ONCE_INIT_FN;
339 
340 #endif /* _RTL_RUN_ONCE_DEF */
341 
342 $endif(_NTDDK_ || _WINNT_)
343 $if(_NTDDK_)
344 
345 #define RTL_HASH_ALLOCATED_HEADER            0x00000001
346 
347 #define RTL_HASH_RESERVED_SIGNATURE 0
348 
349 /* RtlVerifyVersionInfo() ComparisonType */
350 
351 #define VER_EQUAL                       1
352 #define VER_GREATER                     2
353 #define VER_GREATER_EQUAL               3
354 #define VER_LESS                        4
355 #define VER_LESS_EQUAL                  5
356 #define VER_AND                         6
357 #define VER_OR                          7
358 
359 #define VER_CONDITION_MASK              7
360 #define VER_NUM_BITS_PER_CONDITION_MASK 3
361 
362 /* RtlVerifyVersionInfo() TypeMask */
363 
364 #define VER_MINORVERSION                  0x0000001
365 #define VER_MAJORVERSION                  0x0000002
366 #define VER_BUILDNUMBER                   0x0000004
367 #define VER_PLATFORMID                    0x0000008
368 #define VER_SERVICEPACKMINOR              0x0000010
369 #define VER_SERVICEPACKMAJOR              0x0000020
370 #define VER_SUITENAME                     0x0000040
371 #define VER_PRODUCT_TYPE                  0x0000080
372 
373 #define VER_NT_WORKSTATION              0x0000001
374 #define VER_NT_DOMAIN_CONTROLLER        0x0000002
375 #define VER_NT_SERVER                   0x0000003
376 
377 #define VER_PLATFORM_WIN32s             0
378 #define VER_PLATFORM_WIN32_WINDOWS      1
379 #define VER_PLATFORM_WIN32_NT           2
380 
381 typedef enum _TABLE_SEARCH_RESULT {
382   TableEmptyTree,
383   TableFoundNode,
384   TableInsertAsLeft,
385   TableInsertAsRight
386 } TABLE_SEARCH_RESULT;
387 
388 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
389   GenericLessThan,
390   GenericGreaterThan,
391   GenericEqual
392 } RTL_GENERIC_COMPARE_RESULTS;
393 
394 // Forwarder
395 struct _RTL_AVL_TABLE;
396 
397 _IRQL_requires_same_
398 _Function_class_(RTL_AVL_COMPARE_ROUTINE)
399 typedef RTL_GENERIC_COMPARE_RESULTS
400 (NTAPI RTL_AVL_COMPARE_ROUTINE) (
401   _In_ struct _RTL_AVL_TABLE *Table,
402   _In_ PVOID FirstStruct,
403   _In_ PVOID SecondStruct);
404 typedef RTL_AVL_COMPARE_ROUTINE *PRTL_AVL_COMPARE_ROUTINE;
405 
406 _IRQL_requires_same_
407 _Function_class_(RTL_AVL_ALLOCATE_ROUTINE)
408 __drv_allocatesMem(Mem)
409 typedef PVOID
410 (NTAPI RTL_AVL_ALLOCATE_ROUTINE) (
411   _In_ struct _RTL_AVL_TABLE *Table,
412   _In_ CLONG ByteSize);
413 typedef RTL_AVL_ALLOCATE_ROUTINE *PRTL_AVL_ALLOCATE_ROUTINE;
414 
415 _IRQL_requires_same_
416 _Function_class_(RTL_AVL_FREE_ROUTINE)
417 typedef VOID
418 (NTAPI RTL_AVL_FREE_ROUTINE) (
419   _In_ struct _RTL_AVL_TABLE *Table,
420   _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer);
421 typedef RTL_AVL_FREE_ROUTINE *PRTL_AVL_FREE_ROUTINE;
422 
423 _IRQL_requires_same_
424 _Function_class_(RTL_AVL_MATCH_FUNCTION)
425 typedef NTSTATUS
426 (NTAPI RTL_AVL_MATCH_FUNCTION) (
427   _In_ struct _RTL_AVL_TABLE *Table,
428   _In_ PVOID UserData,
429   _In_ PVOID MatchData);
430 typedef RTL_AVL_MATCH_FUNCTION *PRTL_AVL_MATCH_FUNCTION;
431 
432 typedef struct _RTL_BALANCED_LINKS {
433   struct _RTL_BALANCED_LINKS *Parent;
434   struct _RTL_BALANCED_LINKS *LeftChild;
435   struct _RTL_BALANCED_LINKS *RightChild;
436   CHAR Balance;
437   UCHAR Reserved[3];
438 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
439 
440 typedef struct _RTL_AVL_TABLE {
441   RTL_BALANCED_LINKS BalancedRoot;
442   PVOID OrderedPointer;
443   ULONG WhichOrderedElement;
444   ULONG NumberGenericTableElements;
445   ULONG DepthOfTree;
446   PRTL_BALANCED_LINKS RestartKey;
447   ULONG DeleteCount;
448   PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
449   PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
450   PRTL_AVL_FREE_ROUTINE FreeRoutine;
451   PVOID TableContext;
452 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
453 
454 typedef struct _RTL_SPLAY_LINKS {
455   struct _RTL_SPLAY_LINKS *Parent;
456   struct _RTL_SPLAY_LINKS *LeftChild;
457   struct _RTL_SPLAY_LINKS *RightChild;
458 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
459 
460 #ifndef RTL_USE_AVL_TABLES
461 
462 struct _RTL_GENERIC_TABLE;
463 
464 _IRQL_requires_same_
465 _Function_class_(RTL_GENERIC_COMPARE_ROUTINE)
466 typedef RTL_GENERIC_COMPARE_RESULTS
467 (NTAPI RTL_GENERIC_COMPARE_ROUTINE) (
468   _In_ struct _RTL_GENERIC_TABLE *Table,
469   _In_ PVOID FirstStruct,
470   _In_ PVOID SecondStruct);
471 typedef RTL_GENERIC_COMPARE_ROUTINE *PRTL_GENERIC_COMPARE_ROUTINE;
472 
473 _IRQL_requires_same_
474 _Function_class_(RTL_GENERIC_ALLOCATE_ROUTINE)
475 __drv_allocatesMem(Mem)
476 typedef PVOID
477 (NTAPI RTL_GENERIC_ALLOCATE_ROUTINE) (
478   _In_ struct _RTL_GENERIC_TABLE *Table,
479   _In_ CLONG ByteSize);
480 typedef RTL_GENERIC_ALLOCATE_ROUTINE *PRTL_GENERIC_ALLOCATE_ROUTINE;
481 
482 _IRQL_requires_same_
483 _Function_class_(RTL_GENERIC_FREE_ROUTINE)
484 typedef VOID
485 (NTAPI RTL_GENERIC_FREE_ROUTINE) (
486   _In_ struct _RTL_GENERIC_TABLE *Table,
487   _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer);
488 typedef RTL_GENERIC_FREE_ROUTINE *PRTL_GENERIC_FREE_ROUTINE;
489 
490 typedef struct _RTL_GENERIC_TABLE {
491   PRTL_SPLAY_LINKS TableRoot;
492   LIST_ENTRY InsertOrderList;
493   PLIST_ENTRY OrderedPointer;
494   ULONG WhichOrderedElement;
495   ULONG NumberGenericTableElements;
496   PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
497   PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
498   PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
499   PVOID TableContext;
500 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
501 
502 #endif /* !RTL_USE_AVL_TABLES */
503 
504 #ifdef RTL_USE_AVL_TABLES
505 
506 #undef  RTL_GENERIC_COMPARE_ROUTINE
507 #undef PRTL_GENERIC_COMPARE_ROUTINE
508 #undef  RTL_GENERIC_ALLOCATE_ROUTINE
509 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
510 #undef  RTL_GENERIC_FREE_ROUTINE
511 #undef PRTL_GENERIC_FREE_ROUTINE
512 #undef  RTL_GENERIC_TABLE
513 #undef PRTL_GENERIC_TABLE
514 
515 #define  RTL_GENERIC_COMPARE_ROUTINE     RTL_AVL_COMPARE_ROUTINE
516 #define PRTL_GENERIC_COMPARE_ROUTINE    PRTL_AVL_COMPARE_ROUTINE
517 #define  RTL_GENERIC_ALLOCATE_ROUTINE    RTL_AVL_ALLOCATE_ROUTINE
518 #define PRTL_GENERIC_ALLOCATE_ROUTINE   PRTL_AVL_ALLOCATE_ROUTINE
519 #define  RTL_GENERIC_FREE_ROUTINE        RTL_AVL_FREE_ROUTINE
520 #define PRTL_GENERIC_FREE_ROUTINE       PRTL_AVL_FREE_ROUTINE
521 #define  RTL_GENERIC_TABLE               RTL_AVL_TABLE
522 #define PRTL_GENERIC_TABLE              PRTL_AVL_TABLE
523 
524 #endif /* RTL_USE_AVL_TABLES */
525 
526 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
527 
528 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY {
529   LIST_ENTRY Linkage;
530   ULONG_PTR Signature;
531 } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY;
532 
533 typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT {
534   PLIST_ENTRY ChainHead;
535   PLIST_ENTRY PrevLinkage;
536   ULONG_PTR Signature;
537 } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT;
538 
539 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR {
540   RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry;
541   PLIST_ENTRY ChainHead;
542   ULONG BucketIndex;
543 } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR;
544 
545 typedef struct _RTL_DYNAMIC_HASH_TABLE {
546   ULONG Flags;
547   ULONG Shift;
548   ULONG TableSize;
549   ULONG Pivot;
550   ULONG DivisorMask;
551   ULONG NumEntries;
552   ULONG NonEmptyBuckets;
553   ULONG NumEnumerators;
554   PVOID Directory;
555 } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE;
556 
557 #define HASH_ENTRY_KEY(x)    ((x)->Signature)
558 
559 $endif (_NTDDK_)
560 $if (_NTIFS_)
561 
562 #define RTL_SYSTEM_VOLUME_INFORMATION_FOLDER    L"System Volume Information"
563 
564 _Function_class_(RTL_ALLOCATE_STRING_ROUTINE)
565 _IRQL_requires_max_(PASSIVE_LEVEL)
566 __drv_allocatesMem(Mem)
567 typedef PVOID
568 (NTAPI *PRTL_ALLOCATE_STRING_ROUTINE)(
569   _In_ SIZE_T NumberOfBytes);
570 
571 #if _WIN32_WINNT >= 0x0600
572 _Function_class_(RTL_REALLOCATE_STRING_ROUTINE)
573 _IRQL_requires_max_(PASSIVE_LEVEL)
574 __drv_allocatesMem(Mem)
575 typedef PVOID
576 (NTAPI *PRTL_REALLOCATE_STRING_ROUTINE)(
577   _In_ SIZE_T NumberOfBytes,
578   IN PVOID Buffer);
579 #endif
580 
581 typedef VOID
582 (NTAPI *PRTL_FREE_STRING_ROUTINE)(
583   _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer);
584 
585 extern NTKERNELAPI const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine;
586 extern NTKERNELAPI const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine;
587 
588 #if _WIN32_WINNT >= 0x0600
589 extern NTKERNELAPI const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine;
590 #endif
591 
592 _Function_class_(RTL_HEAP_COMMIT_ROUTINE)
593 _IRQL_requires_same_
594 typedef NTSTATUS
595 (NTAPI *PRTL_HEAP_COMMIT_ROUTINE) (
596   _In_ PVOID Base,
597   _Inout_ PVOID *CommitAddress,
598   _Inout_ PSIZE_T CommitSize);
599 
600 typedef struct _RTL_HEAP_PARAMETERS {
601   ULONG Length;
602   SIZE_T SegmentReserve;
603   SIZE_T SegmentCommit;
604   SIZE_T DeCommitFreeBlockThreshold;
605   SIZE_T DeCommitTotalFreeThreshold;
606   SIZE_T MaximumAllocationSize;
607   SIZE_T VirtualMemoryThreshold;
608   SIZE_T InitialCommit;
609   SIZE_T InitialReserve;
610   PRTL_HEAP_COMMIT_ROUTINE CommitRoutine;
611   SIZE_T Reserved[2];
612 } RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
613 
614 #if (NTDDI_VERSION >= NTDDI_WIN2K)
615 
616 typedef struct _GENERATE_NAME_CONTEXT {
617   USHORT Checksum;
618   BOOLEAN CheckSumInserted;
619   _Field_range_(<=, 8) UCHAR NameLength;
620   WCHAR NameBuffer[8];
621   _Field_range_(<=, 4) ULONG ExtensionLength;
622   WCHAR ExtensionBuffer[4];
623   ULONG LastIndexValue;
624 } GENERATE_NAME_CONTEXT, *PGENERATE_NAME_CONTEXT;
625 
626 typedef struct _PREFIX_TABLE_ENTRY {
627   CSHORT NodeTypeCode;
628   CSHORT NameLength;
629   struct _PREFIX_TABLE_ENTRY *NextPrefixTree;
630   RTL_SPLAY_LINKS Links;
631   PSTRING Prefix;
632 } PREFIX_TABLE_ENTRY, *PPREFIX_TABLE_ENTRY;
633 
634 typedef struct _PREFIX_TABLE {
635   CSHORT NodeTypeCode;
636   CSHORT NameLength;
637   PPREFIX_TABLE_ENTRY NextPrefixTree;
638 } PREFIX_TABLE, *PPREFIX_TABLE;
639 
640 typedef struct _UNICODE_PREFIX_TABLE_ENTRY {
641   CSHORT NodeTypeCode;
642   CSHORT NameLength;
643   struct _UNICODE_PREFIX_TABLE_ENTRY *NextPrefixTree;
644   struct _UNICODE_PREFIX_TABLE_ENTRY *CaseMatch;
645   RTL_SPLAY_LINKS Links;
646   PUNICODE_STRING Prefix;
647 } UNICODE_PREFIX_TABLE_ENTRY, *PUNICODE_PREFIX_TABLE_ENTRY;
648 
649 typedef struct _UNICODE_PREFIX_TABLE {
650   CSHORT NodeTypeCode;
651   CSHORT NameLength;
652   PUNICODE_PREFIX_TABLE_ENTRY NextPrefixTree;
653   PUNICODE_PREFIX_TABLE_ENTRY LastNextEntry;
654 } UNICODE_PREFIX_TABLE, *PUNICODE_PREFIX_TABLE;
655 
656 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
657 
658 #if (NTDDI_VERSION >= NTDDI_WINXP)
659 typedef struct _COMPRESSED_DATA_INFO {
660   USHORT CompressionFormatAndEngine;
661   UCHAR CompressionUnitShift;
662   UCHAR ChunkShift;
663   UCHAR ClusterShift;
664   UCHAR Reserved;
665   USHORT NumberOfChunks;
666   ULONG CompressedChunkSizes[ANYSIZE_ARRAY];
667 } COMPRESSED_DATA_INFO, *PCOMPRESSED_DATA_INFO;
668 #endif
669 $endif (_NTIFS_)
670