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 // Exception and Error 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
643 RtlUnhandledExceptionFilter(
644 _In_
struct _EXCEPTION_POINTERS
* ExceptionInfo
664 RtlEncodeSystemPointer(
671 RtlDecodeSystemPointer(
685 RtlGetLastWin32Error(
692 RtlSetLastWin32Error(
699 RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
706 RtlSetThreadErrorMode(
708 _Out_opt_ PULONG OldMode
714 RtlGetThreadErrorMode(
718 #endif /* NTOS_MODE_USER */
724 _Out_ PCONTEXT ContextRecord
730 RtlDispatchException(
731 _In_ PEXCEPTION_RECORD ExceptionRecord
,
732 _In_ PCONTEXT Context
735 _IRQL_requires_max_(APC_LEVEL
)
736 _When_(Status
< 0, _Out_range_(>, 0))
737 _When_(Status
>= 0, _Out_range_(==, 0))
741 RtlNtStatusToDosError(
745 _When_(Status
< 0, _Out_range_(>, 0))
746 _When_(Status
>= 0, _Out_range_(==, 0))
750 RtlNtStatusToDosErrorNoTeb(
757 RtlMapSecurityErrorToNtStatus(
758 _In_ ULONG SecurityError
765 _In_ PEXCEPTION_RECORD ExceptionRecord
780 _In_opt_ PVOID TargetFrame
,
781 _In_opt_ PVOID TargetIp
,
782 _In_opt_ PEXCEPTION_RECORD ExceptionRecord
,
783 _In_ PVOID ReturnValue
786 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
795 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
)) PVOID
*Callers
,
803 RtlLogStackBackTrace(
807 #ifdef NTOS_MODE_USER
811 _Must_inspect_result_
813 _Post_writable_byte_size_(Size
)
818 _In_ PVOID HeapHandle
,
819 _In_opt_ ULONG Flags
,
823 _Must_inspect_result_
829 _In_opt_ PVOID BaseAddress
,
830 _In_opt_ SIZE_T SizeToReserve
,
831 _In_opt_ SIZE_T SizeToCommit
,
833 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
840 _In_ HANDLE HeapHandle
,
843 _In_ PWSTR TagSubName
853 _Must_inspect_result_
859 _In_opt_ PVOID BaseAddress
,
860 _In_opt_ SIZE_T SizeToReserve
,
861 _In_opt_ SIZE_T SizeToCommit
,
863 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
870 _In_ _Post_invalid_ HANDLE Heap
883 _Success_(return != 0)
888 _In_ HANDLE HeapHandle
,
889 _In_opt_ ULONG Flags
,
890 _In_ _Post_invalid_ PVOID P
896 _In_ ULONG HeapCount
,
897 _Out_cap_(HeapCount
) HANDLE
*HeapArray
900 _Success_(return != 0)
904 _In_ PVOID HeapHandle
,
906 _In_ PVOID BaseAddress
,
907 _Inout_opt_ PVOID
*UserValue
,
908 _Out_opt_ PULONG UserFlags
915 _In_ PVOID HeapHandle
,
922 RtlQueryHeapInformation(
923 _In_ PVOID HeapHandle
,
924 _In_ HEAP_INFORMATION_CLASS HeapInformationClass
,
925 _Out_ PVOID HeapInformation
,
926 _In_ SIZE_T HeapInformationLength
,
927 _When_(HeapInformationClass
==HeapCompatibilityInformation
, _On_failure_(_Out_opt_
))
928 _Out_opt_ PSIZE_T ReturnLength
936 _In_ PVOID HeapHandle
,
938 _In_ USHORT TagIndex
,
939 _In_ BOOLEAN ResetCounters
,
940 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
943 _Must_inspect_result_
945 _Post_writable_byte_size_(Size
)
951 _In_opt_ ULONG Flags
,
952 _In_ _Post_invalid_ PVOID Ptr
,
959 RtlSetHeapInformation(
960 _In_ PVOID HeapHandle
,
961 _In_ HEAP_INFORMATION_CLASS HeapInformationClass
,
962 _When_(HeapInformationClass
==HeapCompatibilityInformation
,_In_
) PVOID HeapInformation
,
963 _In_ SIZE_T HeapInformationLength
973 _Must_inspect_result_
977 RtlMultipleAllocateHeap (
978 _In_ HANDLE HeapHandle
,
982 _Out_cap_(Count
) _Deref_post_bytecap_(Size
) PVOID
* Array
988 RtlMultipleFreeHeap (
989 _In_ HANDLE HeapHandle
,
992 _In_count_(Count
) /* _Deref_ _Post_invalid_ */ PVOID
* Array
1001 _Out_ PRTL_HEAP_USAGE Usage
1013 RtlSetUserValueHeap(
1014 _In_ PVOID HeapHandle
,
1016 _In_ PVOID BaseAddress
,
1017 _In_ PVOID UserValue
1022 RtlSetUserFlagsHeap(
1023 _In_ PVOID HeapHandle
,
1025 _In_ PVOID BaseAddress
,
1026 _In_ ULONG UserFlagsReset
,
1027 _In_ ULONG UserFlagsSet
1043 _In_ HANDLE HeapHandle
,
1044 _In_ PVOID HeapEntry
1047 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1049 #endif // NTOS_MODE_USER
1055 _In_ PVOID HeapHandle
,
1057 _In_ PVOID MemoryPointer
1062 // Security Functions
1064 _IRQL_requires_max_(APC_LEVEL
)
1068 RtlAbsoluteToSelfRelativeSD(
1069 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
1070 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
1071 _Inout_ PULONG BufferLength
1074 _IRQL_requires_max_(APC_LEVEL
)
1078 RtlAddAccessAllowedAce(
1080 _In_ ULONG Revision
,
1081 _In_ ACCESS_MASK AccessMask
,
1085 _IRQL_requires_max_(APC_LEVEL
)
1089 RtlAddAccessAllowedAceEx(
1091 _In_ ULONG dwAceRevision
,
1092 _In_ ULONG AceFlags
,
1093 _In_ ACCESS_MASK AccessMask
,
1100 RtlAddAccessAllowedObjectAce(
1102 _In_ ULONG dwAceRevision
,
1103 _In_ ULONG AceFlags
,
1104 _In_ ACCESS_MASK AccessMask
,
1105 _In_opt_ GUID
*ObjectTypeGuid
,
1106 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1113 RtlAddAccessDeniedAce(
1115 _In_ ULONG Revision
,
1116 _In_ ACCESS_MASK AccessMask
,
1123 RtlAddAccessDeniedAceEx(
1125 _In_ ULONG Revision
,
1127 _In_ ACCESS_MASK AccessMask
,
1134 RtlAddAccessDeniedObjectAce(
1136 _In_ ULONG dwAceRevision
,
1137 _In_ ULONG AceFlags
,
1138 _In_ ACCESS_MASK AccessMask
,
1139 _In_opt_ GUID
*ObjectTypeGuid
,
1140 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1149 _In_ ULONG AceRevision
,
1150 _In_ ULONG StartingAceIndex
,
1151 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1152 _In_ ULONG AceListLength
1158 RtlAddAuditAccessAce(
1160 _In_ ULONG Revision
,
1161 _In_ ACCESS_MASK AccessMask
,
1163 _In_ BOOLEAN Success
,
1164 _In_ BOOLEAN Failure
1170 RtlAcquirePrivilege(
1171 _In_ PULONG Privilege
,
1174 _Out_ PVOID
*ReturnedState
1180 RtlAddAuditAccessAceEx(
1182 _In_ ULONG Revision
,
1184 _In_ ACCESS_MASK AccessMask
,
1186 _In_ BOOLEAN Success
,
1187 _In_ BOOLEAN Failure
1193 RtlAddAuditAccessObjectAce(
1195 _In_ ULONG Revision
,
1197 _In_ ACCESS_MASK AccessMask
,
1198 _In_opt_ GUID
*ObjectTypeGuid
,
1199 _In_opt_ GUID
*InheritedObjectTypeGuid
,
1201 _In_ BOOLEAN Success
,
1202 _In_ BOOLEAN Failure
1210 _In_ ULONG Revision
,
1212 _In_ ULONG MandatoryFlags
,
1214 _In_ PSID LabelSid
);
1220 _In_ ULONG Privilege
,
1221 _In_ BOOLEAN NewValue
,
1222 _In_ BOOLEAN ForThread
,
1223 _Out_ PBOOLEAN OldValue
1226 _Must_inspect_result_
1230 RtlAllocateAndInitializeSid(
1231 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1232 _In_ UCHAR SubAuthorityCount
,
1233 _In_ ULONG SubAuthority0
,
1234 _In_ ULONG SubAuthority1
,
1235 _In_ ULONG SubAuthority2
,
1236 _In_ ULONG SubAuthority3
,
1237 _In_ ULONG SubAuthority4
,
1238 _In_ ULONG SubAuthority5
,
1239 _In_ ULONG SubAuthority6
,
1240 _In_ ULONG SubAuthority7
,
1247 RtlAreAllAccessesGranted(
1248 ACCESS_MASK GrantedAccess
,
1249 ACCESS_MASK DesiredAccess
1255 RtlAreAnyAccessesGranted(
1256 ACCESS_MASK GrantedAccess
,
1257 ACCESS_MASK DesiredAccess
1260 _IRQL_requires_max_(APC_LEVEL
)
1265 _Out_ PLUID DestinationLuid
,
1266 _In_ PLUID SourceLuid
1272 RtlCopyLuidAndAttributesArray(
1274 PLUID_AND_ATTRIBUTES Src
,
1275 PLUID_AND_ATTRIBUTES Dest
1281 RtlCopySidAndAttributesArray(
1283 PSID_AND_ATTRIBUTES Src
,
1285 PSID_AND_ATTRIBUTES Dest
,
1287 PVOID
* RemainingSidArea
,
1288 PULONG RemainingSidAreaSize
1291 _IRQL_requires_max_(APC_LEVEL
)
1295 RtlConvertSidToUnicodeString(
1296 _Inout_ PUNICODE_STRING UnicodeString
,
1298 _In_ BOOLEAN AllocateDestinationString
1301 _IRQL_requires_max_(APC_LEVEL
)
1306 _In_ ULONG DestinationSidLength
,
1307 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1323 RtlCreateSecurityDescriptor(
1324 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1331 RtlCreateSecurityDescriptorRelative(
1332 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1339 RtlCopySecurityDescriptor(
1340 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor
,
1341 _Out_ PSECURITY_DESCRIPTOR
*pDestinationSecurityDescriptor
1380 _In_ _Post_invalid_ PSID Sid
1395 RtlGetControlSecurityDescriptor(
1396 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1397 _Out_ PSECURITY_DESCRIPTOR_CONTROL Control
,
1398 _Out_ PULONG Revision
1404 RtlGetDaclSecurityDescriptor(
1405 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1406 _Out_ PBOOLEAN DaclPresent
,
1408 _Out_ PBOOLEAN DaclDefaulted
1414 RtlGetSaclSecurityDescriptor(
1415 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1416 _Out_ PBOOLEAN SaclPresent
,
1418 _Out_ PBOOLEAN SaclDefaulted
1424 RtlGetGroupSecurityDescriptor(
1425 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1427 _Out_ PBOOLEAN GroupDefaulted
1433 RtlGetOwnerSecurityDescriptor(
1434 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1436 _Out_ PBOOLEAN OwnerDefaulted
1442 RtlGetSecurityDescriptorRMControl(
1443 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1444 _Out_ PUCHAR RMControl
1448 PSID_IDENTIFIER_AUTHORITY
1450 RtlIdentifierAuthoritySid(PSID Sid
);
1455 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
);
1457 _IRQL_requires_max_(APC_LEVEL
)
1463 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1464 _In_ UCHAR SubAuthorityCount
1470 RtlLengthRequiredSid(IN ULONG SubAuthorityCount
);
1475 RtlLengthSid(IN PSID Sid
);
1480 RtlMakeSelfRelativeSD(
1481 _In_ PSECURITY_DESCRIPTOR AbsoluteSD
,
1482 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1483 _Inout_ PULONG BufferLength
);
1489 PACCESS_MASK AccessMask
,
1490 PGENERIC_MAPPING GenericMapping
1493 #ifdef NTOS_MODE_USER
1498 RtlQueryInformationAcl(
1501 ULONG InformationLength
,
1502 ACL_INFORMATION_CLASS InformationClass
1510 RtlReleasePrivilege(
1511 _In_ PVOID ReturnedState
1514 _IRQL_requires_max_(APC_LEVEL
)
1518 RtlSelfRelativeToAbsoluteSD(
1519 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
1520 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
1521 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
1522 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
1523 _Inout_ PULONG DaclSize
,
1524 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
1525 _Inout_ PULONG SaclSize
,
1526 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
1527 _Inout_ PULONG OwnerSize
,
1528 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
1529 _Inout_ PULONG PrimaryGroupSize
1535 RtlSelfRelativeToAbsoluteSD2(
1536 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1537 _Out_ PULONG BufferSize
1543 RtlSetAttributesSecurityDescriptor(
1544 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1545 _In_ SECURITY_DESCRIPTOR_CONTROL Control
,
1546 _Out_ PULONG Revision
1552 RtlSetControlSecurityDescriptor(
1553 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1554 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
1555 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1558 _IRQL_requires_max_(APC_LEVEL
)
1562 RtlSetDaclSecurityDescriptor(
1563 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1564 _In_ BOOLEAN DaclPresent
,
1566 _In_opt_ BOOLEAN DaclDefaulted
1569 _IRQL_requires_max_(APC_LEVEL
)
1573 RtlSetGroupSecurityDescriptor(
1574 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1575 _In_opt_ PSID Group
,
1576 _In_opt_ BOOLEAN GroupDefaulted
1579 #ifdef NTOS_MODE_USER
1584 RtlSetInformationAcl(
1587 ULONG InformationLength
,
1588 ACL_INFORMATION_CLASS InformationClass
1593 _IRQL_requires_max_(APC_LEVEL
)
1597 RtlSetOwnerSecurityDescriptor(
1598 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1599 _In_opt_ PSID Owner
,
1600 _In_opt_ BOOLEAN OwnerDefaulted
1606 RtlSetSaclSecurityDescriptor(
1607 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1608 _In_ BOOLEAN SaclPresent
,
1610 _In_ BOOLEAN SaclDefaulted
1616 RtlSetSecurityDescriptorRMControl(
1617 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1618 _In_ PUCHAR RMControl
1624 RtlSubAuthorityCountSid(
1633 _In_ ULONG SubAuthority
1636 _IRQL_requires_max_(APC_LEVEL
)
1637 _Must_inspect_result_
1641 RtlValidRelativeSecurityDescriptor(
1642 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1643 _In_ ULONG SecurityDescriptorLength
,
1644 _In_ SECURITY_INFORMATION RequiredInformation
1650 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
1655 RtlValidSid(IN PSID Sid
);
1660 RtlValidAcl(PACL Acl
);
1665 RtlDeleteSecurityObject(
1666 _In_ PSECURITY_DESCRIPTOR
*ObjectDescriptor
1672 RtlNewSecurityObject(
1673 _In_ PSECURITY_DESCRIPTOR ParentDescriptor
,
1674 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor
,
1675 _Out_ PSECURITY_DESCRIPTOR
*NewDescriptor
,
1676 _In_ BOOLEAN IsDirectoryObject
,
1678 _In_ PGENERIC_MAPPING GenericMapping
1684 RtlQuerySecurityObject(
1685 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor
,
1686 _In_ SECURITY_INFORMATION SecurityInformation
,
1687 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor
,
1688 _In_ ULONG DescriptorLength
,
1689 _Out_ PULONG ReturnLength
1695 RtlSetSecurityObject(
1696 _In_ SECURITY_INFORMATION SecurityInformation
,
1697 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor
,
1698 _Out_ PSECURITY_DESCRIPTOR
*ObjectsSecurityDescriptor
,
1699 _In_ PGENERIC_MAPPING GenericMapping
,
1704 // Single-Character Functions
1709 RtlLargeIntegerToChar(
1710 _In_ PLARGE_INTEGER Value
,
1719 RtlUpperChar(CHAR Source
);
1724 RtlUpcaseUnicodeChar(WCHAR Source
);
1729 RtlDowncaseUnicodeChar(IN WCHAR Source
);
1744 RtlIntegerToUnicode(
1746 _In_opt_ ULONG Base
,
1747 _In_opt_ ULONG Length
,
1748 _Inout_ LPWSTR String
1751 _IRQL_requires_max_(PASSIVE_LEVEL
)
1752 _At_(String
->MaximumLength
, _Const_
)
1756 RtlIntegerToUnicodeString(
1758 _In_opt_ ULONG Base
,
1759 _Inout_ PUNICODE_STRING String
1772 // Byte Swap Functions
1774 #ifdef NTOS_MODE_USER
1776 unsigned short __cdecl
_byteswap_ushort(unsigned short);
1777 unsigned long __cdecl
_byteswap_ulong (unsigned long);
1778 unsigned __int64 __cdecl
_byteswap_uint64(unsigned __int64
);
1780 #pragma intrinsic(_byteswap_ushort)
1781 #pragma intrinsic(_byteswap_ulong)
1782 #pragma intrinsic(_byteswap_uint64)
1784 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1785 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1786 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1788 #endif // NTOS_MODE_USER
1791 // Unicode->Ansi String Functions
1796 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString
);
1798 #ifdef NTOS_MODE_USER
1800 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1801 NLS_MB_CODE_PAGE_TAG ? \
1802 RtlxUnicodeStringToAnsiSize(STRING) : \
1803 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1811 RtlUnicodeStringToAnsiString(
1812 PANSI_STRING DestinationString
,
1813 PCUNICODE_STRING SourceString
,
1814 BOOLEAN AllocateDestinationString
1818 // Unicode->OEM String Functions
1823 RtlUpcaseUnicodeStringToOemString(
1824 POEM_STRING DestinationString
,
1825 PCUNICODE_STRING SourceString
,
1826 BOOLEAN AllocateDestinationString
1829 _IRQL_requires_max_(PASSIVE_LEVEL
)
1830 _Must_inspect_result_
1831 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1835 RtlUpcaseUnicodeStringToCountedOemString(
1836 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1837 _When_(!AllocateDestinationString
, _Inout_
)
1838 POEM_STRING DestinationString
,
1839 _In_ PCUNICODE_STRING SourceString
,
1840 _In_ BOOLEAN AllocateDestinationString
1846 RtlUnicodeStringToOemString(
1847 POEM_STRING DestinationString
,
1848 PCUNICODE_STRING SourceString
,
1849 BOOLEAN AllocateDestinationString
1855 RtlUpcaseUnicodeToOemN(
1859 PCWCH UnicodeString
,
1866 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString
);
1868 #ifdef NTOS_MODE_USER
1870 #define RtlUnicodeStringToOemSize(STRING) ( \
1871 NLS_MB_OEM_CODE_PAGE_TAG ? \
1872 RtlxUnicodeStringToOemSize(STRING) : \
1873 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1876 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1877 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1889 PCWCH UnicodeString
,
1894 // Unicode->MultiByte String Functions
1899 RtlUnicodeToMultiByteN(
1903 PCWCH UnicodeString
,
1910 RtlUpcaseUnicodeToMultiByteN(
1914 PCWCH UnicodeString
,
1921 RtlUnicodeToMultiByteSize(
1923 PCWCH UnicodeString
,
1930 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString
);
1933 // OEM to Unicode Functions
1938 RtlOemStringToUnicodeString(
1939 PUNICODE_STRING DestinationString
,
1940 PCOEM_STRING SourceString
,
1941 BOOLEAN AllocateDestinationString
1944 _IRQL_requires_max_(PASSIVE_LEVEL
)
1949 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1950 _In_ ULONG MaxBytesInUnicodeString
,
1951 _Out_opt_ PULONG BytesInUnicodeString
,
1952 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1953 _In_ ULONG BytesInOemString
1956 #ifdef NTOS_MODE_USER
1958 #define RtlOemStringToUnicodeSize(STRING) ( \
1959 NLS_MB_OEM_CODE_PAGE_TAG ? \
1960 RtlxOemStringToUnicodeSize(STRING) : \
1961 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1964 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1965 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1971 // Ansi->Unicode String Functions
1973 _IRQL_requires_max_(APC_LEVEL
)
1977 RtlAnsiCharToUnicodeChar(
1978 _Inout_ PUCHAR
*SourceCharacter
);
1983 RtlAnsiStringToUnicodeString(
1984 PUNICODE_STRING DestinationString
,
1985 PCANSI_STRING SourceString
,
1986 BOOLEAN AllocateDestinationString
1992 RtlxAnsiStringToUnicodeSize(
1993 PCANSI_STRING AnsiString
1996 #ifdef NTOS_MODE_USER
1998 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1999 NLS_MB_CODE_PAGE_TAG ? \
2000 RtlxAnsiStringToUnicodeSize(STRING) : \
2001 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2009 RtlCreateUnicodeStringFromAsciiz(
2010 _Out_ PUNICODE_STRING Destination
,
2015 // Unicode String Functions
2020 RtlAppendUnicodeToString(
2021 PUNICODE_STRING Destination
,
2028 RtlAppendUnicodeStringToString(
2029 PUNICODE_STRING Destination
,
2030 PCUNICODE_STRING Source
2036 RtlCompareUnicodeString(
2037 PCUNICODE_STRING String1
,
2038 PCUNICODE_STRING String2
,
2039 BOOLEAN CaseInsensitive
2045 RtlCopyUnicodeString(
2046 PUNICODE_STRING DestinationString
,
2047 PCUNICODE_STRING SourceString
2053 RtlCreateUnicodeString(
2054 PUNICODE_STRING DestinationString
,
2058 #ifdef NTOS_MODE_USER
2063 RtlDowncaseUnicodeString(
2064 _Inout_ PUNICODE_STRING UniDest
,
2065 _In_ PCUNICODE_STRING UniSource
,
2066 _In_ BOOLEAN AllocateDestinationString
2072 RtlDuplicateUnicodeString(
2074 _In_ PCUNICODE_STRING SourceString
,
2075 _Out_ PUNICODE_STRING DestinationString
2085 _In_ PVOID Destination
,
2093 RtlFillMemoryUlonglong(
2094 _Out_ PVOID Destination
,
2096 _In_ ULONGLONG Pattern
2102 RtlCopyMappedMemory(
2103 _Out_writes_bytes_all_(Size
) PVOID Destination
,
2104 _In_reads_bytes_(Size
) const VOID
*Source
,
2111 RtlCompareMemoryUlong(
2117 #ifndef RtlEqualMemory
2118 #define RtlEqualMemory(Destination, Source, Length) \
2119 (!memcmp(Destination, Source, Length))
2122 #define RtlCopyBytes RtlCopyMemory
2123 #define RtlFillBytes RtlFillMemory
2124 #define RtlZeroBytes RtlZeroMemory
2131 RtlEqualUnicodeString(
2132 PCUNICODE_STRING String1
,
2133 PCUNICODE_STRING String2
,
2134 BOOLEAN CaseInsensitive
2140 RtlFindCharInUnicodeString(
2142 _In_ PCUNICODE_STRING SearchString
,
2143 _In_ PCUNICODE_STRING MatchString
,
2144 _Out_ PUSHORT Position
2147 _IRQL_requires_max_(PASSIVE_LEVEL
)
2151 RtlFreeUnicodeString(
2152 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
2153 PUNICODE_STRING UnicodeString
2159 RtlEraseUnicodeString(
2160 _Inout_ PUNICODE_STRING String
2166 RtlHashUnicodeString(
2167 _In_ CONST UNICODE_STRING
*String
,
2168 _In_ BOOLEAN CaseInSensitive
,
2169 _In_ ULONG HashAlgorithm
,
2170 _Out_ PULONG HashValue
2173 _IRQL_requires_max_(DISPATCH_LEVEL
)
2174 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2175 _When_(SourceString
!= NULL
,
2176 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2177 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2178 _When_(SourceString
== NULL
,
2179 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2180 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2184 RtlInitUnicodeString(
2185 _Out_ PUNICODE_STRING DestinationString
,
2186 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2189 _IRQL_requires_max_(DISPATCH_LEVEL
)
2193 RtlInitUnicodeStringEx(
2194 _Out_ PUNICODE_STRING DestinationString
,
2195 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2207 _IRQL_requires_max_(PASSIVE_LEVEL
)
2208 _Must_inspect_result_
2213 _In_
const STRING
*String1
,
2214 _In_
const STRING
*String2
,
2215 _In_ BOOLEAN CaseInsensitive
2218 _IRQL_requires_max_(PASSIVE_LEVEL
)
2219 _Must_inspect_result_
2223 RtlPrefixUnicodeString(
2224 _In_ PCUNICODE_STRING String1
,
2225 _In_ PCUNICODE_STRING String2
,
2226 _In_ BOOLEAN CaseInsensitive
2229 _IRQL_requires_max_(PASSIVE_LEVEL
)
2234 _Inout_ PSTRING DestinationString
,
2235 _In_
const STRING
*SourceString
2238 _IRQL_requires_max_(PASSIVE_LEVEL
)
2239 _Must_inspect_result_
2244 _In_
const STRING
*String1
,
2245 _In_
const STRING
*String2
,
2246 _In_ BOOLEAN CaseInSensitive
2253 _Out_ PSTRING DestinationString
,
2254 _In_opt_
const STRING
*SourceString
2257 _IRQL_requires_max_(PASSIVE_LEVEL
)
2258 _Must_inspect_result_
2263 _In_
const STRING
*String1
,
2264 _In_
const STRING
*String2
,
2265 _In_ BOOLEAN CaseInSensitive
2268 _IRQL_requires_max_(APC_LEVEL
)
2272 RtlAppendStringToString(
2273 _Inout_ PSTRING Destination
,
2274 _In_
const STRING
*Source
2277 _IRQL_requires_max_(PASSIVE_LEVEL
)
2278 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2282 RtlUpcaseUnicodeString(
2283 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2284 _When_(!AllocateDestinationString
, _Inout_
)
2285 PUNICODE_STRING DestinationString
,
2286 _In_ PCUNICODE_STRING SourceString
,
2287 _In_ BOOLEAN AllocateDestinationString
2290 _IRQL_requires_max_(PASSIVE_LEVEL
)
2294 RtlUnicodeStringToInteger(
2295 _In_ PCUNICODE_STRING String
,
2296 _In_opt_ ULONG Base
,
2303 RtlValidateUnicodeString(
2305 _In_ PCUNICODE_STRING String
2309 // Ansi String Functions
2311 _IRQL_requires_max_(PASSIVE_LEVEL
)
2316 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2317 PANSI_STRING AnsiString
2320 _IRQL_requires_max_(DISPATCH_LEVEL
)
2325 _Out_ PANSI_STRING DestinationString
,
2326 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2329 _IRQL_requires_max_(DISPATCH_LEVEL
)
2333 RtlInitAnsiStringEx(
2334 _Out_ PANSI_STRING DestinationString
,
2335 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2339 // OEM String Functions
2341 _IRQL_requires_max_(PASSIVE_LEVEL
)
2346 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2347 POEM_STRING OemString
2351 // MultiByte->Unicode String Functions
2353 _IRQL_requires_max_(PASSIVE_LEVEL
)
2357 RtlMultiByteToUnicodeN(
2358 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2359 _In_ ULONG MaxBytesInUnicodeString
,
2360 _Out_opt_ PULONG BytesInUnicodeString
,
2361 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2362 _In_ ULONG BytesInMultiByteString
2365 _IRQL_requires_max_(PASSIVE_LEVEL
)
2369 RtlMultiByteToUnicodeSize(
2370 _Out_ PULONG BytesInUnicodeString
,
2371 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2372 _In_ ULONG BytesInMultiByteString
2381 RtlAddAtomToAtomTable(
2382 _In_ PRTL_ATOM_TABLE AtomTable
,
2383 _In_ PWSTR AtomName
,
2384 _Out_ PRTL_ATOM Atom
2391 _In_ ULONG TableSize
,
2392 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2398 RtlDeleteAtomFromAtomTable(
2399 _In_ PRTL_ATOM_TABLE AtomTable
,
2406 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2411 RtlQueryAtomInAtomTable(
2412 _In_ PRTL_ATOM_TABLE AtomTable
,
2414 _Out_opt_ PULONG RefCount
,
2415 _Out_opt_ PULONG PinCount
,
2416 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2417 _Inout_opt_ PULONG NameLength
2423 RtlPinAtomInAtomTable(
2424 _In_ PRTL_ATOM_TABLE AtomTable
,
2431 RtlLookupAtomInAtomTable(
2432 _In_ PRTL_ATOM_TABLE AtomTable
,
2433 _In_ PWSTR AtomName
,
2434 _Out_ PRTL_ATOM Atom
2438 // Process Management Functions
2450 RtlAcquirePebLock(VOID
);
2455 RtlCreateProcessParameters (
2456 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2457 _In_ PUNICODE_STRING ImagePathName
,
2458 _In_opt_ PUNICODE_STRING DllPath
,
2459 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2460 _In_opt_ PUNICODE_STRING CommandLine
,
2461 _In_opt_ PWSTR Environment
,
2462 _In_opt_ PUNICODE_STRING WindowTitle
,
2463 _In_opt_ PUNICODE_STRING DesktopInfo
,
2464 _In_opt_ PUNICODE_STRING ShellInfo
,
2465 _In_opt_ PUNICODE_STRING RuntimeInfo
2471 RtlCreateUserProcess(
2472 _In_ PUNICODE_STRING ImageFileName
,
2473 _In_ ULONG Attributes
,
2474 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2475 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2476 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2477 _In_opt_ HANDLE ParentProcess
,
2478 _In_ BOOLEAN CurrentDirectory
,
2479 _In_opt_ HANDLE DebugPort
,
2480 _In_opt_ HANDLE ExceptionPort
,
2481 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2484 #if (NTDDI_VERSION >= NTDDI_WIN7)
2488 RtlCreateUserThread(
2489 _In_ PVOID ThreadContext
,
2490 _Out_ HANDLE
*OutThreadHandle
,
2491 _Reserved_ PVOID Reserved1
,
2492 _Reserved_ PVOID Reserved2
,
2493 _Reserved_ PVOID Reserved3
,
2494 _Reserved_ PVOID Reserved4
,
2495 _Reserved_ PVOID Reserved5
,
2496 _Reserved_ PVOID Reserved6
,
2497 _Reserved_ PVOID Reserved7
,
2498 _Reserved_ PVOID Reserved8
2504 RtlCreateUserThread(
2505 _In_ HANDLE ProcessHandle
,
2506 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2507 _In_ BOOLEAN CreateSuspended
,
2508 _In_ ULONG StackZeroBits
,
2509 _In_ SIZE_T StackReserve
,
2510 _In_ SIZE_T StackCommit
,
2511 _In_ PTHREAD_START_ROUTINE StartAddress
,
2512 _In_ PVOID Parameter
,
2513 _Out_opt_ PHANDLE ThreadHandle
,
2514 _Out_opt_ PCLIENT_ID ClientId
2519 PRTL_USER_PROCESS_PARAMETERS
2521 RtlDeNormalizeProcessParams(
2522 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2527 RtlDestroyProcessParameters(
2528 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2534 _In_ NTSTATUS Status
);
2539 RtlInitializeContext(
2540 _In_ HANDLE ProcessHandle
,
2541 _Out_ PCONTEXT ThreadContext
,
2542 _In_opt_ PVOID ThreadStartParam
,
2543 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2544 _In_ PINITIAL_TEB InitialTeb
2548 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2553 RtlWow64GetThreadContext(
2554 _In_ HANDLE ThreadHandle
,
2555 _Inout_ PWOW64_CONTEXT ThreadContext
2562 RtlWow64SetThreadContext(
2563 _In_ HANDLE ThreadHandle
,
2564 _In_ PWOW64_CONTEXT ThreadContext
2571 RtlIsThreadWithinLoaderCallout(VOID
);
2574 PRTL_USER_PROCESS_PARAMETERS
2576 RtlNormalizeProcessParams(
2577 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2582 RtlReleasePebLock(VOID
);
2588 _In_ HANDLE Process
,
2590 _In_ PVOID CallSite
,
2591 _In_ ULONG ArgumentCount
,
2592 _In_ PULONG Arguments
,
2593 _In_ BOOLEAN PassContext
,
2594 _In_ BOOLEAN AlreadySuspended
2600 RtlSetProcessIsCritical(
2601 _In_ BOOLEAN NewValue
,
2602 _Out_opt_ PBOOLEAN OldValue
,
2603 _In_ BOOLEAN NeedBreaks
2609 RtlSetThreadIsCritical(
2610 _In_ BOOLEAN NewValue
,
2611 _Out_opt_ PBOOLEAN OldValue
,
2612 _In_ BOOLEAN NeedBreaks
2618 RtlGetCurrentProcessorNumber(
2622 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2625 // Thread Pool Functions
2630 RtlSetThreadPoolStartFunc(
2631 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2632 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2638 RtlDeregisterWaitEx(
2639 _In_ HANDLE hWaitHandle
,
2640 _In_opt_ HANDLE hCompletionEvent
2647 _In_ HANDLE hWaitHandle
2654 _In_ WORKERCALLBACKFUNC Function
,
2655 _In_opt_ PVOID Context
,
2662 RtlSetIoCompletionCallback(
2663 _In_ HANDLE FileHandle
,
2664 _In_ PIO_APC_ROUTINE Callback
,
2672 _In_ PHANDLE phNewWaitObject
,
2673 _In_ HANDLE hObject
,
2674 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2675 _In_ PVOID pvContext
,
2676 _In_ ULONG ulMilliseconds
,
2681 // Environment/Path Functions
2686 RtlCreateEnvironment(
2687 _In_ BOOLEAN Inherit
,
2688 _Out_ PWSTR
*Environment
2694 RtlComputePrivatizedDllName_U(
2695 _In_ PUNICODE_STRING DllName
,
2696 _Out_ PUNICODE_STRING RealName
,
2697 _Out_ PUNICODE_STRING LocalName
2703 RtlDestroyEnvironment(
2704 _In_ PWSTR Environment
2710 RtlDoesFileExists_U(
2711 _In_ PCWSTR FileName
2717 RtlDetermineDosPathNameType_U(
2726 _In_ PCWSTR FileName
,
2727 _In_ PCWSTR Extension
,
2728 _In_ ULONG BufferSize
,
2730 _Out_ PWSTR
*PartName
2736 RtlDosSearchPath_Ustr(
2738 _In_ PUNICODE_STRING PathString
,
2739 _In_ PUNICODE_STRING FileNameString
,
2740 _In_ PUNICODE_STRING ExtensionString
,
2741 _In_ PUNICODE_STRING CallerBuffer
,
2742 _Inout_opt_ PUNICODE_STRING DynamicString
,
2743 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2744 _Out_opt_ PSIZE_T FilePartSize
,
2745 _Out_opt_ PSIZE_T LengthNeeded
2751 RtlDosPathNameToNtPathName_U(
2752 _In_opt_z_ PCWSTR DosPathName
,
2753 _Out_ PUNICODE_STRING NtPathName
,
2754 _Out_opt_ PCWSTR
*NtFileNamePart
,
2755 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2761 RtlDosPathNameToRelativeNtPathName_U(
2762 _In_ PCWSTR DosName
,
2763 _Out_ PUNICODE_STRING NtName
,
2764 _Out_ PCWSTR
*PartName
,
2765 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2768 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2772 RtlExpandEnvironmentStrings_U(
2773 _In_z_ PWSTR Environment
,
2774 _In_ PUNICODE_STRING Source
,
2775 _Inout_ PUNICODE_STRING Destination
,
2782 RtlGetCurrentDirectory_U(
2783 _In_ ULONG MaximumLength
,
2784 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2790 RtlGetFullPathName_U(
2791 _In_ PCWSTR FileName
,
2793 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2794 _Out_opt_ PWSTR
*ShortName
2797 #if (NTDDI_VERSION >= NTDDI_WIN7)
2801 RtlGetFullPathName_UEx(
2802 _In_ PWSTR FileName
,
2803 _In_ ULONG BufferLength
,
2805 _Out_opt_ PWSTR
*FilePart
,
2806 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2812 RtlGetFullPathName_UstrEx(
2813 _In_ PUNICODE_STRING FileName
,
2814 _In_opt_ PUNICODE_STRING StaticString
,
2815 _In_opt_ PUNICODE_STRING DynamicString
,
2816 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2817 _Out_opt_ PSIZE_T FilePartSize
,
2818 _Out_opt_ PBOOLEAN NameInvalid
,
2819 _Out_ RTL_PATH_TYPE
* PathType
,
2820 _Out_opt_ PSIZE_T LengthNeeded
2826 RtlGetLengthWithoutTrailingPathSeperators(
2827 _Reserved_ ULONG Flags
,
2828 _In_ PCUNICODE_STRING PathString
,
2835 RtlGetLongestNtPathLength(
2842 RtlIsDosDeviceName_U(
2849 RtlIsDosDeviceName_Ustr(
2850 _In_ PCUNICODE_STRING Name
2853 _IRQL_requires_max_(PASSIVE_LEVEL
)
2854 _Must_inspect_result_
2858 RtlIsNameLegalDOS8Dot3(
2859 _In_ PCUNICODE_STRING Name
,
2860 _Inout_opt_ POEM_STRING OemName
,
2861 _Out_opt_ PBOOLEAN NameContainsSpaces
2867 RtlQueryEnvironmentVariable_U(
2868 _In_opt_ PWSTR Environment
,
2869 _In_ PUNICODE_STRING Name
,
2870 _Out_ PUNICODE_STRING Value
2875 RtlReleaseRelativeName(
2876 _In_ PRTL_RELATIVE_NAME_U RelativeName
2882 RtlSetCurrentDirectory_U(
2883 _In_ PUNICODE_STRING name
2889 RtlSetEnvironmentVariable(
2890 _In_z_ PWSTR
*Environment
,
2891 _In_ PUNICODE_STRING Name
,
2892 _In_ PUNICODE_STRING Value
2896 // Critical Section/Resource Functions
2901 RtlDeleteCriticalSection (
2902 _In_ PRTL_CRITICAL_SECTION CriticalSection
2908 RtlEnterCriticalSection(
2909 _In_ PRTL_CRITICAL_SECTION CriticalSection
2915 RtlInitializeCriticalSection(
2916 _In_ PRTL_CRITICAL_SECTION CriticalSection
2922 RtlInitializeCriticalSectionAndSpinCount(
2923 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2924 _In_ ULONG SpinCount
2930 RtlLeaveCriticalSection(
2931 _In_ PRTL_CRITICAL_SECTION CriticalSection
2937 RtlTryEnterCriticalSection(
2938 _In_ PRTL_CRITICAL_SECTION CriticalSection
2944 RtlpUnWaitCriticalSection(
2945 _In_ PRTL_CRITICAL_SECTION CriticalSection
2951 RtlpWaitForCriticalSection(
2952 _In_ PRTL_CRITICAL_SECTION CriticalSection
2958 RtlAcquireResourceExclusive(
2959 _In_ PRTL_RESOURCE Resource
,
2966 RtlAcquireResourceShared(
2967 _In_ PRTL_RESOURCE Resource
,
2974 RtlConvertExclusiveToShared(
2975 _In_ PRTL_RESOURCE Resource
2981 RtlConvertSharedToExclusive(
2982 _In_ PRTL_RESOURCE Resource
2989 _In_ PRTL_RESOURCE Resource
2996 _In_ PRTL_RESOURCE Resource
3002 RtlInitializeResource(
3003 _In_ PRTL_RESOURCE Resource
3010 _In_ PRTL_RESOURCE Resource
3014 // Compression Functions
3016 NTSYSAPI
//NT_RTL_COMPRESS_API
3020 _In_ USHORT CompressionFormatAndEngine
,
3021 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
3022 _In_ ULONG UncompressedBufferSize
,
3023 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
3024 _In_ ULONG CompressedBufferSize
,
3025 _In_ ULONG UncompressedChunkSize
,
3026 _Out_ PULONG FinalCompressedSize
,
3027 _In_ PVOID WorkSpace
3030 _IRQL_requires_max_(APC_LEVEL
)
3031 NTSYSAPI
//NT_RTL_COMPRESS_API
3034 RtlDecompressBuffer(
3035 _In_ USHORT CompressionFormat
,
3036 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
3037 _In_ ULONG UncompressedBufferSize
,
3038 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
3039 _In_ ULONG CompressedBufferSize
,
3040 _Out_ PULONG FinalUncompressedSize
3046 RtlGetCompressionWorkSpaceSize(
3047 _In_ USHORT CompressionFormatAndEngine
,
3048 _Out_ PULONG CompressBufferWorkSpaceSize
,
3049 _Out_ PULONG CompressFragmentWorkSpaceSize
3059 _In_ PTEB_ACTIVE_FRAME Frame
3066 _In_ PTEB_ACTIVE_FRAME Frame
3077 // Debug Info Functions
3080 PRTL_DEBUG_INFORMATION
3082 RtlCreateQueryDebugBuffer(
3084 _In_ BOOLEAN EventPair
3090 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3095 RtlQueryProcessDebugInformation(
3096 _In_ ULONG ProcessId
,
3097 _In_ ULONG DebugInfoClassMask
,
3098 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3108 _In_ PRTL_BITMAP BitMapHeader
,
3109 _In_ ULONG StartingIndex
,
3117 _In_ PRTL_BITMAP BitMapHeader
,
3118 _In_ ULONG StartingIndex
,
3126 _In_ PRTL_BITMAP BitMapHeader
3133 _In_ PRTL_BITMAP BitMapHeader
,
3134 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3135 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3142 _In_ PRTL_BITMAP BitMapHeader
,
3143 _In_ ULONG NumberToFind
,
3144 _In_ ULONG HintIndex
3150 RtlFindClearBitsAndSet(
3151 _In_ PRTL_BITMAP BitMapHeader
,
3152 _In_ ULONG NumberToFind
,
3153 _In_ ULONG HintIndex
3159 RtlFindFirstRunClear(
3160 _In_ PRTL_BITMAP BitMapHeader
,
3161 _Out_ PULONG StartingIndex
3168 _In_ PRTL_BITMAP BitMapHeader
,
3169 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
3170 _In_range_(>, 0) ULONG SizeOfRunArray
,
3171 _In_ BOOLEAN LocateLongestRuns
3177 RtlFindLastBackwardRunClear(
3178 _In_ PRTL_BITMAP BitMapHeader
,
3179 _In_ ULONG FromIndex
,
3180 _Out_ PULONG StartingRunIndex
3186 RtlFindLeastSignificantBit(
3187 _In_ ULONGLONG Value
3193 RtlFindMostSignificantBit(
3194 _In_ ULONGLONG Value
3200 RtlFindNextForwardRunClear(
3201 _In_ PRTL_BITMAP BitMapHeader
,
3202 _In_ ULONG FromIndex
,
3203 _Out_ PULONG StartingRunIndex
3209 RtlFindNextForwardRunSet(
3210 _In_ PRTL_BITMAP BitMapHeader
,
3211 _In_ ULONG FromIndex
,
3212 _Out_ PULONG StartingRunIndex
3219 _In_ PRTL_BITMAP BitMapHeader
,
3220 _In_ ULONG NumberToFind
,
3221 _In_ ULONG HintIndex
3227 RtlFindSetBitsAndClear(
3228 _In_ PRTL_BITMAP BitMapHeader
,
3229 _In_ ULONG NumberToFind
,
3230 _In_ ULONG HintIndex
3233 #ifdef _REACTOS_ // ReactOS improvement
3234 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3235 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3240 RtlInitializeBitMap(
3241 _Out_ PRTL_BITMAP BitMapHeader
,
3242 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3243 _In_opt_ ULONG SizeOfBitMap
3249 RtlNumberOfClearBits(
3250 _In_ PRTL_BITMAP BitMapHeader
3257 _In_ PRTL_BITMAP BitMapHeader
3264 _In_ PRTL_BITMAP BitMapHeader
,
3265 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3272 _In_ PRTL_BITMAP BitMapHeader
,
3273 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3274 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3281 _In_ PRTL_BITMAP BitMapHeader
3284 _Must_inspect_result_
3289 _In_ PRTL_BITMAP BitMapHeader
,
3290 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3300 _In_ HANDLE TimerQueue
,
3301 _In_ PHANDLE phNewTimer
,
3302 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3303 _In_ PVOID Parameter
,
3312 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3318 _In_ HANDLE TimerQueue
,
3320 _In_ HANDLE CompletionEvent
3327 _In_ HANDLE TimerQueue
,
3336 RtlDeleteTimerQueueEx(
3337 _In_ HANDLE TimerQueue
,
3338 _In_opt_ HANDLE CompletionEvent
3344 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3351 InterlockedPushListSList(
3352 _Inout_ PSLIST_HEADER ListHead
,
3353 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3354 _Inout_ PSLIST_ENTRY ListEnd
,
3359 // Range List functions
3364 RtlInitializeRangeList(
3365 _Inout_ PRTL_RANGE_LIST RangeList
3372 _In_ PRTL_RANGE_LIST RangeList
3379 _Inout_ PRTL_RANGE_LIST RangeList
,
3380 _In_ ULONGLONG Start
,
3382 _In_ UCHAR Attributes
,
3384 _In_opt_ PVOID UserData
,
3385 _In_opt_ PVOID Owner
3394 _In_z_ _Printf_format_string_ PCSTR Format
,
3402 _In_ ULONG ComponentId
,
3404 _In_z_ _Printf_format_string_ PCSTR Format
,
3413 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3414 _In_ ULONG MaximumResponseLength
3417 #undef DbgBreakPoint
3426 DbgLoadImageSymbols(
3429 _In_ ULONG_PTR ProcessId
3434 DbgUnLoadImageSymbols(
3437 _In_ ULONG_PTR ProcessId
3448 // Generic Table Functions
3450 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3454 RtlInsertElementGenericTable(
3455 _In_ PRTL_GENERIC_TABLE Table
,
3456 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3457 _In_ CLONG BufferSize
,
3458 _Out_opt_ PBOOLEAN NewElement
3464 RtlInsertElementGenericTableFull(
3465 _In_ PRTL_GENERIC_TABLE Table
,
3466 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3467 _In_ CLONG BufferSize
,
3468 _Out_opt_ PBOOLEAN NewElement
,
3469 _In_ PVOID NodeOrParent
,
3470 _In_ TABLE_SEARCH_RESULT SearchResult
3476 RtlIsGenericTableEmpty(
3477 _In_ PRTL_GENERIC_TABLE Table
3483 RtlLookupElementGenericTableFull(
3484 _In_ PRTL_GENERIC_TABLE Table
,
3486 _Out_ PVOID
*NodeOrParent
,
3487 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3492 // Handle Table Functions
3495 PRTL_HANDLE_TABLE_ENTRY
3498 _In_ PRTL_HANDLE_TABLE HandleTable
,
3499 _Inout_ PULONG Index
3505 RtlDestroyHandleTable(
3506 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3512 _In_ PRTL_HANDLE_TABLE HandleTable
,
3513 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3519 RtlInitializeHandleTable(
3520 _In_ ULONG TableSize
,
3521 _In_ ULONG HandleSize
,
3522 _In_ PRTL_HANDLE_TABLE HandleTable
3529 _In_ PRTL_HANDLE_TABLE HandleTable
,
3530 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3533 _Success_(return!=FALSE
)
3537 RtlIsValidIndexHandle(
3538 _In_ PRTL_HANDLE_TABLE HandleTable
,
3540 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3550 _In_ PVOID BaseAddress
,
3552 _In_ ULONG Language
,
3553 _In_ ULONG MessageId
,
3554 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3560 RtlGetNtGlobalFlags(VOID
);
3562 _Success_(return!=NULL
)
3566 RtlImageDirectoryEntryToData(
3567 _In_ PVOID BaseAddress
,
3568 _In_ BOOLEAN MappedAsImage
,
3569 _In_ USHORT Directory
,
3577 _In_ PIMAGE_NT_HEADERS NtHeader
,
3578 _In_ PVOID BaseAddress
,
3580 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3587 _In_ PVOID BaseAddress
);
3594 _In_ PVOID BaseAddress
,
3595 _In_ ULONGLONG Size
,
3596 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3600 PIMAGE_SECTION_HEADER
3602 RtlImageRvaToSection(
3603 _In_ PIMAGE_NT_HEADERS NtHeader
,
3604 _In_ PVOID BaseAddress
,
3611 LdrRelocateImageWithBias(
3612 _In_ PVOID NewAddress
,
3613 _In_ LONGLONG AdditionalBias
,
3614 _In_ PCCH LoaderName
,
3616 _In_ ULONG Conflict
,
3621 // Activation Context Functions
3623 #ifdef NTOS_MODE_USER
3627 RtlActivateActivationContextEx(
3631 _Out_ PULONG_PTR Cookie
3637 RtlActivateActivationContext(
3640 _Out_ PULONG_PTR Cookie
3646 RtlAddRefActivationContext(
3651 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3653 RtlActivateActivationContextUnsafeFast(
3654 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3661 RtlAllocateActivationContextStack(
3662 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3668 RtlCreateActivationContext(
3670 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3671 _In_ ULONG ExtraBytes
,
3672 _In_ PVOID NotificationRoutine
,
3673 _In_ PVOID NotificationContext
,
3674 _Out_ PACTIVATION_CONTEXT
*ActCtx
3680 RtlGetActiveActivationContext(
3687 RtlReleaseActivationContext(
3694 RtlDeactivateActivationContext(
3696 _In_ ULONG_PTR ulCookie
3702 RtlFreeActivationContextStack(
3703 _In_ PACTIVATION_CONTEXT_STACK Stack
3709 RtlFreeThreadActivationContextStack(VOID
);
3712 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3714 RtlDeactivateActivationContextUnsafeFast(
3715 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3721 RtlDosApplyFileIsolationRedirection_Ustr(
3723 _In_ PUNICODE_STRING OriginalName
,
3724 _In_ PUNICODE_STRING Extension
,
3725 _Inout_ PUNICODE_STRING StaticString
,
3726 _Inout_ PUNICODE_STRING DynamicString
,
3727 _Inout_ PUNICODE_STRING
*NewName
,
3728 _In_ PULONG NewFlags
,
3729 _In_ PSIZE_T FileNameSize
,
3730 _In_ PSIZE_T RequiredLength
3736 RtlFindActivationContextSectionString(
3738 _In_
const GUID
*ExtensionGuid
,
3739 _In_ ULONG SectionType
,
3740 _In_
const UNICODE_STRING
*SectionName
,
3741 _Inout_ PVOID ReturnedData
3747 RtlQueryInformationActivationContext(
3749 _In_opt_ PVOID Context
,
3750 _In_opt_ PVOID pvSubInstance
,
3751 _In_ ULONG ulInfoClass
,
3752 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3753 _In_opt_ SIZE_T cbBuffer
,
3754 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3760 RtlQueryInformationActiveActivationContext(
3761 _In_ ULONG ulInfoClass
,
3762 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3763 _In_opt_ SIZE_T cbBuffer
,
3764 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3770 RtlZombifyActivationContext(
3780 RtlWow64EnableFsRedirection(
3781 _In_ BOOLEAN Wow64FsEnableRedirection
3787 RtlWow64EnableFsRedirectionEx(
3788 _In_ PVOID Wow64FsEnableRedirection
,
3789 _Out_ PVOID
*OldFsRedirectionLevel
3795 // Registry Functions
3797 _IRQL_requires_max_(PASSIVE_LEVEL
)
3798 _Must_inspect_result_
3802 RtlCheckRegistryKey(
3803 _In_ ULONG RelativeTo
,
3810 RtlCreateRegistryKey(
3811 _In_ ULONG RelativeTo
,
3818 RtlFormatCurrentUserKeyPath(
3819 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3820 PUNICODE_STRING KeyPath
3827 _In_ ACCESS_MASK DesiredAccess
,
3828 _Out_ PHANDLE KeyHandle
3831 _IRQL_requires_max_(PASSIVE_LEVEL
)
3835 RtlQueryRegistryValues(
3836 _In_ ULONG RelativeTo
,
3838 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3839 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3840 _In_opt_ PVOID Context
,
3841 _In_opt_ PVOID Environment
3844 _IRQL_requires_max_(PASSIVE_LEVEL
)
3848 RtlWriteRegistryValue(
3849 _In_ ULONG RelativeTo
,
3851 _In_z_ PCWSTR ValueName
,
3852 _In_ ULONG ValueType
,
3853 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3854 _In_ ULONG ValueLength
3857 #ifdef NTOS_MODE_USER
3862 _Out_ HANDLE KeyHandle
,
3863 _In_ ACCESS_MASK DesiredAccess
,
3864 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3865 _In_ ULONG TitleIndex
,
3866 _In_ PUNICODE_STRING Class
,
3867 _Out_ PULONG Disposition
3873 RtlpNtEnumerateSubKey(
3874 _In_ HANDLE KeyHandle
,
3875 _Inout_ PUNICODE_STRING SubKeyName
,
3883 RtlpNtMakeTemporaryKey(
3884 _In_ HANDLE KeyHandle
3891 _Out_ HANDLE KeyHandle
,
3892 _In_ ACCESS_MASK DesiredAccess
,
3893 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3900 RtlpNtQueryValueKey(
3901 _In_ HANDLE KeyHandle
,
3902 _Out_opt_ PULONG Type
,
3903 _Out_opt_ PVOID Data
,
3904 _Inout_opt_ PULONG DataLength
,
3912 _In_ HANDLE KeyHandle
,
3915 _In_ ULONG DataLength
3925 RtlGetDefaultCodePage(
3926 _Out_ PUSHORT AnsiCodePage
,
3927 _Out_ PUSHORT OemCodePage
3934 _In_ PUSHORT AnsiTableBase
,
3935 _In_ PUSHORT OemTableBase
,
3936 _In_ PUSHORT CaseTableBase
,
3937 _Out_ PNLSTABLEINFO NlsTable
3940 _IRQL_requires_max_(PASSIVE_LEVEL
)
3944 RtlInitCodePageTable(
3945 _In_ PUSHORT TableBase
,
3946 _Out_ PCPTABLEINFO CodePageTable
3952 RtlResetRtlTranslations(
3953 _In_ PNLSTABLEINFO NlsTable
);
3955 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3958 // Misc conversion functions
3963 RtlConvertLongToLargeInteger(
3964 _In_ LONG SignedInteger
3967 LARGE_INTEGER Result
;
3969 Result
.QuadPart
= SignedInteger
;
3976 RtlEnlargedIntegerMultiply(
3977 _In_ LONG Multiplicand
,
3978 _In_ LONG Multiplier
3981 LARGE_INTEGER Product
;
3983 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3990 RtlEnlargedUnsignedDivide(
3991 _In_ ULARGE_INTEGER Dividend
,
3993 _In_opt_ PULONG Remainder
3998 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
4000 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
4009 RtlEnlargedUnsignedMultiply(
4010 _In_ ULONG Multiplicand
,
4011 _In_ ULONG Multiplier
4014 LARGE_INTEGER Product
;
4016 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
4020 #if defined(_AMD64_) || defined(_IA64_)
4024 RtlExtendedLargeIntegerDivide(
4025 _In_ LARGE_INTEGER Dividend
,
4027 _Out_opt_ PULONG Remainder
)
4030 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
4032 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
4040 RtlExtendedLargeIntegerDivide(
4041 _In_ LARGE_INTEGER Dividend
,
4043 _Out_opt_ PULONG Remainder
4046 #endif /* defined(_AMD64_) || defined(_IA64_) */
4069 _In_ ULONG InitialCrc
,
4075 // Network Functions
4080 RtlIpv4AddressToStringA(
4081 _In_
const struct in_addr
*Addr
,
4082 _Out_writes_(16) PCHAR S
4088 RtlIpv4AddressToStringW(
4089 _In_
const struct in_addr
*Addr
,
4090 _Out_writes_(16) PWCHAR S
4096 RtlIpv4AddressToStringExA(
4097 _In_
const struct in_addr
*Address
,
4099 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PCHAR AddressString
,
4100 _Inout_ PULONG AddressStringLength
4105 RtlIpv4AddressToStringExW(
4106 _In_
const struct in_addr
*Address
,
4108 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4109 _Inout_ PULONG AddressStringLength
4115 RtlIpv4StringToAddressA(
4117 _In_ BOOLEAN Strict
,
4118 _Out_ PCSTR
*Terminator
,
4119 _Out_
struct in_addr
*Addr
4125 RtlIpv4StringToAddressW(
4127 _In_ BOOLEAN Strict
,
4128 _Out_ PCWSTR
*Terminator
,
4129 _Out_
struct in_addr
*Addr
4135 RtlIpv4StringToAddressExA(
4136 _In_ PCSTR AddressString
,
4137 _In_ BOOLEAN Strict
,
4138 _Out_
struct in_addr
*Address
,
4145 RtlIpv4StringToAddressExW(
4146 _In_ PCWSTR AddressString
,
4147 _In_ BOOLEAN Strict
,
4148 _Out_
struct in_addr
*Address
,
4155 RtlIpv6AddressToStringA(
4156 _In_
const struct in6_addr
*Addr
,
4157 _Out_writes_(46) PSTR S
4163 RtlIpv6AddressToStringW(
4164 _In_
const struct in6_addr
*Addr
,
4165 _Out_writes_(46) PWSTR S
4171 RtlIpv6AddressToStringExA(
4172 _In_
const struct in6_addr
*Address
,
4175 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PSTR AddressString
,
4176 _Inout_ PULONG AddressStringLength
4182 RtlIpv6AddressToStringExW(
4183 _In_
const struct in6_addr
*Address
,
4186 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4187 _Inout_ PULONG AddressStringLength
4193 RtlIpv6StringToAddressA(
4195 _Out_ PCSTR
*Terminator
,
4196 _Out_
struct in6_addr
*Addr
4202 RtlIpv6StringToAddressW(
4204 _Out_ PCWSTR
*Terminator
,
4205 _Out_
struct in6_addr
*Addr
4211 RtlIpv6StringToAddressExA(
4212 _In_ PCSTR AddressString
,
4213 _Out_
struct in6_addr
*Address
,
4214 _Out_ PULONG ScopeId
,
4221 RtlIpv6StringToAddressExW(
4222 _In_ PCWSTR AddressString
,
4223 _Out_
struct in6_addr
*Address
,
4224 _Out_ PULONG ScopeId
,
4235 RtlQueryTimeZoneInformation(
4236 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4241 RtlSecondsSince1970ToTime(
4242 _In_ ULONG SecondsSince1970
,
4243 _Out_ PLARGE_INTEGER Time
4249 RtlSetTimeZoneInformation(
4250 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4252 _Success_(return!=FALSE
)
4253 _Must_inspect_result_
4257 RtlTimeFieldsToTime(
4258 _In_ PTIME_FIELDS TimeFields
,
4259 _Out_ PLARGE_INTEGER Time
4262 _Success_(return != 0)
4263 _Must_inspect_result_
4267 RtlTimeToSecondsSince1970(
4268 _In_ PLARGE_INTEGER Time
,
4269 _Out_ PULONG ElapsedSeconds
4275 RtlTimeToTimeFields(
4276 PLARGE_INTEGER Time
,
4277 PTIME_FIELDS TimeFields
4283 RtlSystemTimeToLocalTime(
4284 _In_ PLARGE_INTEGER SystemTime
,
4285 _Out_ PLARGE_INTEGER LocalTime
4289 // Version Functions
4291 _IRQL_requires_max_(PASSIVE_LEVEL
)
4292 _Must_inspect_result_
4296 RtlVerifyVersionInfo(
4297 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4298 _In_ ULONG TypeMask
,
4299 _In_ ULONGLONG ConditionMask
4302 _IRQL_requires_max_(PASSIVE_LEVEL
)
4308 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4309 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4310 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4311 PRTL_OSVERSIONINFOW lpVersionInformation
4317 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4320 // Secure Memory Functions
4322 #ifdef NTOS_MODE_USER
4326 RtlRegisterSecureMemoryCacheCallback(
4327 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4332 RtlFlushSecureMemoryCache(
4333 _In_ PVOID MemoryCache
,
4334 _In_opt_ SIZE_T MemoryLength
4339 // Boot Status Data Functions
4341 #ifdef NTOS_MODE_USER
4345 RtlCreateBootStatusDataFile(
4352 RtlGetSetBootStatusData(
4353 _In_ HANDLE FileHandle
,
4354 _In_ BOOLEAN WriteMode
,
4355 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4357 _In_ ULONG BufferSize
,
4358 _Out_opt_ PULONG ReturnLength
4364 RtlLockBootStatusData(
4365 _Out_ PHANDLE FileHandle
4371 RtlUnlockBootStatusData(
4372 _In_ HANDLE FileHandle
4376 #ifdef NTOS_MODE_USER
4377 _Must_inspect_result_
4382 _In_ PUNICODE_STRING GuidString
,
4385 _Must_inspect_result_
4391 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4392 PUNICODE_STRING GuidString
);
4397 RtlComputeImportTableHash(
4400 _In_ ULONG ImportTableHashRevision
4405 // MemoryStream functions
4407 #ifdef NTOS_MODE_USER
4412 RtlInitMemoryStream(
4413 _Out_ PRTL_MEMORY_STREAM Stream
4419 RtlInitOutOfProcessMemoryStream(
4420 _Out_ PRTL_MEMORY_STREAM Stream
4426 RtlFinalReleaseOutOfProcessMemoryStream(
4427 _In_ PRTL_MEMORY_STREAM Stream
4433 RtlQueryInterfaceMemoryStream(
4434 _In_
struct IStream
*This
,
4435 _In_ REFIID RequestedIid
,
4436 _Outptr_ PVOID
*ResultObject
4442 RtlAddRefMemoryStream(
4443 _In_
struct IStream
*This
4449 RtlReleaseMemoryStream(
4450 _In_
struct IStream
*This
4456 RtlReadMemoryStream(
4457 _In_
struct IStream
*This
,
4458 _Out_writes_bytes_(Length
) PVOID Buffer
,
4460 _Out_opt_ PULONG BytesRead
4466 RtlReadOutOfProcessMemoryStream(
4467 _In_
struct IStream
*This
,
4468 _Out_writes_bytes_(Length
) PVOID Buffer
,
4470 _Out_opt_ PULONG BytesRead
4476 RtlSeekMemoryStream(
4477 _In_
struct IStream
*This
,
4478 _In_ LARGE_INTEGER RelativeOffset
,
4480 _Out_opt_ PULARGE_INTEGER ResultOffset
4486 RtlCopyMemoryStreamTo(
4487 _In_
struct IStream
*This
,
4488 _In_
struct IStream
*Target
,
4489 _In_ ULARGE_INTEGER Length
,
4490 _Out_opt_ PULARGE_INTEGER BytesRead
,
4491 _Out_opt_ PULARGE_INTEGER BytesWritten
4497 RtlCopyOutOfProcessMemoryStreamTo(
4498 _In_
struct IStream
*This
,
4499 _In_
struct IStream
*Target
,
4500 _In_ ULARGE_INTEGER Length
,
4501 _Out_opt_ PULARGE_INTEGER BytesRead
,
4502 _Out_opt_ PULARGE_INTEGER BytesWritten
4508 RtlStatMemoryStream(
4509 _In_
struct IStream
*This
,
4510 _Out_
struct tagSTATSTG
*Stats
,
4518 RtlWriteMemoryStream(
4519 _In_
struct IStream
*This
,
4520 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4522 _Out_opt_ PULONG BytesWritten
4528 RtlSetMemoryStreamSize(
4529 _In_
struct IStream
*This
,
4530 _In_ ULARGE_INTEGER NewSize
4536 RtlCommitMemoryStream(
4537 _In_
struct IStream
*This
,
4538 _In_ ULONG CommitFlags
4544 RtlRevertMemoryStream(
4545 _In_
struct IStream
*This
4551 RtlLockMemoryStreamRegion(
4552 _In_
struct IStream
*This
,
4553 _In_ ULARGE_INTEGER Offset
,
4554 _In_ ULARGE_INTEGER Length
,
4561 RtlUnlockMemoryStreamRegion(
4562 _In_
struct IStream
*This
,
4563 _In_ ULARGE_INTEGER Offset
,
4564 _In_ ULARGE_INTEGER Length
,
4571 RtlCloneMemoryStream(
4572 _In_
struct IStream
*This
,
4573 _Outptr_
struct IStream
**ResultStream
4576 #endif // NTOS_MODE_USER
4581 RtlFindActivationContextSectionGuid(
4583 const GUID
*extguid
,