3 Copyright (c) Alex Ionescu. All rights reserved.
11 Function definitions for the Run-Time Library
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
45 _Out_ PLIST_ENTRY ListHead
48 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
54 _Inout_ PLIST_ENTRY ListHead
,
55 _Inout_ PLIST_ENTRY Entry
59 OldFlink
= ListHead
->Flink
;
60 Entry
->Flink
= OldFlink
;
61 Entry
->Blink
= ListHead
;
62 OldFlink
->Blink
= Entry
;
63 ListHead
->Flink
= Entry
;
69 _Inout_ PLIST_ENTRY ListHead
,
70 _Inout_ PLIST_ENTRY Entry
74 OldBlink
= ListHead
->Blink
;
75 Entry
->Flink
= ListHead
;
76 Entry
->Blink
= OldBlink
;
77 OldBlink
->Flink
= Entry
;
78 ListHead
->Blink
= Entry
;
85 _In_
const LIST_ENTRY
* ListHead
88 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
94 _Inout_ PSINGLE_LIST_ENTRY ListHead
97 PSINGLE_LIST_ENTRY FirstEntry
;
98 FirstEntry
= ListHead
->Next
;
99 if (FirstEntry
!= NULL
) {
100 ListHead
->Next
= FirstEntry
->Next
;
109 _Inout_ PSINGLE_LIST_ENTRY ListHead
,
110 _Inout_ PSINGLE_LIST_ENTRY Entry
113 Entry
->Next
= ListHead
->Next
;
114 ListHead
->Next
= Entry
;
120 _In_ PLIST_ENTRY Entry
)
122 PLIST_ENTRY OldFlink
;
123 PLIST_ENTRY OldBlink
;
125 OldFlink
= Entry
->Flink
;
126 OldBlink
= Entry
->Blink
;
127 OldFlink
->Blink
= OldBlink
;
128 OldBlink
->Flink
= OldFlink
;
129 return (BOOLEAN
)(OldFlink
== OldBlink
);
135 _Inout_ PLIST_ENTRY ListHead
)
140 Entry
= ListHead
->Flink
;
141 Flink
= Entry
->Flink
;
142 ListHead
->Flink
= Flink
;
143 Flink
->Blink
= ListHead
;
150 _Inout_ PLIST_ENTRY ListHead
)
155 Entry
= ListHead
->Blink
;
156 Blink
= Entry
->Blink
;
157 ListHead
->Blink
= Blink
;
158 Blink
->Flink
= ListHead
;
163 // Unicode string macros
165 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
166 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
167 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
170 RtlInitEmptyUnicodeString(
171 _Out_ PUNICODE_STRING UnicodeString
,
172 _When_(BufferSize
!= 0, _Notnull_
) _Writable_bytes_(BufferSize
) __drv_aliasesMem PWCHAR Buffer
,
173 _In_ USHORT BufferSize
)
175 UnicodeString
->Length
= 0;
176 UnicodeString
->MaximumLength
= BufferSize
;
177 UnicodeString
->Buffer
= Buffer
;
180 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
181 _At_(AnsiString
->Length
, _Post_equal_to_(0))
182 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
185 RtlInitEmptyAnsiString(
186 _Out_ PANSI_STRING AnsiString
,
187 _When_(BufferSize
!= 0, _Notnull_
) _Writable_bytes_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
188 _In_ USHORT BufferSize
)
190 AnsiString
->Length
= 0;
191 AnsiString
->MaximumLength
= BufferSize
;
192 AnsiString
->Buffer
= Buffer
;
198 #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
199 ((L1)->LowPart == (L2)->LowPart))
203 RtlConvertUlongToLuid(
208 TempLuid
.LowPart
= Ulong
;
209 TempLuid
.HighPart
= 0;
219 #define ASSERT( exp ) \
221 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \
224 #define ASSERTMSG( msg, exp ) \
226 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \
231 #define ASSERT( exp ) ((void) 0)
232 #define ASSERTMSG( msg, exp ) ((void) 0)
237 #ifdef NTOS_KERNEL_RUNTIME
240 // Executing RTL functions at DISPATCH_LEVEL or higher will result in a
243 #define RTL_PAGED_CODE PAGED_CODE
248 // This macro does nothing in user mode
250 #define RTL_PAGED_CODE NOP_FUNCTION
255 // RTL Splay Tree Functions
257 #ifndef RTL_USE_AVL_TABLES
262 RtlInitializeGenericTable(
263 _Out_ PRTL_GENERIC_TABLE Table
,
264 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
265 _In_opt_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
266 _In_opt_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
267 _In_opt_ PVOID TableContext
273 RtlInsertElementGenericTable(
274 _In_ PRTL_GENERIC_TABLE Table
,
275 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
276 _In_ CLONG BufferSize
,
277 _Out_opt_ PBOOLEAN NewElement
283 RtlInsertElementGenericTableFull(
284 _In_ PRTL_GENERIC_TABLE Table
,
285 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
286 _In_ CLONG BufferSize
,
287 _Out_opt_ PBOOLEAN NewElement
,
288 _In_ PVOID NodeOrParent
,
289 _In_ TABLE_SEARCH_RESULT SearchResult
295 RtlDeleteElementGenericTable(
296 _In_ PRTL_GENERIC_TABLE Table
,
300 _Must_inspect_result_
304 RtlLookupElementGenericTable(
305 _In_ PRTL_GENERIC_TABLE Table
,
312 RtlLookupElementGenericTableFull(
313 _In_ PRTL_GENERIC_TABLE Table
,
315 _Out_ PVOID
*NodeOrParent
,
316 _Out_ TABLE_SEARCH_RESULT
*SearchResult
319 _Must_inspect_result_
323 RtlEnumerateGenericTable(
324 _In_ PRTL_GENERIC_TABLE Table
,
328 _Must_inspect_result_
332 RtlEnumerateGenericTableWithoutSplaying(
333 _In_ PRTL_GENERIC_TABLE Table
,
334 _Inout_ PVOID
*RestartKey
337 _Must_inspect_result_
341 RtlGetElementGenericTable(
342 _In_ PRTL_GENERIC_TABLE Table
,
349 RtlNumberGenericTableElements(
350 _In_ PRTL_GENERIC_TABLE Table
353 _Must_inspect_result_
357 RtlIsGenericTableEmpty(
358 _In_ PRTL_GENERIC_TABLE Table
361 #endif /* !RTL_USE_AVL_TABLES */
367 _Inout_ PRTL_SPLAY_LINKS Links
374 _In_ PRTL_SPLAY_LINKS Links
381 _In_ PRTL_SPLAY_LINKS Links
,
382 _Inout_ PRTL_SPLAY_LINKS
*Root
385 _Must_inspect_result_
390 _In_ PRTL_SPLAY_LINKS Links
393 _Must_inspect_result_
397 RtlSubtreePredecessor(
398 _In_ PRTL_SPLAY_LINKS Links
401 _Must_inspect_result_
406 _In_ PRTL_SPLAY_LINKS Links
409 _Must_inspect_result_
414 _In_ PRTL_SPLAY_LINKS Links
417 #define RtlIsLeftChild(Links) \
418 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
420 #define RtlIsRightChild(Links) \
421 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
423 #define RtlRightChild(Links) \
424 ((PRTL_SPLAY_LINKS)(Links))->RightChild
426 #define RtlIsRoot(Links) \
427 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
429 #define RtlLeftChild(Links) \
430 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
432 #define RtlParent(Links) \
433 ((PRTL_SPLAY_LINKS)(Links))->Parent
435 // FIXME: use inline function
437 #define RtlInitializeSplayLinks(Links) \
439 PRTL_SPLAY_LINKS _SplayLinks; \
440 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
441 _SplayLinks->Parent = _SplayLinks; \
442 _SplayLinks->LeftChild = NULL; \
443 _SplayLinks->RightChild = NULL; \
446 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
448 PRTL_SPLAY_LINKS _SplayParent; \
449 PRTL_SPLAY_LINKS _SplayChild; \
450 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
451 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
452 _SplayParent->LeftChild = _SplayChild; \
453 _SplayChild->Parent = _SplayParent; \
456 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
458 PRTL_SPLAY_LINKS _SplayParent; \
459 PRTL_SPLAY_LINKS _SplayChild; \
460 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
461 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
462 _SplayParent->RightChild = _SplayChild; \
463 _SplayChild->Parent = _SplayParent; \
467 // RTL AVL Tree Functions
472 RtlInitializeGenericTableAvl(
473 _Out_ PRTL_AVL_TABLE Table
,
474 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
475 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
476 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
477 _In_opt_ PVOID TableContext
483 RtlInsertElementGenericTableAvl(
484 _In_ PRTL_AVL_TABLE Table
,
485 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
486 _In_ CLONG BufferSize
,
487 _Out_opt_ PBOOLEAN NewElement
493 RtlInsertElementGenericTableFullAvl(
494 _In_ PRTL_AVL_TABLE Table
,
495 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
496 _In_ CLONG BufferSize
,
497 _Out_opt_ PBOOLEAN NewElement
,
498 _In_ PVOID NodeOrParent
,
499 _In_ TABLE_SEARCH_RESULT SearchResult
505 RtlDeleteElementGenericTableAvl(
506 _In_ PRTL_AVL_TABLE Table
,
510 _Must_inspect_result_
514 RtlLookupElementGenericTableAvl(
515 _In_ PRTL_AVL_TABLE Table
,
522 RtlLookupElementGenericTableFullAvl(
523 _In_ PRTL_AVL_TABLE Table
,
525 _Out_ PVOID
*NodeOrParent
,
526 _Out_ TABLE_SEARCH_RESULT
*SearchResult
529 _Must_inspect_result_
533 RtlEnumerateGenericTableAvl(
534 _In_ PRTL_AVL_TABLE Table
,
538 _Must_inspect_result_
542 RtlEnumerateGenericTableWithoutSplayingAvl(
543 _In_ PRTL_AVL_TABLE Table
,
544 _Inout_ PVOID
*RestartKey
547 _Must_inspect_result_
551 RtlLookupFirstMatchingElementGenericTableAvl(
552 _In_ PRTL_AVL_TABLE Table
,
554 _Out_ PVOID
*RestartKey
557 _Must_inspect_result_
561 RtlEnumerateGenericTableLikeADirectory(
562 _In_ PRTL_AVL_TABLE Table
,
563 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
564 _In_opt_ PVOID MatchData
,
566 _Inout_ PVOID
*RestartKey
,
567 _Inout_ PULONG DeleteCount
,
571 _Must_inspect_result_
575 RtlGetElementGenericTableAvl(
576 _In_ PRTL_AVL_TABLE Table
,
583 RtlNumberGenericTableElementsAvl(
584 _In_ PRTL_AVL_TABLE Table
587 _Must_inspect_result_
591 RtlIsGenericTableEmptyAvl(
592 _In_ PRTL_AVL_TABLE Table
595 #ifdef RTL_USE_AVL_TABLES
597 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
598 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
599 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
600 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
601 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
602 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
603 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
604 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
605 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
606 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
607 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
609 #endif /* RTL_USE_AVL_TABLES */
612 // Error and Exception Functions
617 RtlAddVectoredExceptionHandler(
618 _In_ ULONG FirstHandler
,
619 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
627 _In_ PVOID FailedAssertion
,
629 _In_ ULONG LineNumber
,
630 _In_opt_z_ PCHAR Message
636 RtlSetUnhandledExceptionFilter(
637 _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter
640 #endif /* NTOS_MODE_USER */
646 _Out_ PCONTEXT ContextRecord
666 RtlEncodeSystemPointer(
673 RtlDecodeSystemPointer(
680 RtlDispatchException(
681 _In_ PEXCEPTION_RECORD ExceptionRecord
,
682 _In_ PCONTEXT Context
685 _IRQL_requires_max_(APC_LEVEL
)
686 _When_(Status
< 0, _Out_range_(>, 0))
687 _When_(Status
>= 0, _Out_range_(==, 0))
691 RtlNtStatusToDosError(
695 _When_(Status
< 0, _Out_range_(>, 0))
696 _When_(Status
>= 0, _Out_range_(==, 0))
700 RtlNtStatusToDosErrorNoTeb(
707 RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
715 _In_ PEXCEPTION_RECORD ExceptionRecord
729 RtlUnhandledExceptionFilter(
730 _In_
struct _EXCEPTION_POINTERS
* ExceptionInfo
737 _In_opt_ PVOID TargetFrame
,
738 _In_opt_ PVOID TargetIp
,
739 _In_opt_ PEXCEPTION_RECORD ExceptionRecord
,
740 _In_ PVOID ReturnValue
743 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
752 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
)) PVOID
*Callers
,
760 RtlLogStackBackTrace(
764 #ifdef NTOS_MODE_USER
768 _Must_inspect_result_
770 _Post_writable_byte_size_(Size
)
775 _In_ PVOID HeapHandle
,
776 _In_opt_ ULONG Flags
,
780 _Must_inspect_result_
786 _In_opt_ PVOID BaseAddress
,
787 _In_opt_ SIZE_T SizeToReserve
,
788 _In_opt_ SIZE_T SizeToCommit
,
790 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
797 _In_ HANDLE HeapHandle
,
800 _In_ PWSTR TagSubName
810 _Must_inspect_result_
816 _In_opt_ PVOID BaseAddress
,
817 _In_opt_ SIZE_T SizeToReserve
,
818 _In_opt_ SIZE_T SizeToCommit
,
820 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
827 _In_ _Post_invalid_ HANDLE Heap
840 _Success_(return != 0)
845 _In_ HANDLE HeapHandle
,
846 _In_opt_ ULONG Flags
,
847 _In_ _Post_invalid_ PVOID P
853 _In_ ULONG HeapCount
,
854 _Out_cap_(HeapCount
) HANDLE
*HeapArray
857 _Success_(return != 0)
861 _In_ PVOID HeapHandle
,
863 _In_ PVOID BaseAddress
,
864 _Inout_opt_ PVOID
*UserValue
,
865 _Out_opt_ PULONG UserFlags
872 _In_ PVOID HeapHandle
,
879 RtlQueryHeapInformation(
880 _In_ PVOID HeapHandle
,
881 _In_ HEAP_INFORMATION_CLASS HeapInformationClass
,
882 _Out_ PVOID HeapInformation
,
883 _In_ SIZE_T HeapInformationLength
,
884 _When_(HeapInformationClass
==HeapCompatibilityInformation
, _On_failure_(_Out_opt_
))
885 _Out_opt_ PSIZE_T ReturnLength
893 _In_ PVOID HeapHandle
,
895 _In_ USHORT TagIndex
,
896 _In_ BOOLEAN ResetCounters
,
897 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
900 _Must_inspect_result_
902 _Post_writable_byte_size_(Size
)
908 _In_opt_ ULONG Flags
,
909 _In_ _Post_invalid_ PVOID Ptr
,
916 RtlSetHeapInformation(
917 _In_ PVOID HeapHandle
,
918 _In_ HEAP_INFORMATION_CLASS HeapInformationClass
,
919 _When_(HeapInformationClass
==HeapCompatibilityInformation
,_In_
) PVOID HeapInformation
,
920 _In_ SIZE_T HeapInformationLength
930 _Must_inspect_result_
934 RtlMultipleAllocateHeap (
935 _In_ HANDLE HeapHandle
,
939 _Out_cap_(Count
) _Deref_post_bytecap_(Size
) PVOID
* Array
945 RtlMultipleFreeHeap (
946 _In_ HANDLE HeapHandle
,
949 _In_count_(Count
) /* _Deref_ _Post_invalid_ */ PVOID
* Array
958 _Out_ PRTL_HEAP_USAGE Usage
971 _In_ PVOID HeapHandle
,
973 _In_ PVOID BaseAddress
,
980 _In_ PVOID HeapHandle
,
982 _In_ PVOID BaseAddress
,
983 _In_ ULONG UserFlagsReset
,
984 _In_ ULONG UserFlagsSet
1000 _In_ HANDLE HeapHandle
,
1001 _In_ PVOID HeapEntry
1004 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1006 #endif // NTOS_MODE_USER
1012 _In_ PVOID HeapHandle
,
1014 _In_ PVOID MemoryPointer
1019 // Security Functions
1021 _IRQL_requires_max_(APC_LEVEL
)
1025 RtlAbsoluteToSelfRelativeSD(
1026 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
1027 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
1028 _Inout_ PULONG BufferLength
1031 _IRQL_requires_max_(APC_LEVEL
)
1035 RtlAddAccessAllowedAce(
1037 _In_ ULONG Revision
,
1038 _In_ ACCESS_MASK AccessMask
,
1042 _IRQL_requires_max_(APC_LEVEL
)
1046 RtlAddAccessAllowedAceEx(
1048 _In_ ULONG dwAceRevision
,
1049 _In_ ULONG AceFlags
,
1050 _In_ ACCESS_MASK AccessMask
,
1057 RtlAddAccessAllowedObjectAce(
1059 _In_ ULONG dwAceRevision
,
1060 _In_ ULONG AceFlags
,
1061 _In_ ACCESS_MASK AccessMask
,
1062 _In_opt_ GUID
*ObjectTypeGuid
,
1063 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1070 RtlAddAccessDeniedAce(
1072 _In_ ULONG Revision
,
1073 _In_ ACCESS_MASK AccessMask
,
1080 RtlAddAccessDeniedAceEx(
1082 _In_ ULONG Revision
,
1084 _In_ ACCESS_MASK AccessMask
,
1091 RtlAddAccessDeniedObjectAce(
1093 _In_ ULONG dwAceRevision
,
1094 _In_ ULONG AceFlags
,
1095 _In_ ACCESS_MASK AccessMask
,
1096 _In_opt_ GUID
*ObjectTypeGuid
,
1097 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1106 _In_ ULONG AceRevision
,
1107 _In_ ULONG StartingAceIndex
,
1108 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1109 _In_ ULONG AceListLength
1115 RtlAddAuditAccessAce(
1117 _In_ ULONG Revision
,
1118 _In_ ACCESS_MASK AccessMask
,
1120 _In_ BOOLEAN Success
,
1121 _In_ BOOLEAN Failure
1127 RtlAcquirePrivilege(
1128 _In_ PULONG Privilege
,
1131 _Out_ PVOID
*ReturnedState
1137 RtlAddAuditAccessAceEx(
1139 _In_ ULONG Revision
,
1141 _In_ ACCESS_MASK AccessMask
,
1143 _In_ BOOLEAN Success
,
1144 _In_ BOOLEAN Failure
1150 RtlAddAuditAccessObjectAce(
1152 _In_ ULONG Revision
,
1154 _In_ ACCESS_MASK AccessMask
,
1155 _In_opt_ GUID
*ObjectTypeGuid
,
1156 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1158 _In_ BOOLEAN Success
,
1159 _In_ BOOLEAN Failure
1167 _In_ ULONG Revision
,
1169 _In_ ULONG MandatoryFlags
,
1171 _In_ PSID LabelSid
);
1177 _In_ ULONG Privilege
,
1178 _In_ BOOLEAN NewValue
,
1179 _In_ BOOLEAN ForThread
,
1180 _Out_ PBOOLEAN OldValue
1183 _Must_inspect_result_
1187 RtlAllocateAndInitializeSid(
1188 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1189 _In_ UCHAR SubAuthorityCount
,
1190 _In_ ULONG SubAuthority0
,
1191 _In_ ULONG SubAuthority1
,
1192 _In_ ULONG SubAuthority2
,
1193 _In_ ULONG SubAuthority3
,
1194 _In_ ULONG SubAuthority4
,
1195 _In_ ULONG SubAuthority5
,
1196 _In_ ULONG SubAuthority6
,
1197 _In_ ULONG SubAuthority7
,
1204 RtlAreAllAccessesGranted(
1205 ACCESS_MASK GrantedAccess
,
1206 ACCESS_MASK DesiredAccess
1212 RtlAreAnyAccessesGranted(
1213 ACCESS_MASK GrantedAccess
,
1214 ACCESS_MASK DesiredAccess
1217 _IRQL_requires_max_(APC_LEVEL
)
1222 _Out_ PLUID DestinationLuid
,
1223 _In_ PLUID SourceLuid
1229 RtlCopyLuidAndAttributesArray(
1231 PLUID_AND_ATTRIBUTES Src
,
1232 PLUID_AND_ATTRIBUTES Dest
1238 RtlCopySidAndAttributesArray(
1240 PSID_AND_ATTRIBUTES Src
,
1242 PSID_AND_ATTRIBUTES Dest
,
1244 PVOID
* RemainingSidArea
,
1245 PULONG RemainingSidAreaSize
1248 _IRQL_requires_max_(APC_LEVEL
)
1252 RtlConvertSidToUnicodeString(
1253 _Inout_ PUNICODE_STRING UnicodeString
,
1255 _In_ BOOLEAN AllocateDestinationString
1258 _IRQL_requires_max_(APC_LEVEL
)
1263 _In_ ULONG DestinationSidLength
,
1264 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1280 RtlCreateSecurityDescriptor(
1281 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1288 RtlCreateSecurityDescriptorRelative(
1289 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1296 RtlCopySecurityDescriptor(
1297 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor
,
1298 _Out_ PSECURITY_DESCRIPTOR
*pDestinationSecurityDescriptor
1337 _In_ _Post_invalid_ PSID Sid
1352 RtlGetControlSecurityDescriptor(
1353 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1354 _Out_ PSECURITY_DESCRIPTOR_CONTROL Control
,
1355 _Out_ PULONG Revision
1361 RtlGetDaclSecurityDescriptor(
1362 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1363 _Out_ PBOOLEAN DaclPresent
,
1365 _Out_ PBOOLEAN DaclDefaulted
1371 RtlGetSaclSecurityDescriptor(
1372 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1373 _Out_ PBOOLEAN SaclPresent
,
1375 _Out_ PBOOLEAN SaclDefaulted
1381 RtlGetGroupSecurityDescriptor(
1382 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1384 _Out_ PBOOLEAN GroupDefaulted
1390 RtlGetOwnerSecurityDescriptor(
1391 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1393 _Out_ PBOOLEAN OwnerDefaulted
1399 RtlGetSecurityDescriptorRMControl(
1400 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1401 _Out_ PUCHAR RMControl
1405 PSID_IDENTIFIER_AUTHORITY
1407 RtlIdentifierAuthoritySid(PSID Sid
);
1412 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
);
1414 _IRQL_requires_max_(APC_LEVEL
)
1420 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1421 _In_ UCHAR SubAuthorityCount
1427 RtlLengthRequiredSid(IN ULONG SubAuthorityCount
);
1432 RtlLengthSid(IN PSID Sid
);
1437 RtlMakeSelfRelativeSD(
1438 _In_ PSECURITY_DESCRIPTOR AbsoluteSD
,
1439 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1440 _Inout_ PULONG BufferLength
);
1446 PACCESS_MASK AccessMask
,
1447 PGENERIC_MAPPING GenericMapping
1450 #ifdef NTOS_MODE_USER
1455 RtlQueryInformationAcl(
1458 ULONG InformationLength
,
1459 ACL_INFORMATION_CLASS InformationClass
1467 RtlReleasePrivilege(
1468 _In_ PVOID ReturnedState
1471 _IRQL_requires_max_(APC_LEVEL
)
1475 RtlSelfRelativeToAbsoluteSD(
1476 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
1477 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
1478 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
1479 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
1480 _Inout_ PULONG DaclSize
,
1481 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
1482 _Inout_ PULONG SaclSize
,
1483 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
1484 _Inout_ PULONG OwnerSize
,
1485 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
1486 _Inout_ PULONG PrimaryGroupSize
1492 RtlSelfRelativeToAbsoluteSD2(
1493 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1494 _Out_ PULONG BufferSize
1500 RtlSetAttributesSecurityDescriptor(
1501 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1502 _In_ SECURITY_DESCRIPTOR_CONTROL Control
,
1503 _Out_ PULONG Revision
1509 RtlSetControlSecurityDescriptor(
1510 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1511 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
1512 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1515 _IRQL_requires_max_(APC_LEVEL
)
1519 RtlSetDaclSecurityDescriptor(
1520 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1521 _In_ BOOLEAN DaclPresent
,
1523 _In_opt_ BOOLEAN DaclDefaulted
1526 _IRQL_requires_max_(APC_LEVEL
)
1530 RtlSetGroupSecurityDescriptor(
1531 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1532 _In_opt_ PSID Group
,
1533 _In_opt_ BOOLEAN GroupDefaulted
1536 #ifdef NTOS_MODE_USER
1541 RtlSetInformationAcl(
1544 ULONG InformationLength
,
1545 ACL_INFORMATION_CLASS InformationClass
1550 _IRQL_requires_max_(APC_LEVEL
)
1554 RtlSetOwnerSecurityDescriptor(
1555 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1556 _In_opt_ PSID Owner
,
1557 _In_opt_ BOOLEAN OwnerDefaulted
1563 RtlSetSaclSecurityDescriptor(
1564 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1565 _In_ BOOLEAN SaclPresent
,
1567 _In_ BOOLEAN SaclDefaulted
1573 RtlSetSecurityDescriptorRMControl(
1574 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1575 _In_ PUCHAR RMControl
1581 RtlSubAuthorityCountSid(
1590 _In_ ULONG SubAuthority
1593 _IRQL_requires_max_(APC_LEVEL
)
1594 _Must_inspect_result_
1598 RtlValidRelativeSecurityDescriptor(
1599 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1600 _In_ ULONG SecurityDescriptorLength
,
1601 _In_ SECURITY_INFORMATION RequiredInformation
1607 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
1612 RtlValidSid(IN PSID Sid
);
1617 RtlValidAcl(PACL Acl
);
1622 RtlDeleteSecurityObject(
1623 _In_ PSECURITY_DESCRIPTOR
*ObjectDescriptor
1629 RtlNewSecurityObject(
1630 _In_ PSECURITY_DESCRIPTOR ParentDescriptor
,
1631 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor
,
1632 _Out_ PSECURITY_DESCRIPTOR
*NewDescriptor
,
1633 _In_ BOOLEAN IsDirectoryObject
,
1635 _In_ PGENERIC_MAPPING GenericMapping
1641 RtlQuerySecurityObject(
1642 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor
,
1643 _In_ SECURITY_INFORMATION SecurityInformation
,
1644 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor
,
1645 _In_ ULONG DescriptorLength
,
1646 _Out_ PULONG ReturnLength
1652 RtlSetSecurityObject(
1653 _In_ SECURITY_INFORMATION SecurityInformation
,
1654 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor
,
1655 _Out_ PSECURITY_DESCRIPTOR
*ObjectsSecurityDescriptor
,
1656 _In_ PGENERIC_MAPPING GenericMapping
,
1661 // Single-Character Functions
1666 RtlLargeIntegerToChar(
1667 _In_ PLARGE_INTEGER Value
,
1676 RtlUpperChar(CHAR Source
);
1681 RtlUpcaseUnicodeChar(WCHAR Source
);
1686 RtlDowncaseUnicodeChar(IN WCHAR Source
);
1701 RtlIntegerToUnicode(
1703 _In_opt_ ULONG Base
,
1704 _In_opt_ ULONG Length
,
1705 _Inout_ LPWSTR String
1708 _IRQL_requires_max_(PASSIVE_LEVEL
)
1709 _At_(String
->MaximumLength
, _Const_
)
1713 RtlIntegerToUnicodeString(
1715 _In_opt_ ULONG Base
,
1716 _Inout_ PUNICODE_STRING String
1729 // Byte Swap Functions
1731 #ifdef NTOS_MODE_USER
1733 unsigned short __cdecl
_byteswap_ushort(unsigned short);
1734 unsigned long __cdecl
_byteswap_ulong (unsigned long);
1735 unsigned __int64 __cdecl
_byteswap_uint64(unsigned __int64
);
1737 #pragma intrinsic(_byteswap_ushort)
1738 #pragma intrinsic(_byteswap_ulong)
1739 #pragma intrinsic(_byteswap_uint64)
1741 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1742 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1743 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1745 #endif // NTOS_MODE_USER
1748 // Unicode->Ansi String Functions
1753 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString
);
1755 #ifdef NTOS_MODE_USER
1757 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1758 NLS_MB_CODE_PAGE_TAG ? \
1759 RtlxUnicodeStringToAnsiSize(STRING) : \
1760 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1768 RtlUnicodeStringToAnsiString(
1769 PANSI_STRING DestinationString
,
1770 PCUNICODE_STRING SourceString
,
1771 BOOLEAN AllocateDestinationString
1775 // Unicode->OEM String Functions
1780 RtlUpcaseUnicodeStringToOemString(
1781 POEM_STRING DestinationString
,
1782 PCUNICODE_STRING SourceString
,
1783 BOOLEAN AllocateDestinationString
1786 _IRQL_requires_max_(PASSIVE_LEVEL
)
1787 _Must_inspect_result_
1788 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1792 RtlUpcaseUnicodeStringToCountedOemString(
1793 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1794 _When_(!AllocateDestinationString
, _Inout_
)
1795 POEM_STRING DestinationString
,
1796 _In_ PCUNICODE_STRING SourceString
,
1797 _In_ BOOLEAN AllocateDestinationString
1803 RtlUnicodeStringToOemString(
1804 POEM_STRING DestinationString
,
1805 PCUNICODE_STRING SourceString
,
1806 BOOLEAN AllocateDestinationString
1812 RtlUpcaseUnicodeToOemN(
1816 PCWCH UnicodeString
,
1823 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString
);
1825 #ifdef NTOS_MODE_USER
1827 #define RtlUnicodeStringToOemSize(STRING) ( \
1828 NLS_MB_OEM_CODE_PAGE_TAG ? \
1829 RtlxUnicodeStringToOemSize(STRING) : \
1830 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1833 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1834 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1846 PCWCH UnicodeString
,
1851 // Unicode->MultiByte String Functions
1856 RtlUnicodeToMultiByteN(
1860 PCWCH UnicodeString
,
1867 RtlUpcaseUnicodeToMultiByteN(
1871 PCWCH UnicodeString
,
1878 RtlUnicodeToMultiByteSize(
1880 PCWCH UnicodeString
,
1887 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString
);
1890 // OEM to Unicode Functions
1895 RtlOemStringToUnicodeString(
1896 PUNICODE_STRING DestinationString
,
1897 PCOEM_STRING SourceString
,
1898 BOOLEAN AllocateDestinationString
1901 _IRQL_requires_max_(PASSIVE_LEVEL
)
1906 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1907 _In_ ULONG MaxBytesInUnicodeString
,
1908 _Out_opt_ PULONG BytesInUnicodeString
,
1909 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1910 _In_ ULONG BytesInOemString
1913 #ifdef NTOS_MODE_USER
1915 #define RtlOemStringToUnicodeSize(STRING) ( \
1916 NLS_MB_OEM_CODE_PAGE_TAG ? \
1917 RtlxOemStringToUnicodeSize(STRING) : \
1918 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1921 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1922 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1928 // Ansi->Unicode String Functions
1930 _IRQL_requires_max_(APC_LEVEL
)
1934 RtlAnsiCharToUnicodeChar(
1935 _Inout_ PUCHAR
*SourceCharacter
);
1940 RtlAnsiStringToUnicodeString(
1941 PUNICODE_STRING DestinationString
,
1942 PCANSI_STRING SourceString
,
1943 BOOLEAN AllocateDestinationString
1949 RtlxAnsiStringToUnicodeSize(
1950 PCANSI_STRING AnsiString
1953 #ifdef NTOS_MODE_USER
1955 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1956 NLS_MB_CODE_PAGE_TAG ? \
1957 RtlxAnsiStringToUnicodeSize(STRING) : \
1958 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1966 RtlCreateUnicodeStringFromAsciiz(
1967 _Out_ PUNICODE_STRING Destination
,
1972 // Unicode String Functions
1977 RtlAppendUnicodeToString(
1978 PUNICODE_STRING Destination
,
1985 RtlAppendUnicodeStringToString(
1986 PUNICODE_STRING Destination
,
1987 PCUNICODE_STRING Source
1993 RtlCompareUnicodeString(
1994 PCUNICODE_STRING String1
,
1995 PCUNICODE_STRING String2
,
1996 BOOLEAN CaseInsensitive
2002 RtlCopyUnicodeString(
2003 PUNICODE_STRING DestinationString
,
2004 PCUNICODE_STRING SourceString
2010 RtlCreateUnicodeString(
2011 PUNICODE_STRING DestinationString
,
2015 #ifdef NTOS_MODE_USER
2020 RtlDowncaseUnicodeString(
2021 _Inout_ PUNICODE_STRING UniDest
,
2022 _In_ PCUNICODE_STRING UniSource
,
2023 _In_ BOOLEAN AllocateDestinationString
2029 RtlDuplicateUnicodeString(
2031 _In_ PCUNICODE_STRING SourceString
,
2032 _Out_ PUNICODE_STRING DestinationString
2042 _In_ PVOID Destination
,
2050 RtlFillMemoryUlonglong(
2051 _Out_ PVOID Destination
,
2053 _In_ ULONGLONG Pattern
2059 RtlCopyMappedMemory(
2060 _Out_writes_bytes_all_(Size
) PVOID Destination
,
2061 _In_reads_bytes_(Size
) const VOID
*Source
,
2068 RtlCompareMemoryUlong(
2074 #ifndef RtlEqualMemory
2075 #define RtlEqualMemory(Destination, Source, Length) \
2076 (!memcmp(Destination, Source, Length))
2079 #define RtlCopyBytes RtlCopyMemory
2080 #define RtlFillBytes RtlFillMemory
2081 #define RtlZeroBytes RtlZeroMemory
2088 RtlEqualUnicodeString(
2089 PCUNICODE_STRING String1
,
2090 PCUNICODE_STRING String2
,
2091 BOOLEAN CaseInsensitive
2097 RtlFindCharInUnicodeString(
2099 _In_ PCUNICODE_STRING SearchString
,
2100 _In_ PCUNICODE_STRING MatchString
,
2101 _Out_ PUSHORT Position
2104 _IRQL_requires_max_(PASSIVE_LEVEL
)
2108 RtlFreeUnicodeString(
2109 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
2110 PUNICODE_STRING UnicodeString
2116 RtlEraseUnicodeString(
2117 _Inout_ PUNICODE_STRING String
2123 RtlHashUnicodeString(
2124 _In_ CONST UNICODE_STRING
*String
,
2125 _In_ BOOLEAN CaseInSensitive
,
2126 _In_ ULONG HashAlgorithm
,
2127 _Out_ PULONG HashValue
2130 _IRQL_requires_max_(DISPATCH_LEVEL
)
2131 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2132 _When_(SourceString
!= NULL
,
2133 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2134 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2135 _When_(SourceString
== NULL
,
2136 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2137 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2141 RtlInitUnicodeString(
2142 _Out_ PUNICODE_STRING DestinationString
,
2143 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2146 _IRQL_requires_max_(DISPATCH_LEVEL
)
2150 RtlInitUnicodeStringEx(
2151 _Out_ PUNICODE_STRING DestinationString
,
2152 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2164 _IRQL_requires_max_(PASSIVE_LEVEL
)
2165 _Must_inspect_result_
2170 _In_
const STRING
*String1
,
2171 _In_
const STRING
*String2
,
2172 _In_ BOOLEAN CaseInsensitive
2175 _IRQL_requires_max_(PASSIVE_LEVEL
)
2176 _Must_inspect_result_
2180 RtlPrefixUnicodeString(
2181 _In_ PCUNICODE_STRING String1
,
2182 _In_ PCUNICODE_STRING String2
,
2183 _In_ BOOLEAN CaseInsensitive
2186 _IRQL_requires_max_(PASSIVE_LEVEL
)
2191 _Inout_ PSTRING DestinationString
,
2192 _In_
const STRING
*SourceString
2195 _IRQL_requires_max_(PASSIVE_LEVEL
)
2196 _Must_inspect_result_
2201 _In_
const STRING
*String1
,
2202 _In_
const STRING
*String2
,
2203 _In_ BOOLEAN CaseInSensitive
2210 _Out_ PSTRING DestinationString
,
2211 _In_opt_
const STRING
*SourceString
2214 _IRQL_requires_max_(PASSIVE_LEVEL
)
2215 _Must_inspect_result_
2220 _In_
const STRING
*String1
,
2221 _In_
const STRING
*String2
,
2222 _In_ BOOLEAN CaseInSensitive
2225 _IRQL_requires_max_(APC_LEVEL
)
2229 RtlAppendStringToString(
2230 _Inout_ PSTRING Destination
,
2231 _In_
const STRING
*Source
2234 _IRQL_requires_max_(PASSIVE_LEVEL
)
2235 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2239 RtlUpcaseUnicodeString(
2240 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2241 _When_(!AllocateDestinationString
, _Inout_
)
2242 PUNICODE_STRING DestinationString
,
2243 _In_ PCUNICODE_STRING SourceString
,
2244 _In_ BOOLEAN AllocateDestinationString
2247 _IRQL_requires_max_(PASSIVE_LEVEL
)
2251 RtlUnicodeStringToInteger(
2252 _In_ PCUNICODE_STRING String
,
2253 _In_opt_ ULONG Base
,
2260 RtlValidateUnicodeString(
2262 _In_ PCUNICODE_STRING String
2266 // Ansi String Functions
2268 _IRQL_requires_max_(PASSIVE_LEVEL
)
2273 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2274 PANSI_STRING AnsiString
2277 _IRQL_requires_max_(DISPATCH_LEVEL
)
2282 _Out_ PANSI_STRING DestinationString
,
2283 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2286 _IRQL_requires_max_(DISPATCH_LEVEL
)
2290 RtlInitAnsiStringEx(
2291 _Out_ PANSI_STRING DestinationString
,
2292 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2296 // OEM String Functions
2298 _IRQL_requires_max_(PASSIVE_LEVEL
)
2303 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2304 POEM_STRING OemString
2308 // MultiByte->Unicode String Functions
2310 _IRQL_requires_max_(PASSIVE_LEVEL
)
2314 RtlMultiByteToUnicodeN(
2315 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2316 _In_ ULONG MaxBytesInUnicodeString
,
2317 _Out_opt_ PULONG BytesInUnicodeString
,
2318 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2319 _In_ ULONG BytesInMultiByteString
2322 _IRQL_requires_max_(PASSIVE_LEVEL
)
2326 RtlMultiByteToUnicodeSize(
2327 _Out_ PULONG BytesInUnicodeString
,
2328 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2329 _In_ ULONG BytesInMultiByteString
2338 RtlAddAtomToAtomTable(
2339 _In_ PRTL_ATOM_TABLE AtomTable
,
2340 _In_ PWSTR AtomName
,
2341 _Out_ PRTL_ATOM Atom
2348 _In_ ULONG TableSize
,
2349 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2355 RtlDeleteAtomFromAtomTable(
2356 _In_ PRTL_ATOM_TABLE AtomTable
,
2363 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2368 RtlQueryAtomInAtomTable(
2369 _In_ PRTL_ATOM_TABLE AtomTable
,
2371 _Out_opt_ PULONG RefCount
,
2372 _Out_opt_ PULONG PinCount
,
2373 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2374 _Inout_opt_ PULONG NameLength
2380 RtlPinAtomInAtomTable(
2381 _In_ PRTL_ATOM_TABLE AtomTable
,
2388 RtlLookupAtomInAtomTable(
2389 _In_ PRTL_ATOM_TABLE AtomTable
,
2390 _In_ PWSTR AtomName
,
2391 _Out_ PRTL_ATOM Atom
2395 // Process Management Functions
2407 RtlAcquirePebLock(VOID
);
2412 RtlCreateProcessParameters (
2413 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2414 _In_ PUNICODE_STRING ImagePathName
,
2415 _In_opt_ PUNICODE_STRING DllPath
,
2416 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2417 _In_opt_ PUNICODE_STRING CommandLine
,
2418 _In_opt_ PWSTR Environment
,
2419 _In_opt_ PUNICODE_STRING WindowTitle
,
2420 _In_opt_ PUNICODE_STRING DesktopInfo
,
2421 _In_opt_ PUNICODE_STRING ShellInfo
,
2422 _In_opt_ PUNICODE_STRING RuntimeInfo
2428 RtlCreateUserProcess(
2429 _In_ PUNICODE_STRING ImageFileName
,
2430 _In_ ULONG Attributes
,
2431 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2432 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2433 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2434 _In_opt_ HANDLE ParentProcess
,
2435 _In_ BOOLEAN CurrentDirectory
,
2436 _In_opt_ HANDLE DebugPort
,
2437 _In_opt_ HANDLE ExceptionPort
,
2438 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2441 #if (NTDDI_VERSION >= NTDDI_WIN7)
2445 RtlCreateUserThread(
2446 _In_ PVOID ThreadContext
,
2447 _Out_ HANDLE
*OutThreadHandle
,
2448 _Reserved_ PVOID Reserved1
,
2449 _Reserved_ PVOID Reserved2
,
2450 _Reserved_ PVOID Reserved3
,
2451 _Reserved_ PVOID Reserved4
,
2452 _Reserved_ PVOID Reserved5
,
2453 _Reserved_ PVOID Reserved6
,
2454 _Reserved_ PVOID Reserved7
,
2455 _Reserved_ PVOID Reserved8
2461 RtlCreateUserThread(
2462 _In_ HANDLE ProcessHandle
,
2463 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2464 _In_ BOOLEAN CreateSuspended
,
2465 _In_ ULONG StackZeroBits
,
2466 _In_ SIZE_T StackReserve
,
2467 _In_ SIZE_T StackCommit
,
2468 _In_ PTHREAD_START_ROUTINE StartAddress
,
2469 _In_ PVOID Parameter
,
2470 _Out_opt_ PHANDLE ThreadHandle
,
2471 _Out_opt_ PCLIENT_ID ClientId
2476 PRTL_USER_PROCESS_PARAMETERS
2478 RtlDeNormalizeProcessParams(
2479 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2484 RtlDestroyProcessParameters(
2485 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2491 _In_ NTSTATUS Status
);
2496 RtlInitializeContext(
2497 _In_ HANDLE ProcessHandle
,
2498 _Out_ PCONTEXT ThreadContext
,
2499 _In_opt_ PVOID ThreadStartParam
,
2500 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2501 _In_ PINITIAL_TEB InitialTeb
2505 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2510 RtlWow64GetThreadContext(
2511 _In_ HANDLE ThreadHandle
,
2512 _Inout_ PWOW64_CONTEXT ThreadContext
2519 RtlWow64SetThreadContext(
2520 _In_ HANDLE ThreadHandle
,
2521 _In_ PWOW64_CONTEXT ThreadContext
2528 RtlIsThreadWithinLoaderCallout(VOID
);
2531 PRTL_USER_PROCESS_PARAMETERS
2533 RtlNormalizeProcessParams(
2534 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2539 RtlReleasePebLock(VOID
);
2545 _In_ HANDLE Process
,
2547 _In_ PVOID CallSite
,
2548 _In_ ULONG ArgumentCount
,
2549 _In_ PULONG Arguments
,
2550 _In_ BOOLEAN PassContext
,
2551 _In_ BOOLEAN AlreadySuspended
2557 RtlSetProcessIsCritical(
2558 _In_ BOOLEAN NewValue
,
2559 _Out_opt_ PBOOLEAN OldValue
,
2560 _In_ BOOLEAN NeedBreaks
2566 RtlSetThreadIsCritical(
2567 _In_ BOOLEAN NewValue
,
2568 _Out_opt_ PBOOLEAN OldValue
,
2569 _In_ BOOLEAN NeedBreaks
2575 RtlGetCurrentProcessorNumber(
2579 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2582 // Thread Pool Functions
2587 RtlSetThreadPoolStartFunc(
2588 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2589 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2595 RtlDeregisterWaitEx(
2596 _In_ HANDLE hWaitHandle
,
2597 _In_opt_ HANDLE hCompletionEvent
2604 _In_ HANDLE hWaitHandle
2611 _In_ WORKERCALLBACKFUNC Function
,
2612 _In_opt_ PVOID Context
,
2619 RtlSetIoCompletionCallback(
2620 _In_ HANDLE FileHandle
,
2621 _In_ PIO_APC_ROUTINE Callback
,
2629 _In_ PHANDLE phNewWaitObject
,
2630 _In_ HANDLE hObject
,
2631 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2632 _In_ PVOID pvContext
,
2633 _In_ ULONG ulMilliseconds
,
2638 // Environment/Path Functions
2643 RtlCreateEnvironment(
2644 _In_ BOOLEAN Inherit
,
2645 _Out_ PWSTR
*Environment
2651 RtlComputePrivatizedDllName_U(
2652 _In_ PUNICODE_STRING DllName
,
2653 _Out_ PUNICODE_STRING RealName
,
2654 _Out_ PUNICODE_STRING LocalName
2660 RtlDestroyEnvironment(
2661 _In_ PWSTR Environment
2667 RtlDoesFileExists_U(
2668 _In_ PCWSTR FileName
2674 RtlDetermineDosPathNameType_U(
2683 _In_ PCWSTR FileName
,
2684 _In_ PCWSTR Extension
,
2685 _In_ ULONG BufferSize
,
2687 _Out_ PWSTR
*PartName
2693 RtlDosSearchPath_Ustr(
2695 _In_ PUNICODE_STRING PathString
,
2696 _In_ PUNICODE_STRING FileNameString
,
2697 _In_ PUNICODE_STRING ExtensionString
,
2698 _In_ PUNICODE_STRING CallerBuffer
,
2699 _Inout_opt_ PUNICODE_STRING DynamicString
,
2700 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2701 _Out_opt_ PSIZE_T FilePartSize
,
2702 _Out_opt_ PSIZE_T LengthNeeded
2708 RtlDosPathNameToNtPathName_U(
2709 _In_opt_z_ PCWSTR DosPathName
,
2710 _Out_ PUNICODE_STRING NtPathName
,
2711 _Out_opt_ PCWSTR
*NtFileNamePart
,
2712 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2718 RtlDosPathNameToRelativeNtPathName_U(
2719 _In_ PCWSTR DosName
,
2720 _Out_ PUNICODE_STRING NtName
,
2721 _Out_ PCWSTR
*PartName
,
2722 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2725 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2729 RtlExpandEnvironmentStrings_U(
2730 _In_z_ PWSTR Environment
,
2731 _In_ PUNICODE_STRING Source
,
2732 _Inout_ PUNICODE_STRING Destination
,
2739 RtlGetCurrentDirectory_U(
2740 _In_ ULONG MaximumLength
,
2741 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2747 RtlGetFullPathName_U(
2748 _In_ PCWSTR FileName
,
2750 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2751 _Out_opt_ PWSTR
*ShortName
2754 #if (NTDDI_VERSION >= NTDDI_WIN7)
2758 RtlGetFullPathName_UEx(
2759 _In_ PWSTR FileName
,
2760 _In_ ULONG BufferLength
,
2762 _Out_opt_ PWSTR
*FilePart
,
2763 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2769 RtlGetFullPathName_UstrEx(
2770 _In_ PUNICODE_STRING FileName
,
2771 _In_opt_ PUNICODE_STRING StaticString
,
2772 _In_opt_ PUNICODE_STRING DynamicString
,
2773 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2774 _Out_opt_ PSIZE_T FilePartSize
,
2775 _Out_opt_ PBOOLEAN NameInvalid
,
2776 _Out_ RTL_PATH_TYPE
* PathType
,
2777 _Out_opt_ PSIZE_T LengthNeeded
2783 RtlGetLengthWithoutTrailingPathSeperators(
2784 _Reserved_ ULONG Flags
,
2785 _In_ PCUNICODE_STRING PathString
,
2792 RtlGetLongestNtPathLength(
2799 RtlIsDosDeviceName_U(
2806 RtlIsDosDeviceName_Ustr(
2807 _In_ PCUNICODE_STRING Name
2810 _IRQL_requires_max_(PASSIVE_LEVEL
)
2811 _Must_inspect_result_
2815 RtlIsNameLegalDOS8Dot3(
2816 _In_ PCUNICODE_STRING Name
,
2817 _Inout_opt_ POEM_STRING OemName
,
2818 _Out_opt_ PBOOLEAN NameContainsSpaces
2824 RtlQueryEnvironmentVariable_U(
2825 _In_opt_ PWSTR Environment
,
2826 _In_ PUNICODE_STRING Name
,
2827 _Out_ PUNICODE_STRING Value
2832 RtlReleaseRelativeName(
2833 _In_ PRTL_RELATIVE_NAME_U RelativeName
2839 RtlSetCurrentDirectory_U(
2840 _In_ PUNICODE_STRING name
2846 RtlSetEnvironmentVariable(
2847 _In_z_ PWSTR
*Environment
,
2848 _In_ PUNICODE_STRING Name
,
2849 _In_ PUNICODE_STRING Value
2853 // Critical Section/Resource Functions
2858 RtlDeleteCriticalSection (
2859 _In_ PRTL_CRITICAL_SECTION CriticalSection
2865 RtlEnterCriticalSection(
2866 _In_ PRTL_CRITICAL_SECTION CriticalSection
2872 RtlInitializeCriticalSection(
2873 _In_ PRTL_CRITICAL_SECTION CriticalSection
2879 RtlInitializeCriticalSectionAndSpinCount(
2880 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2881 _In_ ULONG SpinCount
2887 RtlLeaveCriticalSection(
2888 _In_ PRTL_CRITICAL_SECTION CriticalSection
2894 RtlTryEnterCriticalSection(
2895 _In_ PRTL_CRITICAL_SECTION CriticalSection
2901 RtlpUnWaitCriticalSection(
2902 _In_ PRTL_CRITICAL_SECTION CriticalSection
2908 RtlpWaitForCriticalSection(
2909 _In_ PRTL_CRITICAL_SECTION CriticalSection
2915 RtlAcquireResourceExclusive(
2916 _In_ PRTL_RESOURCE Resource
,
2923 RtlAcquireResourceShared(
2924 _In_ PRTL_RESOURCE Resource
,
2931 RtlConvertExclusiveToShared(
2932 _In_ PRTL_RESOURCE Resource
2938 RtlConvertSharedToExclusive(
2939 _In_ PRTL_RESOURCE Resource
2946 _In_ PRTL_RESOURCE Resource
2953 _In_ PRTL_RESOURCE Resource
2959 RtlInitializeResource(
2960 _In_ PRTL_RESOURCE Resource
2967 _In_ PRTL_RESOURCE Resource
2971 // Compression Functions
2973 NTSYSAPI
//NT_RTL_COMPRESS_API
2977 _In_ USHORT CompressionFormatAndEngine
,
2978 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2979 _In_ ULONG UncompressedBufferSize
,
2980 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2981 _In_ ULONG CompressedBufferSize
,
2982 _In_ ULONG UncompressedChunkSize
,
2983 _Out_ PULONG FinalCompressedSize
,
2984 _In_ PVOID WorkSpace
2987 _IRQL_requires_max_(APC_LEVEL
)
2988 NTSYSAPI
//NT_RTL_COMPRESS_API
2991 RtlDecompressBuffer(
2992 _In_ USHORT CompressionFormat
,
2993 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2994 _In_ ULONG UncompressedBufferSize
,
2995 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2996 _In_ ULONG CompressedBufferSize
,
2997 _Out_ PULONG FinalUncompressedSize
3003 RtlGetCompressionWorkSpaceSize(
3004 _In_ USHORT CompressionFormatAndEngine
,
3005 _Out_ PULONG CompressBufferWorkSpaceSize
,
3006 _Out_ PULONG CompressFragmentWorkSpaceSize
3016 _In_ PTEB_ACTIVE_FRAME Frame
3023 _In_ PTEB_ACTIVE_FRAME Frame
3034 // Debug Info Functions
3037 PRTL_DEBUG_INFORMATION
3039 RtlCreateQueryDebugBuffer(
3041 _In_ BOOLEAN EventPair
3047 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3052 RtlQueryProcessDebugInformation(
3053 _In_ ULONG ProcessId
,
3054 _In_ ULONG DebugInfoClassMask
,
3055 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3065 _In_ PRTL_BITMAP BitMapHeader
,
3066 _In_ ULONG StartingIndex
,
3074 _In_ PRTL_BITMAP BitMapHeader
,
3075 _In_ ULONG StartingIndex
,
3083 _In_ PRTL_BITMAP BitMapHeader
3090 _In_ PRTL_BITMAP BitMapHeader
,
3091 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3092 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3099 _In_ PRTL_BITMAP BitMapHeader
,
3100 _In_ ULONG NumberToFind
,
3101 _In_ ULONG HintIndex
3107 RtlFindClearBitsAndSet(
3108 _In_ PRTL_BITMAP BitMapHeader
,
3109 _In_ ULONG NumberToFind
,
3110 _In_ ULONG HintIndex
3116 RtlFindFirstRunClear(
3117 _In_ PRTL_BITMAP BitMapHeader
,
3118 _Out_ PULONG StartingIndex
3125 _In_ PRTL_BITMAP BitMapHeader
,
3126 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
3127 _In_range_(>, 0) ULONG SizeOfRunArray
,
3128 _In_ BOOLEAN LocateLongestRuns
3134 RtlFindLastBackwardRunClear(
3135 _In_ PRTL_BITMAP BitMapHeader
,
3136 _In_ ULONG FromIndex
,
3137 _Out_ PULONG StartingRunIndex
3143 RtlFindLeastSignificantBit(
3144 _In_ ULONGLONG Value
3150 RtlFindMostSignificantBit(
3151 _In_ ULONGLONG Value
3157 RtlFindNextForwardRunClear(
3158 _In_ PRTL_BITMAP BitMapHeader
,
3159 _In_ ULONG FromIndex
,
3160 _Out_ PULONG StartingRunIndex
3166 RtlFindNextForwardRunSet(
3167 _In_ PRTL_BITMAP BitMapHeader
,
3168 _In_ ULONG FromIndex
,
3169 _Out_ PULONG StartingRunIndex
3176 _In_ PRTL_BITMAP BitMapHeader
,
3177 _In_ ULONG NumberToFind
,
3178 _In_ ULONG HintIndex
3184 RtlFindSetBitsAndClear(
3185 _In_ PRTL_BITMAP BitMapHeader
,
3186 _In_ ULONG NumberToFind
,
3187 _In_ ULONG HintIndex
3190 #ifdef _REACTOS_ // ReactOS improvement
3191 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3192 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3197 RtlInitializeBitMap(
3198 _Out_ PRTL_BITMAP BitMapHeader
,
3199 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3200 _In_opt_ ULONG SizeOfBitMap
3206 RtlNumberOfClearBits(
3207 _In_ PRTL_BITMAP BitMapHeader
3214 _In_ PRTL_BITMAP BitMapHeader
3221 _In_ PRTL_BITMAP BitMapHeader
,
3222 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3229 _In_ PRTL_BITMAP BitMapHeader
,
3230 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3231 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3238 _In_ PRTL_BITMAP BitMapHeader
3241 _Must_inspect_result_
3246 _In_ PRTL_BITMAP BitMapHeader
,
3247 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3257 _In_ HANDLE TimerQueue
,
3258 _In_ PHANDLE phNewTimer
,
3259 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3260 _In_ PVOID Parameter
,
3269 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3275 _In_ HANDLE TimerQueue
,
3277 _In_ HANDLE CompletionEvent
3284 _In_ HANDLE TimerQueue
,
3293 RtlDeleteTimerQueueEx(
3294 _In_ HANDLE TimerQueue
,
3295 _In_opt_ HANDLE CompletionEvent
3301 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3308 InterlockedPushListSList(
3309 _Inout_ PSLIST_HEADER ListHead
,
3310 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3311 _Inout_ PSLIST_ENTRY ListEnd
,
3316 // Range List functions
3321 RtlInitializeRangeList(
3322 _Inout_ PRTL_RANGE_LIST RangeList
3329 _In_ PRTL_RANGE_LIST RangeList
3336 _Inout_ PRTL_RANGE_LIST RangeList
,
3337 _In_ ULONGLONG Start
,
3339 _In_ UCHAR Attributes
,
3341 _In_opt_ PVOID UserData
,
3342 _In_opt_ PVOID Owner
3351 _In_z_ _Printf_format_string_ PCSTR Format
,
3359 _In_ ULONG ComponentId
,
3361 _In_z_ _Printf_format_string_ PCSTR Format
,
3370 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3371 _In_ ULONG MaximumResponseLength
3374 #undef DbgBreakPoint
3383 DbgLoadImageSymbols(
3386 _In_ ULONG_PTR ProcessId
3391 DbgUnLoadImageSymbols(
3394 _In_ ULONG_PTR ProcessId
3405 // Generic Table Functions
3407 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3411 RtlInsertElementGenericTable(
3412 _In_ PRTL_GENERIC_TABLE Table
,
3413 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3414 _In_ CLONG BufferSize
,
3415 _Out_opt_ PBOOLEAN NewElement
3421 RtlInsertElementGenericTableFull(
3422 _In_ PRTL_GENERIC_TABLE Table
,
3423 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3424 _In_ CLONG BufferSize
,
3425 _Out_opt_ PBOOLEAN NewElement
,
3426 _In_ PVOID NodeOrParent
,
3427 _In_ TABLE_SEARCH_RESULT SearchResult
3433 RtlIsGenericTableEmpty(
3434 _In_ PRTL_GENERIC_TABLE Table
3440 RtlLookupElementGenericTableFull(
3441 _In_ PRTL_GENERIC_TABLE Table
,
3443 _Out_ PVOID
*NodeOrParent
,
3444 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3449 // Handle Table Functions
3452 PRTL_HANDLE_TABLE_ENTRY
3455 _In_ PRTL_HANDLE_TABLE HandleTable
,
3456 _Inout_ PULONG Index
3462 RtlDestroyHandleTable(
3463 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3469 _In_ PRTL_HANDLE_TABLE HandleTable
,
3470 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3476 RtlInitializeHandleTable(
3477 _In_ ULONG TableSize
,
3478 _In_ ULONG HandleSize
,
3479 _In_ PRTL_HANDLE_TABLE HandleTable
3486 _In_ PRTL_HANDLE_TABLE HandleTable
,
3487 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3490 _Success_(return!=FALSE
)
3494 RtlIsValidIndexHandle(
3495 _In_ PRTL_HANDLE_TABLE HandleTable
,
3497 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3507 _In_ PVOID BaseAddress
,
3509 _In_ ULONG Language
,
3510 _In_ ULONG MessageId
,
3511 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3517 RtlGetNtGlobalFlags(VOID
);
3519 _Success_(return!=NULL
)
3523 RtlImageDirectoryEntryToData(
3524 _In_ PVOID BaseAddress
,
3525 _In_ BOOLEAN MappedAsImage
,
3526 _In_ USHORT Directory
,
3534 _In_ PIMAGE_NT_HEADERS NtHeader
,
3535 _In_ PVOID BaseAddress
,
3537 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3544 _In_ PVOID BaseAddress
);
3551 _In_ PVOID BaseAddress
,
3552 _In_ ULONGLONG Size
,
3553 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3557 PIMAGE_SECTION_HEADER
3559 RtlImageRvaToSection(
3560 _In_ PIMAGE_NT_HEADERS NtHeader
,
3561 _In_ PVOID BaseAddress
,
3568 LdrRelocateImageWithBias(
3569 _In_ PVOID NewAddress
,
3570 _In_ LONGLONG AdditionalBias
,
3571 _In_ PCCH LoaderName
,
3573 _In_ ULONG Conflict
,
3578 // Activation Context Functions
3580 #ifdef NTOS_MODE_USER
3584 RtlActivateActivationContextEx(
3588 _Out_ PULONG_PTR Cookie
3594 RtlActivateActivationContext(
3597 _Out_ PULONG_PTR Cookie
3603 RtlAddRefActivationContext(
3608 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3610 RtlActivateActivationContextUnsafeFast(
3611 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3618 RtlAllocateActivationContextStack(
3619 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3625 RtlCreateActivationContext(
3627 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3628 _In_ ULONG ExtraBytes
,
3629 _In_ PVOID NotificationRoutine
,
3630 _In_ PVOID NotificationContext
,
3631 _Out_ PACTIVATION_CONTEXT
*ActCtx
3637 RtlGetActiveActivationContext(
3644 RtlReleaseActivationContext(
3651 RtlDeactivateActivationContext(
3653 _In_ ULONG_PTR ulCookie
3659 RtlFreeActivationContextStack(
3660 _In_ PACTIVATION_CONTEXT_STACK Stack
3666 RtlFreeThreadActivationContextStack(VOID
);
3669 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3671 RtlDeactivateActivationContextUnsafeFast(
3672 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3678 RtlDosApplyFileIsolationRedirection_Ustr(
3680 _In_ PUNICODE_STRING OriginalName
,
3681 _In_ PUNICODE_STRING Extension
,
3682 _Inout_ PUNICODE_STRING StaticString
,
3683 _Inout_ PUNICODE_STRING DynamicString
,
3684 _Inout_ PUNICODE_STRING
*NewName
,
3685 _In_ PULONG NewFlags
,
3686 _In_ PSIZE_T FileNameSize
,
3687 _In_ PSIZE_T RequiredLength
3693 RtlFindActivationContextSectionString(
3695 _In_
const GUID
*ExtensionGuid
,
3696 _In_ ULONG SectionType
,
3697 _In_
const UNICODE_STRING
*SectionName
,
3698 _Inout_ PVOID ReturnedData
3704 RtlQueryInformationActivationContext(
3706 _In_opt_ PVOID Context
,
3707 _In_opt_ PVOID pvSubInstance
,
3708 _In_ ULONG ulInfoClass
,
3709 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3710 _In_opt_ SIZE_T cbBuffer
,
3711 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3717 RtlQueryInformationActiveActivationContext(
3718 _In_ ULONG ulInfoClass
,
3719 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3720 _In_opt_ SIZE_T cbBuffer
,
3721 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3727 RtlZombifyActivationContext(
3737 RtlWow64EnableFsRedirection(
3738 _In_ BOOLEAN Wow64FsEnableRedirection
3744 RtlWow64EnableFsRedirectionEx(
3745 _In_ PVOID Wow64FsEnableRedirection
,
3746 _Out_ PVOID
*OldFsRedirectionLevel
3752 // Registry Functions
3754 _IRQL_requires_max_(PASSIVE_LEVEL
)
3755 _Must_inspect_result_
3759 RtlCheckRegistryKey(
3760 _In_ ULONG RelativeTo
,
3767 RtlCreateRegistryKey(
3768 _In_ ULONG RelativeTo
,
3775 RtlFormatCurrentUserKeyPath(
3776 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3777 PUNICODE_STRING KeyPath
3784 _In_ ACCESS_MASK DesiredAccess
,
3785 _Out_ PHANDLE KeyHandle
3788 _IRQL_requires_max_(PASSIVE_LEVEL
)
3792 RtlQueryRegistryValues(
3793 _In_ ULONG RelativeTo
,
3795 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3796 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3797 _In_opt_ PVOID Context
,
3798 _In_opt_ PVOID Environment
3801 _IRQL_requires_max_(PASSIVE_LEVEL
)
3805 RtlWriteRegistryValue(
3806 _In_ ULONG RelativeTo
,
3808 _In_z_ PCWSTR ValueName
,
3809 _In_ ULONG ValueType
,
3810 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3811 _In_ ULONG ValueLength
3814 #ifdef NTOS_MODE_USER
3819 _Out_ HANDLE KeyHandle
,
3820 _In_ ACCESS_MASK DesiredAccess
,
3821 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3822 _In_ ULONG TitleIndex
,
3823 _In_ PUNICODE_STRING Class
,
3824 _Out_ PULONG Disposition
3830 RtlpNtEnumerateSubKey(
3831 _In_ HANDLE KeyHandle
,
3832 _Inout_ PUNICODE_STRING SubKeyName
,
3840 RtlpNtMakeTemporaryKey(
3841 _In_ HANDLE KeyHandle
3848 _Out_ HANDLE KeyHandle
,
3849 _In_ ACCESS_MASK DesiredAccess
,
3850 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3857 RtlpNtQueryValueKey(
3858 _In_ HANDLE KeyHandle
,
3859 _Out_opt_ PULONG Type
,
3860 _Out_opt_ PVOID Data
,
3861 _Inout_opt_ PULONG DataLength
,
3869 _In_ HANDLE KeyHandle
,
3872 _In_ ULONG DataLength
3882 RtlGetDefaultCodePage(
3883 _Out_ PUSHORT AnsiCodePage
,
3884 _Out_ PUSHORT OemCodePage
3891 _In_ PUSHORT AnsiTableBase
,
3892 _In_ PUSHORT OemTableBase
,
3893 _In_ PUSHORT CaseTableBase
,
3894 _Out_ PNLSTABLEINFO NlsTable
3897 _IRQL_requires_max_(PASSIVE_LEVEL
)
3901 RtlInitCodePageTable(
3902 _In_ PUSHORT TableBase
,
3903 _Out_ PCPTABLEINFO CodePageTable
3909 RtlResetRtlTranslations(
3910 _In_ PNLSTABLEINFO NlsTable
);
3912 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3915 // Misc conversion functions
3920 RtlConvertLongToLargeInteger(
3921 _In_ LONG SignedInteger
3924 LARGE_INTEGER Result
;
3926 Result
.QuadPart
= SignedInteger
;
3933 RtlEnlargedIntegerMultiply(
3934 _In_ LONG Multiplicand
,
3935 _In_ LONG Multiplier
3938 LARGE_INTEGER Product
;
3940 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3947 RtlEnlargedUnsignedDivide(
3948 _In_ ULARGE_INTEGER Dividend
,
3950 _In_opt_ PULONG Remainder
3955 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
3957 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3966 RtlEnlargedUnsignedMultiply(
3967 _In_ ULONG Multiplicand
,
3968 _In_ ULONG Multiplier
3971 LARGE_INTEGER Product
;
3973 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3977 #if defined(_AMD64_) || defined(_IA64_)
3981 RtlExtendedLargeIntegerDivide(
3982 _In_ LARGE_INTEGER Dividend
,
3984 _Out_opt_ PULONG Remainder
)
3987 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3989 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3997 RtlExtendedLargeIntegerDivide(
3998 _In_ LARGE_INTEGER Dividend
,
4000 _Out_opt_ PULONG Remainder
4003 #endif /* defined(_AMD64_) || defined(_IA64_) */
4026 _In_ ULONG InitialCrc
,
4032 // Network Functions
4037 RtlIpv4AddressToStringA(
4038 _In_
const struct in_addr
*Addr
,
4039 _Out_writes_(16) PCHAR S
4045 RtlIpv4AddressToStringW(
4046 _In_
const struct in_addr
*Addr
,
4047 _Out_writes_(16) PWCHAR S
4053 RtlIpv4AddressToStringExA(
4054 _In_
const struct in_addr
*Address
,
4056 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PCHAR AddressString
,
4057 _Inout_ PULONG AddressStringLength
4062 RtlIpv4AddressToStringExW(
4063 _In_
const struct in_addr
*Address
,
4065 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4066 _Inout_ PULONG AddressStringLength
4072 RtlIpv4StringToAddressA(
4074 _In_ BOOLEAN Strict
,
4075 _Out_ PCSTR
*Terminator
,
4076 _Out_
struct in_addr
*Addr
4082 RtlIpv4StringToAddressW(
4084 _In_ BOOLEAN Strict
,
4085 _Out_ PCWSTR
*Terminator
,
4086 _Out_
struct in_addr
*Addr
4092 RtlIpv4StringToAddressExA(
4093 _In_ PCSTR AddressString
,
4094 _In_ BOOLEAN Strict
,
4095 _Out_
struct in_addr
*Address
,
4102 RtlIpv4StringToAddressExW(
4103 _In_ PCWSTR AddressString
,
4104 _In_ BOOLEAN Strict
,
4105 _Out_
struct in_addr
*Address
,
4112 RtlIpv6AddressToStringA(
4113 _In_
const struct in6_addr
*Addr
,
4114 _Out_writes_(46) PSTR S
4120 RtlIpv6AddressToStringW(
4121 _In_
const struct in6_addr
*Addr
,
4122 _Out_writes_(46) PWSTR S
4128 RtlIpv6AddressToStringExA(
4129 _In_
const struct in6_addr
*Address
,
4132 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PSTR AddressString
,
4133 _Inout_ PULONG AddressStringLength
4139 RtlIpv6AddressToStringExW(
4140 _In_
const struct in6_addr
*Address
,
4143 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4144 _Inout_ PULONG AddressStringLength
4150 RtlIpv6StringToAddressA(
4152 _Out_ PCSTR
*Terminator
,
4153 _Out_
struct in6_addr
*Addr
4159 RtlIpv6StringToAddressW(
4161 _Out_ PCWSTR
*Terminator
,
4162 _Out_
struct in6_addr
*Addr
4168 RtlIpv6StringToAddressExA(
4169 _In_ PCSTR AddressString
,
4170 _Out_
struct in6_addr
*Address
,
4171 _Out_ PULONG ScopeId
,
4178 RtlIpv6StringToAddressExW(
4179 _In_ PCWSTR AddressString
,
4180 _Out_
struct in6_addr
*Address
,
4181 _Out_ PULONG ScopeId
,
4192 RtlQueryTimeZoneInformation(
4193 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4198 RtlSecondsSince1970ToTime(
4199 _In_ ULONG SecondsSince1970
,
4200 _Out_ PLARGE_INTEGER Time
4206 RtlSetTimeZoneInformation(
4207 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4209 _Success_(return!=FALSE
)
4210 _Must_inspect_result_
4214 RtlTimeFieldsToTime(
4215 _In_ PTIME_FIELDS TimeFields
,
4216 _Out_ PLARGE_INTEGER Time
4219 _Success_(return != 0)
4220 _Must_inspect_result_
4224 RtlTimeToSecondsSince1970(
4225 _In_ PLARGE_INTEGER Time
,
4226 _Out_ PULONG ElapsedSeconds
4232 RtlTimeToTimeFields(
4233 PLARGE_INTEGER Time
,
4234 PTIME_FIELDS TimeFields
4240 RtlSystemTimeToLocalTime(
4241 _In_ PLARGE_INTEGER SystemTime
,
4242 _Out_ PLARGE_INTEGER LocalTime
4246 // Version Functions
4248 _IRQL_requires_max_(PASSIVE_LEVEL
)
4249 _Must_inspect_result_
4253 RtlVerifyVersionInfo(
4254 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4255 _In_ ULONG TypeMask
,
4256 _In_ ULONGLONG ConditionMask
4259 _IRQL_requires_max_(PASSIVE_LEVEL
)
4265 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4266 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4267 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4268 PRTL_OSVERSIONINFOW lpVersionInformation
4274 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4277 // Secure Memory Functions
4279 #ifdef NTOS_MODE_USER
4283 RtlRegisterSecureMemoryCacheCallback(
4284 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4289 RtlFlushSecureMemoryCache(
4290 _In_ PVOID MemoryCache
,
4291 _In_opt_ SIZE_T MemoryLength
4296 // Boot Status Data Functions
4298 #ifdef NTOS_MODE_USER
4302 RtlCreateBootStatusDataFile(
4309 RtlGetSetBootStatusData(
4310 _In_ HANDLE FileHandle
,
4311 _In_ BOOLEAN WriteMode
,
4312 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4314 _In_ ULONG BufferSize
,
4315 _Out_opt_ PULONG ReturnLength
4321 RtlLockBootStatusData(
4322 _Out_ PHANDLE FileHandle
4328 RtlUnlockBootStatusData(
4329 _In_ HANDLE FileHandle
4333 #ifdef NTOS_MODE_USER
4334 _Must_inspect_result_
4339 _In_ PUNICODE_STRING GuidString
,
4342 _Must_inspect_result_
4348 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4349 PUNICODE_STRING GuidString
);
4354 RtlComputeImportTableHash(
4357 _In_ ULONG ImportTableHashRevision
4362 // MemoryStream functions
4364 #ifdef NTOS_MODE_USER
4369 RtlInitMemoryStream(
4370 _Out_ PRTL_MEMORY_STREAM Stream
4376 RtlInitOutOfProcessMemoryStream(
4377 _Out_ PRTL_MEMORY_STREAM Stream
4383 RtlFinalReleaseOutOfProcessMemoryStream(
4384 _In_ PRTL_MEMORY_STREAM Stream
4390 RtlQueryInterfaceMemoryStream(
4391 _In_
struct IStream
*This
,
4392 _In_ REFIID RequestedIid
,
4393 _Outptr_ PVOID
*ResultObject
4399 RtlAddRefMemoryStream(
4400 _In_
struct IStream
*This
4406 RtlReleaseMemoryStream(
4407 _In_
struct IStream
*This
4413 RtlReadMemoryStream(
4414 _In_
struct IStream
*This
,
4415 _Out_writes_bytes_(Length
) PVOID Buffer
,
4417 _Out_opt_ PULONG BytesRead
4423 RtlReadOutOfProcessMemoryStream(
4424 _In_
struct IStream
*This
,
4425 _Out_writes_bytes_(Length
) PVOID Buffer
,
4427 _Out_opt_ PULONG BytesRead
4433 RtlSeekMemoryStream(
4434 _In_
struct IStream
*This
,
4435 _In_ LARGE_INTEGER RelativeOffset
,
4437 _Out_opt_ PULARGE_INTEGER ResultOffset
4443 RtlCopyMemoryStreamTo(
4444 _In_
struct IStream
*This
,
4445 _In_
struct IStream
*Target
,
4446 _In_ ULARGE_INTEGER Length
,
4447 _Out_opt_ PULARGE_INTEGER BytesRead
,
4448 _Out_opt_ PULARGE_INTEGER BytesWritten
4454 RtlCopyOutOfProcessMemoryStreamTo(
4455 _In_
struct IStream
*This
,
4456 _In_
struct IStream
*Target
,
4457 _In_ ULARGE_INTEGER Length
,
4458 _Out_opt_ PULARGE_INTEGER BytesRead
,
4459 _Out_opt_ PULARGE_INTEGER BytesWritten
4465 RtlStatMemoryStream(
4466 _In_
struct IStream
*This
,
4467 _Out_
struct tagSTATSTG
*Stats
,
4475 RtlWriteMemoryStream(
4476 _In_
struct IStream
*This
,
4477 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4479 _Out_opt_ PULONG BytesWritten
4485 RtlSetMemoryStreamSize(
4486 _In_
struct IStream
*This
,
4487 _In_ ULARGE_INTEGER NewSize
4493 RtlCommitMemoryStream(
4494 _In_
struct IStream
*This
,
4495 _In_ ULONG CommitFlags
4501 RtlRevertMemoryStream(
4502 _In_
struct IStream
*This
4508 RtlLockMemoryStreamRegion(
4509 _In_
struct IStream
*This
,
4510 _In_ ULARGE_INTEGER Offset
,
4511 _In_ ULARGE_INTEGER Length
,
4518 RtlUnlockMemoryStreamRegion(
4519 _In_
struct IStream
*This
,
4520 _In_ ULARGE_INTEGER Offset
,
4521 _In_ ULARGE_INTEGER Length
,
4528 RtlCloneMemoryStream(
4529 _In_
struct IStream
*This
,
4530 _Outptr_
struct IStream
**ResultStream
4533 #endif // NTOS_MODE_USER
4538 RtlFindActivationContextSectionGuid(
4540 const GUID
*extguid
,