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 _In_ PSID_AND_ATTRIBUTES Src
,
1284 _In_ ULONG SidAreaSize
,
1285 _In_ PSID_AND_ATTRIBUTES Dest
,
1287 _Out_ PSID
* RemainingSidArea
,
1288 _Out_ 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
);
1472 _IRQL_requires_max_(APC_LEVEL
)
1476 RtlLengthSecurityDescriptor(
1477 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
1482 RtlLengthSid(IN PSID Sid
);
1487 RtlMakeSelfRelativeSD(
1488 _In_ PSECURITY_DESCRIPTOR AbsoluteSD
,
1489 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1490 _Inout_ PULONG BufferLength
);
1496 PACCESS_MASK AccessMask
,
1497 PGENERIC_MAPPING GenericMapping
1500 #ifdef NTOS_MODE_USER
1505 RtlQueryInformationAcl(
1508 ULONG InformationLength
,
1509 ACL_INFORMATION_CLASS InformationClass
1517 RtlReleasePrivilege(
1518 _In_ PVOID ReturnedState
1521 _IRQL_requires_max_(APC_LEVEL
)
1525 RtlSelfRelativeToAbsoluteSD(
1526 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
1527 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
1528 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
1529 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
1530 _Inout_ PULONG DaclSize
,
1531 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
1532 _Inout_ PULONG SaclSize
,
1533 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
1534 _Inout_ PULONG OwnerSize
,
1535 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
1536 _Inout_ PULONG PrimaryGroupSize
1542 RtlSelfRelativeToAbsoluteSD2(
1543 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD
,
1544 _Out_ PULONG BufferSize
1550 RtlSetAttributesSecurityDescriptor(
1551 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1552 _In_ SECURITY_DESCRIPTOR_CONTROL Control
,
1553 _Out_ PULONG Revision
1559 RtlSetControlSecurityDescriptor(
1560 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1561 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
1562 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1565 _IRQL_requires_max_(APC_LEVEL
)
1569 RtlSetDaclSecurityDescriptor(
1570 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1571 _In_ BOOLEAN DaclPresent
,
1573 _In_opt_ BOOLEAN DaclDefaulted
1576 _IRQL_requires_max_(APC_LEVEL
)
1580 RtlSetGroupSecurityDescriptor(
1581 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1582 _In_opt_ PSID Group
,
1583 _In_opt_ BOOLEAN GroupDefaulted
1586 #ifdef NTOS_MODE_USER
1591 RtlSetInformationAcl(
1594 ULONG InformationLength
,
1595 ACL_INFORMATION_CLASS InformationClass
1600 _IRQL_requires_max_(APC_LEVEL
)
1604 RtlSetOwnerSecurityDescriptor(
1605 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1606 _In_opt_ PSID Owner
,
1607 _In_opt_ BOOLEAN OwnerDefaulted
1613 RtlSetSaclSecurityDescriptor(
1614 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1615 _In_ BOOLEAN SaclPresent
,
1617 _In_ BOOLEAN SaclDefaulted
1623 RtlSetSecurityDescriptorRMControl(
1624 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1625 _In_ PUCHAR RMControl
1631 RtlSubAuthorityCountSid(
1640 _In_ ULONG SubAuthority
1643 _IRQL_requires_max_(APC_LEVEL
)
1644 _Must_inspect_result_
1648 RtlValidRelativeSecurityDescriptor(
1649 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1650 _In_ ULONG SecurityDescriptorLength
,
1651 _In_ SECURITY_INFORMATION RequiredInformation
1657 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
1662 RtlValidSid(IN PSID Sid
);
1667 RtlValidAcl(PACL Acl
);
1672 RtlDeleteSecurityObject(
1673 _In_ PSECURITY_DESCRIPTOR
*ObjectDescriptor
1679 RtlNewSecurityObject(
1680 _In_ PSECURITY_DESCRIPTOR ParentDescriptor
,
1681 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor
,
1682 _Out_ PSECURITY_DESCRIPTOR
*NewDescriptor
,
1683 _In_ BOOLEAN IsDirectoryObject
,
1685 _In_ PGENERIC_MAPPING GenericMapping
1691 RtlQuerySecurityObject(
1692 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor
,
1693 _In_ SECURITY_INFORMATION SecurityInformation
,
1694 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor
,
1695 _In_ ULONG DescriptorLength
,
1696 _Out_ PULONG ReturnLength
1702 RtlSetSecurityObject(
1703 _In_ SECURITY_INFORMATION SecurityInformation
,
1704 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor
,
1705 _Out_ PSECURITY_DESCRIPTOR
*ObjectsSecurityDescriptor
,
1706 _In_ PGENERIC_MAPPING GenericMapping
,
1711 // Single-Character Functions
1716 RtlLargeIntegerToChar(
1717 _In_ PLARGE_INTEGER Value
,
1726 RtlUpperChar(CHAR Source
);
1731 RtlUpcaseUnicodeChar(WCHAR Source
);
1736 RtlDowncaseUnicodeChar(IN WCHAR Source
);
1751 RtlIntegerToUnicode(
1753 _In_opt_ ULONG Base
,
1754 _In_opt_ ULONG Length
,
1755 _Inout_ LPWSTR String
1758 _IRQL_requires_max_(PASSIVE_LEVEL
)
1759 _At_(String
->MaximumLength
, _Const_
)
1763 RtlIntegerToUnicodeString(
1765 _In_opt_ ULONG Base
,
1766 _Inout_ PUNICODE_STRING String
1779 // Byte Swap Functions
1781 #ifdef NTOS_MODE_USER
1783 unsigned short __cdecl
_byteswap_ushort(unsigned short);
1784 unsigned long __cdecl
_byteswap_ulong (unsigned long);
1785 unsigned __int64 __cdecl
_byteswap_uint64(unsigned __int64
);
1787 #pragma intrinsic(_byteswap_ushort)
1788 #pragma intrinsic(_byteswap_ulong)
1789 #pragma intrinsic(_byteswap_uint64)
1791 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1792 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1793 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1795 #endif // NTOS_MODE_USER
1798 // Unicode->Ansi String Functions
1803 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString
);
1805 #ifdef NTOS_MODE_USER
1807 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1808 NLS_MB_CODE_PAGE_TAG ? \
1809 RtlxUnicodeStringToAnsiSize(STRING) : \
1810 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1818 RtlUnicodeStringToAnsiString(
1819 PANSI_STRING DestinationString
,
1820 PCUNICODE_STRING SourceString
,
1821 BOOLEAN AllocateDestinationString
1825 // Unicode->OEM String Functions
1830 RtlUpcaseUnicodeStringToOemString(
1831 POEM_STRING DestinationString
,
1832 PCUNICODE_STRING SourceString
,
1833 BOOLEAN AllocateDestinationString
1836 _IRQL_requires_max_(PASSIVE_LEVEL
)
1837 _Must_inspect_result_
1838 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1842 RtlUpcaseUnicodeStringToCountedOemString(
1843 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1844 _When_(!AllocateDestinationString
, _Inout_
)
1845 POEM_STRING DestinationString
,
1846 _In_ PCUNICODE_STRING SourceString
,
1847 _In_ BOOLEAN AllocateDestinationString
1853 RtlUnicodeStringToOemString(
1854 POEM_STRING DestinationString
,
1855 PCUNICODE_STRING SourceString
,
1856 BOOLEAN AllocateDestinationString
1862 RtlUpcaseUnicodeToOemN(
1866 PCWCH UnicodeString
,
1873 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString
);
1875 #ifdef NTOS_MODE_USER
1877 #define RtlUnicodeStringToOemSize(STRING) ( \
1878 NLS_MB_OEM_CODE_PAGE_TAG ? \
1879 RtlxUnicodeStringToOemSize(STRING) : \
1880 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1883 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1884 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1896 PCWCH UnicodeString
,
1901 // Unicode->MultiByte String Functions
1906 RtlUnicodeToMultiByteN(
1910 PCWCH UnicodeString
,
1917 RtlUpcaseUnicodeToMultiByteN(
1921 PCWCH UnicodeString
,
1928 RtlUnicodeToMultiByteSize(
1930 PCWCH UnicodeString
,
1937 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString
);
1940 // OEM to Unicode Functions
1945 RtlOemStringToUnicodeString(
1946 PUNICODE_STRING DestinationString
,
1947 PCOEM_STRING SourceString
,
1948 BOOLEAN AllocateDestinationString
1951 _IRQL_requires_max_(PASSIVE_LEVEL
)
1956 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1957 _In_ ULONG MaxBytesInUnicodeString
,
1958 _Out_opt_ PULONG BytesInUnicodeString
,
1959 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1960 _In_ ULONG BytesInOemString
1963 #ifdef NTOS_MODE_USER
1965 #define RtlOemStringToUnicodeSize(STRING) ( \
1966 NLS_MB_OEM_CODE_PAGE_TAG ? \
1967 RtlxOemStringToUnicodeSize(STRING) : \
1968 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1971 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1972 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1978 // Ansi->Unicode String Functions
1980 _IRQL_requires_max_(APC_LEVEL
)
1984 RtlAnsiCharToUnicodeChar(
1985 _Inout_ PUCHAR
*SourceCharacter
);
1990 RtlAnsiStringToUnicodeString(
1991 PUNICODE_STRING DestinationString
,
1992 PCANSI_STRING SourceString
,
1993 BOOLEAN AllocateDestinationString
1999 RtlxAnsiStringToUnicodeSize(
2000 PCANSI_STRING AnsiString
2003 #ifdef NTOS_MODE_USER
2005 #define RtlAnsiStringToUnicodeSize(STRING) ( \
2006 NLS_MB_CODE_PAGE_TAG ? \
2007 RtlxAnsiStringToUnicodeSize(STRING) : \
2008 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2016 RtlCreateUnicodeStringFromAsciiz(
2017 _Out_ PUNICODE_STRING Destination
,
2022 // Unicode String Functions
2027 RtlAppendUnicodeToString(
2028 PUNICODE_STRING Destination
,
2035 RtlAppendUnicodeStringToString(
2036 PUNICODE_STRING Destination
,
2037 PCUNICODE_STRING Source
2043 RtlCompareUnicodeString(
2044 PCUNICODE_STRING String1
,
2045 PCUNICODE_STRING String2
,
2046 BOOLEAN CaseInsensitive
2052 RtlCopyUnicodeString(
2053 PUNICODE_STRING DestinationString
,
2054 PCUNICODE_STRING SourceString
2060 RtlCreateUnicodeString(
2061 PUNICODE_STRING DestinationString
,
2065 #ifdef NTOS_MODE_USER
2070 RtlDowncaseUnicodeString(
2071 _Inout_ PUNICODE_STRING UniDest
,
2072 _In_ PCUNICODE_STRING UniSource
,
2073 _In_ BOOLEAN AllocateDestinationString
2079 RtlDuplicateUnicodeString(
2081 _In_ PCUNICODE_STRING SourceString
,
2082 _Out_ PUNICODE_STRING DestinationString
2092 _In_ PVOID Destination
,
2100 RtlFillMemoryUlonglong(
2101 _Out_ PVOID Destination
,
2103 _In_ ULONGLONG Pattern
2109 RtlCopyMappedMemory(
2110 _Out_writes_bytes_all_(Size
) PVOID Destination
,
2111 _In_reads_bytes_(Size
) const VOID
*Source
,
2118 RtlCompareMemoryUlong(
2124 #ifndef RtlEqualMemory
2125 #define RtlEqualMemory(Destination, Source, Length) \
2126 (!memcmp(Destination, Source, Length))
2129 #define RtlCopyBytes RtlCopyMemory
2130 #define RtlFillBytes RtlFillMemory
2131 #define RtlZeroBytes RtlZeroMemory
2138 RtlEqualUnicodeString(
2139 PCUNICODE_STRING String1
,
2140 PCUNICODE_STRING String2
,
2141 BOOLEAN CaseInsensitive
2147 RtlFindCharInUnicodeString(
2149 _In_ PCUNICODE_STRING SearchString
,
2150 _In_ PCUNICODE_STRING MatchString
,
2151 _Out_ PUSHORT Position
2154 _IRQL_requires_max_(PASSIVE_LEVEL
)
2158 RtlFreeUnicodeString(
2159 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
2160 PUNICODE_STRING UnicodeString
2166 RtlEraseUnicodeString(
2167 _Inout_ PUNICODE_STRING String
2173 RtlHashUnicodeString(
2174 _In_ CONST UNICODE_STRING
*String
,
2175 _In_ BOOLEAN CaseInSensitive
,
2176 _In_ ULONG HashAlgorithm
,
2177 _Out_ PULONG HashValue
2180 _IRQL_requires_max_(DISPATCH_LEVEL
)
2181 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
2182 _When_(SourceString
!= NULL
,
2183 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
2184 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
2185 _When_(SourceString
== NULL
,
2186 _At_(DestinationString
->Length
, _Post_equal_to_(0))
2187 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
2191 RtlInitUnicodeString(
2192 _Out_ PUNICODE_STRING DestinationString
,
2193 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2196 _IRQL_requires_max_(DISPATCH_LEVEL
)
2200 RtlInitUnicodeStringEx(
2201 _Out_ PUNICODE_STRING DestinationString
,
2202 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2209 _In_ CONST VOID
* Buffer
,
2211 _Inout_opt_ INT
* Flags
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_(PASSIVE_LEVEL
)
2226 _Must_inspect_result_
2230 RtlPrefixUnicodeString(
2231 _In_ PCUNICODE_STRING String1
,
2232 _In_ PCUNICODE_STRING String2
,
2233 _In_ BOOLEAN CaseInsensitive
2236 _IRQL_requires_max_(PASSIVE_LEVEL
)
2241 _Inout_ PSTRING DestinationString
,
2242 _In_
const STRING
*SourceString
2245 _IRQL_requires_max_(PASSIVE_LEVEL
)
2246 _Must_inspect_result_
2251 _In_
const STRING
*String1
,
2252 _In_
const STRING
*String2
,
2253 _In_ BOOLEAN CaseInSensitive
2260 _Out_ PSTRING DestinationString
,
2261 _In_opt_
const STRING
*SourceString
2264 _IRQL_requires_max_(PASSIVE_LEVEL
)
2265 _Must_inspect_result_
2270 _In_
const STRING
*String1
,
2271 _In_
const STRING
*String2
,
2272 _In_ BOOLEAN CaseInSensitive
2275 _IRQL_requires_max_(APC_LEVEL
)
2279 RtlAppendStringToString(
2280 _Inout_ PSTRING Destination
,
2281 _In_
const STRING
*Source
2284 _IRQL_requires_max_(PASSIVE_LEVEL
)
2285 _When_(AllocateDestinationString
, _Must_inspect_result_
)
2289 RtlUpcaseUnicodeString(
2290 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
2291 _When_(!AllocateDestinationString
, _Inout_
)
2292 PUNICODE_STRING DestinationString
,
2293 _In_ PCUNICODE_STRING SourceString
,
2294 _In_ BOOLEAN AllocateDestinationString
2297 _IRQL_requires_max_(PASSIVE_LEVEL
)
2301 RtlUnicodeStringToInteger(
2302 _In_ PCUNICODE_STRING String
,
2303 _In_opt_ ULONG Base
,
2310 RtlValidateUnicodeString(
2312 _In_ PCUNICODE_STRING String
2316 // Ansi String Functions
2318 _IRQL_requires_max_(PASSIVE_LEVEL
)
2323 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
2324 PANSI_STRING AnsiString
2327 _IRQL_requires_max_(DISPATCH_LEVEL
)
2332 _Out_ PANSI_STRING DestinationString
,
2333 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2336 _IRQL_requires_max_(DISPATCH_LEVEL
)
2340 RtlInitAnsiStringEx(
2341 _Out_ PANSI_STRING DestinationString
,
2342 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2346 // OEM String Functions
2348 _IRQL_requires_max_(PASSIVE_LEVEL
)
2353 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
))
2354 POEM_STRING OemString
2358 // MultiByte->Unicode String Functions
2360 _IRQL_requires_max_(PASSIVE_LEVEL
)
2364 RtlMultiByteToUnicodeN(
2365 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
2366 _In_ ULONG MaxBytesInUnicodeString
,
2367 _Out_opt_ PULONG BytesInUnicodeString
,
2368 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2369 _In_ ULONG BytesInMultiByteString
2372 _IRQL_requires_max_(PASSIVE_LEVEL
)
2376 RtlMultiByteToUnicodeSize(
2377 _Out_ PULONG BytesInUnicodeString
,
2378 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
2379 _In_ ULONG BytesInMultiByteString
2388 RtlAddAtomToAtomTable(
2389 _In_ PRTL_ATOM_TABLE AtomTable
,
2390 _In_ PWSTR AtomName
,
2391 _Out_ PRTL_ATOM Atom
2398 _In_ ULONG TableSize
,
2399 _Inout_ PRTL_ATOM_TABLE
*AtomTable
2405 RtlDeleteAtomFromAtomTable(
2406 _In_ PRTL_ATOM_TABLE AtomTable
,
2413 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
2418 RtlQueryAtomInAtomTable(
2419 _In_ PRTL_ATOM_TABLE AtomTable
,
2421 _Out_opt_ PULONG RefCount
,
2422 _Out_opt_ PULONG PinCount
,
2423 _Out_opt_z_bytecap_(*NameLength
) PWSTR AtomName
,
2424 _Inout_opt_ PULONG NameLength
2430 RtlPinAtomInAtomTable(
2431 _In_ PRTL_ATOM_TABLE AtomTable
,
2438 RtlLookupAtomInAtomTable(
2439 _In_ PRTL_ATOM_TABLE AtomTable
,
2440 _In_ PWSTR AtomName
,
2441 _Out_ PRTL_ATOM Atom
2445 // Process Management Functions
2457 RtlAcquirePebLock(VOID
);
2462 RtlCreateProcessParameters (
2463 _Out_ PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
2464 _In_ PUNICODE_STRING ImagePathName
,
2465 _In_opt_ PUNICODE_STRING DllPath
,
2466 _In_opt_ PUNICODE_STRING CurrentDirectory
,
2467 _In_opt_ PUNICODE_STRING CommandLine
,
2468 _In_opt_ PWSTR Environment
,
2469 _In_opt_ PUNICODE_STRING WindowTitle
,
2470 _In_opt_ PUNICODE_STRING DesktopInfo
,
2471 _In_opt_ PUNICODE_STRING ShellInfo
,
2472 _In_opt_ PUNICODE_STRING RuntimeInfo
2478 RtlCreateUserProcess(
2479 _In_ PUNICODE_STRING ImageFileName
,
2480 _In_ ULONG Attributes
,
2481 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
2482 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor
,
2483 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor
,
2484 _In_opt_ HANDLE ParentProcess
,
2485 _In_ BOOLEAN CurrentDirectory
,
2486 _In_opt_ HANDLE DebugPort
,
2487 _In_opt_ HANDLE ExceptionPort
,
2488 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2491 #if (NTDDI_VERSION >= NTDDI_WIN7)
2495 RtlCreateUserThread(
2496 _In_ PVOID ThreadContext
,
2497 _Out_ HANDLE
*OutThreadHandle
,
2498 _Reserved_ PVOID Reserved1
,
2499 _Reserved_ PVOID Reserved2
,
2500 _Reserved_ PVOID Reserved3
,
2501 _Reserved_ PVOID Reserved4
,
2502 _Reserved_ PVOID Reserved5
,
2503 _Reserved_ PVOID Reserved6
,
2504 _Reserved_ PVOID Reserved7
,
2505 _Reserved_ PVOID Reserved8
2511 RtlCreateUserThread(
2512 _In_ HANDLE ProcessHandle
,
2513 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2514 _In_ BOOLEAN CreateSuspended
,
2515 _In_ ULONG StackZeroBits
,
2516 _In_ SIZE_T StackReserve
,
2517 _In_ SIZE_T StackCommit
,
2518 _In_ PTHREAD_START_ROUTINE StartAddress
,
2519 _In_ PVOID Parameter
,
2520 _Out_opt_ PHANDLE ThreadHandle
,
2521 _Out_opt_ PCLIENT_ID ClientId
2526 PRTL_USER_PROCESS_PARAMETERS
2528 RtlDeNormalizeProcessParams(
2529 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2534 RtlDestroyProcessParameters(
2535 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2541 _In_ NTSTATUS Status
);
2546 RtlInitializeContext(
2547 _In_ HANDLE ProcessHandle
,
2548 _Out_ PCONTEXT ThreadContext
,
2549 _In_opt_ PVOID ThreadStartParam
,
2550 _In_ PTHREAD_START_ROUTINE ThreadStartAddress
,
2551 _In_ PINITIAL_TEB InitialTeb
2555 typedef struct _WOW64_CONTEXT
*PWOW64_CONTEXT
;
2560 RtlWow64GetThreadContext(
2561 _In_ HANDLE ThreadHandle
,
2562 _Inout_ PWOW64_CONTEXT ThreadContext
2569 RtlWow64SetThreadContext(
2570 _In_ HANDLE ThreadHandle
,
2571 _In_ PWOW64_CONTEXT ThreadContext
2578 RtlIsThreadWithinLoaderCallout(VOID
);
2581 PRTL_USER_PROCESS_PARAMETERS
2583 RtlNormalizeProcessParams(
2584 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
2589 RtlReleasePebLock(VOID
);
2595 _In_ HANDLE Process
,
2597 _In_ PVOID CallSite
,
2598 _In_ ULONG ArgumentCount
,
2599 _In_ PULONG Arguments
,
2600 _In_ BOOLEAN PassContext
,
2601 _In_ BOOLEAN AlreadySuspended
2607 RtlSetProcessIsCritical(
2608 _In_ BOOLEAN NewValue
,
2609 _Out_opt_ PBOOLEAN OldValue
,
2610 _In_ BOOLEAN NeedBreaks
2616 RtlSetThreadIsCritical(
2617 _In_ BOOLEAN NewValue
,
2618 _Out_opt_ PBOOLEAN OldValue
,
2619 _In_ BOOLEAN NeedBreaks
2625 RtlGetCurrentProcessorNumber(
2629 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2632 // Thread Pool Functions
2637 RtlSetThreadPoolStartFunc(
2638 _In_ PRTL_START_POOL_THREAD StartPoolThread
,
2639 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2645 RtlDeregisterWaitEx(
2646 _In_ HANDLE hWaitHandle
,
2647 _In_opt_ HANDLE hCompletionEvent
2654 _In_ HANDLE hWaitHandle
2661 _In_ WORKERCALLBACKFUNC Function
,
2662 _In_opt_ PVOID Context
,
2669 RtlSetIoCompletionCallback(
2670 _In_ HANDLE FileHandle
,
2671 _In_ PIO_APC_ROUTINE Callback
,
2679 _In_ PHANDLE phNewWaitObject
,
2680 _In_ HANDLE hObject
,
2681 _In_ WAITORTIMERCALLBACKFUNC Callback
,
2682 _In_ PVOID pvContext
,
2683 _In_ ULONG ulMilliseconds
,
2688 // Environment/Path Functions
2693 RtlCreateEnvironment(
2694 _In_ BOOLEAN Inherit
,
2695 _Out_ PWSTR
*Environment
2701 RtlComputePrivatizedDllName_U(
2702 _In_ PUNICODE_STRING DllName
,
2703 _Out_ PUNICODE_STRING RealName
,
2704 _Out_ PUNICODE_STRING LocalName
2710 RtlDestroyEnvironment(
2711 _In_ PWSTR Environment
2717 RtlDoesFileExists_U(
2718 _In_ PCWSTR FileName
2724 RtlDetermineDosPathNameType_U(
2733 _In_ PCWSTR FileName
,
2734 _In_ PCWSTR Extension
,
2735 _In_ ULONG BufferSize
,
2737 _Out_ PWSTR
*PartName
2743 RtlDosSearchPath_Ustr(
2745 _In_ PUNICODE_STRING PathString
,
2746 _In_ PUNICODE_STRING FileNameString
,
2747 _In_ PUNICODE_STRING ExtensionString
,
2748 _In_ PUNICODE_STRING CallerBuffer
,
2749 _Inout_opt_ PUNICODE_STRING DynamicString
,
2750 _Out_opt_ PUNICODE_STRING
* FullNameOut
,
2751 _Out_opt_ PSIZE_T FilePartSize
,
2752 _Out_opt_ PSIZE_T LengthNeeded
2758 RtlDosPathNameToNtPathName_U(
2759 _In_opt_z_ PCWSTR DosPathName
,
2760 _Out_ PUNICODE_STRING NtPathName
,
2761 _Out_opt_ PCWSTR
*NtFileNamePart
,
2762 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2768 RtlDosPathNameToRelativeNtPathName_U(
2769 _In_ PCWSTR DosName
,
2770 _Out_ PUNICODE_STRING NtName
,
2771 _Out_ PCWSTR
*PartName
,
2772 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2775 _At_(Destination
->Buffer
, _Out_bytecap_(Destination
->MaximumLength
))
2779 RtlExpandEnvironmentStrings_U(
2780 _In_z_ PWSTR Environment
,
2781 _In_ PUNICODE_STRING Source
,
2782 _Inout_ PUNICODE_STRING Destination
,
2789 RtlGetCurrentDirectory_U(
2790 _In_ ULONG MaximumLength
,
2791 _Out_bytecap_(MaximumLength
) PWSTR Buffer
2797 RtlGetFullPathName_U(
2798 _In_ PCWSTR FileName
,
2800 _Out_z_bytecap_(Size
) PWSTR Buffer
,
2801 _Out_opt_ PWSTR
*ShortName
2804 #if (NTDDI_VERSION >= NTDDI_WIN7)
2808 RtlGetFullPathName_UEx(
2809 _In_ PWSTR FileName
,
2810 _In_ ULONG BufferLength
,
2812 _Out_opt_ PWSTR
*FilePart
,
2813 _Out_opt_ RTL_PATH_TYPE
*InputPathType
2819 RtlGetFullPathName_UstrEx(
2820 _In_ PUNICODE_STRING FileName
,
2821 _In_opt_ PUNICODE_STRING StaticString
,
2822 _In_opt_ PUNICODE_STRING DynamicString
,
2823 _Out_opt_ PUNICODE_STRING
*StringUsed
,
2824 _Out_opt_ PSIZE_T FilePartSize
,
2825 _Out_opt_ PBOOLEAN NameInvalid
,
2826 _Out_ RTL_PATH_TYPE
* PathType
,
2827 _Out_opt_ PSIZE_T LengthNeeded
2833 RtlGetLengthWithoutTrailingPathSeperators(
2834 _Reserved_ ULONG Flags
,
2835 _In_ PCUNICODE_STRING PathString
,
2842 RtlGetLongestNtPathLength(
2849 RtlIsDosDeviceName_U(
2856 RtlIsDosDeviceName_Ustr(
2857 _In_ PCUNICODE_STRING Name
2860 _IRQL_requires_max_(PASSIVE_LEVEL
)
2861 _Must_inspect_result_
2865 RtlIsNameLegalDOS8Dot3(
2866 _In_ PCUNICODE_STRING Name
,
2867 _Inout_opt_ POEM_STRING OemName
,
2868 _Out_opt_ PBOOLEAN NameContainsSpaces
2874 RtlQueryEnvironmentVariable_U(
2875 _In_opt_ PWSTR Environment
,
2876 _In_ PUNICODE_STRING Name
,
2877 _Out_ PUNICODE_STRING Value
2882 RtlReleaseRelativeName(
2883 _In_ PRTL_RELATIVE_NAME_U RelativeName
2889 RtlSetCurrentDirectory_U(
2890 _In_ PUNICODE_STRING name
2896 RtlSetEnvironmentVariable(
2897 _In_z_ PWSTR
*Environment
,
2898 _In_ PUNICODE_STRING Name
,
2899 _In_ PUNICODE_STRING Value
2903 // Critical Section/Resource Functions
2908 RtlDeleteCriticalSection (
2909 _In_ PRTL_CRITICAL_SECTION CriticalSection
2915 RtlEnterCriticalSection(
2916 _In_ PRTL_CRITICAL_SECTION CriticalSection
2922 RtlInitializeCriticalSection(
2923 _In_ PRTL_CRITICAL_SECTION CriticalSection
2929 RtlInitializeCriticalSectionAndSpinCount(
2930 _In_ PRTL_CRITICAL_SECTION CriticalSection
,
2931 _In_ ULONG SpinCount
2937 RtlLeaveCriticalSection(
2938 _In_ PRTL_CRITICAL_SECTION CriticalSection
2944 RtlTryEnterCriticalSection(
2945 _In_ PRTL_CRITICAL_SECTION CriticalSection
2951 RtlpUnWaitCriticalSection(
2952 _In_ PRTL_CRITICAL_SECTION CriticalSection
2958 RtlpWaitForCriticalSection(
2959 _In_ PRTL_CRITICAL_SECTION CriticalSection
2965 RtlAcquireResourceExclusive(
2966 _In_ PRTL_RESOURCE Resource
,
2973 RtlAcquireResourceShared(
2974 _In_ PRTL_RESOURCE Resource
,
2981 RtlConvertExclusiveToShared(
2982 _In_ PRTL_RESOURCE Resource
2988 RtlConvertSharedToExclusive(
2989 _In_ PRTL_RESOURCE Resource
2996 _In_ PRTL_RESOURCE Resource
3003 _In_ PRTL_RESOURCE Resource
3009 RtlInitializeResource(
3010 _In_ PRTL_RESOURCE Resource
3017 _In_ PRTL_RESOURCE Resource
3021 // Compression Functions
3023 NTSYSAPI
//NT_RTL_COMPRESS_API
3027 _In_ USHORT CompressionFormatAndEngine
,
3028 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
3029 _In_ ULONG UncompressedBufferSize
,
3030 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
3031 _In_ ULONG CompressedBufferSize
,
3032 _In_ ULONG UncompressedChunkSize
,
3033 _Out_ PULONG FinalCompressedSize
,
3034 _In_ PVOID WorkSpace
3037 _IRQL_requires_max_(APC_LEVEL
)
3038 NTSYSAPI
//NT_RTL_COMPRESS_API
3041 RtlDecompressBuffer(
3042 _In_ USHORT CompressionFormat
,
3043 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
3044 _In_ ULONG UncompressedBufferSize
,
3045 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
3046 _In_ ULONG CompressedBufferSize
,
3047 _Out_ PULONG FinalUncompressedSize
3053 RtlGetCompressionWorkSpaceSize(
3054 _In_ USHORT CompressionFormatAndEngine
,
3055 _Out_ PULONG CompressBufferWorkSpaceSize
,
3056 _Out_ PULONG CompressFragmentWorkSpaceSize
3066 _In_ PTEB_ACTIVE_FRAME Frame
3073 _In_ PTEB_ACTIVE_FRAME Frame
3084 // Debug Info Functions
3087 PRTL_DEBUG_INFORMATION
3089 RtlCreateQueryDebugBuffer(
3091 _In_ BOOLEAN EventPair
3097 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
3102 RtlQueryProcessDebugInformation(
3103 _In_ ULONG ProcessId
,
3104 _In_ ULONG DebugInfoClassMask
,
3105 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3115 _In_ PRTL_BITMAP BitMapHeader
,
3116 _In_ ULONG StartingIndex
,
3124 _In_ PRTL_BITMAP BitMapHeader
,
3125 _In_ ULONG StartingIndex
,
3133 _In_ PRTL_BITMAP BitMapHeader
3140 _In_ PRTL_BITMAP BitMapHeader
,
3141 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
3142 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
3149 _In_ PRTL_BITMAP BitMapHeader
,
3150 _In_ ULONG NumberToFind
,
3151 _In_ ULONG HintIndex
3157 RtlFindClearBitsAndSet(
3158 _In_ PRTL_BITMAP BitMapHeader
,
3159 _In_ ULONG NumberToFind
,
3160 _In_ ULONG HintIndex
3166 RtlFindFirstRunClear(
3167 _In_ PRTL_BITMAP BitMapHeader
,
3168 _Out_ PULONG StartingIndex
3175 _In_ PRTL_BITMAP BitMapHeader
,
3176 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
3177 _In_range_(>, 0) ULONG SizeOfRunArray
,
3178 _In_ BOOLEAN LocateLongestRuns
3184 RtlFindLastBackwardRunClear(
3185 _In_ PRTL_BITMAP BitMapHeader
,
3186 _In_ ULONG FromIndex
,
3187 _Out_ PULONG StartingRunIndex
3193 RtlFindLeastSignificantBit(
3194 _In_ ULONGLONG Value
3200 RtlFindMostSignificantBit(
3201 _In_ ULONGLONG Value
3207 RtlFindNextForwardRunClear(
3208 _In_ PRTL_BITMAP BitMapHeader
,
3209 _In_ ULONG FromIndex
,
3210 _Out_ PULONG StartingRunIndex
3216 RtlFindNextForwardRunSet(
3217 _In_ PRTL_BITMAP BitMapHeader
,
3218 _In_ ULONG FromIndex
,
3219 _Out_ PULONG StartingRunIndex
3226 _In_ PRTL_BITMAP BitMapHeader
,
3227 _In_ ULONG NumberToFind
,
3228 _In_ ULONG HintIndex
3234 RtlFindSetBitsAndClear(
3235 _In_ PRTL_BITMAP BitMapHeader
,
3236 _In_ ULONG NumberToFind
,
3237 _In_ ULONG HintIndex
3240 #ifdef _REACTOS_ // ReactOS improvement
3241 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
3242 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
3247 RtlInitializeBitMap(
3248 _Out_ PRTL_BITMAP BitMapHeader
,
3249 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
3250 _In_opt_ ULONG SizeOfBitMap
3256 RtlNumberOfClearBits(
3257 _In_ PRTL_BITMAP BitMapHeader
3264 _In_ PRTL_BITMAP BitMapHeader
3271 _In_ PRTL_BITMAP BitMapHeader
,
3272 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3279 _In_ PRTL_BITMAP BitMapHeader
,
3280 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
3281 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
3288 _In_ PRTL_BITMAP BitMapHeader
3291 _Must_inspect_result_
3296 _In_ PRTL_BITMAP BitMapHeader
,
3297 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
3307 _In_ HANDLE TimerQueue
,
3308 _In_ PHANDLE phNewTimer
,
3309 _In_ WAITORTIMERCALLBACKFUNC Callback
,
3310 _In_ PVOID Parameter
,
3319 RtlCreateTimerQueue(PHANDLE TimerQueue
);
3325 _In_ HANDLE TimerQueue
,
3327 _In_ HANDLE CompletionEvent
3334 _In_ HANDLE TimerQueue
,
3343 RtlDeleteTimerQueueEx(
3344 _In_ HANDLE TimerQueue
,
3345 _In_opt_ HANDLE CompletionEvent
3351 RtlDeleteTimerQueue(HANDLE TimerQueue
);
3358 InterlockedPushListSList(
3359 _Inout_ PSLIST_HEADER ListHead
,
3360 _Inout_ __drv_aliasesMem PSLIST_ENTRY List
,
3361 _Inout_ PSLIST_ENTRY ListEnd
,
3366 // Range List functions
3371 RtlInitializeRangeList(
3372 _Inout_ PRTL_RANGE_LIST RangeList
3379 _In_ PRTL_RANGE_LIST RangeList
3386 _Inout_ PRTL_RANGE_LIST RangeList
,
3387 _In_ ULONGLONG Start
,
3389 _In_ UCHAR Attributes
,
3391 _In_opt_ PVOID UserData
,
3392 _In_opt_ PVOID Owner
3401 _In_z_ _Printf_format_string_ PCSTR Format
,
3409 _In_ ULONG ComponentId
,
3411 _In_z_ _Printf_format_string_ PCSTR Format
,
3420 _Out_writes_bytes_(MaximumResponseLength
) PCH Response
,
3421 _In_ ULONG MaximumResponseLength
3424 #undef DbgBreakPoint
3433 DbgLoadImageSymbols(
3436 _In_ ULONG_PTR ProcessId
3441 DbgUnLoadImageSymbols(
3444 _In_ ULONG_PTR ProcessId
3455 // Generic Table Functions
3457 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3461 RtlInsertElementGenericTable(
3462 _In_ PRTL_GENERIC_TABLE Table
,
3463 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3464 _In_ CLONG BufferSize
,
3465 _Out_opt_ PBOOLEAN NewElement
3471 RtlInsertElementGenericTableFull(
3472 _In_ PRTL_GENERIC_TABLE Table
,
3473 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
3474 _In_ CLONG BufferSize
,
3475 _Out_opt_ PBOOLEAN NewElement
,
3476 _In_ PVOID NodeOrParent
,
3477 _In_ TABLE_SEARCH_RESULT SearchResult
3483 RtlIsGenericTableEmpty(
3484 _In_ PRTL_GENERIC_TABLE Table
3490 RtlLookupElementGenericTableFull(
3491 _In_ PRTL_GENERIC_TABLE Table
,
3493 _Out_ PVOID
*NodeOrParent
,
3494 _Out_ TABLE_SEARCH_RESULT
*SearchResult
3499 // Handle Table Functions
3502 PRTL_HANDLE_TABLE_ENTRY
3505 _In_ PRTL_HANDLE_TABLE HandleTable
,
3506 _Inout_ PULONG Index
3512 RtlDestroyHandleTable(
3513 _Inout_ PRTL_HANDLE_TABLE HandleTable
);
3519 _In_ PRTL_HANDLE_TABLE HandleTable
,
3520 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3526 RtlInitializeHandleTable(
3527 _In_ ULONG TableSize
,
3528 _In_ ULONG HandleSize
,
3529 _In_ PRTL_HANDLE_TABLE HandleTable
3536 _In_ PRTL_HANDLE_TABLE HandleTable
,
3537 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3540 _Success_(return!=FALSE
)
3544 RtlIsValidIndexHandle(
3545 _In_ PRTL_HANDLE_TABLE HandleTable
,
3547 _Out_ PRTL_HANDLE_TABLE_ENTRY
*Handle
3557 _In_ PVOID BaseAddress
,
3559 _In_ ULONG Language
,
3560 _In_ ULONG MessageId
,
3561 _Out_ PMESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
3567 RtlGetNtGlobalFlags(VOID
);
3569 _Success_(return!=NULL
)
3573 RtlImageDirectoryEntryToData(
3574 _In_ PVOID BaseAddress
,
3575 _In_ BOOLEAN MappedAsImage
,
3576 _In_ USHORT Directory
,
3584 _In_ PIMAGE_NT_HEADERS NtHeader
,
3585 _In_ PVOID BaseAddress
,
3587 _Inout_opt_ PIMAGE_SECTION_HEADER
*SectionHeader
3594 _In_ PVOID BaseAddress
);
3601 _In_ PVOID BaseAddress
,
3602 _In_ ULONGLONG Size
,
3603 _Out_ PIMAGE_NT_HEADERS
*NtHeader
3607 PIMAGE_SECTION_HEADER
3609 RtlImageRvaToSection(
3610 _In_ PIMAGE_NT_HEADERS NtHeader
,
3611 _In_ PVOID BaseAddress
,
3618 LdrRelocateImageWithBias(
3619 _In_ PVOID NewAddress
,
3620 _In_ LONGLONG AdditionalBias
,
3621 _In_ PCCH LoaderName
,
3623 _In_ ULONG Conflict
,
3628 // Activation Context Functions
3630 #ifdef NTOS_MODE_USER
3634 RtlActivateActivationContextEx(
3638 _Out_ PULONG_PTR Cookie
3644 RtlActivateActivationContext(
3647 _Out_ PULONG_PTR Cookie
3653 RtlAddRefActivationContext(
3658 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3660 RtlActivateActivationContextUnsafeFast(
3661 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
3668 RtlAllocateActivationContextStack(
3669 _In_ PACTIVATION_CONTEXT_STACK
*Stack
3675 RtlCreateActivationContext(
3677 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData
,
3678 _In_ ULONG ExtraBytes
,
3679 _In_ PVOID NotificationRoutine
,
3680 _In_ PVOID NotificationContext
,
3681 _Out_ PACTIVATION_CONTEXT
*ActCtx
3687 RtlGetActiveActivationContext(
3694 RtlReleaseActivationContext(
3701 RtlDeactivateActivationContext(
3703 _In_ ULONG_PTR ulCookie
3709 RtlFreeActivationContextStack(
3710 _In_ PACTIVATION_CONTEXT_STACK Stack
3716 RtlFreeThreadActivationContextStack(VOID
);
3719 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3721 RtlDeactivateActivationContextUnsafeFast(
3722 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3728 RtlDosApplyFileIsolationRedirection_Ustr(
3730 _In_ PUNICODE_STRING OriginalName
,
3731 _In_ PUNICODE_STRING Extension
,
3732 _Inout_ PUNICODE_STRING StaticString
,
3733 _Inout_ PUNICODE_STRING DynamicString
,
3734 _Inout_ PUNICODE_STRING
*NewName
,
3735 _In_ PULONG NewFlags
,
3736 _In_ PSIZE_T FileNameSize
,
3737 _In_ PSIZE_T RequiredLength
3743 RtlFindActivationContextSectionString(
3745 _In_
const GUID
*ExtensionGuid
,
3746 _In_ ULONG SectionType
,
3747 _In_
const UNICODE_STRING
*SectionName
,
3748 _Inout_ PVOID ReturnedData
3754 RtlQueryInformationActivationContext(
3756 _In_opt_ PVOID Context
,
3757 _In_opt_ PVOID pvSubInstance
,
3758 _In_ ULONG ulInfoClass
,
3759 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3760 _In_opt_ SIZE_T cbBuffer
,
3761 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3767 RtlQueryInformationActiveActivationContext(
3768 _In_ ULONG ulInfoClass
,
3769 _Out_bytecap_(cbBuffer
) PVOID pvBuffer
,
3770 _In_opt_ SIZE_T cbBuffer
,
3771 _Out_opt_ SIZE_T
*pcbWrittenOrRequired
3777 RtlZombifyActivationContext(
3787 RtlWow64EnableFsRedirection(
3788 _In_ BOOLEAN Wow64FsEnableRedirection
3794 RtlWow64EnableFsRedirectionEx(
3795 _In_ PVOID Wow64FsEnableRedirection
,
3796 _Out_ PVOID
*OldFsRedirectionLevel
3802 // Registry Functions
3804 _IRQL_requires_max_(PASSIVE_LEVEL
)
3805 _Must_inspect_result_
3809 RtlCheckRegistryKey(
3810 _In_ ULONG RelativeTo
,
3817 RtlCreateRegistryKey(
3818 _In_ ULONG RelativeTo
,
3825 RtlFormatCurrentUserKeyPath(
3826 _Out_
_At_(KeyPath
->Buffer
, __drv_allocatesMem(Mem
) _Post_bytecap_(KeyPath
->MaximumLength
) _Post_bytecount_(KeyPath
->Length
))
3827 PUNICODE_STRING KeyPath
3834 _In_ ACCESS_MASK DesiredAccess
,
3835 _Out_ PHANDLE KeyHandle
3838 _IRQL_requires_max_(PASSIVE_LEVEL
)
3842 RtlQueryRegistryValues(
3843 _In_ ULONG RelativeTo
,
3845 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
3846 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
3847 _In_opt_ PVOID Context
,
3848 _In_opt_ PVOID Environment
3851 _IRQL_requires_max_(PASSIVE_LEVEL
)
3855 RtlWriteRegistryValue(
3856 _In_ ULONG RelativeTo
,
3858 _In_z_ PCWSTR ValueName
,
3859 _In_ ULONG ValueType
,
3860 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
3861 _In_ ULONG ValueLength
3864 #ifdef NTOS_MODE_USER
3869 _Out_ HANDLE KeyHandle
,
3870 _In_ ACCESS_MASK DesiredAccess
,
3871 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3872 _In_ ULONG TitleIndex
,
3873 _In_ PUNICODE_STRING Class
,
3874 _Out_ PULONG Disposition
3880 RtlpNtEnumerateSubKey(
3881 _In_ HANDLE KeyHandle
,
3882 _Inout_ PUNICODE_STRING SubKeyName
,
3890 RtlpNtMakeTemporaryKey(
3891 _In_ HANDLE KeyHandle
3898 _Out_ HANDLE KeyHandle
,
3899 _In_ ACCESS_MASK DesiredAccess
,
3900 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
3907 RtlpNtQueryValueKey(
3908 _In_ HANDLE KeyHandle
,
3909 _Out_opt_ PULONG Type
,
3910 _Out_opt_ PVOID Data
,
3911 _Inout_opt_ PULONG DataLength
,
3919 _In_ HANDLE KeyHandle
,
3922 _In_ ULONG DataLength
3932 RtlGetDefaultCodePage(
3933 _Out_ PUSHORT AnsiCodePage
,
3934 _Out_ PUSHORT OemCodePage
3941 _In_ PUSHORT AnsiTableBase
,
3942 _In_ PUSHORT OemTableBase
,
3943 _In_ PUSHORT CaseTableBase
,
3944 _Out_ PNLSTABLEINFO NlsTable
3947 _IRQL_requires_max_(PASSIVE_LEVEL
)
3951 RtlInitCodePageTable(
3952 _In_ PUSHORT TableBase
,
3953 _Out_ PCPTABLEINFO CodePageTable
3959 RtlResetRtlTranslations(
3960 _In_ PNLSTABLEINFO NlsTable
);
3962 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3965 // Misc conversion functions
3970 RtlConvertLongToLargeInteger(
3971 _In_ LONG SignedInteger
3974 LARGE_INTEGER Result
;
3976 Result
.QuadPart
= SignedInteger
;
3983 RtlEnlargedIntegerMultiply(
3984 _In_ LONG Multiplicand
,
3985 _In_ LONG Multiplier
3988 LARGE_INTEGER Product
;
3990 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
3997 RtlEnlargedUnsignedDivide(
3998 _In_ ULARGE_INTEGER Dividend
,
4000 _In_opt_ PULONG Remainder
4005 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
4007 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
4016 RtlEnlargedUnsignedMultiply(
4017 _In_ ULONG Multiplicand
,
4018 _In_ ULONG Multiplier
4021 LARGE_INTEGER Product
;
4023 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
4027 #if defined(_AMD64_) || defined(_IA64_)
4031 RtlExtendedLargeIntegerDivide(
4032 _In_ LARGE_INTEGER Dividend
,
4034 _Out_opt_ PULONG Remainder
)
4037 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
4039 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
4047 RtlExtendedLargeIntegerDivide(
4048 _In_ LARGE_INTEGER Dividend
,
4050 _Out_opt_ PULONG Remainder
4053 #endif /* defined(_AMD64_) || defined(_IA64_) */
4076 _In_ ULONG InitialCrc
,
4082 // Network Functions
4087 RtlIpv4AddressToStringA(
4088 _In_
const struct in_addr
*Addr
,
4089 _Out_writes_(16) PCHAR S
4095 RtlIpv4AddressToStringW(
4096 _In_
const struct in_addr
*Addr
,
4097 _Out_writes_(16) PWCHAR S
4103 RtlIpv4AddressToStringExA(
4104 _In_
const struct in_addr
*Address
,
4106 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PCHAR AddressString
,
4107 _Inout_ PULONG AddressStringLength
4112 RtlIpv4AddressToStringExW(
4113 _In_
const struct in_addr
*Address
,
4115 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4116 _Inout_ PULONG AddressStringLength
4122 RtlIpv4StringToAddressA(
4124 _In_ BOOLEAN Strict
,
4125 _Out_ PCSTR
*Terminator
,
4126 _Out_
struct in_addr
*Addr
4132 RtlIpv4StringToAddressW(
4134 _In_ BOOLEAN Strict
,
4135 _Out_ PCWSTR
*Terminator
,
4136 _Out_
struct in_addr
*Addr
4142 RtlIpv4StringToAddressExA(
4143 _In_ PCSTR AddressString
,
4144 _In_ BOOLEAN Strict
,
4145 _Out_
struct in_addr
*Address
,
4152 RtlIpv4StringToAddressExW(
4153 _In_ PCWSTR AddressString
,
4154 _In_ BOOLEAN Strict
,
4155 _Out_
struct in_addr
*Address
,
4162 RtlIpv6AddressToStringA(
4163 _In_
const struct in6_addr
*Addr
,
4164 _Out_writes_(46) PSTR S
4170 RtlIpv6AddressToStringW(
4171 _In_
const struct in6_addr
*Addr
,
4172 _Out_writes_(46) PWSTR S
4178 RtlIpv6AddressToStringExA(
4179 _In_
const struct in6_addr
*Address
,
4182 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PSTR AddressString
,
4183 _Inout_ PULONG AddressStringLength
4189 RtlIpv6AddressToStringExW(
4190 _In_
const struct in6_addr
*Address
,
4193 _Out_writes_to_(*AddressStringLength
, *AddressStringLength
) PWCHAR AddressString
,
4194 _Inout_ PULONG AddressStringLength
4200 RtlIpv6StringToAddressA(
4202 _Out_ PCSTR
*Terminator
,
4203 _Out_
struct in6_addr
*Addr
4209 RtlIpv6StringToAddressW(
4211 _Out_ PCWSTR
*Terminator
,
4212 _Out_
struct in6_addr
*Addr
4218 RtlIpv6StringToAddressExA(
4219 _In_ PCSTR AddressString
,
4220 _Out_
struct in6_addr
*Address
,
4221 _Out_ PULONG ScopeId
,
4228 RtlIpv6StringToAddressExW(
4229 _In_ PCWSTR AddressString
,
4230 _Out_
struct in6_addr
*Address
,
4231 _Out_ PULONG ScopeId
,
4242 RtlQueryTimeZoneInformation(
4243 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4248 RtlSecondsSince1970ToTime(
4249 _In_ ULONG SecondsSince1970
,
4250 _Out_ PLARGE_INTEGER Time
4256 RtlSetTimeZoneInformation(
4257 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
4259 _Success_(return!=FALSE
)
4260 _Must_inspect_result_
4264 RtlTimeFieldsToTime(
4265 _In_ PTIME_FIELDS TimeFields
,
4266 _Out_ PLARGE_INTEGER Time
4269 _Success_(return != 0)
4270 _Must_inspect_result_
4274 RtlTimeToSecondsSince1970(
4275 _In_ PLARGE_INTEGER Time
,
4276 _Out_ PULONG ElapsedSeconds
4282 RtlTimeToTimeFields(
4283 PLARGE_INTEGER Time
,
4284 PTIME_FIELDS TimeFields
4290 RtlSystemTimeToLocalTime(
4291 _In_ PLARGE_INTEGER SystemTime
,
4292 _Out_ PLARGE_INTEGER LocalTime
4296 // Version Functions
4298 _IRQL_requires_max_(PASSIVE_LEVEL
)
4299 _Must_inspect_result_
4303 RtlVerifyVersionInfo(
4304 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
4305 _In_ ULONG TypeMask
,
4306 _In_ ULONGLONG ConditionMask
4309 _IRQL_requires_max_(PASSIVE_LEVEL
)
4315 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
4316 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
4317 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
4318 PRTL_OSVERSIONINFOW lpVersionInformation
4324 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
4327 // Secure Memory Functions
4329 #ifdef NTOS_MODE_USER
4333 RtlRegisterSecureMemoryCacheCallback(
4334 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
4339 RtlFlushSecureMemoryCache(
4340 _In_ PVOID MemoryCache
,
4341 _In_opt_ SIZE_T MemoryLength
4346 // Boot Status Data Functions
4348 #ifdef NTOS_MODE_USER
4352 RtlCreateBootStatusDataFile(
4359 RtlGetSetBootStatusData(
4360 _In_ HANDLE FileHandle
,
4361 _In_ BOOLEAN WriteMode
,
4362 _In_ RTL_BSD_ITEM_TYPE DataClass
,
4364 _In_ ULONG BufferSize
,
4365 _Out_opt_ PULONG ReturnLength
4371 RtlLockBootStatusData(
4372 _Out_ PHANDLE FileHandle
4378 RtlUnlockBootStatusData(
4379 _In_ HANDLE FileHandle
4383 #ifdef NTOS_MODE_USER
4384 _Must_inspect_result_
4389 _In_ PUNICODE_STRING GuidString
,
4392 _Must_inspect_result_
4398 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
4399 PUNICODE_STRING GuidString
);
4404 RtlComputeImportTableHash(
4407 _In_ ULONG ImportTableHashRevision
4412 // MemoryStream functions
4414 #ifdef NTOS_MODE_USER
4419 RtlInitMemoryStream(
4420 _Out_ PRTL_MEMORY_STREAM Stream
4426 RtlInitOutOfProcessMemoryStream(
4427 _Out_ PRTL_MEMORY_STREAM Stream
4433 RtlFinalReleaseOutOfProcessMemoryStream(
4434 _In_ PRTL_MEMORY_STREAM Stream
4440 RtlQueryInterfaceMemoryStream(
4441 _In_
struct IStream
*This
,
4442 _In_ REFIID RequestedIid
,
4443 _Outptr_ PVOID
*ResultObject
4449 RtlAddRefMemoryStream(
4450 _In_
struct IStream
*This
4456 RtlReleaseMemoryStream(
4457 _In_
struct IStream
*This
4463 RtlReadMemoryStream(
4464 _In_
struct IStream
*This
,
4465 _Out_writes_bytes_(Length
) PVOID Buffer
,
4467 _Out_opt_ PULONG BytesRead
4473 RtlReadOutOfProcessMemoryStream(
4474 _In_
struct IStream
*This
,
4475 _Out_writes_bytes_(Length
) PVOID Buffer
,
4477 _Out_opt_ PULONG BytesRead
4483 RtlSeekMemoryStream(
4484 _In_
struct IStream
*This
,
4485 _In_ LARGE_INTEGER RelativeOffset
,
4487 _Out_opt_ PULARGE_INTEGER ResultOffset
4493 RtlCopyMemoryStreamTo(
4494 _In_
struct IStream
*This
,
4495 _In_
struct IStream
*Target
,
4496 _In_ ULARGE_INTEGER Length
,
4497 _Out_opt_ PULARGE_INTEGER BytesRead
,
4498 _Out_opt_ PULARGE_INTEGER BytesWritten
4504 RtlCopyOutOfProcessMemoryStreamTo(
4505 _In_
struct IStream
*This
,
4506 _In_
struct IStream
*Target
,
4507 _In_ ULARGE_INTEGER Length
,
4508 _Out_opt_ PULARGE_INTEGER BytesRead
,
4509 _Out_opt_ PULARGE_INTEGER BytesWritten
4515 RtlStatMemoryStream(
4516 _In_
struct IStream
*This
,
4517 _Out_
struct tagSTATSTG
*Stats
,
4525 RtlWriteMemoryStream(
4526 _In_
struct IStream
*This
,
4527 _In_reads_bytes_(Length
) CONST VOID
*Buffer
,
4529 _Out_opt_ PULONG BytesWritten
4535 RtlSetMemoryStreamSize(
4536 _In_
struct IStream
*This
,
4537 _In_ ULARGE_INTEGER NewSize
4543 RtlCommitMemoryStream(
4544 _In_
struct IStream
*This
,
4545 _In_ ULONG CommitFlags
4551 RtlRevertMemoryStream(
4552 _In_
struct IStream
*This
4558 RtlLockMemoryStreamRegion(
4559 _In_
struct IStream
*This
,
4560 _In_ ULARGE_INTEGER Offset
,
4561 _In_ ULARGE_INTEGER Length
,
4568 RtlUnlockMemoryStreamRegion(
4569 _In_
struct IStream
*This
,
4570 _In_ ULARGE_INTEGER Offset
,
4571 _In_ ULARGE_INTEGER Length
,
4578 RtlCloneMemoryStream(
4579 _In_
struct IStream
*This
,
4580 _Outptr_
struct IStream
**ResultStream
4583 #endif // NTOS_MODE_USER
4588 RtlFindActivationContextSectionGuid(
4590 const GUID
*extguid
,