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
1933 RtlxAnsiStringToUnicodeSize(
1934 PCANSI_STRING AnsiString
1940 RtlAnsiStringToUnicodeString(
1941 PUNICODE_STRING DestinationString
,
1942 PCANSI_STRING SourceString
,
1943 BOOLEAN AllocateDestinationString
1946 #ifdef NTOS_MODE_USER
1948 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1949 NLS_MB_CODE_PAGE_TAG ? \
1950 RtlxAnsiStringToUnicodeSize(STRING) : \
1951 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1959 RtlCreateUnicodeStringFromAsciiz(
1960 _Out_ PUNICODE_STRING Destination
,
1965 // Unicode String Functions
1970 RtlAppendUnicodeToString(
1971 PUNICODE_STRING Destination
,
1978 RtlAppendUnicodeStringToString(
1979 PUNICODE_STRING Destination
,
1980 PCUNICODE_STRING Source
1986 RtlCompareUnicodeString(
1987 PCUNICODE_STRING String1
,
1988 PCUNICODE_STRING String2
,
1989 BOOLEAN CaseInsensitive
1995 RtlCopyUnicodeString(
1996 PUNICODE_STRING DestinationString
,
1997 PCUNICODE_STRING SourceString
2003 RtlCreateUnicodeString(
2004 PUNICODE_STRING DestinationString
,
2008 #ifdef NTOS_MODE_USER
2013 RtlDowncaseUnicodeString(
2014 _Inout_ PUNICODE_STRING UniDest
,
2015 _In_ PCUNICODE_STRING UniSource
,
2016 _In_ BOOLEAN AllocateDestinationString
2022 RtlDuplicateUnicodeString(
2024 _In_ PCUNICODE_STRING SourceString
,
2025 _Out_ PUNICODE_STRING DestinationString
2035 _In_ PVOID Destination
,
2043 RtlFillMemoryUlonglong(
2044 _Out_ PVOID Destination
,
2046 _In_ ULONGLONG Pattern
2052 RtlCopyMappedMemory(
2053 _Out_writes_bytes_all_(Size
) PVOID Destination
,
2054 _In_reads_bytes_(Size
) const VOID
*Source
,
2061 RtlCompareMemoryUlong(
2067 #ifndef RtlEqualMemory
2068 #define RtlEqualMemory(Destination, Source, Length) \
2069 (!memcmp(Destination, Source, Length))
2072 #define RtlCopyBytes RtlCopyMemory
2073 #define RtlFillBytes RtlFillMemory
2074 #define RtlZeroBytes RtlZeroMemory
2081 RtlEqualUnicodeString(
2082 PCUNICODE_STRING String1
,
2083 PCUNICODE_STRING String2
,
2084 BOOLEAN CaseInsensitive
2090 RtlFindCharInUnicodeString(
2092 _In_ PCUNICODE_STRING SearchString
,
2093 _In_ PCUNICODE_STRING MatchString
,
2094 _Out_ PUSHORT Position
2097 _IRQL_requires_max_(PASSIVE_LEVEL
)
2101 RtlFreeUnicodeString(
2102 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
2103 PUNICODE_STRING UnicodeString
2109 RtlEraseUnicodeString(
2110 _Inout_ PUNICODE_STRING String
2116 RtlHashUnicodeString(
2117 _In_ CONST UNICODE_STRING
*String
,
2118 _In_ BOOLEAN CaseInSensitive
,
2119 _In_ ULONG HashAlgorithm
,
2120 _Out_ PULONG HashValue
2123 _IRQL_requires_max_(DISPATCH_LEVEL
)
2124 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2125 _When_(SourceString
!= NULL
,
2126 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2127 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2128 _When_(SourceString
== NULL
,
2129 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2130 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2134 RtlInitUnicodeString(
2135 _Out_ PUNICODE_STRING DestinationString
,
2136 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2139 _IRQL_requires_max_(DISPATCH_LEVEL
)
2143 RtlInitUnicodeStringEx(
2144 _Out_ PUNICODE_STRING DestinationString
,
2145 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2157 _IRQL_requires_max_(PASSIVE_LEVEL
)
2158 _Must_inspect_result_
2163 _In_
const STRING
*String1
,
2164 _In_
const STRING
*String2
,
2165 _In_ BOOLEAN CaseInsensitive
2168 _IRQL_requires_max_(PASSIVE_LEVEL
)
2169 _Must_inspect_result_
2173 RtlPrefixUnicodeString(
2174 _In_ PCUNICODE_STRING String1
,
2175 _In_ PCUNICODE_STRING String2
,
2176 _In_ BOOLEAN CaseInsensitive
2179 _IRQL_requires_max_(PASSIVE_LEVEL
)
2184 _Inout_ PSTRING DestinationString
,
2185 _In_
const STRING
*SourceString
2188 _IRQL_requires_max_(PASSIVE_LEVEL
)
2189 _Must_inspect_result_
2194 _In_
const STRING
*String1
,
2195 _In_
const STRING
*String2
,
2196 _In_ BOOLEAN CaseInSensitive
2203 _Out_ PSTRING DestinationString
,
2204 _In_opt_
const STRING
*SourceString
2207 _IRQL_requires_max_(PASSIVE_LEVEL
)
2208 _Must_inspect_result_
2213 _In_
const STRING
*String1
,
2214 _In_
const STRING
*String2
,
2215 _In_ BOOLEAN CaseInSensitive
2218 _IRQL_requires_max_(APC_LEVEL
)
2222 RtlAppendStringToString(
2223 _Inout_ PSTRING Destination
,
2224 _In_
const STRING
*Source
2227 _IRQL_requires_max_(PASSIVE_LEVEL
)
2228 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2232 RtlUpcaseUnicodeString(
2233 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2234 _When_(!AllocateDestinationString
, _Inout_
)
2235 PUNICODE_STRING DestinationString
,
2236 _In_ PCUNICODE_STRING SourceString
,
2237 _In_ BOOLEAN AllocateDestinationString
2240 _IRQL_requires_max_(PASSIVE_LEVEL
)
2244 RtlUnicodeStringToInteger(
2245 _In_ PCUNICODE_STRING String
,
2246 _In_opt_ ULONG Base
,
2253 RtlValidateUnicodeString(
2255 _In_ PCUNICODE_STRING String
2259 // Ansi String Functions
2261 _IRQL_requires_max_(PASSIVE_LEVEL
)
2266 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2267 PANSI_STRING AnsiString
2270 _IRQL_requires_max_(DISPATCH_LEVEL
)
2275 _Out_ PANSI_STRING DestinationString
,
2276 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2279 _IRQL_requires_max_(DISPATCH_LEVEL
)
2283 RtlInitAnsiStringEx(
2284 _Out_ PANSI_STRING DestinationString
,
2285 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2289 // OEM String Functions
2291 _IRQL_requires_max_(PASSIVE_LEVEL
)
2296 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2297 POEM_STRING OemString
2301 // MultiByte->Unicode String Functions
2303 _IRQL_requires_max_(PASSIVE_LEVEL
)
2307 RtlMultiByteToUnicodeN(
2308 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2309 _In_ ULONG MaxBytesInUnicodeString
,
2310 _Out_opt_ PULONG BytesInUnicodeString
,
2311 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2312 _In_ ULONG BytesInMultiByteString
2315 _IRQL_requires_max_(PASSIVE_LEVEL
)
2319 RtlMultiByteToUnicodeSize(
2320 _Out_ PULONG BytesInUnicodeString
,
2321 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2322 _In_ ULONG BytesInMultiByteString
2331 RtlAddAtomToAtomTable(
2332 _In_ PRTL_ATOM_TABLE AtomTable
,
2333 _In_ PWSTR AtomName
,
2334 _Out_ PRTL_ATOM Atom
2341 _In_ ULONG TableSize
,
2342 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2348 RtlDeleteAtomFromAtomTable(
2349 _In_ PRTL_ATOM_TABLE AtomTable
,
2356 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2361 RtlQueryAtomInAtomTable(
2362 _In_ PRTL_ATOM_TABLE AtomTable
,
2364 _Out_opt_ PULONG RefCount
,
2365 _Out_opt_ PULONG PinCount
,
2366 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2367 _Inout_opt_ PULONG NameLength
2373 RtlPinAtomInAtomTable(
2374 _In_ PRTL_ATOM_TABLE AtomTable
,
2381 RtlLookupAtomInAtomTable(
2382 _In_ PRTL_ATOM_TABLE AtomTable
,
2383 _In_ PWSTR AtomName
,
2384 _Out_ PRTL_ATOM Atom
2388 // Process Management Functions
2400 RtlAcquirePebLock(VOID
);
2405 RtlCreateProcessParameters (
2406 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2407 _In_ PUNICODE_STRING ImagePathName
,
2408 _In_opt_ PUNICODE_STRING DllPath
,
2409 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2410 _In_opt_ PUNICODE_STRING CommandLine
,
2411 _In_opt_ PWSTR Environment
,
2412 _In_opt_ PUNICODE_STRING WindowTitle
,
2413 _In_opt_ PUNICODE_STRING DesktopInfo
,
2414 _In_opt_ PUNICODE_STRING ShellInfo
,
2415 _In_opt_ PUNICODE_STRING RuntimeInfo
2421 RtlCreateUserProcess(
2422 _In_ PUNICODE_STRING ImageFileName
,
2423 _In_ ULONG Attributes
,
2424 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2425 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2426 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2427 _In_opt_ HANDLE ParentProcess
,
2428 _In_ BOOLEAN CurrentDirectory
,
2429 _In_opt_ HANDLE DebugPort
,
2430 _In_opt_ HANDLE ExceptionPort
,
2431 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2434 #if (NTDDI_VERSION >= NTDDI_WIN7)
2438 RtlCreateUserThread(
2439 _In_ PVOID ThreadContext
,
2440 _Out_ HANDLE
*OutThreadHandle
,
2441 _Reserved_ PVOID Reserved1
,
2442 _Reserved_ PVOID Reserved2
,
2443 _Reserved_ PVOID Reserved3
,
2444 _Reserved_ PVOID Reserved4
,
2445 _Reserved_ PVOID Reserved5
,
2446 _Reserved_ PVOID Reserved6
,
2447 _Reserved_ PVOID Reserved7
,
2448 _Reserved_ PVOID Reserved8
2454 RtlCreateUserThread(
2455 _In_ HANDLE ProcessHandle
,
2456 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2457 _In_ BOOLEAN CreateSuspended
,
2458 _In_ ULONG StackZeroBits
,
2459 _In_ SIZE_T StackReserve
,
2460 _In_ SIZE_T StackCommit
,
2461 _In_ PTHREAD_START_ROUTINE StartAddress
,
2462 _In_ PVOID Parameter
,
2463 _Out_opt_ PHANDLE ThreadHandle
,
2464 _Out_opt_ PCLIENT_ID ClientId
2469 PRTL_USER_PROCESS_PARAMETERS
2471 RtlDeNormalizeProcessParams(
2472 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2477 RtlDestroyProcessParameters(
2478 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2484 _In_ NTSTATUS Status
);
2489 RtlInitializeContext(
2490 _In_ HANDLE ProcessHandle
,
2491 _Out_ PCONTEXT ThreadContext
,
2492 _In_opt_ PVOID ThreadStartParam
,
2493 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2494 _In_ PINITIAL_TEB InitialTeb
2498 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2503 RtlWow64GetThreadContext(
2504 _In_ HANDLE ThreadHandle
,
2505 _Inout_ PWOW64_CONTEXT ThreadContext
2512 RtlWow64SetThreadContext(
2513 _In_ HANDLE ThreadHandle
,
2514 _In_ PWOW64_CONTEXT ThreadContext
2521 RtlIsThreadWithinLoaderCallout(VOID
);
2524 PRTL_USER_PROCESS_PARAMETERS
2526 RtlNormalizeProcessParams(
2527 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2532 RtlReleasePebLock(VOID
);
2538 _In_ HANDLE Process
,
2540 _In_ PVOID CallSite
,
2541 _In_ ULONG ArgumentCount
,
2542 _In_ PULONG Arguments
,
2543 _In_ BOOLEAN PassContext
,
2544 _In_ BOOLEAN AlreadySuspended
2550 RtlSetProcessIsCritical(
2551 _In_ BOOLEAN NewValue
,
2552 _Out_opt_ PBOOLEAN OldValue
,
2553 _In_ BOOLEAN NeedBreaks
2559 RtlSetThreadIsCritical(
2560 _In_ BOOLEAN NewValue
,
2561 _Out_opt_ PBOOLEAN OldValue
,
2562 _In_ BOOLEAN NeedBreaks
2568 RtlGetCurrentProcessorNumber(
2572 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2575 // Thread Pool Functions
2580 RtlSetThreadPoolStartFunc(
2581 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2582 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2588 RtlDeregisterWaitEx(
2589 _In_ HANDLE hWaitHandle
,
2590 _In_opt_ HANDLE hCompletionEvent
2597 _In_ HANDLE hWaitHandle
2604 _In_ WORKERCALLBACKFUNC Function
,
2605 _In_opt_ PVOID Context
,
2612 RtlSetIoCompletionCallback(
2613 _In_ HANDLE FileHandle
,
2614 _In_ PIO_APC_ROUTINE Callback
,
2622 _In_ PHANDLE phNewWaitObject
,
2623 _In_ HANDLE hObject
,
2624 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2625 _In_ PVOID pvContext
,
2626 _In_ ULONG ulMilliseconds
,
2631 // Environment/Path Functions
2636 RtlCreateEnvironment(
2637 _In_ BOOLEAN Inherit
,
2638 _Out_ PWSTR
*Environment
2644 RtlComputePrivatizedDllName_U(
2645 _In_ PUNICODE_STRING DllName
,
2646 _Out_ PUNICODE_STRING RealName
,
2647 _Out_ PUNICODE_STRING LocalName
2653 RtlDestroyEnvironment(
2654 _In_ PWSTR Environment
2660 RtlDoesFileExists_U(
2661 _In_ PCWSTR FileName
2667 RtlDetermineDosPathNameType_U(
2676 _In_ PCWSTR FileName
,
2677 _In_ PCWSTR Extension
,
2678 _In_ ULONG BufferSize
,
2680 _Out_ PWSTR
*PartName
2686 RtlDosSearchPath_Ustr(
2688 _In_ PUNICODE_STRING PathString
,
2689 _In_ PUNICODE_STRING FileNameString
,
2690 _In_ PUNICODE_STRING ExtensionString
,
2691 _In_ PUNICODE_STRING CallerBuffer
,
2692 _Inout_opt_ PUNICODE_STRING DynamicString
,
2693 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2694 _Out_opt_ PSIZE_T FilePartSize
,
2695 _Out_opt_ PSIZE_T LengthNeeded
2701 RtlDosPathNameToNtPathName_U(
2702 _In_opt_z_ PCWSTR DosPathName
,
2703 _Out_ PUNICODE_STRING NtPathName
,
2704 _Out_opt_ PCWSTR
*NtFileNamePart
,
2705 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2711 RtlDosPathNameToRelativeNtPathName_U(
2712 _In_ PCWSTR DosName
,
2713 _Out_ PUNICODE_STRING NtName
,
2714 _Out_ PCWSTR
*PartName
,
2715 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2718 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2722 RtlExpandEnvironmentStrings_U(
2723 _In_z_ PWSTR Environment
,
2724 _In_ PUNICODE_STRING Source
,
2725 _Inout_ PUNICODE_STRING Destination
,
2732 RtlGetCurrentDirectory_U(
2733 _In_ ULONG MaximumLength
,
2734 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2740 RtlGetFullPathName_U(
2741 _In_ PCWSTR FileName
,
2743 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2744 _Out_opt_ PWSTR
*ShortName
2747 #if (NTDDI_VERSION >= NTDDI_WIN7)
2751 RtlGetFullPathName_UEx(
2752 _In_ PWSTR FileName
,
2753 _In_ ULONG BufferLength
,
2755 _Out_opt_ PWSTR
*FilePart
,
2756 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2762 RtlGetFullPathName_UstrEx(
2763 _In_ PUNICODE_STRING FileName
,
2764 _In_opt_ PUNICODE_STRING StaticString
,
2765 _In_opt_ PUNICODE_STRING DynamicString
,
2766 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2767 _Out_opt_ PSIZE_T FilePartSize
,
2768 _Out_opt_ PBOOLEAN NameInvalid
,
2769 _Out_ RTL_PATH_TYPE
* PathType
,
2770 _Out_opt_ PSIZE_T LengthNeeded
2776 RtlGetLengthWithoutTrailingPathSeperators(
2777 _Reserved_ ULONG Flags
,
2778 _In_ PCUNICODE_STRING PathString
,
2785 RtlGetLongestNtPathLength(
2792 RtlIsDosDeviceName_U(
2799 RtlIsDosDeviceName_Ustr(
2800 _In_ PCUNICODE_STRING Name
2803 _IRQL_requires_max_(PASSIVE_LEVEL
)
2804 _Must_inspect_result_
2808 RtlIsNameLegalDOS8Dot3(
2809 _In_ PCUNICODE_STRING Name
,
2810 _Inout_opt_ POEM_STRING OemName
,
2811 _Out_opt_ PBOOLEAN NameContainsSpaces
2817 RtlQueryEnvironmentVariable_U(
2818 _In_opt_ PWSTR Environment
,
2819 _In_ PUNICODE_STRING Name
,
2820 _Out_ PUNICODE_STRING Value
2825 RtlReleaseRelativeName(
2826 _In_ PRTL_RELATIVE_NAME_U RelativeName
2832 RtlSetCurrentDirectory_U(
2833 _In_ PUNICODE_STRING name
2839 RtlSetEnvironmentVariable(
2840 _In_z_ PWSTR
*Environment
,
2841 _In_ PUNICODE_STRING Name
,
2842 _In_ PUNICODE_STRING Value
2846 // Critical Section/Resource Functions
2851 RtlDeleteCriticalSection (
2852 _In_ PRTL_CRITICAL_SECTION CriticalSection
2858 RtlEnterCriticalSection(
2859 _In_ PRTL_CRITICAL_SECTION CriticalSection
2865 RtlInitializeCriticalSection(
2866 _In_ PRTL_CRITICAL_SECTION CriticalSection
2872 RtlInitializeCriticalSectionAndSpinCount(
2873 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2874 _In_ ULONG SpinCount
2880 RtlLeaveCriticalSection(
2881 _In_ PRTL_CRITICAL_SECTION CriticalSection
2887 RtlTryEnterCriticalSection(
2888 _In_ PRTL_CRITICAL_SECTION CriticalSection
2894 RtlpUnWaitCriticalSection(
2895 _In_ PRTL_CRITICAL_SECTION CriticalSection
2901 RtlpWaitForCriticalSection(
2902 _In_ PRTL_CRITICAL_SECTION CriticalSection
2908 RtlAcquireResourceExclusive(
2909 _In_ PRTL_RESOURCE Resource
,
2916 RtlAcquireResourceShared(
2917 _In_ PRTL_RESOURCE Resource
,
2924 RtlConvertExclusiveToShared(
2925 _In_ PRTL_RESOURCE Resource
2931 RtlConvertSharedToExclusive(
2932 _In_ PRTL_RESOURCE Resource
2939 _In_ PRTL_RESOURCE Resource
2946 _In_ PRTL_RESOURCE Resource
2952 RtlInitializeResource(
2953 _In_ PRTL_RESOURCE Resource
2960 _In_ PRTL_RESOURCE Resource
2964 // Compression Functions
2966 NTSYSAPI
//NT_RTL_COMPRESS_API
2970 _In_ USHORT CompressionFormatAndEngine
,
2971 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2972 _In_ ULONG UncompressedBufferSize
,
2973 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2974 _In_ ULONG CompressedBufferSize
,
2975 _In_ ULONG UncompressedChunkSize
,
2976 _Out_ PULONG FinalCompressedSize
,
2977 _In_ PVOID WorkSpace
2980 _IRQL_requires_max_(APC_LEVEL
)
2981 NTSYSAPI
//NT_RTL_COMPRESS_API
2984 RtlDecompressBuffer(
2985 _In_ USHORT CompressionFormat
,
2986 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2987 _In_ ULONG UncompressedBufferSize
,
2988 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2989 _In_ ULONG CompressedBufferSize
,
2990 _Out_ PULONG FinalUncompressedSize
2996 RtlGetCompressionWorkSpaceSize(
2997 _In_ USHORT CompressionFormatAndEngine
,
2998 _Out_ PULONG CompressBufferWorkSpaceSize
,
2999 _Out_ PULONG CompressFragmentWorkSpaceSize
3003 // Debug Info Functions
3006 PRTL_DEBUG_INFORMATION
3008 RtlCreateQueryDebugBuffer(
3010 _In_ BOOLEAN EventPair
3016 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3021 RtlQueryProcessDebugInformation(
3022 _In_ ULONG ProcessId
,
3023 _In_ ULONG DebugInfoClassMask
,
3024 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3034 _In_ PRTL_BITMAP BitMapHeader
,
3035 _In_ ULONG StartingIndex
,
3043 _In_ PRTL_BITMAP BitMapHeader
,
3044 _In_ ULONG StartingIndex
,
3052 _In_ PRTL_BITMAP BitMapHeader
3059 _In_ PRTL_BITMAP BitMapHeader
,
3060 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3061 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3068 _In_ PRTL_BITMAP BitMapHeader
,
3069 _In_ ULONG NumberToFind
,
3070 _In_ ULONG HintIndex
3076 RtlFindClearBitsAndSet(
3077 _In_ PRTL_BITMAP BitMapHeader
,
3078 _In_ ULONG NumberToFind
,
3079 _In_ ULONG HintIndex
3085 RtlFindLeastSignificantBit(
3086 _In_ ULONGLONG Value
3092 RtlFindMostSignificantBit(
3093 _In_ ULONGLONG Value
3099 RtlFindNextForwardRunClear(
3100 _In_ PRTL_BITMAP BitMapHeader
,
3101 _In_ ULONG FromIndex
,
3102 _Out_ PULONG StartingRunIndex
3108 RtlFindNextForwardRunSet(
3109 _In_ PRTL_BITMAP BitMapHeader
,
3110 _In_ ULONG FromIndex
,
3111 _Out_ PULONG StartingRunIndex
3118 _In_ PRTL_BITMAP BitMapHeader
,
3119 _In_ ULONG NumberToFind
,
3120 _In_ ULONG HintIndex
3126 RtlFindSetBitsAndClear(
3127 _In_ PRTL_BITMAP BitMapHeader
,
3128 _In_ ULONG NumberToFind
,
3129 _In_ ULONG HintIndex
3132 #ifdef _REACTOS_ // ReactOS improvement
3133 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3134 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3139 RtlInitializeBitMap(
3140 _Out_ PRTL_BITMAP BitMapHeader
,
3141 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3142 _In_opt_ ULONG SizeOfBitMap
3148 RtlNumberOfClearBits(
3149 _In_ PRTL_BITMAP BitMapHeader
3156 _In_ PRTL_BITMAP BitMapHeader
3163 _In_ PRTL_BITMAP BitMapHeader
,
3164 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3171 _In_ PRTL_BITMAP BitMapHeader
,
3172 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3173 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3180 _In_ PRTL_BITMAP BitMapHeader
3183 _Must_inspect_result_
3188 _In_ PRTL_BITMAP BitMapHeader
,
3189 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3199 _In_ HANDLE TimerQueue
,
3200 _In_ PHANDLE phNewTimer
,
3201 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3202 _In_ PVOID Parameter
,
3211 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3217 _In_ HANDLE TimerQueue
,
3219 _In_ HANDLE CompletionEvent
3226 _In_ HANDLE TimerQueue
,
3235 RtlDeleteTimerQueueEx(
3236 _In_ HANDLE TimerQueue
,
3237 _In_opt_ HANDLE CompletionEvent
3243 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3250 InterlockedPushListSList(
3251 _Inout_ PSLIST_HEADER ListHead
,
3252 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3253 _Inout_ PSLIST_ENTRY ListEnd
,
3258 // Range List functions
3263 RtlInitializeRangeList(
3264 _Inout_ PRTL_RANGE_LIST RangeList
3271 _In_ PRTL_RANGE_LIST RangeList
3278 _Inout_ PRTL_RANGE_LIST RangeList
,
3279 _In_ ULONGLONG Start
,
3281 _In_ UCHAR Attributes
,
3283 _In_opt_ PVOID UserData
,
3284 _In_opt_ PVOID Owner
3293 _In_z_ _Printf_format_string_ PCSTR Format
,
3301 _In_ ULONG ComponentId
,
3303 _In_z_ _Printf_format_string_ PCSTR Format
,
3312 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3313 _In_ ULONG MaximumResponseLength
3316 #undef DbgBreakPoint
3325 DbgLoadImageSymbols(
3328 _In_ ULONG_PTR ProcessId
3333 DbgUnLoadImageSymbols(
3336 _In_ ULONG_PTR ProcessId
3347 // Generic Table Functions
3349 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3353 RtlInsertElementGenericTable(
3354 _In_ PRTL_GENERIC_TABLE Table
,
3355 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3356 _In_ CLONG BufferSize
,
3357 _Out_opt_ PBOOLEAN NewElement
3363 RtlInsertElementGenericTableFull(
3364 _In_ PRTL_GENERIC_TABLE Table
,
3365 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3366 _In_ CLONG BufferSize
,
3367 _Out_opt_ PBOOLEAN NewElement
,
3368 _In_ PVOID NodeOrParent
,
3369 _In_ TABLE_SEARCH_RESULT SearchResult
3375 RtlIsGenericTableEmpty(
3376 _In_ PRTL_GENERIC_TABLE Table
3382 RtlLookupElementGenericTableFull(
3383 _In_ PRTL_GENERIC_TABLE Table
,
3385 _Out_ PVOID
*NodeOrParent
,
3386 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3391 // Handle Table Functions
3394 PRTL_HANDLE_TABLE_ENTRY
3397 _In_ PRTL_HANDLE_TABLE HandleTable
,
3398 _Inout_ PULONG Index
3404 RtlDestroyHandleTable(
3405 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3411 _In_ PRTL_HANDLE_TABLE HandleTable
,
3412 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3418 RtlInitializeHandleTable(
3419 _In_ ULONG TableSize
,
3420 _In_ ULONG HandleSize
,
3421 _In_ PRTL_HANDLE_TABLE HandleTable
3428 _In_ PRTL_HANDLE_TABLE HandleTable
,
3429 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3432 _Success_(return!=FALSE
)
3436 RtlIsValidIndexHandle(
3437 _In_ PRTL_HANDLE_TABLE HandleTable
,
3439 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3449 _In_ PVOID BaseAddress
,
3451 _In_ ULONG Language
,
3452 _In_ ULONG MessageId
,
3453 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3459 RtlGetNtGlobalFlags(VOID
);
3461 _Success_(return!=NULL
)
3465 RtlImageDirectoryEntryToData(
3466 _In_ PVOID BaseAddress
,
3467 _In_ BOOLEAN MappedAsImage
,
3468 _In_ USHORT Directory
,
3476 _In_ PIMAGE_NT_HEADERS NtHeader
,
3477 _In_ PVOID BaseAddress
,
3479 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3486 _In_ PVOID BaseAddress
);
3493 _In_ PVOID BaseAddress
,
3494 _In_ ULONGLONG Size
,
3495 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3499 PIMAGE_SECTION_HEADER
3501 RtlImageRvaToSection(
3502 _In_ PIMAGE_NT_HEADERS NtHeader
,
3503 _In_ PVOID BaseAddress
,
3510 LdrRelocateImageWithBias(
3511 _In_ PVOID NewAddress
,
3512 _In_ LONGLONG AdditionalBias
,
3513 _In_ PCCH LoaderName
,
3515 _In_ ULONG Conflict
,
3520 // Activation Context Functions
3522 #ifdef NTOS_MODE_USER
3526 RtlActivateActivationContextEx(
3530 _Out_ PULONG_PTR Cookie
3536 RtlActivateActivationContext(
3539 _Out_ PULONG_PTR Cookie
3545 RtlAddRefActivationContext(
3550 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3552 RtlActivateActivationContextUnsafeFast(
3553 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3560 RtlAllocateActivationContextStack(
3561 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3567 RtlCreateActivationContext(
3569 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3570 _In_ ULONG ExtraBytes
,
3571 _In_ PVOID NotificationRoutine
,
3572 _In_ PVOID NotificationContext
,
3573 _Out_ PACTIVATION_CONTEXT
*ActCtx
3579 RtlGetActiveActivationContext(
3586 RtlReleaseActivationContext(
3593 RtlDeactivateActivationContext(
3595 _In_ ULONG_PTR ulCookie
3601 RtlFreeActivationContextStack(
3602 _In_ PACTIVATION_CONTEXT_STACK Stack
3608 RtlFreeThreadActivationContextStack(VOID
);
3611 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3613 RtlDeactivateActivationContextUnsafeFast(
3614 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3620 RtlDosApplyFileIsolationRedirection_Ustr(
3622 _In_ PUNICODE_STRING OriginalName
,
3623 _In_ PUNICODE_STRING Extension
,
3624 _Inout_ PUNICODE_STRING StaticString
,
3625 _Inout_ PUNICODE_STRING DynamicString
,
3626 _Inout_ PUNICODE_STRING
*NewName
,
3627 _In_ PULONG NewFlags
,
3628 _In_ PSIZE_T FileNameSize
,
3629 _In_ PSIZE_T RequiredLength
3635 RtlFindActivationContextSectionString(
3637 _In_
const GUID
*ExtensionGuid
,
3638 _In_ ULONG SectionType
,
3639 _In_
const UNICODE_STRING
*SectionName
,
3640 _Inout_ PVOID ReturnedData
3646 RtlQueryInformationActivationContext(
3648 _In_opt_ PVOID Context
,
3649 _In_opt_ PVOID pvSubInstance
,
3650 _In_ ULONG ulInfoClass
,
3651 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3652 _In_opt_ SIZE_T cbBuffer
,
3653 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3659 RtlQueryInformationActiveActivationContext(
3660 _In_ ULONG ulInfoClass
,
3661 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3662 _In_opt_ SIZE_T cbBuffer
,
3663 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3669 RtlZombifyActivationContext(
3679 RtlWow64EnableFsRedirection(
3680 _In_ BOOLEAN Wow64FsEnableRedirection
3686 RtlWow64EnableFsRedirectionEx(
3687 _In_ PVOID Wow64FsEnableRedirection
,
3688 _Out_ PVOID
*OldFsRedirectionLevel
3694 // Registry Functions
3696 _IRQL_requires_max_(PASSIVE_LEVEL
)
3697 _Must_inspect_result_
3701 RtlCheckRegistryKey(
3702 _In_ ULONG RelativeTo
,
3709 RtlCreateRegistryKey(
3710 _In_ ULONG RelativeTo
,
3717 RtlFormatCurrentUserKeyPath(
3718 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3719 PUNICODE_STRING KeyPath
3726 _In_ ACCESS_MASK DesiredAccess
,
3727 _Out_ PHANDLE KeyHandle
3730 _IRQL_requires_max_(PASSIVE_LEVEL
)
3734 RtlQueryRegistryValues(
3735 _In_ ULONG RelativeTo
,
3737 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3738 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3739 _In_opt_ PVOID Context
,
3740 _In_opt_ PVOID Environment
3743 _IRQL_requires_max_(PASSIVE_LEVEL
)
3747 RtlWriteRegistryValue(
3748 _In_ ULONG RelativeTo
,
3750 _In_z_ PCWSTR ValueName
,
3751 _In_ ULONG ValueType
,
3752 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3753 _In_ ULONG ValueLength
3756 #ifdef NTOS_MODE_USER
3761 _Out_ HANDLE KeyHandle
,
3762 _In_ ACCESS_MASK DesiredAccess
,
3763 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3764 _In_ ULONG TitleIndex
,
3765 _In_ PUNICODE_STRING Class
,
3766 _Out_ PULONG Disposition
3772 RtlpNtEnumerateSubKey(
3773 _In_ HANDLE KeyHandle
,
3774 _Inout_ PUNICODE_STRING SubKeyName
,
3782 RtlpNtMakeTemporaryKey(
3783 _In_ HANDLE KeyHandle
3790 _Out_ HANDLE KeyHandle
,
3791 _In_ ACCESS_MASK DesiredAccess
,
3792 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3799 RtlpNtQueryValueKey(
3800 _In_ HANDLE KeyHandle
,
3801 _Out_opt_ PULONG Type
,
3802 _Out_opt_ PVOID Data
,
3803 _Inout_opt_ PULONG DataLength
,
3811 _In_ HANDLE KeyHandle
,
3814 _In_ ULONG DataLength
3824 RtlGetDefaultCodePage(
3825 _Out_ PUSHORT AnsiCodePage
,
3826 _Out_ PUSHORT OemCodePage
3833 _In_ PUSHORT AnsiTableBase
,
3834 _In_ PUSHORT OemTableBase
,
3835 _In_ PUSHORT CaseTableBase
,
3836 _Out_ PNLSTABLEINFO NlsTable
3839 _IRQL_requires_max_(PASSIVE_LEVEL
)
3843 RtlInitCodePageTable(
3844 _In_ PUSHORT TableBase
,
3845 _Out_ PCPTABLEINFO CodePageTable
3851 RtlResetRtlTranslations(
3852 _In_ PNLSTABLEINFO NlsTable
);
3854 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3857 // Misc conversion functions
3862 RtlConvertLongToLargeInteger(
3863 _In_ LONG SignedInteger
3866 LARGE_INTEGER Result
;
3868 Result
.QuadPart
= SignedInteger
;
3875 RtlEnlargedIntegerMultiply(
3876 _In_ LONG Multiplicand
,
3877 _In_ LONG Multiplier
3880 LARGE_INTEGER Product
;
3882 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3889 RtlEnlargedUnsignedDivide(
3890 _In_ ULARGE_INTEGER Dividend
,
3892 _In_opt_ PULONG Remainder
3897 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
3899 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3908 RtlEnlargedUnsignedMultiply(
3909 _In_ ULONG Multiplicand
,
3910 _In_ ULONG Multiplier
3913 LARGE_INTEGER Product
;
3915 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3919 #if defined(_AMD64_) || defined(_IA64_)
3923 RtlExtendedLargeIntegerDivide(
3924 _In_ LARGE_INTEGER Dividend
,
3926 _Out_opt_ PULONG Remainder
)
3929 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3931 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3939 RtlExtendedLargeIntegerDivide(
3940 _In_ LARGE_INTEGER Dividend
,
3942 _Out_opt_ PULONG Remainder
3945 #endif /* defined(_AMD64_) || defined(_IA64_) */
3968 _In_ ULONG InitialCrc
,
3974 // Network Functions
3979 RtlIpv4AddressToStringA(
3980 _In_
const struct in_addr
*Addr
,
3981 _Out_writes_(16) PCHAR S
3987 RtlIpv4AddressToStringW(
3988 _In_
const struct in_addr
*Addr
,
3989 _Out_writes_(16) PWCHAR S
3995 RtlIpv4AddressToStringExA(
3996 _In_
const struct in_addr
*Address
,
3998 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PCHAR AddressString
,
3999 _Inout_ PULONG AddressStringLength
4004 RtlIpv4AddressToStringExW(
4005 _In_
const struct in_addr
*Address
,
4007 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4008 _Inout_ PULONG AddressStringLength
4014 RtlIpv4StringToAddressA(
4016 _In_ BOOLEAN Strict
,
4017 _Out_ PCSTR
*Terminator
,
4018 _Out_
struct in_addr
*Addr
4024 RtlIpv4StringToAddressW(
4026 _In_ BOOLEAN Strict
,
4027 _Out_ PCWSTR
*Terminator
,
4028 _Out_
struct in_addr
*Addr
4034 RtlIpv4StringToAddressExA(
4035 _In_ PCSTR AddressString
,
4036 _In_ BOOLEAN Strict
,
4037 _Out_
struct in_addr
*Address
,
4044 RtlIpv4StringToAddressExW(
4045 _In_ PCWSTR AddressString
,
4046 _In_ BOOLEAN Strict
,
4047 _Out_
struct in_addr
*Address
,
4054 RtlIpv6AddressToStringA(
4055 _In_
const struct in6_addr
*Addr
,
4056 _Out_writes_(46) PSTR S
4062 RtlIpv6AddressToStringW(
4063 _In_
const struct in6_addr
*Addr
,
4064 _Out_writes_(46) PWSTR S
4070 RtlIpv6AddressToStringExA(
4071 _In_
const struct in6_addr
*Address
,
4074 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PSTR AddressString
,
4075 _Inout_ PULONG AddressStringLength
4081 RtlIpv6AddressToStringExW(
4082 _In_
const struct in6_addr
*Address
,
4085 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4086 _Inout_ PULONG AddressStringLength
4092 RtlIpv6StringToAddressA(
4094 _Out_ PCSTR
*Terminator
,
4095 _Out_
struct in6_addr
*Addr
4101 RtlIpv6StringToAddressW(
4103 _Out_ PCWSTR
*Terminator
,
4104 _Out_
struct in6_addr
*Addr
4110 RtlIpv6StringToAddressExA(
4111 _In_ PCSTR AddressString
,
4112 _Out_
struct in6_addr
*Address
,
4113 _Out_ PULONG ScopeId
,
4120 RtlIpv6StringToAddressExW(
4121 _In_ PCWSTR AddressString
,
4122 _Out_
struct in6_addr
*Address
,
4123 _Out_ PULONG ScopeId
,
4134 RtlQueryTimeZoneInformation(
4135 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4140 RtlSecondsSince1970ToTime(
4141 _In_ ULONG SecondsSince1970
,
4142 _Out_ PLARGE_INTEGER Time
4148 RtlSetTimeZoneInformation(
4149 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4151 _Success_(return!=FALSE
)
4152 _Must_inspect_result_
4156 RtlTimeFieldsToTime(
4157 _In_ PTIME_FIELDS TimeFields
,
4158 _Out_ PLARGE_INTEGER Time
4161 _Success_(return != 0)
4162 _Must_inspect_result_
4166 RtlTimeToSecondsSince1970(
4167 _In_ PLARGE_INTEGER Time
,
4168 _Out_ PULONG ElapsedSeconds
4174 RtlTimeToTimeFields(
4175 PLARGE_INTEGER Time
,
4176 PTIME_FIELDS TimeFields
4182 RtlSystemTimeToLocalTime(
4183 _In_ PLARGE_INTEGER SystemTime
,
4184 _Out_ PLARGE_INTEGER LocalTime
4188 // Version Functions
4190 _IRQL_requires_max_(PASSIVE_LEVEL
)
4191 _Must_inspect_result_
4195 RtlVerifyVersionInfo(
4196 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4197 _In_ ULONG TypeMask
,
4198 _In_ ULONGLONG ConditionMask
4201 _IRQL_requires_max_(PASSIVE_LEVEL
)
4207 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4208 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4209 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4210 PRTL_OSVERSIONINFOW lpVersionInformation
4216 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4219 // Secure Memory Functions
4221 #ifdef NTOS_MODE_USER
4225 RtlRegisterSecureMemoryCacheCallback(
4226 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4231 RtlFlushSecureMemoryCache(
4232 _In_ PVOID MemoryCache
,
4233 _In_opt_ SIZE_T MemoryLength
4238 // Boot Status Data Functions
4240 #ifdef NTOS_MODE_USER
4244 RtlCreateBootStatusDataFile(
4251 RtlGetSetBootStatusData(
4252 _In_ HANDLE FileHandle
,
4253 _In_ BOOLEAN WriteMode
,
4254 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4256 _In_ ULONG BufferSize
,
4257 _Out_opt_ PULONG ReturnLength
4263 RtlLockBootStatusData(
4264 _Out_ PHANDLE FileHandle
4270 RtlUnlockBootStatusData(
4271 _In_ HANDLE FileHandle
4275 #ifdef NTOS_MODE_USER
4276 _Must_inspect_result_
4281 _In_ PUNICODE_STRING GuidString
,
4284 _Must_inspect_result_
4290 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4291 PUNICODE_STRING GuidString
);
4296 RtlComputeImportTableHash(
4299 _In_ ULONG ImportTableHashRevision
4304 // MemoryStream functions
4306 #ifdef NTOS_MODE_USER
4311 RtlInitMemoryStream(
4312 _Out_ PRTL_MEMORY_STREAM Stream
4318 RtlInitOutOfProcessMemoryStream(
4319 _Out_ PRTL_MEMORY_STREAM Stream
4325 RtlFinalReleaseOutOfProcessMemoryStream(
4326 _In_ PRTL_MEMORY_STREAM Stream
4332 RtlQueryInterfaceMemoryStream(
4333 _In_
struct IStream
*This
,
4334 _In_ REFIID RequestedIid
,
4335 _Outptr_ PVOID
*ResultObject
4341 RtlAddRefMemoryStream(
4342 _In_
struct IStream
*This
4348 RtlReleaseMemoryStream(
4349 _In_
struct IStream
*This
4355 RtlReadMemoryStream(
4356 _In_
struct IStream
*This
,
4357 _Out_writes_bytes_(Length
) PVOID Buffer
,
4359 _Out_opt_ PULONG BytesRead
4365 RtlReadOutOfProcessMemoryStream(
4366 _In_
struct IStream
*This
,
4367 _Out_writes_bytes_(Length
) PVOID Buffer
,
4369 _Out_opt_ PULONG BytesRead
4375 RtlSeekMemoryStream(
4376 _In_
struct IStream
*This
,
4377 _In_ LARGE_INTEGER RelativeOffset
,
4379 _Out_opt_ PULARGE_INTEGER ResultOffset
4385 RtlCopyMemoryStreamTo(
4386 _In_
struct IStream
*This
,
4387 _In_
struct IStream
*Target
,
4388 _In_ ULARGE_INTEGER Length
,
4389 _Out_opt_ PULARGE_INTEGER BytesRead
,
4390 _Out_opt_ PULARGE_INTEGER BytesWritten
4396 RtlCopyOutOfProcessMemoryStreamTo(
4397 _In_
struct IStream
*This
,
4398 _In_
struct IStream
*Target
,
4399 _In_ ULARGE_INTEGER Length
,
4400 _Out_opt_ PULARGE_INTEGER BytesRead
,
4401 _Out_opt_ PULARGE_INTEGER BytesWritten
4407 RtlStatMemoryStream(
4408 _In_
struct IStream
*This
,
4409 _Out_
struct tagSTATSTG
*Stats
,
4417 RtlWriteMemoryStream(
4418 _In_
struct IStream
*This
,
4419 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4421 _Out_opt_ PULONG BytesWritten
4427 RtlSetMemoryStreamSize(
4428 _In_
struct IStream
*This
,
4429 _In_ ULARGE_INTEGER NewSize
4435 RtlCommitMemoryStream(
4436 _In_
struct IStream
*This
,
4437 _In_ ULONG CommitFlags
4443 RtlRevertMemoryStream(
4444 _In_
struct IStream
*This
4450 RtlLockMemoryStreamRegion(
4451 _In_
struct IStream
*This
,
4452 _In_ ULARGE_INTEGER Offset
,
4453 _In_ ULARGE_INTEGER Length
,
4460 RtlUnlockMemoryStreamRegion(
4461 _In_
struct IStream
*This
,
4462 _In_ ULARGE_INTEGER Offset
,
4463 _In_ ULARGE_INTEGER Length
,
4470 RtlCloneMemoryStream(
4471 _In_
struct IStream
*This
,
4472 _Outptr_
struct IStream
**ResultStream
4475 #endif // NTOS_MODE_USER
4480 RtlFindActivationContextSectionGuid(
4482 const GUID
*extguid
,