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 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || \
1734 ((defined(_M_AMD64) || \
1735 defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
1737 unsigned short __cdecl
_byteswap_ushort(unsigned short);
1738 unsigned long __cdecl
_byteswap_ulong (unsigned long);
1739 unsigned __int64 __cdecl
_byteswap_uint64(unsigned __int64
);
1740 #pragma intrinsic(_byteswap_ushort)
1741 #pragma intrinsic(_byteswap_ulong)
1742 #pragma intrinsic(_byteswap_uint64)
1743 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1744 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1745 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1747 #elif defined (__GNUC__)
1749 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1750 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1751 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1755 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1759 RtlUshortByteSwap(IN USHORT Source
);
1764 RtlUlongByteSwap(IN ULONG Source
);
1769 RtlUlonglongByteSwap(IN ULONGLONG Source
);
1773 #endif // NTOS_MODE_USER
1776 // Unicode->Ansi String Functions
1781 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString
);
1783 #ifdef NTOS_MODE_USER
1785 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1786 NLS_MB_CODE_PAGE_TAG ? \
1787 RtlxUnicodeStringToAnsiSize(STRING) : \
1788 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1796 RtlUnicodeStringToAnsiString(
1797 PANSI_STRING DestinationString
,
1798 PCUNICODE_STRING SourceString
,
1799 BOOLEAN AllocateDestinationString
1803 // Unicode->OEM String Functions
1808 RtlUpcaseUnicodeStringToOemString(
1809 POEM_STRING DestinationString
,
1810 PCUNICODE_STRING SourceString
,
1811 BOOLEAN AllocateDestinationString
1814 _IRQL_requires_max_(PASSIVE_LEVEL
)
1815 _Must_inspect_result_
1816 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1820 RtlUpcaseUnicodeStringToCountedOemString(
1821 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1822 _When_(!AllocateDestinationString
, _Inout_
)
1823 POEM_STRING DestinationString
,
1824 _In_ PCUNICODE_STRING SourceString
,
1825 _In_ BOOLEAN AllocateDestinationString
1831 RtlUnicodeStringToOemString(
1832 POEM_STRING DestinationString
,
1833 PCUNICODE_STRING SourceString
,
1834 BOOLEAN AllocateDestinationString
1840 RtlUpcaseUnicodeToOemN(
1844 PCWCH UnicodeString
,
1851 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString
);
1853 #ifdef NTOS_MODE_USER
1855 #define RtlUnicodeStringToOemSize(STRING) ( \
1856 NLS_MB_OEM_CODE_PAGE_TAG ? \
1857 RtlxUnicodeStringToOemSize(STRING) : \
1858 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1861 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1862 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1874 PCWCH UnicodeString
,
1879 // Unicode->MultiByte String Functions
1884 RtlUnicodeToMultiByteN(
1888 PCWCH UnicodeString
,
1895 RtlUpcaseUnicodeToMultiByteN(
1899 PCWCH UnicodeString
,
1906 RtlUnicodeToMultiByteSize(
1908 PCWCH UnicodeString
,
1915 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString
);
1918 // OEM to Unicode Functions
1923 RtlOemStringToUnicodeString(
1924 PUNICODE_STRING DestinationString
,
1925 PCOEM_STRING SourceString
,
1926 BOOLEAN AllocateDestinationString
1929 _IRQL_requires_max_(PASSIVE_LEVEL
)
1934 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1935 _In_ ULONG MaxBytesInUnicodeString
,
1936 _Out_opt_ PULONG BytesInUnicodeString
,
1937 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1938 _In_ ULONG BytesInOemString
1941 #ifdef NTOS_MODE_USER
1943 #define RtlOemStringToUnicodeSize(STRING) ( \
1944 NLS_MB_OEM_CODE_PAGE_TAG ? \
1945 RtlxOemStringToUnicodeSize(STRING) : \
1946 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1949 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1950 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1956 // Ansi->Unicode String Functions
1961 RtlxAnsiStringToUnicodeSize(
1962 PCANSI_STRING AnsiString
1968 RtlAnsiStringToUnicodeString(
1969 PUNICODE_STRING DestinationString
,
1970 PCANSI_STRING SourceString
,
1971 BOOLEAN AllocateDestinationString
1974 #ifdef NTOS_MODE_USER
1976 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1977 NLS_MB_CODE_PAGE_TAG ? \
1978 RtlxAnsiStringToUnicodeSize(STRING) : \
1979 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1987 RtlCreateUnicodeStringFromAsciiz(
1988 _Out_ PUNICODE_STRING Destination
,
1993 // Unicode String Functions
1998 RtlAppendUnicodeToString(
1999 PUNICODE_STRING Destination
,
2006 RtlAppendUnicodeStringToString(
2007 PUNICODE_STRING Destination
,
2008 PCUNICODE_STRING Source
2014 RtlCompareUnicodeString(
2015 PCUNICODE_STRING String1
,
2016 PCUNICODE_STRING String2
,
2017 BOOLEAN CaseInsensitive
2023 RtlCopyUnicodeString(
2024 PUNICODE_STRING DestinationString
,
2025 PCUNICODE_STRING SourceString
2031 RtlCreateUnicodeString(
2032 PUNICODE_STRING DestinationString
,
2036 #ifdef NTOS_MODE_USER
2041 RtlDowncaseUnicodeString(
2042 _Inout_ PUNICODE_STRING UniDest
,
2043 _In_ PCUNICODE_STRING UniSource
,
2044 _In_ BOOLEAN AllocateDestinationString
2050 RtlDuplicateUnicodeString(
2052 _In_ PCUNICODE_STRING SourceString
,
2053 _Out_ PUNICODE_STRING DestinationString
2063 _In_ PVOID Destination
,
2071 RtlFillMemoryUlonglong(
2072 _Out_ PVOID Destination
,
2074 _In_ ULONGLONG Pattern
2081 RtlCompareMemoryUlong(
2087 #define RtlEqualMemory(Destination, Source, Length) \
2088 (!memcmp(Destination, Source, Length))
2090 #define RtlCopyBytes RtlCopyMemory
2091 #define RtlFillBytes RtlFillMemory
2092 #define RtlZeroBytes RtlZeroMemory
2099 RtlEqualUnicodeString(
2100 PCUNICODE_STRING String1
,
2101 PCUNICODE_STRING String2
,
2102 BOOLEAN CaseInsensitive
2108 RtlFindCharInUnicodeString(
2110 _In_ PCUNICODE_STRING SearchString
,
2111 _In_ PCUNICODE_STRING MatchString
,
2112 _Out_ PUSHORT Position
2115 _IRQL_requires_max_(PASSIVE_LEVEL
)
2119 RtlFreeUnicodeString(
2120 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
2121 PUNICODE_STRING UnicodeString
2127 RtlEraseUnicodeString(
2128 _Inout_ PUNICODE_STRING String
2134 RtlHashUnicodeString(
2135 _In_ CONST UNICODE_STRING
*String
,
2136 _In_ BOOLEAN CaseInSensitive
,
2137 _In_ ULONG HashAlgorithm
,
2138 _Out_ PULONG HashValue
2141 _IRQL_requires_max_(DISPATCH_LEVEL
)
2142 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2143 _When_(SourceString
!= NULL
,
2144 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2145 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2146 _When_(SourceString
== NULL
,
2147 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2148 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2152 RtlInitUnicodeString(
2153 _Out_ PUNICODE_STRING DestinationString
,
2154 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2157 _IRQL_requires_max_(DISPATCH_LEVEL
)
2161 RtlInitUnicodeStringEx(
2162 _Out_ PUNICODE_STRING DestinationString
,
2163 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2175 _IRQL_requires_max_(PASSIVE_LEVEL
)
2176 _Must_inspect_result_
2181 _In_
const STRING
*String1
,
2182 _In_
const STRING
*String2
,
2183 _In_ BOOLEAN CaseInsensitive
2186 _IRQL_requires_max_(PASSIVE_LEVEL
)
2187 _Must_inspect_result_
2191 RtlPrefixUnicodeString(
2192 _In_ PCUNICODE_STRING String1
,
2193 _In_ PCUNICODE_STRING String2
,
2194 _In_ BOOLEAN CaseInsensitive
2197 _IRQL_requires_max_(PASSIVE_LEVEL
)
2202 _Inout_ PSTRING DestinationString
,
2203 _In_
const STRING
*SourceString
2206 _IRQL_requires_max_(PASSIVE_LEVEL
)
2207 _Must_inspect_result_
2212 _In_
const STRING
*String1
,
2213 _In_
const STRING
*String2
,
2214 _In_ BOOLEAN CaseInSensitive
2221 _Out_ PSTRING DestinationString
,
2222 _In_opt_
const STRING
*SourceString
2225 _IRQL_requires_max_(PASSIVE_LEVEL
)
2226 _Must_inspect_result_
2231 _In_
const STRING
*String1
,
2232 _In_
const STRING
*String2
,
2233 _In_ BOOLEAN CaseInSensitive
2236 _IRQL_requires_max_(APC_LEVEL
)
2240 RtlAppendStringToString(
2241 _Inout_ PSTRING Destination
,
2242 _In_
const STRING
*Source
2245 _IRQL_requires_max_(PASSIVE_LEVEL
)
2246 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2250 RtlUpcaseUnicodeString(
2251 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2252 _When_(!AllocateDestinationString
, _Inout_
)
2253 PUNICODE_STRING DestinationString
,
2254 _In_ PCUNICODE_STRING SourceString
,
2255 _In_ BOOLEAN AllocateDestinationString
2258 _IRQL_requires_max_(PASSIVE_LEVEL
)
2262 RtlUnicodeStringToInteger(
2263 _In_ PCUNICODE_STRING String
,
2264 _In_opt_ ULONG Base
,
2271 RtlValidateUnicodeString(
2273 _In_ PCUNICODE_STRING String
2277 // Ansi String Functions
2279 _IRQL_requires_max_(PASSIVE_LEVEL
)
2284 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2285 PANSI_STRING AnsiString
2288 _IRQL_requires_max_(DISPATCH_LEVEL
)
2293 _Out_ PANSI_STRING DestinationString
,
2294 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2297 _IRQL_requires_max_(DISPATCH_LEVEL
)
2301 RtlInitAnsiStringEx(
2302 _Out_ PANSI_STRING DestinationString
,
2303 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2307 // OEM String Functions
2309 _IRQL_requires_max_(PASSIVE_LEVEL
)
2314 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2315 POEM_STRING OemString
2319 // MultiByte->Unicode String Functions
2321 _IRQL_requires_max_(PASSIVE_LEVEL
)
2325 RtlMultiByteToUnicodeN(
2326 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2327 _In_ ULONG MaxBytesInUnicodeString
,
2328 _Out_opt_ PULONG BytesInUnicodeString
,
2329 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2330 _In_ ULONG BytesInMultiByteString
2333 _IRQL_requires_max_(PASSIVE_LEVEL
)
2337 RtlMultiByteToUnicodeSize(
2338 _Out_ PULONG BytesInUnicodeString
,
2339 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2340 _In_ ULONG BytesInMultiByteString
2349 RtlAddAtomToAtomTable(
2350 _In_ PRTL_ATOM_TABLE AtomTable
,
2351 _In_ PWSTR AtomName
,
2352 _Out_ PRTL_ATOM Atom
2359 _In_ ULONG TableSize
,
2360 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2366 RtlDeleteAtomFromAtomTable(
2367 _In_ PRTL_ATOM_TABLE AtomTable
,
2374 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2379 RtlQueryAtomInAtomTable(
2380 _In_ PRTL_ATOM_TABLE AtomTable
,
2382 _Out_opt_ PULONG RefCount
,
2383 _Out_opt_ PULONG PinCount
,
2384 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2385 _Inout_opt_ PULONG NameLength
2391 RtlPinAtomInAtomTable(
2392 _In_ PRTL_ATOM_TABLE AtomTable
,
2399 RtlLookupAtomInAtomTable(
2400 _In_ PRTL_ATOM_TABLE AtomTable
,
2401 _In_ PWSTR AtomName
,
2402 _Out_ PRTL_ATOM Atom
2406 // Process Management Functions
2418 RtlAcquirePebLock(VOID
);
2423 RtlCreateProcessParameters (
2424 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2425 _In_ PUNICODE_STRING ImagePathName
,
2426 _In_opt_ PUNICODE_STRING DllPath
,
2427 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2428 _In_opt_ PUNICODE_STRING CommandLine
,
2429 _In_opt_ PWSTR Environment
,
2430 _In_opt_ PUNICODE_STRING WindowTitle
,
2431 _In_opt_ PUNICODE_STRING DesktopInfo
,
2432 _In_opt_ PUNICODE_STRING ShellInfo
,
2433 _In_opt_ PUNICODE_STRING RuntimeInfo
2439 RtlCreateUserProcess(
2440 _In_ PUNICODE_STRING ImageFileName
,
2441 _In_ ULONG Attributes
,
2442 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2443 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2444 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2445 _In_opt_ HANDLE ParentProcess
,
2446 _In_ BOOLEAN CurrentDirectory
,
2447 _In_opt_ HANDLE DebugPort
,
2448 _In_opt_ HANDLE ExceptionPort
,
2449 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2452 #if (NTDDI_VERSION >= NTDDI_WIN7)
2456 RtlCreateUserThread(
2457 _In_ PVOID ThreadContext
,
2458 _Out_ HANDLE
*OutThreadHandle
,
2459 _Reserved_ PVOID Reserved1
,
2460 _Reserved_ PVOID Reserved2
,
2461 _Reserved_ PVOID Reserved3
,
2462 _Reserved_ PVOID Reserved4
,
2463 _Reserved_ PVOID Reserved5
,
2464 _Reserved_ PVOID Reserved6
,
2465 _Reserved_ PVOID Reserved7
,
2466 _Reserved_ PVOID Reserved8
2472 RtlCreateUserThread(
2473 _In_ HANDLE ProcessHandle
,
2474 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2475 _In_ BOOLEAN CreateSuspended
,
2476 _In_ ULONG StackZeroBits
,
2477 _In_ SIZE_T StackReserve
,
2478 _In_ SIZE_T StackCommit
,
2479 _In_ PTHREAD_START_ROUTINE StartAddress
,
2480 _In_ PVOID Parameter
,
2481 _Out_opt_ PHANDLE ThreadHandle
,
2482 _Out_opt_ PCLIENT_ID ClientId
2487 PRTL_USER_PROCESS_PARAMETERS
2489 RtlDeNormalizeProcessParams(
2490 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2495 RtlDestroyProcessParameters(
2496 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2502 _In_ NTSTATUS Status
);
2507 RtlInitializeContext(
2508 _In_ HANDLE ProcessHandle
,
2509 _Out_ PCONTEXT ThreadContext
,
2510 _In_opt_ PVOID ThreadStartParam
,
2511 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2512 _In_ PINITIAL_TEB InitialTeb
2516 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2521 RtlWow64GetThreadContext(
2522 _In_ HANDLE ThreadHandle
,
2523 _Inout_ PWOW64_CONTEXT ThreadContext
2530 RtlWow64SetThreadContext(
2531 _In_ HANDLE ThreadHandle
,
2532 _In_ PWOW64_CONTEXT ThreadContext
2539 RtlIsThreadWithinLoaderCallout(VOID
);
2542 PRTL_USER_PROCESS_PARAMETERS
2544 RtlNormalizeProcessParams(
2545 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2550 RtlReleasePebLock(VOID
);
2556 _In_ HANDLE Process
,
2558 _In_ PVOID CallSite
,
2559 _In_ ULONG ArgumentCount
,
2560 _In_ PULONG Arguments
,
2561 _In_ BOOLEAN PassContext
,
2562 _In_ BOOLEAN AlreadySuspended
2568 RtlSetProcessIsCritical(
2569 _In_ BOOLEAN NewValue
,
2570 _Out_opt_ PBOOLEAN OldValue
,
2571 _In_ BOOLEAN NeedBreaks
2577 RtlSetThreadIsCritical(
2578 _In_ BOOLEAN NewValue
,
2579 _Out_opt_ PBOOLEAN OldValue
,
2580 _In_ BOOLEAN NeedBreaks
2586 RtlGetCurrentProcessorNumber(
2590 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2593 // Thread Pool Functions
2598 RtlSetThreadPoolStartFunc(
2599 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2600 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2606 RtlDeregisterWaitEx(
2607 _In_ HANDLE hWaitHandle
,
2608 _In_opt_ HANDLE hCompletionEvent
2615 _In_ HANDLE hWaitHandle
2622 _In_ WORKERCALLBACKFUNC Function
,
2623 _In_opt_ PVOID Context
,
2630 RtlSetIoCompletionCallback(
2631 _In_ HANDLE FileHandle
,
2632 _In_ PIO_APC_ROUTINE Callback
,
2640 _In_ PHANDLE phNewWaitObject
,
2641 _In_ HANDLE hObject
,
2642 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2643 _In_ PVOID pvContext
,
2644 _In_ ULONG ulMilliseconds
,
2649 // Environment/Path Functions
2654 RtlCreateEnvironment(
2655 _In_ BOOLEAN Inherit
,
2656 _Out_ PWSTR
*Environment
2662 RtlComputePrivatizedDllName_U(
2663 _In_ PUNICODE_STRING DllName
,
2664 _Out_ PUNICODE_STRING RealName
,
2665 _Out_ PUNICODE_STRING LocalName
2671 RtlDestroyEnvironment(
2672 _In_ PWSTR Environment
2678 RtlDoesFileExists_U(
2679 _In_ PCWSTR FileName
2685 RtlDetermineDosPathNameType_U(
2694 _In_ PCWSTR FileName
,
2695 _In_ PCWSTR Extension
,
2696 _In_ ULONG BufferSize
,
2698 _Out_ PWSTR
*PartName
2704 RtlDosSearchPath_Ustr(
2706 _In_ PUNICODE_STRING PathString
,
2707 _In_ PUNICODE_STRING FileNameString
,
2708 _In_ PUNICODE_STRING ExtensionString
,
2709 _In_ PUNICODE_STRING CallerBuffer
,
2710 _Inout_opt_ PUNICODE_STRING DynamicString
,
2711 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2712 _Out_opt_ PSIZE_T FilePartSize
,
2713 _Out_opt_ PSIZE_T LengthNeeded
2719 RtlDosPathNameToNtPathName_U(
2720 _In_opt_z_ PCWSTR DosPathName
,
2721 _Out_ PUNICODE_STRING NtPathName
,
2722 _Out_opt_ PCWSTR
*NtFileNamePart
,
2723 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2729 RtlDosPathNameToRelativeNtPathName_U(
2730 _In_ PCWSTR DosName
,
2731 _Out_ PUNICODE_STRING NtName
,
2732 _Out_ PCWSTR
*PartName
,
2733 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2736 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2740 RtlExpandEnvironmentStrings_U(
2741 _In_z_ PWSTR Environment
,
2742 _In_ PUNICODE_STRING Source
,
2743 _Inout_ PUNICODE_STRING Destination
,
2750 RtlGetCurrentDirectory_U(
2751 _In_ ULONG MaximumLength
,
2752 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2758 RtlGetFullPathName_U(
2759 _In_ PCWSTR FileName
,
2761 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2762 _Out_opt_ PWSTR
*ShortName
2765 #if (NTDDI_VERSION >= NTDDI_WIN7)
2769 RtlGetFullPathName_UEx(
2770 _In_ PWSTR FileName
,
2771 _In_ ULONG BufferLength
,
2773 _Out_opt_ PWSTR
*FilePart
,
2774 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2780 RtlGetFullPathName_UstrEx(
2781 _In_ PUNICODE_STRING FileName
,
2782 _In_opt_ PUNICODE_STRING StaticString
,
2783 _In_opt_ PUNICODE_STRING DynamicString
,
2784 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2785 _Out_opt_ PSIZE_T FilePartSize
,
2786 _Out_opt_ PBOOLEAN NameInvalid
,
2787 _Out_ RTL_PATH_TYPE
* PathType
,
2788 _Out_opt_ PSIZE_T LengthNeeded
2794 RtlGetLengthWithoutTrailingPathSeperators(
2795 _Reserved_ ULONG Flags
,
2796 _In_ PCUNICODE_STRING PathString
,
2803 RtlGetLongestNtPathLength(
2810 RtlIsDosDeviceName_U(
2817 RtlIsDosDeviceName_Ustr(
2818 _In_ PCUNICODE_STRING Name
2821 _IRQL_requires_max_(PASSIVE_LEVEL
)
2822 _Must_inspect_result_
2826 RtlIsNameLegalDOS8Dot3(
2827 _In_ PCUNICODE_STRING Name
,
2828 _Inout_opt_ POEM_STRING OemName
,
2829 _Out_opt_ PBOOLEAN NameContainsSpaces
2835 RtlQueryEnvironmentVariable_U(
2836 _In_opt_ PWSTR Environment
,
2837 _In_ PUNICODE_STRING Name
,
2838 _Out_ PUNICODE_STRING Value
2843 RtlReleaseRelativeName(
2844 _In_ PRTL_RELATIVE_NAME_U RelativeName
2850 RtlSetCurrentDirectory_U(
2851 _In_ PUNICODE_STRING name
2857 RtlSetEnvironmentVariable(
2858 _In_z_ PWSTR
*Environment
,
2859 _In_ PUNICODE_STRING Name
,
2860 _In_ PUNICODE_STRING Value
2864 // Critical Section/Resource Functions
2869 RtlDeleteCriticalSection (
2870 _In_ PRTL_CRITICAL_SECTION CriticalSection
2876 RtlEnterCriticalSection(
2877 _In_ PRTL_CRITICAL_SECTION CriticalSection
2883 RtlInitializeCriticalSection(
2884 _In_ PRTL_CRITICAL_SECTION CriticalSection
2890 RtlInitializeCriticalSectionAndSpinCount(
2891 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2892 _In_ ULONG SpinCount
2898 RtlLeaveCriticalSection(
2899 _In_ PRTL_CRITICAL_SECTION CriticalSection
2905 RtlTryEnterCriticalSection(
2906 _In_ PRTL_CRITICAL_SECTION CriticalSection
2912 RtlpUnWaitCriticalSection(
2913 _In_ PRTL_CRITICAL_SECTION CriticalSection
2919 RtlpWaitForCriticalSection(
2920 _In_ PRTL_CRITICAL_SECTION CriticalSection
2926 RtlAcquireResourceExclusive(
2927 _In_ PRTL_RESOURCE Resource
,
2934 RtlAcquireResourceShared(
2935 _In_ PRTL_RESOURCE Resource
,
2942 RtlConvertExclusiveToShared(
2943 _In_ PRTL_RESOURCE Resource
2949 RtlConvertSharedToExclusive(
2950 _In_ PRTL_RESOURCE Resource
2957 _In_ PRTL_RESOURCE Resource
2964 _In_ PRTL_RESOURCE Resource
2970 RtlInitializeResource(
2971 _In_ PRTL_RESOURCE Resource
2978 _In_ PRTL_RESOURCE Resource
2982 // Compression Functions
2984 NTSYSAPI
//NT_RTL_COMPRESS_API
2988 _In_ USHORT CompressionFormatAndEngine
,
2989 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2990 _In_ ULONG UncompressedBufferSize
,
2991 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2992 _In_ ULONG CompressedBufferSize
,
2993 _In_ ULONG UncompressedChunkSize
,
2994 _Out_ PULONG FinalCompressedSize
,
2995 _In_ PVOID WorkSpace
2998 _IRQL_requires_max_(APC_LEVEL
)
2999 NTSYSAPI
//NT_RTL_COMPRESS_API
3002 RtlDecompressBuffer(
3003 _In_ USHORT CompressionFormat
,
3004 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
3005 _In_ ULONG UncompressedBufferSize
,
3006 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
3007 _In_ ULONG CompressedBufferSize
,
3008 _Out_ PULONG FinalUncompressedSize
3014 RtlGetCompressionWorkSpaceSize(
3015 _In_ USHORT CompressionFormatAndEngine
,
3016 _Out_ PULONG CompressBufferWorkSpaceSize
,
3017 _Out_ PULONG CompressFragmentWorkSpaceSize
3021 // Debug Info Functions
3024 PRTL_DEBUG_INFORMATION
3026 RtlCreateQueryDebugBuffer(
3028 _In_ BOOLEAN EventPair
3034 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3039 RtlQueryProcessDebugInformation(
3040 _In_ ULONG ProcessId
,
3041 _In_ ULONG DebugInfoClassMask
,
3042 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3052 _In_ PRTL_BITMAP BitMapHeader
,
3053 _In_ ULONG StartingIndex
,
3061 _In_ PRTL_BITMAP BitMapHeader
,
3062 _In_ ULONG StartingIndex
,
3070 _In_ PRTL_BITMAP BitMapHeader
3077 _In_ PRTL_BITMAP BitMapHeader
,
3078 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3079 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3086 _In_ PRTL_BITMAP BitMapHeader
,
3087 _In_ ULONG NumberToFind
,
3088 _In_ ULONG HintIndex
3094 RtlFindClearBitsAndSet(
3095 _In_ PRTL_BITMAP BitMapHeader
,
3096 _In_ ULONG NumberToFind
,
3097 _In_ ULONG HintIndex
3103 RtlFindLeastSignificantBit(
3104 _In_ ULONGLONG Value
3110 RtlFindMostSignificantBit(
3111 _In_ ULONGLONG Value
3117 RtlFindNextForwardRunClear(
3118 _In_ PRTL_BITMAP BitMapHeader
,
3119 _In_ ULONG FromIndex
,
3120 _Out_ PULONG StartingRunIndex
3126 RtlFindNextForwardRunSet(
3127 _In_ PRTL_BITMAP BitMapHeader
,
3128 _In_ ULONG FromIndex
,
3129 _Out_ PULONG StartingRunIndex
3136 _In_ PRTL_BITMAP BitMapHeader
,
3137 _In_ ULONG NumberToFind
,
3138 _In_ ULONG HintIndex
3144 RtlFindSetBitsAndClear(
3145 _In_ PRTL_BITMAP BitMapHeader
,
3146 _In_ ULONG NumberToFind
,
3147 _In_ ULONG HintIndex
3150 #ifdef _REACTOS_ // ReactOS improvement
3151 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3152 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3157 RtlInitializeBitMap(
3158 _Out_ PRTL_BITMAP BitMapHeader
,
3159 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3160 _In_opt_ ULONG SizeOfBitMap
3166 RtlNumberOfClearBits(
3167 _In_ PRTL_BITMAP BitMapHeader
3174 _In_ PRTL_BITMAP BitMapHeader
3181 _In_ PRTL_BITMAP BitMapHeader
,
3182 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3189 _In_ PRTL_BITMAP BitMapHeader
,
3190 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3191 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3198 _In_ PRTL_BITMAP BitMapHeader
3201 _Must_inspect_result_
3206 _In_ PRTL_BITMAP BitMapHeader
,
3207 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3217 _In_ HANDLE TimerQueue
,
3218 _In_ PHANDLE phNewTimer
,
3219 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3220 _In_ PVOID Parameter
,
3229 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3235 _In_ HANDLE TimerQueue
,
3237 _In_ HANDLE CompletionEvent
3244 _In_ HANDLE TimerQueue
,
3253 RtlDeleteTimerQueueEx(
3254 _In_ HANDLE TimerQueue
,
3255 _In_opt_ HANDLE CompletionEvent
3261 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3268 InterlockedPushListSList(
3269 _Inout_ PSLIST_HEADER ListHead
,
3270 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3271 _Inout_ PSLIST_ENTRY ListEnd
,
3276 // Range List functions
3281 RtlInitializeRangeList(
3282 _Inout_ PRTL_RANGE_LIST RangeList
3289 _In_ PRTL_RANGE_LIST RangeList
3296 _Inout_ PRTL_RANGE_LIST RangeList
,
3297 _In_ ULONGLONG Start
,
3299 _In_ UCHAR Attributes
,
3301 _In_opt_ PVOID UserData
,
3302 _In_opt_ PVOID Owner
3311 _In_z_ _Printf_format_string_ PCSTR Format
,
3319 _In_ ULONG ComponentId
,
3321 _In_z_ _Printf_format_string_ PCSTR Format
,
3330 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3331 _In_ ULONG MaximumResponseLength
3334 #undef DbgBreakPoint
3343 DbgLoadImageSymbols(
3346 _In_ ULONG_PTR ProcessId
3351 DbgUnLoadImageSymbols(
3354 _In_ ULONG_PTR ProcessId
3365 // Generic Table Functions
3367 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3371 RtlInsertElementGenericTable(
3372 _In_ PRTL_GENERIC_TABLE Table
,
3373 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3374 _In_ CLONG BufferSize
,
3375 _Out_opt_ PBOOLEAN NewElement
3381 RtlInsertElementGenericTableFull(
3382 _In_ PRTL_GENERIC_TABLE Table
,
3383 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3384 _In_ CLONG BufferSize
,
3385 _Out_opt_ PBOOLEAN NewElement
,
3386 _In_ PVOID NodeOrParent
,
3387 _In_ TABLE_SEARCH_RESULT SearchResult
3393 RtlIsGenericTableEmpty(
3394 _In_ PRTL_GENERIC_TABLE Table
3400 RtlLookupElementGenericTableFull(
3401 _In_ PRTL_GENERIC_TABLE Table
,
3403 _Out_ PVOID
*NodeOrParent
,
3404 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3409 // Handle Table Functions
3412 PRTL_HANDLE_TABLE_ENTRY
3415 _In_ PRTL_HANDLE_TABLE HandleTable
,
3416 _Inout_ PULONG Index
3422 RtlDestroyHandleTable(
3423 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3429 _In_ PRTL_HANDLE_TABLE HandleTable
,
3430 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3436 RtlInitializeHandleTable(
3437 _In_ ULONG TableSize
,
3438 _In_ ULONG HandleSize
,
3439 _In_ PRTL_HANDLE_TABLE HandleTable
3446 _In_ PRTL_HANDLE_TABLE HandleTable
,
3447 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3450 _Success_(return!=FALSE
)
3454 RtlIsValidIndexHandle(
3455 _In_ PRTL_HANDLE_TABLE HandleTable
,
3457 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3467 _In_ PVOID BaseAddress
,
3469 _In_ ULONG Language
,
3470 _In_ ULONG MessageId
,
3471 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3477 RtlGetNtGlobalFlags(VOID
);
3479 _Success_(return!=NULL
)
3483 RtlImageDirectoryEntryToData(
3484 _In_ PVOID BaseAddress
,
3485 _In_ BOOLEAN MappedAsImage
,
3486 _In_ USHORT Directory
,
3494 _In_ PIMAGE_NT_HEADERS NtHeader
,
3495 _In_ PVOID BaseAddress
,
3497 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3504 _In_ PVOID BaseAddress
);
3511 _In_ PVOID BaseAddress
,
3512 _In_ ULONGLONG Size
,
3513 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3517 PIMAGE_SECTION_HEADER
3519 RtlImageRvaToSection(
3520 _In_ PIMAGE_NT_HEADERS NtHeader
,
3521 _In_ PVOID BaseAddress
,
3528 LdrRelocateImageWithBias(
3529 _In_ PVOID NewAddress
,
3530 _In_ LONGLONG AdditionalBias
,
3531 _In_ PCCH LoaderName
,
3533 _In_ ULONG Conflict
,
3538 // Activation Context Functions
3540 #ifdef NTOS_MODE_USER
3544 RtlActivateActivationContextEx(
3548 _Out_ PULONG_PTR Cookie
3554 RtlActivateActivationContext(
3557 _Out_ PULONG_PTR Cookie
3563 RtlAddRefActivationContext(
3568 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3570 RtlActivateActivationContextUnsafeFast(
3571 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3578 RtlAllocateActivationContextStack(
3579 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3585 RtlCreateActivationContext(
3587 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3588 _In_ ULONG ExtraBytes
,
3589 _In_ PVOID NotificationRoutine
,
3590 _In_ PVOID NotificationContext
,
3591 _Out_ PACTIVATION_CONTEXT
*ActCtx
3597 RtlGetActiveActivationContext(
3604 RtlReleaseActivationContext(
3611 RtlDeactivateActivationContext(
3613 _In_ ULONG_PTR ulCookie
3619 RtlFreeActivationContextStack(
3620 _In_ PACTIVATION_CONTEXT_STACK Stack
3626 RtlFreeThreadActivationContextStack(VOID
);
3629 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3631 RtlDeactivateActivationContextUnsafeFast(
3632 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3638 RtlDosApplyFileIsolationRedirection_Ustr(
3640 _In_ PUNICODE_STRING OriginalName
,
3641 _In_ PUNICODE_STRING Extension
,
3642 _Inout_ PUNICODE_STRING StaticString
,
3643 _Inout_ PUNICODE_STRING DynamicString
,
3644 _Inout_ PUNICODE_STRING
*NewName
,
3645 _In_ PULONG NewFlags
,
3646 _In_ PSIZE_T FileNameSize
,
3647 _In_ PSIZE_T RequiredLength
3653 RtlFindActivationContextSectionString(
3655 _In_
const GUID
*ExtensionGuid
,
3656 _In_ ULONG SectionType
,
3657 _In_
const UNICODE_STRING
*SectionName
,
3658 _Inout_ PVOID ReturnedData
3664 RtlQueryInformationActivationContext(
3666 _In_opt_ PVOID Context
,
3667 _In_opt_ PVOID pvSubInstance
,
3668 _In_ ULONG ulInfoClass
,
3669 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3670 _In_opt_ SIZE_T cbBuffer
,
3671 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3677 RtlQueryInformationActiveActivationContext(
3678 _In_ ULONG ulInfoClass
,
3679 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3680 _In_opt_ SIZE_T cbBuffer
,
3681 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3687 RtlZombifyActivationContext(
3697 RtlWow64EnableFsRedirection(
3698 _In_ BOOLEAN Wow64FsEnableRedirection
3704 RtlWow64EnableFsRedirectionEx(
3705 _In_ PVOID Wow64FsEnableRedirection
,
3706 _Out_ PVOID
*OldFsRedirectionLevel
3712 // Registry Functions
3714 _IRQL_requires_max_(PASSIVE_LEVEL
)
3715 _Must_inspect_result_
3719 RtlCheckRegistryKey(
3720 _In_ ULONG RelativeTo
,
3727 RtlCreateRegistryKey(
3728 _In_ ULONG RelativeTo
,
3735 RtlFormatCurrentUserKeyPath(
3736 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3737 PUNICODE_STRING KeyPath
3744 _In_ ACCESS_MASK DesiredAccess
,
3745 _Out_ PHANDLE KeyHandle
3748 _IRQL_requires_max_(PASSIVE_LEVEL
)
3752 RtlQueryRegistryValues(
3753 _In_ ULONG RelativeTo
,
3755 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3756 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3757 _In_opt_ PVOID Context
,
3758 _In_opt_ PVOID Environment
3761 _IRQL_requires_max_(PASSIVE_LEVEL
)
3765 RtlWriteRegistryValue(
3766 _In_ ULONG RelativeTo
,
3768 _In_z_ PCWSTR ValueName
,
3769 _In_ ULONG ValueType
,
3770 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3771 _In_ ULONG ValueLength
3774 #ifdef NTOS_MODE_USER
3779 _Out_ HANDLE KeyHandle
,
3780 _In_ ACCESS_MASK DesiredAccess
,
3781 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3782 _In_ ULONG TitleIndex
,
3783 _In_ PUNICODE_STRING Class
,
3784 _Out_ PULONG Disposition
3790 RtlpNtEnumerateSubKey(
3791 _In_ HANDLE KeyHandle
,
3792 _Inout_ PUNICODE_STRING SubKeyName
,
3800 RtlpNtMakeTemporaryKey(
3801 _In_ HANDLE KeyHandle
3808 _Out_ HANDLE KeyHandle
,
3809 _In_ ACCESS_MASK DesiredAccess
,
3810 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3817 RtlpNtQueryValueKey(
3818 _In_ HANDLE KeyHandle
,
3819 _Out_opt_ PULONG Type
,
3820 _Out_opt_ PVOID Data
,
3821 _Inout_opt_ PULONG DataLength
,
3829 _In_ HANDLE KeyHandle
,
3832 _In_ ULONG DataLength
3842 RtlGetDefaultCodePage(
3843 _Out_ PUSHORT AnsiCodePage
,
3844 _Out_ PUSHORT OemCodePage
3851 _In_ PUSHORT AnsiTableBase
,
3852 _In_ PUSHORT OemTableBase
,
3853 _In_ PUSHORT CaseTableBase
,
3854 _Out_ PNLSTABLEINFO NlsTable
3857 _IRQL_requires_max_(PASSIVE_LEVEL
)
3861 RtlInitCodePageTable(
3862 _In_ PUSHORT TableBase
,
3863 _Out_ PCPTABLEINFO CodePageTable
3869 RtlResetRtlTranslations(
3870 _In_ PNLSTABLEINFO NlsTable
);
3872 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3875 // Misc conversion functions
3880 RtlConvertLongToLargeInteger(
3881 _In_ LONG SignedInteger
3884 LARGE_INTEGER Result
;
3886 Result
.QuadPart
= SignedInteger
;
3893 RtlEnlargedIntegerMultiply(
3894 _In_ LONG Multiplicand
,
3895 _In_ LONG Multiplier
3898 LARGE_INTEGER Product
;
3900 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3907 RtlEnlargedUnsignedDivide(
3908 _In_ ULARGE_INTEGER Dividend
,
3910 _In_opt_ PULONG Remainder
3915 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
3917 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3926 RtlEnlargedUnsignedMultiply(
3927 _In_ ULONG Multiplicand
,
3928 _In_ ULONG Multiplier
3931 LARGE_INTEGER Product
;
3933 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3937 #if defined(_AMD64_) || defined(_IA64_)
3941 RtlExtendedLargeIntegerDivide(
3942 _In_ LARGE_INTEGER Dividend
,
3944 _Out_opt_ PULONG Remainder
)
3947 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3949 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3957 RtlExtendedLargeIntegerDivide(
3958 _In_ LARGE_INTEGER Dividend
,
3960 _Out_opt_ PULONG Remainder
3963 #endif /* defined(_AMD64_) || defined(_IA64_) */
3986 _In_ ULONG InitialCrc
,
3992 // Network Functions
3997 RtlIpv4StringToAddressA(
3999 _In_ BOOLEAN Strict
,
4000 _Out_ PCSTR
*Terminator
,
4001 _Out_
struct in_addr
*Addr
4007 RtlIpv4StringToAddressW(
4009 _In_ BOOLEAN Strict
,
4010 _Out_ PCWSTR
*Terminator
,
4011 _Out_
struct in_addr
*Addr
4017 RtlIpv4StringToAddressExA(
4018 _In_ PCSTR AddressString
,
4019 _In_ BOOLEAN Strict
,
4020 _Out_
struct in_addr
*Address
,
4027 RtlIpv4StringToAddressExW(
4028 _In_ PCWSTR AddressString
,
4029 _In_ BOOLEAN Strict
,
4030 _Out_
struct in_addr
*Address
,
4037 RtlIpv6StringToAddressA(
4039 _Out_ PCHAR
*Terminator
,
4040 _Out_
struct in6_addr
*Addr
4046 RtlIpv6StringToAddressW(
4048 _Out_ PCHAR
*Terminator
,
4049 _Out_
struct in6_addr
*Addr
4055 RtlIpv6StringToAddressExA(
4056 _In_ PCHAR AddressString
,
4057 _In_
struct in6_addr
*Address
,
4058 _In_ PULONG ScopeId
,
4065 RtlIpv6StringToAddressExW(
4066 _In_ PWCHAR AddressName
,
4067 _In_
struct in6_addr
*Address
,
4068 _In_ PULONG ScopeId
,
4079 RtlQueryTimeZoneInformation(
4080 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4085 RtlSecondsSince1970ToTime(
4086 _In_ ULONG SecondsSince1970
,
4087 _Out_ PLARGE_INTEGER Time
4093 RtlSetTimeZoneInformation(
4094 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4096 _Success_(return!=FALSE
)
4097 _Must_inspect_result_
4101 RtlTimeFieldsToTime(
4102 _In_ PTIME_FIELDS TimeFields
,
4103 _Out_ PLARGE_INTEGER Time
4106 _Success_(return != 0)
4107 _Must_inspect_result_
4111 RtlTimeToSecondsSince1970(
4112 _In_ PLARGE_INTEGER Time
,
4113 _Out_ PULONG ElapsedSeconds
4119 RtlTimeToTimeFields(
4120 PLARGE_INTEGER Time
,
4121 PTIME_FIELDS TimeFields
4127 RtlSystemTimeToLocalTime(
4128 _In_ PLARGE_INTEGER SystemTime
,
4129 _Out_ PLARGE_INTEGER LocalTime
4133 // Version Functions
4135 _IRQL_requires_max_(PASSIVE_LEVEL
)
4136 _Must_inspect_result_
4140 RtlVerifyVersionInfo(
4141 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4142 _In_ ULONG TypeMask
,
4143 _In_ ULONGLONG ConditionMask
4146 _IRQL_requires_max_(PASSIVE_LEVEL
)
4152 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4153 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4154 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4155 PRTL_OSVERSIONINFOW lpVersionInformation
4161 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4164 // Secure Memory Functions
4166 #ifdef NTOS_MODE_USER
4170 RtlRegisterSecureMemoryCacheCallback(
4171 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4176 RtlFlushSecureMemoryCache(
4177 _In_ PVOID MemoryCache
,
4178 _In_opt_ SIZE_T MemoryLength
4183 // Boot Status Data Functions
4185 #ifdef NTOS_MODE_USER
4189 RtlCreateBootStatusDataFile(
4196 RtlGetSetBootStatusData(
4197 _In_ HANDLE FileHandle
,
4198 _In_ BOOLEAN WriteMode
,
4199 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4201 _In_ ULONG BufferSize
,
4202 _Out_opt_ PULONG ReturnLength
4208 RtlLockBootStatusData(
4209 _Out_ PHANDLE FileHandle
4215 RtlUnlockBootStatusData(
4216 _In_ HANDLE FileHandle
4220 #ifdef NTOS_MODE_USER
4221 _Must_inspect_result_
4226 _In_ PUNICODE_STRING GuidString
,
4229 _Must_inspect_result_
4235 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4236 PUNICODE_STRING GuidString
);
4241 RtlComputeImportTableHash(
4244 _In_ ULONG ImportTableHashRevision
4249 // MemoryStream functions
4251 #ifdef NTOS_MODE_USER
4256 RtlInitMemoryStream(
4257 _Out_ PRTL_MEMORY_STREAM Stream
4263 RtlInitOutOfProcessMemoryStream(
4264 _Out_ PRTL_MEMORY_STREAM Stream
4270 RtlFinalReleaseOutOfProcessMemoryStream(
4271 _In_ PRTL_MEMORY_STREAM Stream
4277 RtlQueryInterfaceMemoryStream(
4278 _In_
struct IStream
*This
,
4279 _In_ REFIID RequestedIid
,
4280 _Outptr_ PVOID
*ResultObject
4286 RtlAddRefMemoryStream(
4287 _In_
struct IStream
*This
4293 RtlReleaseMemoryStream(
4294 _In_
struct IStream
*This
4300 RtlReadMemoryStream(
4301 _In_
struct IStream
*This
,
4302 _Out_writes_bytes_(Length
) PVOID Buffer
,
4304 _Out_opt_ PULONG BytesRead
4310 RtlReadOutOfProcessMemoryStream(
4311 _In_
struct IStream
*This
,
4312 _Out_writes_bytes_(Length
) PVOID Buffer
,
4314 _Out_opt_ PULONG BytesRead
4320 RtlSeekMemoryStream(
4321 _In_
struct IStream
*This
,
4322 _In_ LARGE_INTEGER RelativeOffset
,
4324 _Out_opt_ PULARGE_INTEGER ResultOffset
4330 RtlCopyMemoryStreamTo(
4331 _In_
struct IStream
*This
,
4332 _In_
struct IStream
*Target
,
4333 _In_ ULARGE_INTEGER Length
,
4334 _Out_opt_ PULARGE_INTEGER BytesRead
,
4335 _Out_opt_ PULARGE_INTEGER BytesWritten
4341 RtlCopyOutOfProcessMemoryStreamTo(
4342 _In_
struct IStream
*This
,
4343 _In_
struct IStream
*Target
,
4344 _In_ ULARGE_INTEGER Length
,
4345 _Out_opt_ PULARGE_INTEGER BytesRead
,
4346 _Out_opt_ PULARGE_INTEGER BytesWritten
4352 RtlStatMemoryStream(
4353 _In_
struct IStream
*This
,
4354 _Out_
struct tagSTATSTG
*Stats
,
4362 RtlWriteMemoryStream(
4363 _In_
struct IStream
*This
,
4364 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4366 _Out_opt_ PULONG BytesWritten
4372 RtlSetMemoryStreamSize(
4373 _In_
struct IStream
*This
,
4374 _In_ ULARGE_INTEGER NewSize
4380 RtlCommitMemoryStream(
4381 _In_
struct IStream
*This
,
4382 _In_ ULONG CommitFlags
4388 RtlRevertMemoryStream(
4389 _In_
struct IStream
*This
4395 RtlLockMemoryStreamRegion(
4396 _In_
struct IStream
*This
,
4397 _In_ ULARGE_INTEGER Offset
,
4398 _In_ ULARGE_INTEGER Length
,
4405 RtlUnlockMemoryStreamRegion(
4406 _In_
struct IStream
*This
,
4407 _In_ ULARGE_INTEGER Offset
,
4408 _In_ ULARGE_INTEGER Length
,
4415 RtlCloneMemoryStream(
4416 _In_
struct IStream
*This
,
4417 _Outptr_
struct IStream
**ResultStream
4420 #endif // NTOS_MODE_USER
4425 RtlFindActivationContextSectionGuid(
4427 const GUID
*extguid
,