xref: /reactos/sdk/include/ndk/rtltypes.h (revision 0622ce17)
1 /*++ NDK Version: 0098
2 
3 Copyright (c) Alex Ionescu.  All rights reserved.
4 
5 Header Name:
6 
7     rtltypes.h
8 
9 Abstract:
10 
11     Type definitions for the Run-Time Library
12 
13 Author:
14 
15     Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16 
17 --*/
18 
19 #ifndef _RTLTYPES_H
20 #define _RTLTYPES_H
21 
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <mmtypes.h>
27 #include <ldrtypes.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 //
34 // Maximum Atom Length
35 //
36 #define RTL_MAXIMUM_ATOM_LENGTH                             255
37 
38 //
39 // Process Parameters Flags
40 //
41 #define RTL_USER_PROCESS_PARAMETERS_NORMALIZED              0x01
42 #define RTL_USER_PROCESS_PARAMETERS_PROFILE_USER            0x02
43 #define RTL_USER_PROCESS_PARAMETERS_PROFILE_KERNEL          0x04
44 #define RTL_USER_PROCESS_PARAMETERS_PROFILE_SERVER          0x08
45 #define RTL_USER_PROCESS_PARAMETERS_UNKNOWN                 0x10
46 #define RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB             0x20
47 #define RTL_USER_PROCESS_PARAMETERS_RESERVE_16MB            0x40
48 #define RTL_USER_PROCESS_PARAMETERS_CASE_SENSITIVE          0x80
49 #define RTL_USER_PROCESS_PARAMETERS_DISABLE_HEAP_CHECKS     0x100
50 #define RTL_USER_PROCESS_PARAMETERS_PROCESS_OR_1            0x200
51 #define RTL_USER_PROCESS_PARAMETERS_PROCESS_OR_2            0x400
52 #define RTL_USER_PROCESS_PARAMETERS_PRIVATE_DLL_PATH        0x1000
53 #define RTL_USER_PROCESS_PARAMETERS_LOCAL_DLL_PATH          0x2000
54 #define RTL_USER_PROCESS_PARAMETERS_IMAGE_KEY_MISSING       0x4000
55 #define RTL_USER_PROCESS_PARAMETERS_NX                      0x20000
56 
57 #define RTL_MAX_DRIVE_LETTERS 32
58 #define RTL_DRIVE_LETTER_VALID (USHORT)0x0001
59 
60 //
61 // End of Exception List
62 //
63 #define EXCEPTION_CHAIN_END                                 ((PEXCEPTION_REGISTRATION_RECORD)-1)
64 
65 //
66 // Thread Error Mode Flags
67 //
68 /* Also defined in psdk/winbase.h */
69 #define SEM_FAILCRITICALERRORS          0x0001
70 #define SEM_NOGPFAULTERRORBOX           0x0002
71 #define SEM_NOALIGNMENTFAULTEXCEPT      0x0004
72 #define SEM_NOOPENFILEERRORBOX          0x8000
73 
74 #define RTL_SEM_FAILCRITICALERRORS      (SEM_FAILCRITICALERRORS     << 4)
75 #define RTL_SEM_NOGPFAULTERRORBOX       (SEM_NOGPFAULTERRORBOX      << 4)
76 #define RTL_SEM_NOALIGNMENTFAULTEXCEPT  (SEM_NOALIGNMENTFAULTEXCEPT << 4)
77 
78 //
79 // Range and Range List Flags
80 //
81 #define RTL_RANGE_LIST_ADD_IF_CONFLICT                      0x00000001
82 #define RTL_RANGE_LIST_ADD_SHARED                           0x00000002
83 
84 #define RTL_RANGE_SHARED                                    0x01
85 #define RTL_RANGE_CONFLICT                                  0x02
86 
87 //
88 // Flags in RTL_ACTIVATION_CONTEXT_STACK_FRAME (from Checked NTDLL)
89 //
90 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_RELEASE_ON_DEACTIVATION         0x01
91 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NO_DEACTIVATE                   0x02
92 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_ON_FREE_LIST                    0x04
93 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_HEAP_ALLOCATED                  0x08
94 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NOT_REALLY_ACTIVATED            0x10
95 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_ACTIVATED                       0x20
96 #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_DEACTIVATED                     0x40
97 
98 //
99 // Activation Context Frame Flags (from Checked NTDLL)
100 //
101 #define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER     0x01
102 
103 //
104 // RtlActivateActivationContextEx Flags (from Checked NTDLL)
105 //
106 #define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION   0x01
107 
108 //
109 // RtlDeactivateActivationContext Flags (based on Win32 flag and name of above)
110 //
111 #define RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION         0x01
112 
113 //
114 // RtlQueryActivationContext Flags (based on Win32 flag and name of above)
115 //
116 #define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT         0x01
117 #define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_HMODULE                            0x02
118 #define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_IS_ADDRESS                            0x04
119 #define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF                             0x80000000
120 
121 //
122 // Public Heap Flags
123 //
124 #if !defined(NTOS_MODE_USER) && !defined(_NTIFS_)
125 #define HEAP_NO_SERIALIZE                                   0x00000001
126 #define HEAP_GROWABLE                                       0x00000002
127 #define HEAP_GENERATE_EXCEPTIONS                            0x00000004
128 #define HEAP_ZERO_MEMORY                                    0x00000008
129 #define HEAP_REALLOC_IN_PLACE_ONLY                          0x00000010
130 #define HEAP_TAIL_CHECKING_ENABLED                          0x00000020
131 #define HEAP_FREE_CHECKING_ENABLED                          0x00000040
132 #define HEAP_DISABLE_COALESCE_ON_FREE                       0x00000080
133 #define HEAP_CREATE_ALIGN_16                                0x00010000
134 #define HEAP_CREATE_ENABLE_TRACING                          0x00020000
135 #define HEAP_CREATE_ENABLE_EXECUTE                          0x00040000
136 #endif
137 
138 //
139 // User-Defined Heap Flags and Classes
140 //
141 #define HEAP_SETTABLE_USER_VALUE                            0x00000100
142 #define HEAP_SETTABLE_USER_FLAG1                            0x00000200
143 #define HEAP_SETTABLE_USER_FLAG2                            0x00000400
144 #define HEAP_SETTABLE_USER_FLAG3                            0x00000800
145 #define HEAP_SETTABLE_USER_FLAGS                            0x00000E00
146 #define HEAP_CLASS_0                                        0x00000000
147 #define HEAP_CLASS_1                                        0x00001000
148 #define HEAP_CLASS_2                                        0x00002000
149 #define HEAP_CLASS_3                                        0x00003000
150 #define HEAP_CLASS_4                                        0x00004000
151 #define HEAP_CLASS_5                                        0x00005000
152 #define HEAP_CLASS_6                                        0x00006000
153 #define HEAP_CLASS_7                                        0x00007000
154 #define HEAP_CLASS_8                                        0x00008000
155 #define HEAP_CLASS_MASK                                     0x0000F000
156 
157 //
158 // Internal HEAP Structure Flags
159 //
160 #define HEAP_FLAG_PAGE_ALLOCS                               0x01000000
161 #define HEAP_PROTECTION_ENABLED                             0x02000000
162 #define HEAP_BREAK_WHEN_OUT_OF_VM                           0x04000000
163 #define HEAP_NO_ALIGNMENT                                   0x08000000
164 #define HEAP_CAPTURE_STACK_BACKTRACES                       0x08000000
165 #define HEAP_SKIP_VALIDATION_CHECKS                         0x10000000
166 #define HEAP_VALIDATE_ALL_ENABLED                           0x20000000
167 #define HEAP_VALIDATE_PARAMETERS_ENABLED                    0x40000000
168 #define HEAP_LOCK_USER_ALLOCATED                            0x80000000
169 
170 //
171 // Heap Validation Flags
172 //
173 #define HEAP_CREATE_VALID_MASK                              \
174     (HEAP_NO_SERIALIZE              |                       \
175      HEAP_GROWABLE                  |                       \
176      HEAP_GENERATE_EXCEPTIONS       |                       \
177      HEAP_ZERO_MEMORY               |                       \
178      HEAP_REALLOC_IN_PLACE_ONLY     |                       \
179      HEAP_TAIL_CHECKING_ENABLED     |                       \
180      HEAP_FREE_CHECKING_ENABLED     |                       \
181      HEAP_DISABLE_COALESCE_ON_FREE  |                       \
182      HEAP_CLASS_MASK                |                       \
183      HEAP_CREATE_ALIGN_16           |                       \
184      HEAP_CREATE_ENABLE_TRACING     |                       \
185      HEAP_CREATE_ENABLE_EXECUTE)
186 #ifdef C_ASSERT
187 C_ASSERT(HEAP_CREATE_VALID_MASK == 0x0007F0FF);
188 #endif
189 
190 //
191 // Native image architecture
192 //
193 #if defined(_M_IX86)
194 #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386
195 #elif defined(_M_ARM)
196 #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM
197 #elif defined(_M_AMD64)
198 #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64
199 #else
200 #error Define these please!
201 #endif
202 
203 //
204 // Registry Keys
205 //
206 #define RTL_REGISTRY_ABSOLUTE                               0
207 #define RTL_REGISTRY_SERVICES                               1
208 #define RTL_REGISTRY_CONTROL                                2
209 #define RTL_REGISTRY_WINDOWS_NT                             3
210 #define RTL_REGISTRY_DEVICEMAP                              4
211 #define RTL_REGISTRY_USER                                   5
212 #define RTL_REGISTRY_MAXIMUM                                6
213 #define RTL_REGISTRY_HANDLE                                 0x40000000
214 #define RTL_REGISTRY_OPTIONAL                               0x80000000
215 #define RTL_QUERY_REGISTRY_SUBKEY                           0x00000001
216 #define RTL_QUERY_REGISTRY_TOPKEY                           0x00000002
217 #define RTL_QUERY_REGISTRY_REQUIRED                         0x00000004
218 #define RTL_QUERY_REGISTRY_NOVALUE                          0x00000008
219 #define RTL_QUERY_REGISTRY_NOEXPAND                         0x00000010
220 #define RTL_QUERY_REGISTRY_DIRECT                           0x00000020
221 #define RTL_QUERY_REGISTRY_DELETE                           0x00000040
222 
223 //
224 // Versioning
225 //
226 #define VER_MINORVERSION                                    0x0000001
227 #define VER_MAJORVERSION                                    0x0000002
228 #define VER_BUILDNUMBER                                     0x0000004
229 #define VER_PLATFORMID                                      0x0000008
230 #define VER_SERVICEPACKMINOR                                0x0000010
231 #define VER_SERVICEPACKMAJOR                                0x0000020
232 #define VER_SUITENAME                                       0x0000040
233 #define VER_PRODUCT_TYPE                                    0x0000080
234 #define VER_PLATFORM_WIN32s                                 0
235 #define VER_PLATFORM_WIN32_WINDOWS                          1
236 #define VER_PLATFORM_WIN32_NT                               2
237 #define VER_EQUAL                                           1
238 #define VER_GREATER                                         2
239 #define VER_GREATER_EQUAL                                   3
240 #define VER_LESS                                            4
241 #define VER_LESS_EQUAL                                      5
242 #define VER_AND                                             6
243 #define VER_OR                                              7
244 #define VER_CONDITION_MASK                                  7
245 #define VER_NUM_BITS_PER_CONDITION_MASK                     3
246 
247 //
248 // Timezone IDs
249 //
250 #define TIME_ZONE_ID_UNKNOWN                                0
251 #define TIME_ZONE_ID_STANDARD                               1
252 #define TIME_ZONE_ID_DAYLIGHT                               2
253 
254 //
255 // Maximum Path Length
256 //
257 #define MAX_PATH                                            260
258 
259 //
260 // RTL Lock Type (Critical Section or Resource)
261 //
262 #define RTL_CRITSECT_TYPE                                   0
263 #define RTL_RESOURCE_TYPE                                   1
264 
265 //
266 // RtlAcquirePrivileges Flags
267 //
268 #define RTL_ACQUIRE_PRIVILEGE_IMPERSONATE                   1
269 #define RTL_ACQUIRE_PRIVILEGE_PROCESS                       2
270 
271 #ifdef NTOS_MODE_USER
272 
273 //
274 // String Hash Algorithms
275 //
276 #define HASH_STRING_ALGORITHM_DEFAULT                       0
277 #define HASH_STRING_ALGORITHM_X65599                        1
278 #define HASH_STRING_ALGORITHM_INVALID                       0xffffffff
279 
280 //
281 // RtlDuplicateString Flags
282 //
283 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE         1
284 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING   2
285 
286 //
287 // RtlFindCharInUnicodeString Flags
288 //
289 #define RTL_FIND_CHAR_IN_UNICODE_STRING_START_AT_END        1
290 #define RTL_FIND_CHAR_IN_UNICODE_STRING_COMPLEMENT_CHAR_SET 2
291 #define RTL_FIND_CHAR_IN_UNICODE_STRING_CASE_INSENSITIVE    4
292 
293 //
294 // RtlImageNtHeaderEx Flags
295 //
296 #define RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK          0x00000001
297 
298 //
299 // RtlDosApplyFileIsolationRedirection_Ustr Flags
300 //
301 #define RTL_DOS_APPLY_FILE_REDIRECTION_USTR_FLAG_RESPECT_DOT_LOCAL  0x01
302 
303 //
304 // Codepages
305 //
306 #define NLS_MB_CODE_PAGE_TAG                                NlsMbCodePageTag
307 #define NLS_MB_OEM_CODE_PAGE_TAG                            NlsMbOemCodePageTag
308 #define NLS_OEM_LEAD_BYTE_INFO                              NlsOemLeadByteInfo
309 
310 //
311 // Activation Contexts
312 //
313 #define INVALID_ACTIVATION_CONTEXT                          (PVOID)0xFFFFFFFF
314 
315 //
316 // C++ CONST casting
317 //
318 #if defined(__cplusplus)
319 #define RTL_CONST_CAST(type)                    const_cast<type>
320 #else
321 #define RTL_CONST_CAST(type)                    (type)
322 #endif
323 
324 //
325 // Constant String Macro
326 //
327 #define RTL_CONSTANT_STRING(__SOURCE_STRING__)                  \
328 {                                                               \
329     sizeof(__SOURCE_STRING__) - sizeof((__SOURCE_STRING__)[0]), \
330     sizeof(__SOURCE_STRING__),                                  \
331     (__SOURCE_STRING__)                                         \
332 }
333 
334 //
335 // Constant Object Attributes Macro
336 //
337 #define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)                    \
338 {                                                               \
339     sizeof(OBJECT_ATTRIBUTES),                                  \
340     NULL,                                                       \
341     RTL_CONST_CAST(PUNICODE_STRING)(n),                         \
342     a,                                                          \
343     NULL,                                                       \
344     NULL                                                        \
345 }
346 
347 #define RTL_INIT_OBJECT_ATTRIBUTES(n, a)                        \
348     RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
349 
350 #else /* NTOS_MODE_USER */
351 //
352 // Message Resource Flag
353 //
354 #define MESSAGE_RESOURCE_UNICODE                            0x0001
355 
356 #endif /* !NTOS_MODE_USER */
357 #define MAXIMUM_LEADBYTES                                   12
358 
359 //
360 // RTL Debug Queries
361 //
362 #define RTL_DEBUG_QUERY_MODULES                             0x01
363 #define RTL_DEBUG_QUERY_BACKTRACES                          0x02
364 #define RTL_DEBUG_QUERY_HEAPS                               0x04
365 #define RTL_DEBUG_QUERY_HEAP_TAGS                           0x08
366 #define RTL_DEBUG_QUERY_HEAP_BLOCKS                         0x10
367 #define RTL_DEBUG_QUERY_LOCKS                               0x20
368 
369 //
370 // RTL Handle Flags
371 //
372 #define RTL_HANDLE_VALID                                    0x1
373 
374 //
375 // RTL Atom Flags
376 //
377 #define RTL_ATOM_IS_PINNED                                  0x1
378 
379 //
380 // Critical section lock bits
381 //
382 #define CS_LOCK_BIT                                         0x1
383 #define CS_LOCK_BIT_V                                       0x0
384 #define CS_LOCK_WAITER_WOKEN                                0x2
385 #define CS_LOCK_WAITER_INC                                  0x4
386 
387 //
388 // Codepage Tags
389 //
390 #ifdef NTOS_MODE_USER
391 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
392 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
393 
394 //
395 // Constant String Macro
396 //
397 #define RTL_CONSTANT_STRING(__SOURCE_STRING__)                  \
398 {                                                               \
399     sizeof(__SOURCE_STRING__) - sizeof((__SOURCE_STRING__)[0]), \
400     sizeof(__SOURCE_STRING__),                                  \
401     (__SOURCE_STRING__)                                         \
402 }
403 
404 #endif /* NTOS_MODE_USER */
405 
406 #ifdef NTOS_MODE_USER
407 
408 //
409 // Boot Status Data Field Types
410 //
411 typedef enum _RTL_BSD_ITEM_TYPE
412 {
413     RtlBsdItemVersionNumber,
414     RtlBsdItemProductType,
415     RtlBsdItemAabEnabled,
416     RtlBsdItemAabTimeout,
417     RtlBsdItemBootGood,
418     RtlBsdItemBootShutdown,
419     RtlBsdItemMax
420 } RTL_BSD_ITEM_TYPE, *PRTL_BSD_ITEM_TYPE;
421 
422 //
423 // Table and Compare result types
424 //
425 typedef enum _TABLE_SEARCH_RESULT
426 {
427     TableEmptyTree,
428     TableFoundNode,
429     TableInsertAsLeft,
430     TableInsertAsRight
431 } TABLE_SEARCH_RESULT;
432 
433 typedef enum _RTL_GENERIC_COMPARE_RESULTS
434 {
435     GenericLessThan,
436     GenericGreaterThan,
437     GenericEqual
438 } RTL_GENERIC_COMPARE_RESULTS;
439 
440 #endif /* NTOS_MODE_USER */
441 
442 //
443 // RTL Path Types
444 //
445 typedef enum _RTL_PATH_TYPE
446 {
447     RtlPathTypeUnknown,
448     RtlPathTypeUncAbsolute,
449     RtlPathTypeDriveAbsolute,
450     RtlPathTypeDriveRelative,
451     RtlPathTypeRooted,
452     RtlPathTypeRelative,
453     RtlPathTypeLocalDevice,
454     RtlPathTypeRootLocalDevice,
455 } RTL_PATH_TYPE;
456 
457 #ifndef NTOS_MODE_USER
458 
459 //
460 // Heap Information Class
461 //
462 typedef enum _HEAP_INFORMATION_CLASS
463 {
464     HeapCompatibilityInformation,
465     HeapEnableTerminationOnCorruption
466 } HEAP_INFORMATION_CLASS;
467 
468 //
469 // Callback function for RTL Timers or Registered Waits
470 //
471 typedef VOID
472 (NTAPI *WAITORTIMERCALLBACKFUNC)(
473     PVOID pvContext,
474     BOOLEAN fTimerOrWaitFired
475 );
476 
477 //
478 // Handler during Vectored RTL Exceptions
479 //
480 typedef LONG
481 (NTAPI *PVECTORED_EXCEPTION_HANDLER)(
482     PEXCEPTION_POINTERS ExceptionPointers
483 );
484 
485 //
486 // Worker Thread Callback for Rtl
487 //
488 typedef VOID
489 (NTAPI *WORKERCALLBACKFUNC)(
490     _In_ PVOID Context
491 );
492 
493 #else /* !NTOS_MODE_USER */
494 
495 //
496 // RTL Library Allocation/Free Routines
497 //
498 typedef PVOID
499 (NTAPI *PRTL_ALLOCATE_STRING_ROUTINE)(
500     SIZE_T NumberOfBytes
501 );
502 
503 typedef PVOID
504 (NTAPI *PRTL_REALLOCATE_STRING_ROUTINE)(
505     SIZE_T NumberOfBytes,
506     PVOID Buffer
507 );
508 
509 typedef
510 VOID
511 (NTAPI *PRTL_FREE_STRING_ROUTINE)(
512     PVOID Buffer
513 );
514 
515 extern const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine;
516 extern const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine;
517 extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine;
518 
519 #endif /* NTOS_MODE_USER */
520 
521 //
522 // Unhandled Exception Filter
523 //
524 typedef ULONG
525 (NTAPI *RTLP_UNHANDLED_EXCEPTION_FILTER)(
526     _In_ struct _EXCEPTION_POINTERS *ExceptionInfo
527 );
528 typedef RTLP_UNHANDLED_EXCEPTION_FILTER *PRTLP_UNHANDLED_EXCEPTION_FILTER;
529 
530 //
531 // Callback for RTL Heap Enumeration
532 //
533 typedef NTSTATUS
534 (NTAPI *PHEAP_ENUMERATION_ROUTINE)(
535     _In_ PVOID HeapHandle,
536     _In_ PVOID UserParam
537 );
538 
539 //
540 // Thread and Process Start Routines for RtlCreateUserThread/Process
541 //
542 typedef ULONG (NTAPI *PTHREAD_START_ROUTINE)(
543     PVOID Parameter
544 );
545 
546 typedef VOID
547 (NTAPI *PRTL_BASE_PROCESS_START_ROUTINE)(
548     PTHREAD_START_ROUTINE StartAddress,
549     PVOID Parameter
550 );
551 
552 //
553 // Worker Start/Exit Function
554 //
555 typedef NTSTATUS
556 (NTAPI *PRTL_START_POOL_THREAD)(
557     _In_ PTHREAD_START_ROUTINE Function,
558     _In_ PVOID Parameter,
559     _Out_ PHANDLE ThreadHandle
560 );
561 
562 typedef NTSTATUS
563 (NTAPI *PRTL_EXIT_POOL_THREAD)(
564     _In_ NTSTATUS ExitStatus
565 );
566 
567 //
568 // Declare empty structure definitions so that they may be referenced by
569 // routines before they are defined
570 //
571 struct _RTL_AVL_TABLE;
572 struct _RTL_GENERIC_TABLE;
573 struct _RTL_RANGE;
574 
575 //
576 // Routines and callbacks for the RTL AVL/Generic Table package
577 //
578 #ifdef NTOS_MODE_USER
579 typedef NTSTATUS
580 (NTAPI RTL_AVL_MATCH_FUNCTION)(
581     struct _RTL_AVL_TABLE *Table,
582     PVOID UserData,
583     PVOID MatchData
584 );
585 typedef RTL_AVL_MATCH_FUNCTION *PRTL_AVL_MATCH_FUNCTION;
586 
587 typedef RTL_GENERIC_COMPARE_RESULTS
588 (NTAPI RTL_AVL_COMPARE_ROUTINE) (
589     struct _RTL_AVL_TABLE *Table,
590     PVOID FirstStruct,
591     PVOID SecondStruct
592 );
593 typedef RTL_AVL_COMPARE_ROUTINE *PRTL_AVL_COMPARE_ROUTINE;
594 
595 typedef RTL_GENERIC_COMPARE_RESULTS
596 (NTAPI RTL_GENERIC_COMPARE_ROUTINE) (
597     struct _RTL_GENERIC_TABLE *Table,
598     PVOID FirstStruct,
599     PVOID SecondStruct
600 );
601 typedef RTL_GENERIC_COMPARE_ROUTINE *PRTL_GENERIC_COMPARE_ROUTINE;
602 
603 typedef PVOID
604 (NTAPI RTL_GENERIC_ALLOCATE_ROUTINE) (
605     struct _RTL_GENERIC_TABLE *Table,
606     CLONG ByteSize
607 );
608 typedef RTL_GENERIC_ALLOCATE_ROUTINE *PRTL_GENERIC_ALLOCATE_ROUTINE;
609 
610 typedef PVOID
611 (NTAPI RTL_AVL_ALLOCATE_ROUTINE) (
612     struct _RTL_AVL_TABLE *Table,
613     CLONG ByteSize
614 );
615 typedef RTL_AVL_ALLOCATE_ROUTINE *PRTL_AVL_ALLOCATE_ROUTINE;
616 
617 typedef VOID
618 (NTAPI RTL_GENERIC_FREE_ROUTINE) (
619     struct _RTL_GENERIC_TABLE *Table,
620     PVOID Buffer
621 );
622 typedef RTL_GENERIC_FREE_ROUTINE *PRTL_GENERIC_FREE_ROUTINE;
623 
624 typedef VOID
625 (NTAPI RTL_AVL_FREE_ROUTINE) (
626     struct _RTL_AVL_TABLE *Table,
627     PVOID Buffer
628 );
629 typedef RTL_AVL_FREE_ROUTINE *PRTL_AVL_FREE_ROUTINE;
630 
631 #ifdef RTL_USE_AVL_TABLES
632 #undef  RTL_GENERIC_COMPARE_ROUTINE
633 #undef PRTL_GENERIC_COMPARE_ROUTINE
634 #undef  RTL_GENERIC_ALLOCATE_ROUTINE
635 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
636 #undef  RTL_GENERIC_FREE_ROUTINE
637 #undef PRTL_GENERIC_FREE_ROUTINE
638 
639 #define  RTL_GENERIC_COMPARE_ROUTINE     RTL_AVL_COMPARE_ROUTINE
640 #define PRTL_GENERIC_COMPARE_ROUTINE    PRTL_AVL_COMPARE_ROUTINE
641 #define  RTL_GENERIC_ALLOCATE_ROUTINE    RTL_AVL_ALLOCATE_ROUTINE
642 #define PRTL_GENERIC_ALLOCATE_ROUTINE   PRTL_AVL_ALLOCATE_ROUTINE
643 #define  RTL_GENERIC_FREE_ROUTINE        RTL_AVL_FREE_ROUTINE
644 #define PRTL_GENERIC_FREE_ROUTINE       PRTL_AVL_FREE_ROUTINE
645 #endif /* RTL_USE_AVL_TABLES */
646 
647 #endif /* NTOS_MODE_USER */
648 
649 //
650 // RTL Query Registry callback
651 //
652 #ifdef NTOS_MODE_USER
653 typedef NTSTATUS
654 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
655     _In_ PWSTR ValueName,
656     _In_ ULONG ValueType,
657     _In_ PVOID ValueData,
658     _In_ ULONG ValueLength,
659     _In_ PVOID Context,
660     _In_ PVOID EntryContext
661 );
662 #endif
663 
664 //
665 // RTL Secure Memory callbacks
666 //
667 #ifdef NTOS_MODE_USER
668 typedef NTSTATUS
669 (NTAPI *PRTL_SECURE_MEMORY_CACHE_CALLBACK)(
670     _In_ PVOID Address,
671     _In_ SIZE_T Length
672 );
673 #endif
674 
675 //
676 // RTL Range List callbacks
677 //
678 #ifdef NTOS_MODE_USER
679 typedef BOOLEAN
680 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK)(
681     PVOID Context,
682     struct _RTL_RANGE *Range
683 );
684 
685 //
686 // Custom Heap Commit Routine for RtlCreateHeap
687 //
688 typedef NTSTATUS
689 (NTAPI * PRTL_HEAP_COMMIT_ROUTINE)(
690     _In_ PVOID Base,
691     _Inout_ PVOID *CommitAddress,
692     _Inout_ PSIZE_T CommitSize
693 );
694 
695 //
696 // Parameters for RtlCreateHeap
697 //
698 typedef struct _RTL_HEAP_PARAMETERS
699 {
700     ULONG Length;
701     SIZE_T SegmentReserve;
702     SIZE_T SegmentCommit;
703     SIZE_T DeCommitFreeBlockThreshold;
704     SIZE_T DeCommitTotalFreeThreshold;
705     SIZE_T MaximumAllocationSize;
706     SIZE_T VirtualMemoryThreshold;
707     SIZE_T InitialCommit;
708     SIZE_T InitialReserve;
709     PRTL_HEAP_COMMIT_ROUTINE CommitRoutine;
710     SIZE_T Reserved[2];
711 } RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
712 
713 //
714 // RTL Bitmap structures
715 //
716 typedef struct _RTL_BITMAP
717 {
718     ULONG SizeOfBitMap;
719     PULONG Buffer;
720 } RTL_BITMAP, *PRTL_BITMAP;
721 
722 typedef struct _RTL_BITMAP_RUN
723 {
724     ULONG StartingIndex;
725     ULONG NumberOfBits;
726 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
727 
728 //
729 // RtlGenerateXxxName context
730 //
731 typedef struct _GENERATE_NAME_CONTEXT
732 {
733     USHORT Checksum;
734     BOOLEAN CheckSumInserted;
735     UCHAR NameLength;
736     WCHAR NameBuffer[8];
737     ULONG ExtensionLength;
738     WCHAR ExtensionBuffer[4];
739     ULONG LastIndexValue;
740 } GENERATE_NAME_CONTEXT, *PGENERATE_NAME_CONTEXT;
741 
742 //
743 // RTL Splay and Balanced Links structures
744 //
745 typedef struct _RTL_SPLAY_LINKS
746 {
747     struct _RTL_SPLAY_LINKS *Parent;
748     struct _RTL_SPLAY_LINKS *LeftChild;
749     struct _RTL_SPLAY_LINKS *RightChild;
750 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
751 
752 typedef struct _RTL_BALANCED_LINKS
753 {
754     struct _RTL_BALANCED_LINKS *Parent;
755     struct _RTL_BALANCED_LINKS *LeftChild;
756     struct _RTL_BALANCED_LINKS *RightChild;
757     CHAR Balance;
758     UCHAR Reserved[3];
759 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
760 
761 //
762 // RTL Avl/Generic Tables
763 //
764 #ifndef RTL_USE_AVL_TABLES
765 typedef struct _RTL_GENERIC_TABLE
766 {
767     PRTL_SPLAY_LINKS TableRoot;
768     LIST_ENTRY InsertOrderList;
769     PLIST_ENTRY OrderedPointer;
770     ULONG WhichOrderedElement;
771     ULONG NumberGenericTableElements;
772     PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
773     PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
774     PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
775     PVOID TableContext;
776 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
777 #endif /* !RTL_USE_AVL_TABLES */
778 
779 typedef struct _RTL_AVL_TABLE
780 {
781     RTL_BALANCED_LINKS BalancedRoot;
782     PVOID OrderedPointer;
783     ULONG WhichOrderedElement;
784     ULONG NumberGenericTableElements;
785     ULONG DepthOfTree;
786     PRTL_BALANCED_LINKS RestartKey;
787     ULONG DeleteCount;
788     PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
789     PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
790     PRTL_AVL_FREE_ROUTINE FreeRoutine;
791     PVOID TableContext;
792 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
793 
794 #ifdef RTL_USE_AVL_TABLES
795 #undef  RTL_GENERIC_TABLE
796 #undef PRTL_GENERIC_TABLE
797 
798 #define  RTL_GENERIC_TABLE  RTL_AVL_TABLE
799 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
800 #endif /* RTL_USE_AVL_TABLES */
801 
802 //
803 // RTL Compression Buffer
804 //
805 typedef struct _COMPRESSED_DATA_INFO {
806     USHORT CompressionFormatAndEngine;
807     UCHAR CompressionUnitShift;
808     UCHAR ChunkShift;
809     UCHAR ClusterShift;
810     UCHAR Reserved;
811     USHORT NumberOfChunks;
812     ULONG CompressedChunkSizes[ANYSIZE_ARRAY];
813 } COMPRESSED_DATA_INFO, *PCOMPRESSED_DATA_INFO;
814 
815 //
816 // RtlQueryRegistry Data
817 //
818 typedef struct _RTL_QUERY_REGISTRY_TABLE
819 {
820     PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
821     ULONG Flags;
822     PCWSTR Name;
823     PVOID EntryContext;
824     ULONG DefaultType;
825     PVOID DefaultData;
826     ULONG DefaultLength;
827 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
828 
829 //
830 // RTL Unicode Table Structures
831 //
832 typedef struct _UNICODE_PREFIX_TABLE_ENTRY
833 {
834     CSHORT NodeTypeCode;
835     CSHORT NameLength;
836     struct _UNICODE_PREFIX_TABLE_ENTRY *NextPrefixTree;
837     struct _UNICODE_PREFIX_TABLE_ENTRY *CaseMatch;
838     RTL_SPLAY_LINKS Links;
839     PUNICODE_STRING Prefix;
840 } UNICODE_PREFIX_TABLE_ENTRY, *PUNICODE_PREFIX_TABLE_ENTRY;
841 
842 typedef struct _UNICODE_PREFIX_TABLE
843 {
844     CSHORT NodeTypeCode;
845     CSHORT NameLength;
846     PUNICODE_PREFIX_TABLE_ENTRY NextPrefixTree;
847     PUNICODE_PREFIX_TABLE_ENTRY LastNextEntry;
848 } UNICODE_PREFIX_TABLE, *PUNICODE_PREFIX_TABLE;
849 
850 //
851 // Pfx* routines' table structures
852 //
853 typedef struct _PREFIX_TABLE_ENTRY
854 {
855   CSHORT NodeTypeCode;
856   CSHORT NameLength;
857   struct _PREFIX_TABLE_ENTRY *NextPrefixTree;
858   RTL_SPLAY_LINKS Links;
859   PSTRING Prefix;
860 } PREFIX_TABLE_ENTRY, *PPREFIX_TABLE_ENTRY;
861 
862 typedef struct _PREFIX_TABLE
863 {
864   CSHORT NodeTypeCode;
865   CSHORT NameLength;
866   PPREFIX_TABLE_ENTRY NextPrefixTree;
867 } PREFIX_TABLE, *PPREFIX_TABLE;
868 
869 //
870 // Time Structure for RTL Time calls
871 //
872 typedef struct _TIME_FIELDS
873 {
874     CSHORT Year;
875     CSHORT Month;
876     CSHORT Day;
877     CSHORT Hour;
878     CSHORT Minute;
879     CSHORT Second;
880     CSHORT Milliseconds;
881     CSHORT Weekday;
882 } TIME_FIELDS, *PTIME_FIELDS;
883 
884 //
885 // Activation Context Frame
886 //
887 typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME
888 {
889     struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *Previous;
890     PACTIVATION_CONTEXT ActivationContext;
891     ULONG Flags;
892 } RTL_ACTIVATION_CONTEXT_STACK_FRAME, *PRTL_ACTIVATION_CONTEXT_STACK_FRAME;
893 
894 typedef struct _RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_BASIC
895 {
896     SIZE_T Size;
897     ULONG Format;
898     RTL_ACTIVATION_CONTEXT_STACK_FRAME Frame;
899 } RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_BASIC, *PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_BASIC;
900 
901 typedef struct _RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED
902 {
903     SIZE_T Size;
904     ULONG Format;
905     RTL_ACTIVATION_CONTEXT_STACK_FRAME Frame;
906     PVOID Extra1;
907     PVOID Extra2;
908     PVOID Extra3;
909     PVOID Extra4;
910 } RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED, *PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED;
911 
912 typedef RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME;
913 typedef PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME;
914 
915 typedef struct _RTL_HEAP_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME
916 {
917     RTL_ACTIVATION_CONTEXT_STACK_FRAME Frame;
918     ULONG_PTR Cookie;
919     PVOID ActivationStackBackTrace[8];
920 } RTL_HEAP_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME, *PRTL_HEAP_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME;
921 
922 typedef struct _ACTIVATION_CONTEXT_DATA
923 {
924     ULONG Magic;
925     ULONG HeaderSize;
926     ULONG FormatVersion;
927     ULONG TotalSize;
928     ULONG DefaultTocOffset;
929     ULONG ExtendedTocOffset;
930     ULONG AssemblyRosterOffset;
931     ULONG Flags;
932 } ACTIVATION_CONTEXT_DATA, *PACTIVATION_CONTEXT_DATA;
933 
934 typedef struct _ACTIVATION_CONTEXT_STACK_FRAMELIST
935 {
936     ULONG Magic;
937     ULONG FramesInUse;
938     LIST_ENTRY Links;
939     ULONG Flags;
940     ULONG NotFramesInUse;
941     RTL_HEAP_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME Frames[32];
942 } ACTIVATION_CONTEXT_STACK_FRAMELIST, *PACTIVATION_CONTEXT_STACK_FRAMELIST;
943 
944 #endif /* NTOS_MODE_USER */
945 
946 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
947 typedef struct _ACTIVATION_CONTEXT_STACK
948 {
949     struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *ActiveFrame;
950     LIST_ENTRY FrameListCache;
951     ULONG Flags;
952     ULONG NextCookieSequenceNumber;
953     ULONG StackId;
954 } ACTIVATION_CONTEXT_STACK, *PACTIVATION_CONTEXT_STACK;
955 #else
956 typedef struct _ACTIVATION_CONTEXT_STACK
957 {
958     ULONG Flags;
959     ULONG NextCookieSequenceNumber;
960     struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *ActiveFrame;
961     LIST_ENTRY FrameListCache;
962 } ACTIVATION_CONTEXT_STACK, *PACTIVATION_CONTEXT_STACK;
963 #endif
964 
965 //
966 // ACE Structure
967 //
968 typedef struct _ACE
969 {
970     ACE_HEADER Header;
971     ACCESS_MASK AccessMask;
972 } ACE, *PACE;
973 
974 //
975 // Information Structures for RTL Debug Functions
976 //
977 typedef struct _RTL_PROCESS_MODULE_INFORMATION
978 {
979     ULONG Section;
980     PVOID MappedBase;
981     PVOID ImageBase;
982     ULONG ImageSize;
983     ULONG Flags;
984     USHORT LoadOrderIndex;
985     USHORT InitOrderIndex;
986     USHORT LoadCount;
987     USHORT OffsetToFileName;
988     CHAR FullPathName[256];
989 } RTL_PROCESS_MODULE_INFORMATION, *PRTL_PROCESS_MODULE_INFORMATION;
990 
991 typedef struct _RTL_PROCESS_MODULES
992 {
993     ULONG NumberOfModules;
994     RTL_PROCESS_MODULE_INFORMATION Modules[1];
995 } RTL_PROCESS_MODULES, *PRTL_PROCESS_MODULES;
996 
997 typedef struct _RTL_PROCESS_MODULE_INFORMATION_EX
998 {
999     ULONG NextOffset;
1000     RTL_PROCESS_MODULE_INFORMATION BaseInfo;
1001     ULONG ImageCheckSum;
1002     ULONG TimeDateStamp;
1003     PVOID DefaultBase;
1004 } RTL_PROCESS_MODULE_INFORMATION_EX, *PRTL_PROCESS_MODULE_INFORMATION_EX;
1005 
1006 typedef struct _RTL_HEAP_TAG_INFO
1007 {
1008     ULONG NumberOfAllocations;
1009     ULONG NumberOfFrees;
1010     SIZE_T BytesAllocated;
1011 } RTL_HEAP_TAG_INFO, *PRTL_HEAP_TAG_INFO;
1012 
1013 typedef struct _RTL_HEAP_USAGE_ENTRY
1014 {
1015     struct _RTL_HEAP_USAGE_ENTRY *Next;
1016     PVOID Address;
1017     SIZE_T Size;
1018     USHORT AllocatorBackTraceIndex;
1019     USHORT TagIndex;
1020 } RTL_HEAP_USAGE_ENTRY, *PRTL_HEAP_USAGE_ENTRY;
1021 
1022 typedef struct _RTL_HEAP_USAGE
1023 {
1024     ULONG Length;
1025     SIZE_T BytesAllocated;
1026     SIZE_T BytesCommitted;
1027     SIZE_T BytesReserved;
1028     SIZE_T BytesReservedMaximum;
1029     PRTL_HEAP_USAGE_ENTRY Entries;
1030     PRTL_HEAP_USAGE_ENTRY AddedEntries;
1031     PRTL_HEAP_USAGE_ENTRY RemovedEntries;
1032     ULONG_PTR Reserved[8];
1033 } RTL_HEAP_USAGE, *PRTL_HEAP_USAGE;
1034 
1035 typedef struct _RTL_HEAP_WALK_ENTRY
1036 {
1037     PVOID DataAddress;
1038     SIZE_T DataSize;
1039     UCHAR OverheadBytes;
1040     UCHAR SegmentIndex;
1041     USHORT Flags;
1042     union
1043     {
1044         struct
1045         {
1046             SIZE_T Settable;
1047             USHORT TagIndex;
1048             USHORT AllocatorBackTraceIndex;
1049             ULONG Reserved[2];
1050         } Block;
1051         struct
1052         {
1053             ULONG_PTR CommittedSize;
1054             ULONG_PTR UnCommittedSize;
1055             PVOID FirstEntry;
1056             PVOID LastEntry;
1057         } Segment;
1058     };
1059 } RTL_HEAP_WALK_ENTRY, *PRTL_HEAP_WALK_ENTRY;
1060 
1061 typedef struct _RTL_HEAP_ENTRY
1062 {
1063     SIZE_T Size;
1064     USHORT Flags;
1065     USHORT AllocatorBackTraceIndex;
1066     union
1067     {
1068         struct
1069         {
1070             SIZE_T Settable;
1071             ULONG Tag;
1072         } s1;
1073         struct
1074         {
1075             SIZE_T CommittedSize;
1076             PVOID FirstBlock;
1077         } s2;
1078     } u;
1079 } RTL_HEAP_ENTRY, *PRTL_HEAP_ENTRY;
1080 
1081 typedef struct _RTL_HEAP_TAG
1082 {
1083     ULONG NumberOfAllocations;
1084     ULONG NumberOfFrees;
1085     SIZE_T BytesAllocated;
1086     USHORT TagIndex;
1087     USHORT CreatorBackTraceIndex;
1088     WCHAR TagName[24];
1089 } RTL_HEAP_TAG, *PRTL_HEAP_TAG;
1090 
1091 typedef struct _RTL_HEAP_INFORMATION
1092 {
1093     PVOID BaseAddress;
1094     ULONG Flags;
1095     USHORT EntryOverhead;
1096     USHORT CreatorBackTraceIndex;
1097     SIZE_T BytesAllocated;
1098     SIZE_T BytesCommitted;
1099     ULONG NumberOfTags;
1100     ULONG NumberOfEntries;
1101     ULONG NumberOfPseudoTags;
1102     ULONG PseudoTagGranularity;
1103     ULONG Reserved[5];
1104     PRTL_HEAP_TAG Tags;
1105     PRTL_HEAP_ENTRY Entries;
1106 } RTL_HEAP_INFORMATION, *PRTL_HEAP_INFORMATION;
1107 
1108 typedef struct _RTL_PROCESS_HEAPS
1109 {
1110     ULONG NumberOfHeaps;
1111     RTL_HEAP_INFORMATION Heaps[1];
1112 } RTL_PROCESS_HEAPS, *PRTL_PROCESS_HEAPS;
1113 
1114 typedef struct _RTL_PROCESS_LOCK_INFORMATION
1115 {
1116     PVOID Address;
1117     USHORT Type;
1118     USHORT CreatorBackTraceIndex;
1119     ULONG OwnerThreadId;
1120     ULONG ActiveCount;
1121     ULONG ContentionCount;
1122     ULONG EntryCount;
1123     ULONG RecursionCount;
1124     ULONG NumberOfSharedWaiters;
1125     ULONG NumberOfExclusiveWaiters;
1126 } RTL_PROCESS_LOCK_INFORMATION, *PRTL_PROCESS_LOCK_INFORMATION;
1127 
1128 typedef struct _RTL_PROCESS_LOCKS
1129 {
1130     ULONG NumberOfLocks;
1131     RTL_PROCESS_LOCK_INFORMATION Locks[1];
1132 } RTL_PROCESS_LOCKS, *PRTL_PROCESS_LOCKS;
1133 
1134 typedef struct _RTL_PROCESS_BACKTRACE_INFORMATION
1135 {
1136     PVOID SymbolicBackTrace;
1137     ULONG TraceCount;
1138     USHORT Index;
1139     USHORT Depth;
1140     PVOID BackTrace[16];
1141 } RTL_PROCESS_BACKTRACE_INFORMATION, *PRTL_PROCESS_BACKTRACE_INFORMATION;
1142 
1143 typedef struct _RTL_PROCESS_BACKTRACES
1144 {
1145     ULONG CommittedMemory;
1146     ULONG ReservedMemory;
1147     ULONG NumberOfBackTraceLookups;
1148     ULONG NumberOfBackTraces;
1149     RTL_PROCESS_BACKTRACE_INFORMATION BackTraces[1];
1150 } RTL_PROCESS_BACKTRACES, *PRTL_PROCESS_BACKTRACES;
1151 
1152 typedef struct _RTL_PROCESS_VERIFIER_OPTIONS
1153 {
1154     ULONG SizeStruct;
1155     ULONG Option;
1156     UCHAR OptionData[1];
1157     //
1158     // Option array continues below
1159     //
1160 } RTL_PROCESS_VERIFIER_OPTIONS, *PRTL_PROCESS_VERIFIER_OPTIONS;
1161 
1162 typedef struct _RTL_DEBUG_INFORMATION
1163 {
1164     HANDLE SectionHandleClient;
1165     PVOID ViewBaseClient;
1166     PVOID ViewBaseTarget;
1167     ULONG ViewBaseDelta;
1168     HANDLE EventPairClient;
1169     PVOID EventPairTarget;
1170     HANDLE TargetProcessId;
1171     HANDLE TargetThreadHandle;
1172     ULONG Flags;
1173     ULONG OffsetFree;
1174     ULONG CommitSize;
1175     ULONG ViewSize;
1176     union
1177     {
1178         PRTL_PROCESS_MODULES Modules;
1179         PRTL_PROCESS_MODULE_INFORMATION_EX ModulesEx;
1180     };
1181     PRTL_PROCESS_BACKTRACES BackTraces;
1182     PRTL_PROCESS_HEAPS Heaps;
1183     PRTL_PROCESS_LOCKS Locks;
1184     HANDLE SpecificHeap;
1185     HANDLE TargetProcessHandle;
1186     RTL_PROCESS_VERIFIER_OPTIONS VerifierOptions;
1187     HANDLE ProcessHeap;
1188     HANDLE CriticalSectionHandle;
1189     HANDLE CriticalSectionOwnerThread;
1190     PVOID Reserved[4];
1191 } RTL_DEBUG_INFORMATION, *PRTL_DEBUG_INFORMATION;
1192 
1193 //
1194 // Unload Event Trace Structure for RtlGetUnloadEventTrace
1195 //
1196 typedef struct _RTL_UNLOAD_EVENT_TRACE
1197 {
1198     PVOID BaseAddress;
1199     ULONG SizeOfImage;
1200     ULONG Sequence;
1201     ULONG TimeDateStamp;
1202     ULONG CheckSum;
1203     WCHAR ImageName[32];
1204 } RTL_UNLOAD_EVENT_TRACE, *PRTL_UNLOAD_EVENT_TRACE;
1205 
1206 //
1207 // RTL Handle Structures
1208 //
1209 typedef struct _RTL_HANDLE_TABLE_ENTRY
1210 {
1211     union
1212     {
1213         ULONG Flags;
1214         struct _RTL_HANDLE_TABLE_ENTRY *NextFree;
1215     };
1216 } RTL_HANDLE_TABLE_ENTRY, *PRTL_HANDLE_TABLE_ENTRY;
1217 
1218 typedef struct _RTL_HANDLE_TABLE
1219 {
1220     ULONG MaximumNumberOfHandles;
1221     ULONG SizeOfHandleTableEntry;
1222     ULONG Reserved[2];
1223     PRTL_HANDLE_TABLE_ENTRY FreeHandles;
1224     PRTL_HANDLE_TABLE_ENTRY CommittedHandles;
1225     PRTL_HANDLE_TABLE_ENTRY UnCommittedHandles;
1226     PRTL_HANDLE_TABLE_ENTRY MaxReservedHandles;
1227 } RTL_HANDLE_TABLE, *PRTL_HANDLE_TABLE;
1228 
1229 #ifdef NTOS_MODE_USER
1230 //
1231 // Exception Record
1232 //
1233 typedef struct _EXCEPTION_REGISTRATION_RECORD
1234 {
1235     struct _EXCEPTION_REGISTRATION_RECORD *Next;
1236     PEXCEPTION_ROUTINE Handler;
1237 } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
1238 #endif /* NTOS_MODE_USER */
1239 
1240 //
1241 // Current Directory Structures
1242 //
1243 typedef struct _CURDIR
1244 {
1245     UNICODE_STRING DosPath;
1246     HANDLE Handle;
1247 } CURDIR, *PCURDIR;
1248 
1249 typedef struct _RTLP_CURDIR_REF
1250 {
1251     LONG RefCount;
1252     HANDLE Handle;
1253 } RTLP_CURDIR_REF, *PRTLP_CURDIR_REF;
1254 
1255 typedef struct _RTL_RELATIVE_NAME_U
1256 {
1257     UNICODE_STRING RelativeName;
1258     HANDLE ContainingDirectory;
1259     PRTLP_CURDIR_REF CurDirRef;
1260 } RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
1261 
1262 typedef struct _RTL_DRIVE_LETTER_CURDIR
1263 {
1264     USHORT Flags;
1265     USHORT Length;
1266     ULONG TimeStamp;
1267     UNICODE_STRING DosPath;
1268 } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
1269 
1270 typedef struct _RTL_PERTHREAD_CURDIR
1271 {
1272     PRTL_DRIVE_LETTER_CURDIR CurrentDirectories;
1273     PUNICODE_STRING ImageName;
1274     PVOID Environment;
1275 } RTL_PERTHREAD_CURDIR, *PRTL_PERTHREAD_CURDIR;
1276 
1277 //
1278 // Private State structure for RtlAcquirePrivilege/RtlReleasePrivilege
1279 //
1280 typedef struct _RTL_ACQUIRE_STATE
1281 {
1282     HANDLE Token;
1283     HANDLE OldImpersonationToken;
1284     PTOKEN_PRIVILEGES OldPrivileges;
1285     PTOKEN_PRIVILEGES NewPrivileges;
1286     ULONG Flags;
1287     UCHAR OldPrivBuffer[1024];
1288 } RTL_ACQUIRE_STATE, *PRTL_ACQUIRE_STATE;
1289 
1290 #ifndef NTOS_MODE_USER
1291 
1292 //
1293 // RTL Critical Section Structures
1294 //
1295 typedef struct _RTL_CRITICAL_SECTION_DEBUG
1296 {
1297     USHORT Type;
1298     USHORT CreatorBackTraceIndex;
1299     struct _RTL_CRITICAL_SECTION *CriticalSection;
1300     LIST_ENTRY ProcessLocksList;
1301     ULONG EntryCount;
1302     ULONG ContentionCount;
1303     ULONG Spare[2];
1304 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
1305 
1306 typedef struct _RTL_CRITICAL_SECTION
1307 {
1308     PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
1309     LONG LockCount;
1310     LONG RecursionCount;
1311     HANDLE OwningThread;
1312     HANDLE LockSemaphore;
1313     ULONG_PTR SpinCount;
1314 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
1315 
1316 #endif /* !NTOS_MODE_USER */
1317 
1318 //
1319 // RTL Private Heap Structures
1320 //
1321 typedef struct _HEAP_LOCK
1322 {
1323     union
1324     {
1325         RTL_CRITICAL_SECTION CriticalSection;
1326 #ifndef NTOS_MODE_USER
1327         ERESOURCE Resource;
1328 #endif
1329         UCHAR Padding[0x68]; /* Max ERESOURCE size for x64 build. Needed because RTL is built only once */
1330     };
1331 } HEAP_LOCK, *PHEAP_LOCK;
1332 
1333 //
1334 // RTL Range List Structures
1335 //
1336 typedef struct _RTL_RANGE_LIST
1337 {
1338     LIST_ENTRY ListHead;
1339     ULONG Flags;
1340     ULONG Count;
1341     ULONG Stamp;
1342 } RTL_RANGE_LIST, *PRTL_RANGE_LIST;
1343 
1344 typedef struct _RTL_RANGE
1345 {
1346     ULONGLONG Start;
1347     ULONGLONG End;
1348     PVOID UserData;
1349     PVOID Owner;
1350     UCHAR Attributes;
1351     UCHAR Flags;
1352 } RTL_RANGE, *PRTL_RANGE;
1353 
1354 typedef struct _RANGE_LIST_ITERATOR
1355 {
1356     PLIST_ENTRY RangeListHead;
1357     PLIST_ENTRY MergedHead;
1358     PVOID Current;
1359     ULONG Stamp;
1360 } RTL_RANGE_LIST_ITERATOR, *PRTL_RANGE_LIST_ITERATOR;
1361 
1362 //
1363 // RTL Resource
1364 //
1365 #define RTL_RESOURCE_FLAG_LONG_TERM ((ULONG)0x00000001)
1366 
1367 typedef struct _RTL_RESOURCE
1368 {
1369     RTL_CRITICAL_SECTION Lock;
1370     HANDLE SharedSemaphore;
1371     ULONG SharedWaiters;
1372     HANDLE ExclusiveSemaphore;
1373     ULONG ExclusiveWaiters;
1374     LONG NumberActive;
1375     HANDLE OwningThread;
1376     ULONG TimeoutBoost;
1377     PVOID DebugInfo;
1378 } RTL_RESOURCE, *PRTL_RESOURCE;
1379 
1380 //
1381 // Structures for RtlCreateUserProcess
1382 //
1383 typedef struct _RTL_USER_PROCESS_PARAMETERS
1384 {
1385     ULONG MaximumLength;
1386     ULONG Length;
1387     ULONG Flags;
1388     ULONG DebugFlags;
1389     HANDLE ConsoleHandle;
1390     ULONG ConsoleFlags;
1391     HANDLE StandardInput;
1392     HANDLE StandardOutput;
1393     HANDLE StandardError;
1394     CURDIR CurrentDirectory;
1395     UNICODE_STRING DllPath;
1396     UNICODE_STRING ImagePathName;
1397     UNICODE_STRING CommandLine;
1398     PWSTR Environment;
1399     ULONG StartingX;
1400     ULONG StartingY;
1401     ULONG CountX;
1402     ULONG CountY;
1403     ULONG CountCharsX;
1404     ULONG CountCharsY;
1405     ULONG FillAttribute;
1406     ULONG WindowFlags;
1407     ULONG ShowWindowFlags;
1408     UNICODE_STRING WindowTitle;
1409     UNICODE_STRING DesktopInfo;
1410     UNICODE_STRING ShellInfo;
1411     UNICODE_STRING RuntimeData;
1412     RTL_DRIVE_LETTER_CURDIR CurrentDirectories[RTL_MAX_DRIVE_LETTERS];
1413 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1414     SIZE_T EnvironmentSize;
1415 #endif
1416 #if (NTDDI_VERSION >= NTDDI_WIN7)
1417     SIZE_T EnvironmentVersion;
1418 #endif
1419 } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
1420 
1421 typedef struct _RTL_USER_PROCESS_INFORMATION
1422 {
1423     ULONG Size;
1424     HANDLE ProcessHandle;
1425     HANDLE ThreadHandle;
1426     CLIENT_ID ClientId;
1427     SECTION_IMAGE_INFORMATION ImageInformation;
1428 } RTL_USER_PROCESS_INFORMATION, *PRTL_USER_PROCESS_INFORMATION;
1429 
1430 #if (NTDDI_VERSION >= NTDDI_WIN7)
1431 
1432 typedef enum _RTL_UMS_SCHEDULER_REASON
1433 {
1434     UmsSchedulerStartup = 0,
1435     UmsSchedulerThreadBlocked = 1,
1436     UmsSchedulerThreadYield = 2,
1437 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
1438 
1439 typedef enum _RTL_UMSCTX_FLAGS
1440 {
1441     UMSCTX_SCHEDULED_THREAD_BIT = 0,
1442 #if (NTDDI_VERSION < NTDDI_WIN8)
1443     UMSCTX_HAS_QUANTUM_REQ_BIT,
1444     UMSCTX_HAS_AFFINITY_REQ_BIT,
1445     UMSCTX_HAS_PRIORITY_REQ_BIT,
1446 #endif
1447     UMSCTX_SUSPENDED_BIT,
1448     UMSCTX_VOLATILE_CONTEXT_BIT,
1449     UMSCTX_TERMINATED_BIT,
1450     UMSCTX_DEBUG_ACTIVE_BIT,
1451     UMSCTX_RUNNING_ON_SELF_THREAD_BIT,
1452     UMSCTX_DENY_RUNNING_ON_SELF_THREAD_BIT
1453 
1454 } RTL_UMSCTX_FLAGS, *PRTL_UMSCTX_FLAGS;
1455 
1456 #define UMSCTX_SCHEDULED_THREAD_MASK (1 << UMSCTX_SCHEDULED_THREAD_BIT)
1457 #define UMSCTX_SUSPENDED_MASK        (1 << UMSCTX_SUSPENDED_BIT)
1458 #define UMSCTX_VOLATILE_CONTEXT_MASK (1 << UMSCTX_VOLATILE_CONTEXT_BIT)
1459 #define UMSCTX_TERMINATED_MASK       (1 << UMSCTX_TERMINATED_BIT)
1460 #define UMSCTX_DEBUG_ACTIVE_MASK     (1 << UMSCTX_DEBUG_ACTIVE_BIT)
1461 #define UMSCTX_RUNNING_ON_SELF_THREAD_MASK (1 << UMSCTX_RUNNING_ON_SELF_THREAD_BIT)
1462 #define UMSCTX_DENY_RUNNING_ON_SELF_THREAD_MASK (1 << UMSCTX_DENY_RUNNING_ON_SELF_THREAD_BIT)
1463 
1464 //
1465 // UMS Context
1466 //
1467 typedef struct DECLSPEC_ALIGN(16) _RTL_UMS_CONTEXT
1468 {
1469     SINGLE_LIST_ENTRY Link;
1470     CONTEXT Context;
1471     PVOID Teb;
1472     PVOID UserContext;
1473     union
1474     {
1475         struct
1476         {
1477             ULONG ScheduledThread : 1;
1478 #if (NTDDI_VERSION < NTDDI_WIN8)
1479             ULONG HasQuantumReq : 1;
1480             ULONG HasAffinityReq : 1;
1481             ULONG HasPriorityReq : 1;
1482 #endif
1483             ULONG Suspended : 1;
1484             ULONG VolatileContext : 1;
1485             ULONG Terminated : 1;
1486             ULONG DebugActive : 1;
1487             ULONG RunningOnSelfThread : 1;
1488             ULONG DenyRunningOnSelfThread : 1;
1489 #if (NTDDI_VERSION < NTDDI_WIN8)
1490             ULONG ReservedFlags : 22;
1491 #endif
1492         };
1493         LONG Flags;
1494     };
1495     union
1496     {
1497         struct
1498         {
1499 #if (NTDDI_VERSION >= NTDDI_WIN8)
1500             ULONG64 KernelUpdateLock : 2;
1501 #else
1502             ULONG64 KernelUpdateLock : 1;
1503             ULONG64 Reserved : 1;
1504 #endif
1505             ULONG64 PrimaryClientID : 62;
1506         };
1507         ULONG64 ContextLock;
1508     };
1509 #if (NTDDI_VERSION < NTDDI_WIN8)
1510     ULONG64 QuantumValue;
1511     GROUP_AFFINITY AffinityMask;
1512     LONG Priority;
1513 #endif
1514     struct _RTL_UMS_CONTEXT* PrimaryUmsContext;
1515     ULONG SwitchCount;
1516     ULONG KernelYieldCount;
1517     ULONG MixedYieldCount;
1518     ULONG YieldCount;
1519 } RTL_UMS_CONTEXT, *PRTL_UMS_CONTEXT;
1520 #endif // #if (NTDDI_VERSION >= NTDDI_WIN7)
1521 
1522 //
1523 // RTL Atom Table Structures
1524 //
1525 typedef struct _RTL_ATOM_TABLE_ENTRY
1526 {
1527     struct _RTL_ATOM_TABLE_ENTRY *HashLink;
1528     USHORT HandleIndex;
1529     USHORT Atom;
1530     USHORT ReferenceCount;
1531     UCHAR Flags;
1532     UCHAR NameLength;
1533     WCHAR Name[1];
1534 } RTL_ATOM_TABLE_ENTRY, *PRTL_ATOM_TABLE_ENTRY;
1535 
1536 typedef struct _RTL_ATOM_TABLE
1537 {
1538     ULONG Signature;
1539     union
1540     {
1541 #ifdef NTOS_MODE_USER
1542         RTL_CRITICAL_SECTION CriticalSection;
1543 #else
1544         FAST_MUTEX FastMutex;
1545 #endif
1546     };
1547     union
1548     {
1549 #ifdef NTOS_MODE_USER
1550         RTL_HANDLE_TABLE RtlHandleTable;
1551 #else
1552         PHANDLE_TABLE ExHandleTable;
1553 #endif
1554     };
1555     ULONG NumberOfBuckets;
1556     PRTL_ATOM_TABLE_ENTRY Buckets[1];
1557 } RTL_ATOM_TABLE, *PRTL_ATOM_TABLE;
1558 
1559 #ifndef _WINBASE_
1560 //
1561 // System Time and Timezone Structures
1562 //
1563 typedef struct _SYSTEMTIME
1564 {
1565     USHORT wYear;
1566     USHORT wMonth;
1567     USHORT wDayOfWeek;
1568     USHORT wDay;
1569     USHORT wHour;
1570     USHORT wMinute;
1571     USHORT wSecond;
1572     USHORT wMilliseconds;
1573 } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
1574 
1575 typedef struct _TIME_ZONE_INFORMATION
1576 {
1577     LONG Bias;
1578     WCHAR StandardName[32];
1579     SYSTEMTIME StandardDate;
1580     LONG StandardBias;
1581     WCHAR DaylightName[32];
1582     SYSTEMTIME DaylightDate;
1583     LONG DaylightBias;
1584 } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
1585 #endif /* !_WINBASE_ */
1586 
1587 //
1588 // Native version of Timezone Structure
1589 //
1590 typedef LPTIME_ZONE_INFORMATION PRTL_TIME_ZONE_INFORMATION;
1591 
1592 //
1593 // Hotpatch Header
1594 //
1595 typedef struct _RTL_PATCH_HEADER
1596 {
1597     LIST_ENTRY PatchList;
1598     PVOID PatchImageBase;
1599     struct _RTL_PATCH_HEADER *NextPath;
1600     ULONG PatchFlags;
1601     LONG PatchRefCount;
1602     struct _HOTPATCH_HEADER *HotpatchHeader;
1603     UNICODE_STRING TargetDllName;
1604     PVOID TargetDllBase;
1605     PLDR_DATA_TABLE_ENTRY TargetLdrDataTableEntry;
1606     PLDR_DATA_TABLE_ENTRY PatchLdrDataTableEntry;
1607     struct _SYSTEM_HOTPATCH_CODE_INFORMATION *CodeInfo;
1608 } RTL_PATCH_HEADER, *PRTL_PATCH_HEADER;
1609 
1610 //
1611 // Header for NLS Files
1612 //
1613 typedef struct _NLS_FILE_HEADER
1614 {
1615     USHORT HeaderSize;
1616     USHORT CodePage;
1617     USHORT MaximumCharacterSize;
1618     USHORT DefaultChar;
1619     USHORT UniDefaultChar;
1620     USHORT TransDefaultChar;
1621     USHORT TransUniDefaultChar;
1622     UCHAR LeadByte[MAXIMUM_LEADBYTES];
1623 } NLS_FILE_HEADER, *PNLS_FILE_HEADER;
1624 
1625 //
1626 // Stack Traces
1627 //
1628 typedef struct _RTL_STACK_TRACE_ENTRY
1629 {
1630     struct _RTL_STACK_TRACE_ENTRY *HashChain;
1631     ULONG TraceCount;
1632     USHORT Index;
1633     USHORT Depth;
1634     PVOID BackTrace[32];
1635 } RTL_STACK_TRACE_ENTRY, *PRTL_STACK_TRACE_ENTRY;
1636 
1637 typedef struct _STACK_TRACE_DATABASE
1638 {
1639     RTL_CRITICAL_SECTION CriticalSection;
1640 } STACK_TRACE_DATABASE, *PSTACK_TRACE_DATABASE;
1641 
1642 //
1643 // Trace Database
1644 //
1645 
1646 typedef ULONG (NTAPI *RTL_TRACE_HASH_FUNCTION) (ULONG Count, PVOID *Trace);
1647 
1648 typedef struct _RTL_TRACE_BLOCK
1649 {
1650     ULONG Magic;
1651     ULONG Count;
1652     ULONG Size;
1653     ULONG UserCount;
1654     ULONG UserSize;
1655     PVOID UserContext;
1656     struct _RTL_TRACE_BLOCK *Next;
1657     PVOID *Trace;
1658 } RTL_TRACE_BLOCK, *PRTL_TRACE_BLOCK;
1659 
1660 typedef struct _RTL_TRACE_DATABASE
1661 {
1662     ULONG Magic;
1663     ULONG Flags;
1664     ULONG Tag;
1665     struct _RTL_TRACE_SEGMENT *SegmentList;
1666     SIZE_T MaximumSize;
1667     SIZE_T CurrentSize;
1668     PVOID Owner;
1669 #ifdef NTOS_MODE_USER
1670     RTL_CRITICAL_SECTION Lock;
1671 #else
1672     union
1673     {
1674         KSPIN_LOCK SpinLock;
1675         FAST_MUTEX FastMutex;
1676     } u;
1677 #endif
1678     ULONG NoOfBuckets;
1679     struct _RTL_TRACE_BLOCK **Buckets;
1680     RTL_TRACE_HASH_FUNCTION HashFunction;
1681     SIZE_T NoOfTraces;
1682     SIZE_T NoOfHits;
1683     ULONG HashCounter[16];
1684 } RTL_TRACE_DATABASE, *PRTL_TRACE_DATABASE;
1685 
1686 typedef struct _RTL_TRACE_SEGMENT
1687 {
1688     ULONG Magic;
1689     struct _RTL_TRACE_DATABASE *Database;
1690     struct _RTL_TRACE_SEGMENT *NextSegment;
1691     SIZE_T TotalSize;
1692     PCHAR SegmentStart;
1693     PCHAR SegmentEnd;
1694     PCHAR SegmentFree;
1695 } RTL_TRACE_SEGMENT, *PRTL_TRACE_SEGMENT;
1696 
1697 typedef struct _RTL_TRACE_ENUMERATE
1698 {
1699     struct _RTL_TRACE_DATABASE *Database;
1700     ULONG Index;
1701     struct _RTL_TRACE_BLOCK *Block;
1702 } RTL_TRACE_ENUMERATE, * PRTL_TRACE_ENUMERATE;
1703 
1704 //
1705 // Auto-Managed Rtl* String Buffer
1706 //
1707 typedef struct _RTL_BUFFER
1708 {
1709     PUCHAR Buffer;
1710     PUCHAR StaticBuffer;
1711     SIZE_T Size;
1712     SIZE_T StaticSize;
1713     SIZE_T ReservedForAllocatedSize;
1714     PVOID ReservedForIMalloc;
1715 } RTL_BUFFER, *PRTL_BUFFER;
1716 
1717 typedef struct _RTL_UNICODE_STRING_BUFFER
1718 {
1719     UNICODE_STRING String;
1720     RTL_BUFFER ByteBuffer;
1721     WCHAR MinimumStaticBufferForTerminalNul;
1722 } RTL_UNICODE_STRING_BUFFER, *PRTL_UNICODE_STRING_BUFFER;
1723 
1724 #ifndef NTOS_MODE_USER
1725 
1726 //
1727 // Message Resource Entry, Block and Data
1728 //
1729 typedef struct _MESSAGE_RESOURCE_ENTRY
1730 {
1731     USHORT Length;
1732     USHORT Flags;
1733     UCHAR Text[ANYSIZE_ARRAY];
1734 } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
1735 
1736 typedef struct _MESSAGE_RESOURCE_BLOCK
1737 {
1738     ULONG LowId;
1739     ULONG HighId;
1740     ULONG OffsetToEntries;
1741 } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
1742 
1743 typedef struct _MESSAGE_RESOURCE_DATA
1744 {
1745     ULONG NumberOfBlocks;
1746     MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY];
1747 } MESSAGE_RESOURCE_DATA, *PMESSAGE_RESOURCE_DATA;
1748 
1749 #endif /* !NTOS_MODE_USER */
1750 
1751 #ifdef NTOS_MODE_USER
1752 
1753 //
1754 // Memory Stream
1755 //
1756 #ifndef CONST_VTBL
1757 #ifdef CONST_VTABLE
1758 #define CONST_VTBL const
1759 #else
1760 #define CONST_VTBL
1761 #endif
1762 #endif
1763 
1764 struct IStreamVtbl;
1765 struct IStream;
1766 struct tagSTATSTG;
1767 
1768 typedef struct _RTL_MEMORY_STREAM RTL_MEMORY_STREAM, *PRTL_MEMORY_STREAM;
1769 
1770 typedef VOID
1771 (NTAPI *PRTL_MEMORY_STREAM_FINAL_RELEASE_ROUTINE)(
1772     _In_ PRTL_MEMORY_STREAM Stream
1773 );
1774 
1775 struct _RTL_MEMORY_STREAM
1776 {
1777     CONST_VTBL struct IStreamVtbl *Vtbl;
1778     LONG RefCount;
1779     ULONG Unk1;
1780     PVOID Current;
1781     PVOID Start;
1782     PVOID End;
1783     PRTL_MEMORY_STREAM_FINAL_RELEASE_ROUTINE FinalRelease;
1784     HANDLE ProcessHandle;
1785 };
1786 
1787 #endif /* NTOS_MODE_USER */
1788 
1789 #ifdef __cplusplus
1790 }
1791 #endif
1792 
1793 #endif /* !_RTLTYPES_H */
1794