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
2118 RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString
);
2123 RtlHashUnicodeString(
2124 _In_ CONST UNICODE_STRING
*String
,
2125 _In_ BOOLEAN CaseInSensitive
,
2126 _In_ ULONG HashAlgorithm
,
2127 _Out_ PULONG HashValue
2130 _IRQL_requires_max_(DISPATCH_LEVEL
)
2131 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2132 _When_(SourceString
!= NULL
,
2133 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2134 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2135 _When_(SourceString
== NULL
,
2136 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2137 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2141 RtlInitUnicodeString(
2142 _Out_ PUNICODE_STRING DestinationString
,
2143 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2146 _IRQL_requires_max_(DISPATCH_LEVEL
)
2150 RtlInitUnicodeStringEx(
2151 _Out_ PUNICODE_STRING DestinationString
,
2152 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2164 _IRQL_requires_max_(PASSIVE_LEVEL
)
2165 _Must_inspect_result_
2170 _In_
const STRING
*String1
,
2171 _In_
const STRING
*String2
,
2172 _In_ BOOLEAN CaseInsensitive
2175 _IRQL_requires_max_(PASSIVE_LEVEL
)
2176 _Must_inspect_result_
2180 RtlPrefixUnicodeString(
2181 _In_ PCUNICODE_STRING String1
,
2182 _In_ PCUNICODE_STRING String2
,
2183 _In_ BOOLEAN CaseInsensitive
2186 _IRQL_requires_max_(PASSIVE_LEVEL
)
2191 _Inout_ PSTRING DestinationString
,
2192 _In_
const STRING
*SourceString
2195 _IRQL_requires_max_(PASSIVE_LEVEL
)
2196 _Must_inspect_result_
2201 _In_
const STRING
*String1
,
2202 _In_
const STRING
*String2
,
2203 _In_ BOOLEAN CaseInSensitive
2210 _Out_ PSTRING DestinationString
,
2211 _In_opt_
const STRING
*SourceString
2214 _IRQL_requires_max_(PASSIVE_LEVEL
)
2215 _Must_inspect_result_
2220 _In_
const STRING
*String1
,
2221 _In_
const STRING
*String2
,
2222 _In_ BOOLEAN CaseInSensitive
2225 _IRQL_requires_max_(APC_LEVEL
)
2229 RtlAppendStringToString(
2230 _Inout_ PSTRING Destination
,
2231 _In_
const STRING
*Source
2234 _IRQL_requires_max_(PASSIVE_LEVEL
)
2235 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2239 RtlUpcaseUnicodeString(
2240 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2241 _When_(!AllocateDestinationString
, _Inout_
)
2242 PUNICODE_STRING DestinationString
,
2243 _In_ PCUNICODE_STRING SourceString
,
2244 _In_ BOOLEAN AllocateDestinationString
2247 _IRQL_requires_max_(PASSIVE_LEVEL
)
2251 RtlUnicodeStringToInteger(
2252 _In_ PCUNICODE_STRING String
,
2253 _In_opt_ ULONG Base
,
2260 RtlValidateUnicodeString(
2262 _In_ PCUNICODE_STRING String
2266 // Ansi String Functions
2268 _IRQL_requires_max_(PASSIVE_LEVEL
)
2273 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2274 PANSI_STRING AnsiString
2277 _IRQL_requires_max_(DISPATCH_LEVEL
)
2282 _Out_ PANSI_STRING DestinationString
,
2283 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2286 _IRQL_requires_max_(DISPATCH_LEVEL
)
2290 RtlInitAnsiStringEx(
2291 _Out_ PANSI_STRING DestinationString
,
2292 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2296 // OEM String Functions
2298 _IRQL_requires_max_(PASSIVE_LEVEL
)
2303 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2304 POEM_STRING OemString
2308 // MultiByte->Unicode String Functions
2310 _IRQL_requires_max_(PASSIVE_LEVEL
)
2314 RtlMultiByteToUnicodeN(
2315 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2316 _In_ ULONG MaxBytesInUnicodeString
,
2317 _Out_opt_ PULONG BytesInUnicodeString
,
2318 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2319 _In_ ULONG BytesInMultiByteString
2322 _IRQL_requires_max_(PASSIVE_LEVEL
)
2326 RtlMultiByteToUnicodeSize(
2327 _Out_ PULONG BytesInUnicodeString
,
2328 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2329 _In_ ULONG BytesInMultiByteString
2338 RtlAddAtomToAtomTable(
2339 _In_ PRTL_ATOM_TABLE AtomTable
,
2340 _In_ PWSTR AtomName
,
2341 _Out_ PRTL_ATOM Atom
2348 _In_ ULONG TableSize
,
2349 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2355 RtlDeleteAtomFromAtomTable(
2356 _In_ PRTL_ATOM_TABLE AtomTable
,
2363 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2368 RtlQueryAtomInAtomTable(
2369 _In_ PRTL_ATOM_TABLE AtomTable
,
2371 _Out_opt_ PULONG RefCount
,
2372 _Out_opt_ PULONG PinCount
,
2373 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2374 _Inout_opt_ PULONG NameLength
2380 RtlPinAtomInAtomTable(
2381 _In_ PRTL_ATOM_TABLE AtomTable
,
2388 RtlLookupAtomInAtomTable(
2389 _In_ PRTL_ATOM_TABLE AtomTable
,
2390 _In_ PWSTR AtomName
,
2391 _Out_ PRTL_ATOM Atom
2395 // Process Management Functions
2407 RtlAcquirePebLock(VOID
);
2412 RtlCreateProcessParameters (
2413 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2414 _In_ PUNICODE_STRING ImagePathName
,
2415 _In_opt_ PUNICODE_STRING DllPath
,
2416 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2417 _In_opt_ PUNICODE_STRING CommandLine
,
2418 _In_opt_ PWSTR Environment
,
2419 _In_opt_ PUNICODE_STRING WindowTitle
,
2420 _In_opt_ PUNICODE_STRING DesktopInfo
,
2421 _In_opt_ PUNICODE_STRING ShellInfo
,
2422 _In_opt_ PUNICODE_STRING RuntimeInfo
2428 RtlCreateUserProcess(
2429 _In_ PUNICODE_STRING ImageFileName
,
2430 _In_ ULONG Attributes
,
2431 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2432 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2433 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2434 _In_opt_ HANDLE ParentProcess
,
2435 _In_ BOOLEAN CurrentDirectory
,
2436 _In_opt_ HANDLE DebugPort
,
2437 _In_opt_ HANDLE ExceptionPort
,
2438 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2441 #if (NTDDI_VERSION >= NTDDI_WIN7)
2445 RtlCreateUserThread(
2446 _In_ PVOID ThreadContext
,
2447 _Out_ HANDLE
*OutThreadHandle
,
2448 _Reserved_ PVOID Reserved1
,
2449 _Reserved_ PVOID Reserved2
,
2450 _Reserved_ PVOID Reserved3
,
2451 _Reserved_ PVOID Reserved4
,
2452 _Reserved_ PVOID Reserved5
,
2453 _Reserved_ PVOID Reserved6
,
2454 _Reserved_ PVOID Reserved7
,
2455 _Reserved_ PVOID Reserved8
2461 RtlCreateUserThread(
2462 _In_ HANDLE ProcessHandle
,
2463 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2464 _In_ BOOLEAN CreateSuspended
,
2465 _In_ ULONG StackZeroBits
,
2466 _In_ SIZE_T StackReserve
,
2467 _In_ SIZE_T StackCommit
,
2468 _In_ PTHREAD_START_ROUTINE StartAddress
,
2469 _In_ PVOID Parameter
,
2470 _Out_opt_ PHANDLE ThreadHandle
,
2471 _Out_opt_ PCLIENT_ID ClientId
2476 PRTL_USER_PROCESS_PARAMETERS
2478 RtlDeNormalizeProcessParams(
2479 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2484 RtlDestroyProcessParameters(
2485 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2491 _In_ NTSTATUS Status
);
2496 RtlInitializeContext(
2497 _In_ HANDLE ProcessHandle
,
2498 _Out_ PCONTEXT ThreadContext
,
2499 _In_opt_ PVOID ThreadStartParam
,
2500 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2501 _In_ PINITIAL_TEB InitialTeb
2505 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2510 RtlWow64GetThreadContext(
2511 _In_ HANDLE ThreadHandle
,
2512 _Inout_ PWOW64_CONTEXT ThreadContext
2519 RtlWow64SetThreadContext(
2520 _In_ HANDLE ThreadHandle
,
2521 _In_ PWOW64_CONTEXT ThreadContext
2528 RtlIsThreadWithinLoaderCallout(VOID
);
2531 PRTL_USER_PROCESS_PARAMETERS
2533 RtlNormalizeProcessParams(
2534 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2539 RtlReleasePebLock(VOID
);
2545 _In_ HANDLE Process
,
2547 _In_ PVOID CallSite
,
2548 _In_ ULONG ArgumentCount
,
2549 _In_ PULONG Arguments
,
2550 _In_ BOOLEAN PassContext
,
2551 _In_ BOOLEAN AlreadySuspended
2557 RtlSetProcessIsCritical(
2558 _In_ BOOLEAN NewValue
,
2559 _Out_opt_ PBOOLEAN OldValue
,
2560 _In_ BOOLEAN NeedBreaks
2566 RtlSetThreadIsCritical(
2567 _In_ BOOLEAN NewValue
,
2568 _Out_opt_ PBOOLEAN OldValue
,
2569 _In_ BOOLEAN NeedBreaks
2575 RtlGetCurrentProcessorNumber(
2579 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2582 // Thread Pool Functions
2587 RtlSetThreadPoolStartFunc(
2588 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2589 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2595 RtlDeregisterWaitEx(
2596 _In_ HANDLE hWaitHandle
,
2597 _In_opt_ HANDLE hCompletionEvent
2604 _In_ HANDLE hWaitHandle
2611 _In_ WORKERCALLBACKFUNC Function
,
2612 _In_opt_ PVOID Context
,
2619 RtlSetIoCompletionCallback(
2620 _In_ HANDLE FileHandle
,
2621 _In_ PIO_APC_ROUTINE Callback
,
2629 _In_ PHANDLE phNewWaitObject
,
2630 _In_ HANDLE hObject
,
2631 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2632 _In_ PVOID pvContext
,
2633 _In_ ULONG ulMilliseconds
,
2638 // Environment/Path Functions
2643 RtlCreateEnvironment(
2644 _In_ BOOLEAN Inherit
,
2645 _Out_ PWSTR
*Environment
2651 RtlComputePrivatizedDllName_U(
2652 _In_ PUNICODE_STRING DllName
,
2653 _Out_ PUNICODE_STRING RealName
,
2654 _Out_ PUNICODE_STRING LocalName
2660 RtlDestroyEnvironment(
2661 _In_ PWSTR Environment
2667 RtlDoesFileExists_U(
2668 _In_ PCWSTR FileName
2674 RtlDetermineDosPathNameType_U(
2683 _In_ PCWSTR FileName
,
2684 _In_ PCWSTR Extension
,
2685 _In_ ULONG BufferSize
,
2687 _Out_ PWSTR
*PartName
2693 RtlDosSearchPath_Ustr(
2695 _In_ PUNICODE_STRING PathString
,
2696 _In_ PUNICODE_STRING FileNameString
,
2697 _In_ PUNICODE_STRING ExtensionString
,
2698 _In_ PUNICODE_STRING CallerBuffer
,
2699 _Inout_opt_ PUNICODE_STRING DynamicString
,
2700 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2701 _Out_opt_ PSIZE_T FilePartSize
,
2702 _Out_opt_ PSIZE_T LengthNeeded
2708 RtlDosPathNameToNtPathName_U(
2709 _In_opt_z_ PCWSTR DosPathName
,
2710 _Out_ PUNICODE_STRING NtPathName
,
2711 _Out_opt_ PCWSTR
*NtFileNamePart
,
2712 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2718 RtlDosPathNameToRelativeNtPathName_U(
2719 _In_ PCWSTR DosName
,
2720 _Out_ PUNICODE_STRING NtName
,
2721 _Out_ PCWSTR
*PartName
,
2722 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2725 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2729 RtlExpandEnvironmentStrings_U(
2730 _In_z_ PWSTR Environment
,
2731 _In_ PUNICODE_STRING Source
,
2732 _Inout_ PUNICODE_STRING Destination
,
2739 RtlGetCurrentDirectory_U(
2740 _In_ ULONG MaximumLength
,
2741 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2747 RtlGetFullPathName_U(
2748 _In_ PCWSTR FileName
,
2750 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2751 _Out_opt_ PWSTR
*ShortName
2754 #if (NTDDI_VERSION >= NTDDI_WIN7)
2758 RtlGetFullPathName_UEx(
2759 _In_ PWSTR FileName
,
2760 _In_ ULONG BufferLength
,
2762 _Out_opt_ PWSTR
*FilePart
,
2763 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2769 RtlGetFullPathName_UstrEx(
2770 _In_ PUNICODE_STRING FileName
,
2771 _In_opt_ PUNICODE_STRING StaticString
,
2772 _In_opt_ PUNICODE_STRING DynamicString
,
2773 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2774 _Out_opt_ PSIZE_T FilePartSize
,
2775 _Out_opt_ PBOOLEAN NameInvalid
,
2776 _Out_ RTL_PATH_TYPE
* PathType
,
2777 _Out_opt_ PSIZE_T LengthNeeded
2783 RtlGetLengthWithoutTrailingPathSeperators(
2784 _Reserved_ ULONG Flags
,
2785 _In_ PCUNICODE_STRING PathString
,
2792 RtlGetLongestNtPathLength(
2799 RtlIsDosDeviceName_U(
2806 RtlIsDosDeviceName_Ustr(
2807 _In_ PCUNICODE_STRING Name
2810 _IRQL_requires_max_(PASSIVE_LEVEL
)
2811 _Must_inspect_result_
2815 RtlIsNameLegalDOS8Dot3(
2816 _In_ PCUNICODE_STRING Name
,
2817 _Inout_opt_ POEM_STRING OemName
,
2818 _Out_opt_ PBOOLEAN NameContainsSpaces
2824 RtlQueryEnvironmentVariable_U(
2825 _In_opt_ PWSTR Environment
,
2826 _In_ PUNICODE_STRING Name
,
2827 _Out_ PUNICODE_STRING Value
2832 RtlReleaseRelativeName(
2833 _In_ PRTL_RELATIVE_NAME_U RelativeName
2839 RtlSetCurrentDirectory_U(
2840 _In_ PUNICODE_STRING name
2846 RtlSetEnvironmentVariable(
2847 _In_z_ PWSTR
*Environment
,
2848 _In_ PUNICODE_STRING Name
,
2849 _In_ PUNICODE_STRING Value
2853 // Critical Section/Resource Functions
2858 RtlDeleteCriticalSection (
2859 _In_ PRTL_CRITICAL_SECTION CriticalSection
2865 RtlEnterCriticalSection(
2866 _In_ PRTL_CRITICAL_SECTION CriticalSection
2872 RtlInitializeCriticalSection(
2873 _In_ PRTL_CRITICAL_SECTION CriticalSection
2879 RtlInitializeCriticalSectionAndSpinCount(
2880 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2881 _In_ ULONG SpinCount
2887 RtlLeaveCriticalSection(
2888 _In_ PRTL_CRITICAL_SECTION CriticalSection
2894 RtlTryEnterCriticalSection(
2895 _In_ PRTL_CRITICAL_SECTION CriticalSection
2901 RtlpUnWaitCriticalSection(
2902 _In_ PRTL_CRITICAL_SECTION CriticalSection
2908 RtlpWaitForCriticalSection(
2909 _In_ PRTL_CRITICAL_SECTION CriticalSection
2915 RtlAcquireResourceExclusive(
2916 _In_ PRTL_RESOURCE Resource
,
2923 RtlAcquireResourceShared(
2924 _In_ PRTL_RESOURCE Resource
,
2931 RtlConvertExclusiveToShared(
2932 _In_ PRTL_RESOURCE Resource
2938 RtlConvertSharedToExclusive(
2939 _In_ PRTL_RESOURCE Resource
2946 _In_ PRTL_RESOURCE Resource
2953 _In_ PRTL_RESOURCE Resource
2959 RtlInitializeResource(
2960 _In_ PRTL_RESOURCE Resource
2967 _In_ PRTL_RESOURCE Resource
2971 // Compression Functions
2973 NTSYSAPI
//NT_RTL_COMPRESS_API
2977 _In_ USHORT CompressionFormatAndEngine
,
2978 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2979 _In_ ULONG UncompressedBufferSize
,
2980 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2981 _In_ ULONG CompressedBufferSize
,
2982 _In_ ULONG UncompressedChunkSize
,
2983 _Out_ PULONG FinalCompressedSize
,
2984 _In_ PVOID WorkSpace
2987 _IRQL_requires_max_(APC_LEVEL
)
2988 NTSYSAPI
//NT_RTL_COMPRESS_API
2991 RtlDecompressBuffer(
2992 _In_ USHORT CompressionFormat
,
2993 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2994 _In_ ULONG UncompressedBufferSize
,
2995 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2996 _In_ ULONG CompressedBufferSize
,
2997 _Out_ PULONG FinalUncompressedSize
3003 RtlGetCompressionWorkSpaceSize(
3004 _In_ USHORT CompressionFormatAndEngine
,
3005 _Out_ PULONG CompressBufferWorkSpaceSize
,
3006 _Out_ PULONG CompressFragmentWorkSpaceSize
3010 // Debug Info Functions
3013 PRTL_DEBUG_INFORMATION
3015 RtlCreateQueryDebugBuffer(
3017 _In_ BOOLEAN EventPair
3023 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3028 RtlQueryProcessDebugInformation(
3029 _In_ ULONG ProcessId
,
3030 _In_ ULONG DebugInfoClassMask
,
3031 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3041 _In_ PRTL_BITMAP BitMapHeader
,
3042 _In_ ULONG StartingIndex
,
3050 _In_ PRTL_BITMAP BitMapHeader
,
3051 _In_ ULONG StartingIndex
,
3059 _In_ PRTL_BITMAP BitMapHeader
3066 _In_ PRTL_BITMAP BitMapHeader
,
3067 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3068 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3075 _In_ PRTL_BITMAP BitMapHeader
,
3076 _In_ ULONG NumberToFind
,
3077 _In_ ULONG HintIndex
3083 RtlFindClearBitsAndSet(
3084 _In_ PRTL_BITMAP BitMapHeader
,
3085 _In_ ULONG NumberToFind
,
3086 _In_ ULONG HintIndex
3092 RtlFindLeastSignificantBit(
3093 _In_ ULONGLONG Value
3099 RtlFindMostSignificantBit(
3100 _In_ ULONGLONG Value
3106 RtlFindNextForwardRunClear(
3107 _In_ PRTL_BITMAP BitMapHeader
,
3108 _In_ ULONG FromIndex
,
3109 _Out_ PULONG StartingRunIndex
3115 RtlFindNextForwardRunSet(
3116 _In_ PRTL_BITMAP BitMapHeader
,
3117 _In_ ULONG FromIndex
,
3118 _Out_ PULONG StartingRunIndex
3125 _In_ PRTL_BITMAP BitMapHeader
,
3126 _In_ ULONG NumberToFind
,
3127 _In_ ULONG HintIndex
3133 RtlFindSetBitsAndClear(
3134 _In_ PRTL_BITMAP BitMapHeader
,
3135 _In_ ULONG NumberToFind
,
3136 _In_ ULONG HintIndex
3139 #ifdef _REACTOS_ // ReactOS improvement
3140 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3141 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3146 RtlInitializeBitMap(
3147 _Out_ PRTL_BITMAP BitMapHeader
,
3148 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3149 _In_opt_ ULONG SizeOfBitMap
3155 RtlNumberOfClearBits(
3156 _In_ PRTL_BITMAP BitMapHeader
3163 _In_ PRTL_BITMAP BitMapHeader
3170 _In_ PRTL_BITMAP BitMapHeader
,
3171 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3178 _In_ PRTL_BITMAP BitMapHeader
,
3179 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3180 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3187 _In_ PRTL_BITMAP BitMapHeader
3190 _Must_inspect_result_
3195 _In_ PRTL_BITMAP BitMapHeader
,
3196 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3206 _In_ HANDLE TimerQueue
,
3207 _In_ PHANDLE phNewTimer
,
3208 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3209 _In_ PVOID Parameter
,
3218 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3224 _In_ HANDLE TimerQueue
,
3226 _In_ HANDLE CompletionEvent
3233 _In_ HANDLE TimerQueue
,
3242 RtlDeleteTimerQueueEx(
3243 _In_ HANDLE TimerQueue
,
3244 _In_opt_ HANDLE CompletionEvent
3250 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3257 InterlockedPushListSList(
3258 _Inout_ PSLIST_HEADER ListHead
,
3259 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3260 _Inout_ PSLIST_ENTRY ListEnd
,
3265 // Range List functions
3270 RtlInitializeRangeList(
3271 _Inout_ PRTL_RANGE_LIST RangeList
3278 _In_ PRTL_RANGE_LIST RangeList
3285 _Inout_ PRTL_RANGE_LIST RangeList
,
3286 _In_ ULONGLONG Start
,
3288 _In_ UCHAR Attributes
,
3290 _In_opt_ PVOID UserData
,
3291 _In_opt_ PVOID Owner
3300 _In_z_ _Printf_format_string_ PCSTR Format
,
3308 _In_ ULONG ComponentId
,
3310 _In_z_ _Printf_format_string_ PCSTR Format
,
3319 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3320 _In_ ULONG MaximumResponseLength
3323 #undef DbgBreakPoint
3332 DbgLoadImageSymbols(
3335 _In_ ULONG_PTR ProcessId
3340 DbgUnLoadImageSymbols(
3343 _In_ ULONG_PTR ProcessId
3354 // Generic Table Functions
3356 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3360 RtlInsertElementGenericTable(
3361 _In_ PRTL_GENERIC_TABLE Table
,
3362 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3363 _In_ CLONG BufferSize
,
3364 _Out_opt_ PBOOLEAN NewElement
3370 RtlInsertElementGenericTableFull(
3371 _In_ PRTL_GENERIC_TABLE Table
,
3372 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3373 _In_ CLONG BufferSize
,
3374 _Out_opt_ PBOOLEAN NewElement
,
3375 _In_ PVOID NodeOrParent
,
3376 _In_ TABLE_SEARCH_RESULT SearchResult
3382 RtlIsGenericTableEmpty(
3383 _In_ PRTL_GENERIC_TABLE Table
3389 RtlLookupElementGenericTableFull(
3390 _In_ PRTL_GENERIC_TABLE Table
,
3392 _Out_ PVOID
*NodeOrParent
,
3393 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3398 // Handle Table Functions
3401 PRTL_HANDLE_TABLE_ENTRY
3404 _In_ PRTL_HANDLE_TABLE HandleTable
,
3405 _Inout_ PULONG Index
3411 RtlDestroyHandleTable(
3412 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3418 _In_ PRTL_HANDLE_TABLE HandleTable
,
3419 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3425 RtlInitializeHandleTable(
3426 _In_ ULONG TableSize
,
3427 _In_ ULONG HandleSize
,
3428 _In_ PRTL_HANDLE_TABLE HandleTable
3435 _In_ PRTL_HANDLE_TABLE HandleTable
,
3436 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3439 _Success_(return!=FALSE
)
3443 RtlIsValidIndexHandle(
3444 _In_ PRTL_HANDLE_TABLE HandleTable
,
3446 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3456 _In_ PVOID BaseAddress
,
3458 _In_ ULONG Language
,
3459 _In_ ULONG MessageId
,
3460 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3466 RtlGetNtGlobalFlags(VOID
);
3468 _Success_(return!=NULL
)
3472 RtlImageDirectoryEntryToData(
3473 _In_ PVOID BaseAddress
,
3474 _In_ BOOLEAN MappedAsImage
,
3475 _In_ USHORT Directory
,
3483 _In_ PIMAGE_NT_HEADERS NtHeader
,
3484 _In_ PVOID BaseAddress
,
3486 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3493 _In_ PVOID BaseAddress
);
3500 _In_ PVOID BaseAddress
,
3501 _In_ ULONGLONG Size
,
3502 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3506 PIMAGE_SECTION_HEADER
3508 RtlImageRvaToSection(
3509 _In_ PIMAGE_NT_HEADERS NtHeader
,
3510 _In_ PVOID BaseAddress
,
3517 LdrRelocateImageWithBias(
3518 _In_ PVOID NewAddress
,
3519 _In_ LONGLONG AdditionalBias
,
3520 _In_ PCCH LoaderName
,
3522 _In_ ULONG Conflict
,
3527 // Activation Context Functions
3529 #ifdef NTOS_MODE_USER
3533 RtlActivateActivationContextEx(
3537 _Out_ PULONG_PTR Cookie
3543 RtlActivateActivationContext(
3546 _Out_ PULONG_PTR Cookie
3552 RtlAddRefActivationContext(
3557 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3559 RtlActivateActivationContextUnsafeFast(
3560 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3567 RtlAllocateActivationContextStack(
3568 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3574 RtlCreateActivationContext(
3576 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3577 _In_ ULONG ExtraBytes
,
3578 _In_ PVOID NotificationRoutine
,
3579 _In_ PVOID NotificationContext
,
3580 _Out_ PACTIVATION_CONTEXT
*ActCtx
3586 RtlGetActiveActivationContext(
3593 RtlReleaseActivationContext(
3600 RtlDeactivateActivationContext(
3602 _In_ ULONG_PTR ulCookie
3608 RtlFreeActivationContextStack(
3609 _In_ PACTIVATION_CONTEXT_STACK Stack
3615 RtlFreeThreadActivationContextStack(VOID
);
3618 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3620 RtlDeactivateActivationContextUnsafeFast(
3621 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3627 RtlDosApplyFileIsolationRedirection_Ustr(
3629 _In_ PUNICODE_STRING OriginalName
,
3630 _In_ PUNICODE_STRING Extension
,
3631 _Inout_ PUNICODE_STRING StaticString
,
3632 _Inout_ PUNICODE_STRING DynamicString
,
3633 _Inout_ PUNICODE_STRING
*NewName
,
3634 _In_ PULONG NewFlags
,
3635 _In_ PSIZE_T FileNameSize
,
3636 _In_ PSIZE_T RequiredLength
3642 RtlFindActivationContextSectionString(
3644 _In_
const GUID
*ExtensionGuid
,
3645 _In_ ULONG SectionType
,
3646 _In_ PUNICODE_STRING SectionName
,
3647 _Inout_ PVOID ReturnedData
3653 RtlQueryInformationActivationContext(
3655 _In_opt_ PVOID Context
,
3656 _In_opt_ PVOID pvSubInstance
,
3657 _In_ ULONG ulInfoClass
,
3658 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3659 _In_opt_ SIZE_T cbBuffer
,
3660 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3666 RtlQueryInformationActiveActivationContext(
3667 _In_ ULONG ulInfoClass
,
3668 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3669 _In_opt_ SIZE_T cbBuffer
,
3670 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3676 RtlZombifyActivationContext(
3686 RtlWow64EnableFsRedirection(
3687 _In_ BOOLEAN Wow64FsEnableRedirection
3693 RtlWow64EnableFsRedirectionEx(
3694 _In_ PVOID Wow64FsEnableRedirection
,
3695 _Out_ PVOID
*OldFsRedirectionLevel
3701 // Registry Functions
3703 _IRQL_requires_max_(PASSIVE_LEVEL
)
3704 _Must_inspect_result_
3708 RtlCheckRegistryKey(
3709 _In_ ULONG RelativeTo
,
3716 RtlCreateRegistryKey(
3717 _In_ ULONG RelativeTo
,
3724 RtlFormatCurrentUserKeyPath(
3725 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3726 PUNICODE_STRING KeyPath
3733 _In_ ACCESS_MASK DesiredAccess
,
3734 _Out_ PHANDLE KeyHandle
3737 _IRQL_requires_max_(PASSIVE_LEVEL
)
3741 RtlQueryRegistryValues(
3742 _In_ ULONG RelativeTo
,
3744 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3745 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3746 _In_opt_ PVOID Context
,
3747 _In_opt_ PVOID Environment
3750 _IRQL_requires_max_(PASSIVE_LEVEL
)
3754 RtlWriteRegistryValue(
3755 _In_ ULONG RelativeTo
,
3757 _In_z_ PCWSTR ValueName
,
3758 _In_ ULONG ValueType
,
3759 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3760 _In_ ULONG ValueLength
3763 #ifdef NTOS_MODE_USER
3768 _Out_ HANDLE KeyHandle
,
3769 _In_ ACCESS_MASK DesiredAccess
,
3770 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3771 _In_ ULONG TitleIndex
,
3772 _In_ PUNICODE_STRING Class
,
3773 _Out_ PULONG Disposition
3779 RtlpNtEnumerateSubKey(
3780 _In_ HANDLE KeyHandle
,
3781 _Inout_ PUNICODE_STRING SubKeyName
,
3789 RtlpNtMakeTemporaryKey(
3790 _In_ HANDLE KeyHandle
3797 _Out_ HANDLE KeyHandle
,
3798 _In_ ACCESS_MASK DesiredAccess
,
3799 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3806 RtlpNtQueryValueKey(
3807 _In_ HANDLE KeyHandle
,
3808 _Out_opt_ PULONG Type
,
3809 _Out_opt_ PVOID Data
,
3810 _Inout_opt_ PULONG DataLength
,
3818 _In_ HANDLE KeyHandle
,
3821 _In_ ULONG DataLength
3831 RtlGetDefaultCodePage(
3832 _Out_ PUSHORT AnsiCodePage
,
3833 _Out_ PUSHORT OemCodePage
3840 _In_ PUSHORT AnsiTableBase
,
3841 _In_ PUSHORT OemTableBase
,
3842 _In_ PUSHORT CaseTableBase
,
3843 _Out_ PNLSTABLEINFO NlsTable
3846 _IRQL_requires_max_(PASSIVE_LEVEL
)
3850 RtlInitCodePageTable(
3851 _In_ PUSHORT TableBase
,
3852 _Out_ PCPTABLEINFO CodePageTable
3858 RtlResetRtlTranslations(
3859 _In_ PNLSTABLEINFO NlsTable
);
3861 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3864 // Misc conversion functions
3869 RtlConvertLongToLargeInteger(
3870 _In_ LONG SignedInteger
3873 LARGE_INTEGER Result
;
3875 Result
.QuadPart
= SignedInteger
;
3882 RtlEnlargedIntegerMultiply(
3883 _In_ LONG Multiplicand
,
3884 _In_ LONG Multiplier
3887 LARGE_INTEGER Product
;
3889 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3896 RtlEnlargedUnsignedDivide(
3897 _In_ ULARGE_INTEGER Dividend
,
3899 _In_opt_ PULONG Remainder
3904 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
3906 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3915 RtlEnlargedUnsignedMultiply(
3916 _In_ ULONG Multiplicand
,
3917 _In_ ULONG Multiplier
3920 LARGE_INTEGER Product
;
3922 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3926 #if defined(_AMD64_) || defined(_IA64_)
3930 RtlExtendedLargeIntegerDivide(
3931 _In_ LARGE_INTEGER Dividend
,
3933 _Out_opt_ PULONG Remainder
)
3936 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3938 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3946 RtlExtendedLargeIntegerDivide(
3947 _In_ LARGE_INTEGER Dividend
,
3949 _Out_opt_ PULONG Remainder
3952 #endif /* defined(_AMD64_) || defined(_IA64_) */
3975 _In_ ULONG InitialCrc
,
3981 // Network Functions
3986 RtlIpv4StringToAddressW(
3988 _In_ BOOLEAN Strict
,
3989 _Out_ LPWSTR
*Terminator
,
3990 _Out_
struct in_addr
*Addr
3996 RtlIpv6StringToAddressA(
3998 _Out_ PCHAR
*Terminator
,
3999 _Out_
struct in6_addr
*Addr
4005 RtlIpv6StringToAddressW(
4007 _Out_ PCHAR
*Terminator
,
4008 _Out_
struct in6_addr
*Addr
4014 RtlIpv6StringToAddressExA(
4015 _In_ PCHAR AddressString
,
4016 _In_
struct in6_addr
*Address
,
4017 _In_ PULONG ScopeId
,
4024 RtlIpv6StringToAddressExW(
4025 _In_ PWCHAR AddressName
,
4026 _In_
struct in6_addr
*Address
,
4027 _In_ PULONG ScopeId
,
4038 RtlQueryTimeZoneInformation(
4039 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4044 RtlSecondsSince1970ToTime(
4045 _In_ ULONG SecondsSince1970
,
4046 _Out_ PLARGE_INTEGER Time
4052 RtlSetTimeZoneInformation(
4053 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4055 _Success_(return!=FALSE
)
4056 _Must_inspect_result_
4060 RtlTimeFieldsToTime(
4061 _In_ PTIME_FIELDS TimeFields
,
4062 _Out_ PLARGE_INTEGER Time
4065 _Success_(return != 0)
4066 _Must_inspect_result_
4070 RtlTimeToSecondsSince1970(
4071 _In_ PLARGE_INTEGER Time
,
4072 _Out_ PULONG ElapsedSeconds
4078 RtlTimeToTimeFields(
4079 PLARGE_INTEGER Time
,
4080 PTIME_FIELDS TimeFields
4086 RtlSystemTimeToLocalTime(
4087 _In_ PLARGE_INTEGER SystemTime
,
4088 _Out_ PLARGE_INTEGER LocalTime
4092 // Version Functions
4094 _IRQL_requires_max_(PASSIVE_LEVEL
)
4095 _Must_inspect_result_
4099 RtlVerifyVersionInfo(
4100 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4101 _In_ ULONG TypeMask
,
4102 _In_ ULONGLONG ConditionMask
4105 _IRQL_requires_max_(PASSIVE_LEVEL
)
4111 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4112 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4113 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4114 PRTL_OSVERSIONINFOW lpVersionInformation
4120 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4123 // Secure Memory Functions
4125 #ifdef NTOS_MODE_USER
4129 RtlRegisterSecureMemoryCacheCallback(
4130 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4135 RtlFlushSecureMemoryCache(
4136 _In_ PVOID MemoryCache
,
4137 _In_opt_ SIZE_T MemoryLength
4142 // Boot Status Data Functions
4144 #ifdef NTOS_MODE_USER
4148 RtlCreateBootStatusDataFile(
4155 RtlGetSetBootStatusData(
4156 _In_ HANDLE FileHandle
,
4157 _In_ BOOLEAN WriteMode
,
4158 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4160 _In_ ULONG BufferSize
,
4161 _Out_opt_ PULONG ReturnLength
4167 RtlLockBootStatusData(
4168 _Out_ PHANDLE FileHandle
4174 RtlUnlockBootStatusData(
4175 _In_ HANDLE FileHandle
4179 #ifdef NTOS_MODE_USER
4180 _Must_inspect_result_
4185 _In_ PUNICODE_STRING GuidString
,
4188 _Must_inspect_result_
4194 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4195 PUNICODE_STRING GuidString
);
4200 RtlComputeImportTableHash(
4203 _In_ ULONG ImportTableHashRevision
4208 // MemoryStream functions
4210 #ifdef NTOS_MODE_USER
4215 RtlInitMemoryStream(
4216 _Out_ PRTL_MEMORY_STREAM Stream
4222 RtlInitOutOfProcessMemoryStream(
4223 _Out_ PRTL_MEMORY_STREAM Stream
4229 RtlFinalReleaseOutOfProcessMemoryStream(
4230 _In_ PRTL_MEMORY_STREAM Stream
4236 RtlQueryInterfaceMemoryStream(
4237 _In_
struct IStream
*This
,
4238 _In_ REFIID RequestedIid
,
4239 _Outptr_ PVOID
*ResultObject
4245 RtlAddRefMemoryStream(
4246 _In_
struct IStream
*This
4252 RtlReleaseMemoryStream(
4253 _In_
struct IStream
*This
4259 RtlReadMemoryStream(
4260 _In_
struct IStream
*This
,
4261 _Out_writes_bytes_(Length
) PVOID Buffer
,
4263 _Out_opt_ PULONG BytesRead
4269 RtlReadOutOfProcessMemoryStream(
4270 _In_
struct IStream
*This
,
4271 _Out_writes_bytes_(Length
) PVOID Buffer
,
4273 _Out_opt_ PULONG BytesRead
4279 RtlSeekMemoryStream(
4280 _In_
struct IStream
*This
,
4281 _In_ LARGE_INTEGER RelativeOffset
,
4283 _Out_opt_ PULARGE_INTEGER ResultOffset
4289 RtlCopyMemoryStreamTo(
4290 _In_
struct IStream
*This
,
4291 _In_
struct IStream
*Target
,
4292 _In_ ULARGE_INTEGER Length
,
4293 _Out_opt_ PULARGE_INTEGER BytesRead
,
4294 _Out_opt_ PULARGE_INTEGER BytesWritten
4300 RtlCopyOutOfProcessMemoryStreamTo(
4301 _In_
struct IStream
*This
,
4302 _In_
struct IStream
*Target
,
4303 _In_ ULARGE_INTEGER Length
,
4304 _Out_opt_ PULARGE_INTEGER BytesRead
,
4305 _Out_opt_ PULARGE_INTEGER BytesWritten
4311 RtlStatMemoryStream(
4312 _In_
struct IStream
*This
,
4313 _Out_
struct tagSTATSTG
*Stats
,
4321 RtlWriteMemoryStream(
4322 _In_
struct IStream
*This
,
4323 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4325 _Out_opt_ PULONG BytesWritten
4331 RtlSetMemoryStreamSize(
4332 _In_
struct IStream
*This
,
4333 _In_ ULARGE_INTEGER NewSize
4339 RtlCommitMemoryStream(
4340 _In_
struct IStream
*This
,
4341 _In_ ULONG CommitFlags
4347 RtlRevertMemoryStream(
4348 _In_
struct IStream
*This
4354 RtlLockMemoryStreamRegion(
4355 _In_
struct IStream
*This
,
4356 _In_ ULARGE_INTEGER Offset
,
4357 _In_ ULARGE_INTEGER Length
,
4364 RtlUnlockMemoryStreamRegion(
4365 _In_
struct IStream
*This
,
4366 _In_ ULARGE_INTEGER Offset
,
4367 _In_ ULARGE_INTEGER Length
,
4374 RtlCloneMemoryStream(
4375 _In_
struct IStream
*This
,
4376 _Outptr_
struct IStream
**ResultStream
4379 #endif // NTOS_MODE_USER