1 /******************************************************************************
2 * Runtime Library Functions *
3 ******************************************************************************/
7 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
9 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
14 _Out_ PLIST_ENTRY ListHead
)
16 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
23 _In_
const LIST_ENTRY
* ListHead
)
25 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
31 _In_ PLIST_ENTRY Entry
)
36 OldFlink
= Entry
->Flink
;
37 OldBlink
= Entry
->Blink
;
38 OldFlink
->Blink
= OldBlink
;
39 OldBlink
->Flink
= OldFlink
;
40 return (BOOLEAN
)(OldFlink
== OldBlink
);
46 _Inout_ PLIST_ENTRY ListHead
)
51 Entry
= ListHead
->Flink
;
53 ListHead
->Flink
= Flink
;
54 Flink
->Blink
= ListHead
;
61 _Inout_ PLIST_ENTRY ListHead
)
66 Entry
= ListHead
->Blink
;
68 ListHead
->Blink
= Blink
;
69 Blink
->Flink
= ListHead
;
76 _Inout_ PLIST_ENTRY ListHead
,
77 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
80 OldBlink
= ListHead
->Blink
;
81 Entry
->Flink
= ListHead
;
82 Entry
->Blink
= OldBlink
;
83 OldBlink
->Flink
= Entry
;
84 ListHead
->Blink
= Entry
;
90 _Inout_ PLIST_ENTRY ListHead
,
91 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
94 OldFlink
= ListHead
->Flink
;
95 Entry
->Flink
= OldFlink
;
96 Entry
->Blink
= ListHead
;
97 OldFlink
->Blink
= Entry
;
98 ListHead
->Flink
= Entry
;
104 _Inout_ PLIST_ENTRY ListHead
,
105 _Inout_ PLIST_ENTRY ListToAppend
)
107 PLIST_ENTRY ListEnd
= ListHead
->Blink
;
109 ListHead
->Blink
->Flink
= ListToAppend
;
110 ListHead
->Blink
= ListToAppend
->Blink
;
111 ListToAppend
->Blink
->Flink
= ListHead
;
112 ListToAppend
->Blink
= ListEnd
;
118 _Inout_ PSINGLE_LIST_ENTRY ListHead
)
120 PSINGLE_LIST_ENTRY FirstEntry
;
121 FirstEntry
= ListHead
->Next
;
122 if (FirstEntry
!= NULL
) {
123 ListHead
->Next
= FirstEntry
->Next
;
131 _Inout_ PSINGLE_LIST_ENTRY ListHead
,
132 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry
)
134 Entry
->Next
= ListHead
->Next
;
135 ListHead
->Next
= Entry
;
138 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
145 _In_ PVOID FailedAssertion
,
147 _In_ ULONG LineNumber
,
148 _In_opt_ PSTR Message
);
152 * IN VOID UNALIGNED *Destination,
153 * IN CONST VOID UNALIGNED *Source,
156 #define RtlCopyMemory(Destination, Source, Length) \
157 memcpy(Destination, Source, Length)
159 #define RtlCopyBytes RtlCopyMemory
161 #if defined(_M_AMD64)
165 RtlCopyMemoryNonTemporal(
166 _Out_writes_bytes_all_(Length
) VOID UNALIGNED
*Destination
,
167 _In_reads_bytes_(Length
) const VOID UNALIGNED
*Source
,
170 #define RtlCopyMemoryNonTemporal RtlCopyMemory
178 #define RtlEqualLuid(Luid1, Luid2) \
179 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
183 * IN VOID UNALIGNED *Destination,
184 * IN CONST VOID UNALIGNED *Source,
187 #define RtlEqualMemory(Destination, Source, Length) \
188 (!memcmp(Destination, Source, Length))
192 * IN VOID UNALIGNED *Destination,
196 #define RtlFillMemory(Destination, Length, Fill) \
197 memset(Destination, Fill, Length)
199 #define RtlFillBytes RtlFillMemory
201 _IRQL_requires_max_(PASSIVE_LEVEL
)
205 RtlFreeUnicodeString(
206 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
207 PUNICODE_STRING UnicodeString
);
209 _IRQL_requires_max_(PASSIVE_LEVEL
)
210 _Must_inspect_result_
215 _In_ PUNICODE_STRING GuidString
,
218 _IRQL_requires_max_(DISPATCH_LEVEL
)
219 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
220 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
221 _At_(DestinationString
->MaximumLength
, _Post_equal_to_((_String_length_(SourceString
)+1) * sizeof(WCHAR
)))
225 RtlInitUnicodeString(
226 _Out_ PUNICODE_STRING DestinationString
,
227 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
231 * IN VOID UNALIGNED *Destination,
232 * IN CONST VOID UNALIGNED *Source,
235 #define RtlMoveMemory(Destination, Source, Length) \
236 memmove(Destination, Source, Length)
238 _IRQL_requires_max_(PASSIVE_LEVEL
)
239 _Must_inspect_result_
245 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
246 PUNICODE_STRING GuidString
);
250 * IN VOID UNALIGNED *Destination,
253 #define RtlZeroMemory(Destination, Length) \
254 memset(Destination, 0, Length)
256 #define RtlZeroBytes RtlZeroMemory
259 #if (NTDDI_VERSION >= NTDDI_WIN2K)
262 _Must_inspect_result_
267 _In_ PRTL_BITMAP BitMapHeader
,
268 _In_ ULONG StartingIndex
,
271 _Must_inspect_result_
276 _In_ PRTL_BITMAP BitMapHeader
,
277 _In_ ULONG StartingIndex
,
280 _IRQL_requires_max_(PASSIVE_LEVEL
)
281 _Must_inspect_result_
285 RtlAnsiStringToUnicodeString(
286 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
287 _When_(!AllocateDestinationString
, _Inout_
)
288 PUNICODE_STRING DestinationString
,
289 _In_ PANSI_STRING SourceString
,
290 _In_ BOOLEAN AllocateDestinationString
);
292 _IRQL_requires_max_(PASSIVE_LEVEL
)
296 RtlxAnsiStringToUnicodeSize(
297 _In_ PCANSI_STRING AnsiString
);
299 #define RtlAnsiStringToUnicodeSize(String) ( \
300 NLS_MB_CODE_PAGE_TAG ? \
301 RtlxAnsiStringToUnicodeSize(String) : \
302 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
306 _Unchanged_(Destination
->MaximumLength
)
307 _Unchanged_(Destination
->Buffer
)
308 _When_(_Old_(Destination
->Length
) + Source
->Length
<= Destination
->MaximumLength
,
309 _At_(Destination
->Length
, _Post_equal_to_(_Old_(Destination
->Length
) + Source
->Length
))
310 _At_(return, _Out_range_(==, 0)))
311 _When_(_Old_(Destination
->Length
) + Source
->Length
> Destination
->MaximumLength
,
312 _Unchanged_(Destination
->Length
)
313 _At_(return, _Out_range_(<, 0)))
317 RtlAppendUnicodeStringToString(
318 _Inout_ PUNICODE_STRING Destination
,
319 _In_ PCUNICODE_STRING Source
);
322 _Unchanged_(Destination
->MaximumLength
)
323 _Unchanged_(Destination
->Buffer
)
324 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength,
325 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR)))
326 _At_(return, _Out_range_(==, 0)))
327 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength,
328 _Unchanged_(Destination->Length)
329 _At_(return, _Out_range_(<, 0))) */
333 RtlAppendUnicodeToString(
334 _Inout_ PUNICODE_STRING Destination
,
335 _In_opt_z_ PCWSTR Source
);
337 _IRQL_requires_max_(PASSIVE_LEVEL
)
338 _Must_inspect_result_
343 _In_ ULONG RelativeTo
,
350 _In_ PRTL_BITMAP BitMapHeader
);
356 _In_ PRTL_BITMAP BitMapHeader
,
357 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
358 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
);
360 _Must_inspect_result_
365 _In_
const VOID
*Source1
,
366 _In_
const VOID
*Source2
,
369 _IRQL_requires_max_(PASSIVE_LEVEL
)
370 _Must_inspect_result_
374 RtlCompareUnicodeString(
375 _In_ PCUNICODE_STRING String1
,
376 _In_ PCUNICODE_STRING String2
,
377 _In_ BOOLEAN CaseInSensitive
);
379 _IRQL_requires_max_(PASSIVE_LEVEL
)
380 _Must_inspect_result_
384 RtlCompareUnicodeStrings(
385 _In_reads_(String1Length
) PCWCH String1
,
386 _In_ SIZE_T String1Length
,
387 _In_reads_(String2Length
) PCWCH String2
,
388 _In_ SIZE_T String2Length
,
389 _In_ BOOLEAN CaseInSensitive
);
391 _Unchanged_(DestinationString
->Buffer
)
392 _Unchanged_(DestinationString
->MaximumLength
)
393 _At_(DestinationString
->Length
,
394 _When_(SourceString
->Length
> DestinationString
->MaximumLength
,
395 _Post_equal_to_(DestinationString
->MaximumLength
))
396 _When_(SourceString
->Length
<= DestinationString
->MaximumLength
,
397 _Post_equal_to_(SourceString
->Length
)))
401 RtlCopyUnicodeString(
402 _Inout_ PUNICODE_STRING DestinationString
,
403 _In_opt_ PCUNICODE_STRING SourceString
);
405 _IRQL_requires_max_(PASSIVE_LEVEL
)
409 RtlCreateRegistryKey(
410 _In_ ULONG RelativeTo
,
413 _IRQL_requires_max_(APC_LEVEL
)
417 RtlCreateSecurityDescriptor(
418 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
419 _In_ ULONG Revision
);
421 _IRQL_requires_max_(PASSIVE_LEVEL
)
425 RtlDeleteRegistryValue(
426 _In_ ULONG RelativeTo
,
428 _In_z_ PCWSTR ValueName
);
430 _IRQL_requires_max_(PASSIVE_LEVEL
)
431 _Must_inspect_result_
435 RtlEqualUnicodeString(
436 _In_ CONST UNICODE_STRING
*String1
,
437 _In_ CONST UNICODE_STRING
*String2
,
438 _In_ BOOLEAN CaseInSensitive
);
440 #if !defined(_AMD64_) && !defined(_IA64_)
444 RtlExtendedIntegerMultiply(
445 _In_ LARGE_INTEGER Multiplicand
,
446 _In_ LONG Multiplier
);
451 RtlExtendedLargeIntegerDivide(
452 _In_ LARGE_INTEGER Dividend
,
454 _Out_opt_ PULONG Remainder
);
457 #if defined(_X86_) || defined(_IA64_)
461 RtlExtendedMagicDivide(
462 _In_ LARGE_INTEGER Dividend
,
463 _In_ LARGE_INTEGER MagicDivisor
,
464 _In_ CCHAR ShiftCount
);
467 _IRQL_requires_max_(PASSIVE_LEVEL
)
472 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
473 PANSI_STRING AnsiString
);
475 _Success_(return != -1)
476 _Must_inspect_result_
481 _In_ PRTL_BITMAP BitMapHeader
,
482 _In_ ULONG NumberToFind
,
483 _In_ ULONG HintIndex
);
485 _Success_(return != -1)
489 RtlFindClearBitsAndSet(
490 _In_ PRTL_BITMAP BitMapHeader
,
491 _In_ ULONG NumberToFind
,
492 _In_ ULONG HintIndex
);
497 RtlFindFirstRunClear(
498 _In_ PRTL_BITMAP BitMapHeader
,
499 _Out_ PULONG StartingIndex
);
505 _In_ PRTL_BITMAP BitMapHeader
,
506 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
507 _In_range_(>, 0) ULONG SizeOfRunArray
,
508 _In_ BOOLEAN LocateLongestRuns
);
513 RtlFindLastBackwardRunClear(
514 _In_ PRTL_BITMAP BitMapHeader
,
515 _In_ ULONG FromIndex
,
516 _Out_ PULONG StartingRunIndex
);
518 _Success_(return != -1)
519 _Must_inspect_result_
523 RtlFindLeastSignificantBit(
529 RtlFindLongestRunClear(
530 _In_ PRTL_BITMAP BitMapHeader
,
531 _Out_ PULONG StartingIndex
);
533 _Success_(return != -1)
534 _Must_inspect_result_
538 RtlFindMostSignificantBit(
544 RtlFindNextForwardRunClear(
545 _In_ PRTL_BITMAP BitMapHeader
,
546 _In_ ULONG FromIndex
,
547 _Out_ PULONG StartingRunIndex
);
549 _Success_(return != -1)
550 _Must_inspect_result_
555 _In_ PRTL_BITMAP BitMapHeader
,
556 _In_ ULONG NumberToFind
,
557 _In_ ULONG HintIndex
);
559 _Success_(return != -1)
563 RtlFindSetBitsAndClear(
564 _In_ PRTL_BITMAP BitMapHeader
,
565 _In_ ULONG NumberToFind
,
566 _In_ ULONG HintIndex
);
568 _IRQL_requires_max_(DISPATCH_LEVEL
)
573 _Out_ PANSI_STRING DestinationString
,
574 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
576 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
577 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
582 _Out_ PRTL_BITMAP BitMapHeader
,
583 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
584 _In_opt_ ULONG SizeOfBitMap
);
586 _IRQL_requires_max_(DISPATCH_LEVEL
)
591 _Out_ PSTRING DestinationString
,
592 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
594 _IRQL_requires_max_(PASSIVE_LEVEL
)
595 _At_(String
->MaximumLength
, _Const_
)
599 RtlIntegerToUnicodeString(
602 _Inout_ PUNICODE_STRING String
);
604 _IRQL_requires_max_(PASSIVE_LEVEL
)
605 _At_(String
->MaximumLength
, _Const_
)
609 RtlInt64ToUnicodeString(
610 _In_ ULONGLONG Value
,
612 _Inout_ PUNICODE_STRING String
);
615 #define RtlIntPtrToUnicodeString(Value, Base, String) \
616 RtlInt64ToUnicodeString(Value, Base, String)
618 #define RtlIntPtrToUnicodeString(Value, Base, String) \
619 RtlIntegerToUnicodeString(Value, Base, String)
626 #define RtlIsZeroLuid(_L1) \
627 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
629 _IRQL_requires_max_(APC_LEVEL
)
633 RtlLengthSecurityDescriptor(
634 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
639 RtlNumberOfClearBits(
640 _In_ PRTL_BITMAP BitMapHeader
);
646 _In_ PRTL_BITMAP BitMapHeader
);
648 _IRQL_requires_max_(PASSIVE_LEVEL
)
652 RtlQueryRegistryValues(
653 _In_ ULONG RelativeTo
,
655 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
656 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
657 _In_opt_ PVOID Context
,
658 _In_opt_ PVOID Environment
);
660 #define SHORT_SIZE (sizeof(USHORT))
661 #define SHORT_MASK (SHORT_SIZE - 1)
662 #define LONG_SIZE (sizeof(LONG))
663 #define LONGLONG_SIZE (sizeof(LONGLONG))
664 #define LONG_MASK (LONG_SIZE - 1)
665 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
666 #define LOWBYTE_MASK 0x00FF
668 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
669 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
670 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
671 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
677 _In_ PRTL_BITMAP BitMapHeader
);
683 _In_ PRTL_BITMAP BitMapHeader
,
684 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
685 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
);
687 _IRQL_requires_max_(APC_LEVEL
)
691 RtlSetDaclSecurityDescriptor(
692 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
693 _In_ BOOLEAN DaclPresent
,
695 _In_opt_ BOOLEAN DaclDefaulted
);
704 #define RtlStoreUlong(Address,Value) \
705 *(ULONG UNALIGNED *)(Address) = (Value)
709 * IN OUT PULONGLONG Address,
712 #define RtlStoreUlonglong(Address,Value) \
713 *(ULONGLONG UNALIGNED *)(Address) = (Value)
717 * IN PUSHORT Address,
720 #define RtlStoreUshort(Address,Value) \
721 *(USHORT UNALIGNED *)(Address) = (Value)
725 * PUSHORT DestinationAddress,
726 * PUSHORT SourceAddress);
728 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
729 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
733 * PULONG DestinationAddress,
734 * PULONG SourceAddress);
736 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
737 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
741 #define RtlStoreUlong(Address,Value) \
742 if ((ULONG_PTR)(Address) & LONG_MASK) { \
743 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
744 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
745 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
746 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
749 *((PULONG)(Address)) = (ULONG) (Value); \
752 #define RtlStoreUlonglong(Address,Value) \
753 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
754 RtlStoreUlong((ULONG_PTR)(Address), \
755 (ULONGLONG)(Value) & 0xFFFFFFFF); \
756 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
757 (ULONGLONG)(Value) >> 32); \
759 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
762 #define RtlStoreUshort(Address,Value) \
763 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
764 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
765 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
768 *((PUSHORT) (Address)) = (USHORT)Value; \
771 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
772 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
774 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
775 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
779 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
782 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
783 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
785 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
786 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
787 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
788 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
792 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
795 #endif /* defined(_AMD64_) */
800 * IN OUT PULONG_PTR Address,
801 * IN ULONG_PTR Value);
803 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
805 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
808 _Success_(return != 0)
813 _In_ PTIME_FIELDS TimeFields
,
814 _Out_ PLARGE_INTEGER Time
);
820 _In_ PLARGE_INTEGER Time
,
821 _Out_ PTIME_FIELDS TimeFields
);
832 RtlUlonglongByteSwap(
833 _In_ ULONGLONG Source
);
835 _When_(AllocateDestinationString
,
836 _At_(DestinationString
->MaximumLength
,
837 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
838 _When_(!AllocateDestinationString
,
839 _At_(DestinationString
->Buffer
, _Const_
)
840 _At_(DestinationString
->MaximumLength
, _Const_
))
841 _IRQL_requires_max_(PASSIVE_LEVEL
)
842 _When_(AllocateDestinationString
, _Must_inspect_result_
)
846 RtlUnicodeStringToAnsiString(
847 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
848 _When_(!AllocateDestinationString
, _Inout_
)
849 PANSI_STRING DestinationString
,
850 _In_ PCUNICODE_STRING SourceString
,
851 _In_ BOOLEAN AllocateDestinationString
);
853 _IRQL_requires_max_(PASSIVE_LEVEL
)
857 RtlxUnicodeStringToAnsiSize(
858 _In_ PCUNICODE_STRING UnicodeString
);
860 #define RtlUnicodeStringToAnsiSize(String) ( \
861 NLS_MB_CODE_PAGE_TAG ? \
862 RtlxUnicodeStringToAnsiSize(String) : \
863 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
866 _IRQL_requires_max_(PASSIVE_LEVEL
)
870 RtlUnicodeStringToInteger(
871 _In_ PCUNICODE_STRING String
,
875 _IRQL_requires_max_(PASSIVE_LEVEL
)
879 RtlUpcaseUnicodeChar(
880 _In_ WCHAR SourceCharacter
);
888 _IRQL_requires_max_(APC_LEVEL
)
889 _Must_inspect_result_
893 RtlValidRelativeSecurityDescriptor(
894 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
895 _In_ ULONG SecurityDescriptorLength
,
896 _In_ SECURITY_INFORMATION RequiredInformation
);
898 _IRQL_requires_max_(APC_LEVEL
)
899 _Must_inspect_result_
903 RtlValidSecurityDescriptor(
904 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
906 _IRQL_requires_max_(PASSIVE_LEVEL
)
912 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
913 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
914 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
915 PRTL_OSVERSIONINFOW lpVersionInformation
);
917 _IRQL_requires_max_(PASSIVE_LEVEL
)
918 _Must_inspect_result_
922 RtlVerifyVersionInfo(
923 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
925 _In_ ULONGLONG ConditionMask
);
927 _IRQL_requires_max_(PASSIVE_LEVEL
)
931 RtlWriteRegistryValue(
932 _In_ ULONG RelativeTo
,
934 _In_z_ PCWSTR ValueName
,
935 _In_ ULONG ValueType
,
936 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
937 _In_ ULONG ValueLength
);
942 #ifndef RTL_USE_AVL_TABLES
947 RtlInitializeGenericTable(
948 _Out_ PRTL_GENERIC_TABLE Table
,
949 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
950 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
951 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
952 _In_opt_ PVOID TableContext
);
957 RtlInsertElementGenericTable(
958 _In_ PRTL_GENERIC_TABLE Table
,
959 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
960 _In_ CLONG BufferSize
,
961 _Out_opt_ PBOOLEAN NewElement
);
966 RtlInsertElementGenericTableFull(
967 _In_ PRTL_GENERIC_TABLE Table
,
968 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
969 _In_ CLONG BufferSize
,
970 _Out_opt_ PBOOLEAN NewElement
,
971 _In_ PVOID NodeOrParent
,
972 _In_ TABLE_SEARCH_RESULT SearchResult
);
977 RtlDeleteElementGenericTable(
978 _In_ PRTL_GENERIC_TABLE Table
,
981 _Must_inspect_result_
985 RtlLookupElementGenericTable(
986 _In_ PRTL_GENERIC_TABLE Table
,
992 RtlLookupElementGenericTableFull(
993 _In_ PRTL_GENERIC_TABLE Table
,
995 _Out_ PVOID
*NodeOrParent
,
996 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
998 _Must_inspect_result_
1002 RtlEnumerateGenericTable(
1003 _In_ PRTL_GENERIC_TABLE Table
,
1004 _In_ BOOLEAN Restart
);
1006 _Must_inspect_result_
1010 RtlEnumerateGenericTableWithoutSplaying(
1011 _In_ PRTL_GENERIC_TABLE Table
,
1012 _Inout_ PVOID
*RestartKey
);
1014 _Must_inspect_result_
1018 RtlGetElementGenericTable(
1019 _In_ PRTL_GENERIC_TABLE Table
,
1025 RtlNumberGenericTableElements(
1026 _In_ PRTL_GENERIC_TABLE Table
);
1028 _Must_inspect_result_
1032 RtlIsGenericTableEmpty(
1033 _In_ PRTL_GENERIC_TABLE Table
);
1035 #endif /* !RTL_USE_AVL_TABLES */
1037 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1043 _Inout_ PRTL_SPLAY_LINKS Links
);
1049 _In_ PRTL_SPLAY_LINKS Links
);
1055 _In_ PRTL_SPLAY_LINKS Links
,
1056 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1058 _Must_inspect_result_
1062 RtlSubtreeSuccessor(
1063 _In_ PRTL_SPLAY_LINKS Links
);
1065 _Must_inspect_result_
1069 RtlSubtreePredecessor(
1070 _In_ PRTL_SPLAY_LINKS Links
);
1072 _Must_inspect_result_
1077 _In_ PRTL_SPLAY_LINKS Links
);
1079 _Must_inspect_result_
1084 _In_ PRTL_SPLAY_LINKS Links
);
1086 _IRQL_requires_max_(PASSIVE_LEVEL
)
1087 _Must_inspect_result_
1091 RtlPrefixUnicodeString(
1092 _In_ PCUNICODE_STRING String1
,
1093 _In_ PCUNICODE_STRING String2
,
1094 _In_ BOOLEAN CaseInSensitive
);
1096 _IRQL_requires_max_(PASSIVE_LEVEL
)
1101 _Inout_ PSTRING DestinationString
,
1102 _In_
const PSTRING SourceString
);
1104 _IRQL_requires_max_(PASSIVE_LEVEL
)
1105 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1109 RtlUpcaseUnicodeString(
1110 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1111 _When_(!AllocateDestinationString
, _Inout_
)
1112 PUNICODE_STRING DestinationString
,
1113 _In_ PCUNICODE_STRING SourceString
,
1114 _In_ BOOLEAN AllocateDestinationString
);
1116 _IRQL_requires_max_(APC_LEVEL
)
1121 _Inout_ PACCESS_MASK AccessMask
,
1122 _In_ PGENERIC_MAPPING GenericMapping
);
1124 _IRQL_requires_max_(PASSIVE_LEVEL
)
1128 RtlVolumeDeviceToDosName(
1129 _In_ PVOID VolumeDeviceObject
,
1130 _Out_ PUNICODE_STRING DosName
);
1132 _IRQL_requires_max_(PASSIVE_LEVEL
)
1133 _Must_inspect_result_
1138 _In_
const PSTRING String1
,
1139 _In_
const PSTRING String2
,
1140 _In_ BOOLEAN CaseInSensitive
);
1146 _Out_ PSTRING DestinationString
,
1147 _In_opt_
const PSTRING SourceString
);
1149 _IRQL_requires_max_(PASSIVE_LEVEL
)
1150 _Must_inspect_result_
1155 _In_
const PSTRING String1
,
1156 _In_
const PSTRING String2
,
1157 _In_ BOOLEAN CaseInSensitive
);
1159 _IRQL_requires_max_(PASSIVE_LEVEL
)
1165 _In_opt_ ULONG Base
,
1166 _Out_ PULONG Value
);
1168 _IRQL_requires_max_(PASSIVE_LEVEL
)
1173 _In_ CHAR Character
);
1179 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1187 _Must_inspect_result_
1189 _Post_writable_byte_size_(Size
)
1194 _In_ HANDLE HeapHandle
,
1195 _In_opt_ ULONG Flags
,
1198 _Success_(return != 0)
1203 _In_ PVOID HeapHandle
,
1204 _In_opt_ ULONG Flags
,
1205 _In_ _Post_invalid_ PVOID BaseAddress
);
1211 _Out_ PCONTEXT ContextRecord
);
1213 _Ret_range_(<, MAXLONG
)
1218 _Inout_ PULONG Seed
);
1220 _IRQL_requires_max_(APC_LEVEL
)
1221 _Success_(return != 0)
1222 _Must_inspect_result_
1226 RtlCreateUnicodeString(
1227 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1228 PUNICODE_STRING DestinationString
,
1229 _In_z_ PCWSTR SourceString
);
1231 _IRQL_requires_max_(APC_LEVEL
)
1235 RtlAppendStringToString(
1236 _Inout_ PSTRING Destination
,
1237 _In_
const STRING
*Source
);
1239 _IRQL_requires_max_(PASSIVE_LEVEL
)
1240 _Must_inspect_result_
1244 RtlOemStringToUnicodeString(
1245 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1246 _When_(!AllocateDestinationString
, _Inout_
)
1247 PUNICODE_STRING DestinationString
,
1248 _In_ PCOEM_STRING SourceString
,
1249 _In_ BOOLEAN AllocateDestinationString
);
1251 _IRQL_requires_max_(PASSIVE_LEVEL
)
1252 _Must_inspect_result_
1256 RtlUnicodeStringToOemString(
1257 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1258 _When_(!AllocateDestinationString
, _Inout_
)
1259 POEM_STRING DestinationString
,
1260 _In_ PCUNICODE_STRING SourceString
,
1261 _In_ BOOLEAN AllocateDestinationString
);
1263 _IRQL_requires_max_(PASSIVE_LEVEL
)
1264 _Must_inspect_result_
1268 RtlUpcaseUnicodeStringToOemString(
1269 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1270 _When_(!AllocateDestinationString
, _Inout_
)
1271 POEM_STRING DestinationString
,
1272 _In_ PCUNICODE_STRING SourceString
,
1273 _In_ BOOLEAN AllocateDestinationString
);
1275 _IRQL_requires_max_(PASSIVE_LEVEL
)
1276 _Must_inspect_result_
1280 RtlOemStringToCountedUnicodeString(
1281 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1282 _When_(!AllocateDestinationString
, _Inout_
)
1283 PUNICODE_STRING DestinationString
,
1284 _In_ PCOEM_STRING SourceString
,
1285 _In_ BOOLEAN AllocateDestinationString
);
1287 _IRQL_requires_max_(PASSIVE_LEVEL
)
1288 _Must_inspect_result_
1292 RtlUnicodeStringToCountedOemString(
1293 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1294 _When_(!AllocateDestinationString
, _Inout_
)
1295 POEM_STRING DestinationString
,
1296 _In_ PCUNICODE_STRING SourceString
,
1297 _In_ BOOLEAN AllocateDestinationString
);
1299 _IRQL_requires_max_(PASSIVE_LEVEL
)
1300 _Must_inspect_result_
1304 RtlUpcaseUnicodeStringToCountedOemString(
1305 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1306 _When_(!AllocateDestinationString
, _Inout_
)
1307 POEM_STRING DestinationString
,
1308 _In_ PCUNICODE_STRING SourceString
,
1309 _In_ BOOLEAN AllocateDestinationString
);
1311 _IRQL_requires_max_(PASSIVE_LEVEL
)
1312 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1316 RtlDowncaseUnicodeString(
1317 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1318 _When_(!AllocateDestinationString
, _Inout_
)
1319 PUNICODE_STRING UniDest
,
1320 _In_ PCUNICODE_STRING UniSource
,
1321 _In_ BOOLEAN AllocateDestinationString
);
1323 _IRQL_requires_max_(PASSIVE_LEVEL
)
1328 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1330 _IRQL_requires_max_(PASSIVE_LEVEL
)
1334 RtlxUnicodeStringToOemSize(
1335 _In_ PCUNICODE_STRING UnicodeString
);
1337 _IRQL_requires_max_(PASSIVE_LEVEL
)
1341 RtlxOemStringToUnicodeSize(
1342 _In_ PCOEM_STRING OemString
);
1344 _IRQL_requires_max_(PASSIVE_LEVEL
)
1348 RtlMultiByteToUnicodeN(
1349 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1350 _In_ ULONG MaxBytesInUnicodeString
,
1351 _Out_opt_ PULONG BytesInUnicodeString
,
1352 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1353 _In_ ULONG BytesInMultiByteString
);
1355 _IRQL_requires_max_(PASSIVE_LEVEL
)
1359 RtlMultiByteToUnicodeSize(
1360 _Out_ PULONG BytesInUnicodeString
,
1361 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1362 _In_ ULONG BytesInMultiByteString
);
1364 _IRQL_requires_max_(PASSIVE_LEVEL
)
1368 RtlUnicodeToMultiByteSize(
1369 _Out_ PULONG BytesInMultiByteString
,
1370 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1371 _In_ ULONG BytesInUnicodeString
);
1373 _IRQL_requires_max_(PASSIVE_LEVEL
)
1377 RtlUnicodeToMultiByteN(
1378 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1379 _In_ ULONG MaxBytesInMultiByteString
,
1380 _Out_opt_ PULONG BytesInMultiByteString
,
1381 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1382 _In_ ULONG BytesInUnicodeString
);
1384 _IRQL_requires_max_(PASSIVE_LEVEL
)
1388 RtlUpcaseUnicodeToMultiByteN(
1389 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1390 _In_ ULONG MaxBytesInMultiByteString
,
1391 _Out_opt_ PULONG BytesInMultiByteString
,
1392 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1393 _In_ ULONG BytesInUnicodeString
);
1395 _IRQL_requires_max_(PASSIVE_LEVEL
)
1400 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1401 _In_ ULONG MaxBytesInUnicodeString
,
1402 _Out_opt_ PULONG BytesInUnicodeString
,
1403 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1404 _In_ ULONG BytesInOemString
);
1406 _IRQL_requires_max_(PASSIVE_LEVEL
)
1411 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1412 _In_ ULONG MaxBytesInOemString
,
1413 _Out_opt_ PULONG BytesInOemString
,
1414 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1415 _In_ ULONG BytesInUnicodeString
);
1417 _IRQL_requires_max_(PASSIVE_LEVEL
)
1421 RtlUpcaseUnicodeToOemN(
1422 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1423 _In_ ULONG MaxBytesInOemString
,
1424 _Out_opt_ PULONG BytesInOemString
,
1425 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1426 _In_ ULONG BytesInUnicodeString
);
1428 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1429 _IRQL_requires_max_(PASSIVE_LEVEL
)
1433 RtlGenerate8dot3Name(
1434 _In_ PCUNICODE_STRING Name
,
1435 _In_ BOOLEAN AllowExtendedCharacters
,
1436 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1437 _Inout_ PUNICODE_STRING Name8dot3
);
1439 _IRQL_requires_max_(PASSIVE_LEVEL
)
1443 RtlGenerate8dot3Name(
1444 _In_ PCUNICODE_STRING Name
,
1445 _In_ BOOLEAN AllowExtendedCharacters
,
1446 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1447 _Inout_ PUNICODE_STRING Name8dot3
);
1450 _IRQL_requires_max_(PASSIVE_LEVEL
)
1451 _Must_inspect_result_
1455 RtlIsNameLegalDOS8Dot3(
1456 _In_ PCUNICODE_STRING Name
,
1457 _Inout_opt_ POEM_STRING OemName
,
1458 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1460 _IRQL_requires_max_(PASSIVE_LEVEL
)
1461 _Must_inspect_result_
1465 RtlIsValidOemCharacter(
1466 _Inout_ PWCHAR Char
);
1468 _IRQL_requires_max_(PASSIVE_LEVEL
)
1473 _Out_ PPREFIX_TABLE PrefixTable
);
1475 _IRQL_requires_max_(PASSIVE_LEVEL
)
1480 _In_ PPREFIX_TABLE PrefixTable
,
1481 _In_ __drv_aliasesMem PSTRING Prefix
,
1482 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1484 _IRQL_requires_max_(PASSIVE_LEVEL
)
1489 _In_ PPREFIX_TABLE PrefixTable
,
1490 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1492 _IRQL_requires_max_(PASSIVE_LEVEL
)
1493 _Must_inspect_result_
1498 _In_ PPREFIX_TABLE PrefixTable
,
1499 _In_ PSTRING FullName
);
1501 _IRQL_requires_max_(PASSIVE_LEVEL
)
1505 RtlInitializeUnicodePrefix(
1506 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1508 _IRQL_requires_max_(PASSIVE_LEVEL
)
1512 RtlInsertUnicodePrefix(
1513 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1514 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1515 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1517 _IRQL_requires_max_(PASSIVE_LEVEL
)
1521 RtlRemoveUnicodePrefix(
1522 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1523 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1525 _IRQL_requires_max_(PASSIVE_LEVEL
)
1526 _Must_inspect_result_
1528 PUNICODE_PREFIX_TABLE_ENTRY
1530 RtlFindUnicodePrefix(
1531 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1532 _In_ PUNICODE_STRING FullName
,
1533 _In_ ULONG CaseInsensitiveIndex
);
1535 _IRQL_requires_max_(PASSIVE_LEVEL
)
1536 _Must_inspect_result_
1538 PUNICODE_PREFIX_TABLE_ENTRY
1540 RtlNextUnicodePrefix(
1541 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1542 _In_ BOOLEAN Restart
);
1544 _Must_inspect_result_
1548 RtlCompareMemoryUlong(
1549 _In_reads_bytes_(Length
) PVOID Source
,
1551 _In_ ULONG Pattern
);
1553 _Success_(return != 0)
1557 RtlTimeToSecondsSince1980(
1558 _In_ PLARGE_INTEGER Time
,
1559 _Out_ PULONG ElapsedSeconds
);
1564 RtlSecondsSince1980ToTime(
1565 _In_ ULONG ElapsedSeconds
,
1566 _Out_ PLARGE_INTEGER Time
);
1568 _Success_(return != 0)
1572 RtlTimeToSecondsSince1970(
1573 _In_ PLARGE_INTEGER Time
,
1574 _Out_ PULONG ElapsedSeconds
);
1579 RtlSecondsSince1970ToTime(
1580 _In_ ULONG ElapsedSeconds
,
1581 _Out_ PLARGE_INTEGER Time
);
1583 _IRQL_requires_max_(APC_LEVEL
)
1584 _Must_inspect_result_
1591 _Must_inspect_result_
1599 _IRQL_requires_max_(APC_LEVEL
)
1600 _Must_inspect_result_
1608 _IRQL_requires_max_(APC_LEVEL
)
1612 RtlLengthRequiredSid(
1613 _In_ ULONG SubAuthorityCount
);
1619 _In_ _Post_invalid_ PSID Sid
);
1621 _Must_inspect_result_
1625 RtlAllocateAndInitializeSid(
1626 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1627 _In_ UCHAR SubAuthorityCount
,
1628 _In_ ULONG SubAuthority0
,
1629 _In_ ULONG SubAuthority1
,
1630 _In_ ULONG SubAuthority2
,
1631 _In_ ULONG SubAuthority3
,
1632 _In_ ULONG SubAuthority4
,
1633 _In_ ULONG SubAuthority5
,
1634 _In_ ULONG SubAuthority6
,
1635 _In_ ULONG SubAuthority7
,
1636 _Outptr_ PSID
*Sid
);
1638 _IRQL_requires_max_(APC_LEVEL
)
1644 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1645 _In_ UCHAR SubAuthorityCount
);
1652 _In_ ULONG SubAuthority
);
1654 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1661 _IRQL_requires_max_(APC_LEVEL
)
1667 _Out_writes_bytes_(Length
) PSID Destination
,
1670 _IRQL_requires_max_(APC_LEVEL
)
1674 RtlConvertSidToUnicodeString(
1675 _Inout_ PUNICODE_STRING UnicodeString
,
1677 _In_ BOOLEAN AllocateDestinationString
);
1679 _IRQL_requires_max_(APC_LEVEL
)
1684 _Out_ PLUID DestinationLuid
,
1685 _In_ PLUID SourceLuid
);
1687 _IRQL_requires_max_(APC_LEVEL
)
1692 _Out_writes_bytes_(AclLength
) PACL Acl
,
1693 _In_ ULONG AclLength
,
1694 _In_ ULONG AclRevision
);
1696 _IRQL_requires_max_(APC_LEVEL
)
1702 _In_ ULONG AceRevision
,
1703 _In_ ULONG StartingAceIndex
,
1704 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1705 _In_ ULONG AceListLength
);
1707 _IRQL_requires_max_(APC_LEVEL
)
1713 _In_ ULONG AceIndex
);
1720 _In_ ULONG AceIndex
,
1721 _Outptr_ PVOID
*Ace
);
1723 _IRQL_requires_max_(APC_LEVEL
)
1727 RtlAddAccessAllowedAce(
1729 _In_ ULONG AceRevision
,
1730 _In_ ACCESS_MASK AccessMask
,
1733 _IRQL_requires_max_(APC_LEVEL
)
1737 RtlAddAccessAllowedAceEx(
1739 _In_ ULONG AceRevision
,
1740 _In_ ULONG AceFlags
,
1741 _In_ ACCESS_MASK AccessMask
,
1744 _IRQL_requires_max_(APC_LEVEL
)
1748 RtlCreateSecurityDescriptorRelative(
1749 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1750 _In_ ULONG Revision
);
1755 RtlGetDaclSecurityDescriptor(
1756 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1757 _Out_ PBOOLEAN DaclPresent
,
1759 _Out_ PBOOLEAN DaclDefaulted
);
1761 _IRQL_requires_max_(APC_LEVEL
)
1765 RtlSetOwnerSecurityDescriptor(
1766 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1767 _In_opt_ PSID Owner
,
1768 _In_opt_ BOOLEAN OwnerDefaulted
);
1770 _IRQL_requires_max_(APC_LEVEL
)
1774 RtlGetOwnerSecurityDescriptor(
1775 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1777 _Out_ PBOOLEAN OwnerDefaulted
);
1779 _IRQL_requires_max_(APC_LEVEL
)
1780 _When_(Status
< 0, _Out_range_(>, 0))
1781 _When_(Status
>= 0, _Out_range_(==, 0))
1785 RtlNtStatusToDosError(
1786 _In_ NTSTATUS Status
);
1788 _IRQL_requires_max_(PASSIVE_LEVEL
)
1792 RtlCustomCPToUnicodeN(
1793 _In_ PCPTABLEINFO CustomCP
,
1794 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1795 _In_ ULONG MaxBytesInUnicodeString
,
1796 _Out_opt_ PULONG BytesInUnicodeString
,
1797 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1798 _In_ ULONG BytesInCustomCPString
);
1800 _IRQL_requires_max_(PASSIVE_LEVEL
)
1804 RtlUnicodeToCustomCPN(
1805 _In_ PCPTABLEINFO CustomCP
,
1806 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1807 _In_ ULONG MaxBytesInCustomCPString
,
1808 _Out_opt_ PULONG BytesInCustomCPString
,
1809 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1810 _In_ ULONG BytesInUnicodeString
);
1812 _IRQL_requires_max_(PASSIVE_LEVEL
)
1816 RtlUpcaseUnicodeToCustomCPN(
1817 _In_ PCPTABLEINFO CustomCP
,
1818 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1819 _In_ ULONG MaxBytesInCustomCPString
,
1820 _Out_opt_ PULONG BytesInCustomCPString
,
1821 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1822 _In_ ULONG BytesInUnicodeString
);
1824 _IRQL_requires_max_(PASSIVE_LEVEL
)
1828 RtlInitCodePageTable(
1829 _In_ PUSHORT TableBase
,
1830 _Inout_ PCPTABLEINFO CodePageTable
);
1834 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1838 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1842 RtlPrefetchMemoryNonTemporal(
1844 _In_ SIZE_T Length
);
1849 #if (NTDDI_VERSION >= NTDDI_WINXP)
1857 _In_ PRTL_BITMAP BitMapHeader
,
1858 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1860 _IRQL_requires_max_(PASSIVE_LEVEL
)
1864 RtlDowncaseUnicodeChar(
1865 _In_ WCHAR SourceCharacter
);
1871 _In_ PRTL_BITMAP BitMapHeader
,
1872 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1874 _Must_inspect_result_
1879 _In_ PRTL_BITMAP BitMapHeader
,
1880 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1882 _IRQL_requires_max_(PASSIVE_LEVEL
)
1886 RtlHashUnicodeString(
1887 _In_ CONST UNICODE_STRING
*String
,
1888 _In_ BOOLEAN CaseInSensitive
,
1889 _In_ ULONG HashAlgorithm
,
1890 _Out_ PULONG HashValue
);
1899 RtlInitializeGenericTableAvl(
1900 _Out_ PRTL_AVL_TABLE Table
,
1901 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
1902 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
1903 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
1904 _In_opt_ PVOID TableContext
);
1909 RtlInsertElementGenericTableAvl(
1910 _In_ PRTL_AVL_TABLE Table
,
1911 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1912 _In_ CLONG BufferSize
,
1913 _Out_opt_ PBOOLEAN NewElement
);
1918 RtlInsertElementGenericTableFullAvl(
1919 _In_ PRTL_AVL_TABLE Table
,
1920 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1921 _In_ CLONG BufferSize
,
1922 _Out_opt_ PBOOLEAN NewElement
,
1923 _In_ PVOID NodeOrParent
,
1924 _In_ TABLE_SEARCH_RESULT SearchResult
);
1929 RtlDeleteElementGenericTableAvl(
1930 _In_ PRTL_AVL_TABLE Table
,
1933 _Must_inspect_result_
1937 RtlLookupElementGenericTableAvl(
1938 _In_ PRTL_AVL_TABLE Table
,
1944 RtlLookupElementGenericTableFullAvl(
1945 _In_ PRTL_AVL_TABLE Table
,
1947 _Out_ PVOID
*NodeOrParent
,
1948 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1950 _Must_inspect_result_
1954 RtlEnumerateGenericTableAvl(
1955 _In_ PRTL_AVL_TABLE Table
,
1956 _In_ BOOLEAN Restart
);
1958 _Must_inspect_result_
1962 RtlEnumerateGenericTableWithoutSplayingAvl(
1963 _In_ PRTL_AVL_TABLE Table
,
1964 _Inout_ PVOID
*RestartKey
);
1966 _Must_inspect_result_
1970 RtlLookupFirstMatchingElementGenericTableAvl(
1971 _In_ PRTL_AVL_TABLE Table
,
1973 _Out_ PVOID
*RestartKey
);
1975 _Must_inspect_result_
1979 RtlEnumerateGenericTableLikeADirectory(
1980 _In_ PRTL_AVL_TABLE Table
,
1981 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
1982 _In_opt_ PVOID MatchData
,
1983 _In_ ULONG NextFlag
,
1984 _Inout_ PVOID
*RestartKey
,
1985 _Inout_ PULONG DeleteCount
,
1988 _Must_inspect_result_
1992 RtlGetElementGenericTableAvl(
1993 _In_ PRTL_AVL_TABLE Table
,
1999 RtlNumberGenericTableElementsAvl(
2000 _In_ PRTL_AVL_TABLE Table
);
2002 _Must_inspect_result_
2006 RtlIsGenericTableEmptyAvl(
2007 _In_ PRTL_AVL_TABLE Table
);
2012 _Must_inspect_result_
2018 _In_opt_ PVOID HeapBase
,
2019 _In_opt_ SIZE_T ReserveSize
,
2020 _In_opt_ SIZE_T CommitSize
,
2021 _In_opt_ PVOID Lock
,
2022 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2028 _In_ _Post_invalid_ PVOID HeapHandle
);
2033 RtlCaptureStackBackTrace(
2034 _In_ ULONG FramesToSkip
,
2035 _In_ ULONG FramesToCapture
,
2036 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2037 _Out_opt_ PULONG BackTraceHash
);
2039 _Ret_range_(<, MAXLONG
)
2044 _Inout_ PULONG Seed
);
2046 _IRQL_requires_max_(DISPATCH_LEVEL
)
2050 RtlInitUnicodeStringEx(
2051 _Out_ PUNICODE_STRING DestinationString
,
2052 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2054 _Must_inspect_result_
2058 RtlValidateUnicodeString(
2060 _In_ PCUNICODE_STRING String
);
2062 _IRQL_requires_max_(PASSIVE_LEVEL
)
2063 _Must_inspect_result_
2067 RtlDuplicateUnicodeString(
2069 _In_ PCUNICODE_STRING SourceString
,
2070 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2075 RtlGetCompressionWorkSpaceSize(
2076 _In_ USHORT CompressionFormatAndEngine
,
2077 _Out_ PULONG CompressBufferWorkSpaceSize
,
2078 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2084 _In_ USHORT CompressionFormatAndEngine
,
2085 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2086 _In_ ULONG UncompressedBufferSize
,
2087 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2088 _In_ ULONG CompressedBufferSize
,
2089 _In_ ULONG UncompressedChunkSize
,
2090 _Out_ PULONG FinalCompressedSize
,
2091 _In_ PVOID WorkSpace
);
2093 _IRQL_requires_max_(APC_LEVEL
)
2097 RtlDecompressBuffer(
2098 _In_ USHORT CompressionFormat
,
2099 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2100 _In_ ULONG UncompressedBufferSize
,
2101 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2102 _In_ ULONG CompressedBufferSize
,
2103 _Out_ PULONG FinalUncompressedSize
);
2105 _IRQL_requires_max_(APC_LEVEL
)
2109 RtlDecompressFragment(
2110 _In_ USHORT CompressionFormat
,
2111 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2112 _In_ ULONG UncompressedFragmentSize
,
2113 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2114 _In_ ULONG CompressedBufferSize
,
2115 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2116 _Out_ PULONG FinalUncompressedSize
,
2117 _In_ PVOID WorkSpace
);
2119 _IRQL_requires_max_(APC_LEVEL
)
2124 _In_ USHORT CompressionFormat
,
2125 _Inout_ PUCHAR
*CompressedBuffer
,
2126 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2127 _Out_ PUCHAR
*ChunkBuffer
,
2128 _Out_ PULONG ChunkSize
);
2130 _IRQL_requires_max_(APC_LEVEL
)
2135 _In_ USHORT CompressionFormat
,
2136 _Inout_ PUCHAR
*CompressedBuffer
,
2137 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2138 _Out_ PUCHAR
*ChunkBuffer
,
2139 _In_ ULONG ChunkSize
);
2141 _IRQL_requires_max_(APC_LEVEL
)
2145 RtlDecompressChunks(
2146 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2147 _In_ ULONG UncompressedBufferSize
,
2148 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2149 _In_ ULONG CompressedBufferSize
,
2150 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2151 _In_ ULONG CompressedTailSize
,
2152 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2154 _IRQL_requires_max_(APC_LEVEL
)
2159 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2160 _In_ ULONG UncompressedBufferSize
,
2161 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2162 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2163 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2164 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2165 _In_ PVOID WorkSpace
);
2167 _IRQL_requires_max_(APC_LEVEL
)
2169 PSID_IDENTIFIER_AUTHORITY
2171 RtlIdentifierAuthoritySid(
2177 RtlSubAuthorityCountSid(
2180 _When_(Status
< 0, _Out_range_(>, 0))
2181 _When_(Status
>= 0, _Out_range_(==, 0))
2185 RtlNtStatusToDosErrorNoTeb(
2186 _In_ NTSTATUS Status
);
2188 _IRQL_requires_max_(PASSIVE_LEVEL
)
2192 RtlCreateSystemVolumeInformationFolder(
2193 _In_ PCUNICODE_STRING VolumeRootPath
);
2195 #if defined(_M_AMD64)
2200 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2204 PULONG Address
= (PULONG
)Destination
;
2205 if ((Length
/= 4) != 0) {
2206 if (((ULONG64
)Address
& 4) != 0) {
2208 if ((Length
-= 1) == 0) {
2213 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2214 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2219 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2220 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2228 OUT PVOID Destination
,
2235 RtlFillMemoryUlonglong(
2236 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2238 _In_ ULONGLONG Pattern
);
2240 #endif /* defined(_M_AMD64) */
2243 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2246 #if (NTDDI_VERSION >= NTDDI_WS03)
2247 _IRQL_requires_max_(DISPATCH_LEVEL
)
2251 RtlInitAnsiStringEx(
2252 _Out_ PANSI_STRING DestinationString
,
2253 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2256 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2258 _IRQL_requires_max_(APC_LEVEL
)
2262 RtlGetSaclSecurityDescriptor(
2263 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2264 _Out_ PBOOLEAN SaclPresent
,
2266 _Out_ PBOOLEAN SaclDefaulted
);
2268 _IRQL_requires_max_(APC_LEVEL
)
2272 RtlSetGroupSecurityDescriptor(
2273 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2274 _In_opt_ PSID Group
,
2275 _In_opt_ BOOLEAN GroupDefaulted
);
2277 _IRQL_requires_max_(APC_LEVEL
)
2281 RtlGetGroupSecurityDescriptor(
2282 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2284 _Out_ PBOOLEAN GroupDefaulted
);
2286 _IRQL_requires_max_(APC_LEVEL
)
2290 RtlAbsoluteToSelfRelativeSD(
2291 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2292 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2293 _Inout_ PULONG BufferLength
);
2295 _IRQL_requires_max_(APC_LEVEL
)
2299 RtlSelfRelativeToAbsoluteSD(
2300 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2301 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2302 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2303 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2304 _Inout_ PULONG DaclSize
,
2305 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2306 _Inout_ PULONG SaclSize
,
2307 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2308 _Inout_ PULONG OwnerSize
,
2309 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2310 _Inout_ PULONG PrimaryGroupSize
);
2312 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2315 #if (NTDDI_VERSION >= NTDDI_VISTA)
2321 RtlNumberOfSetBitsUlongPtr(
2322 _In_ ULONG_PTR Target
);
2327 RtlIoDecodeMemIoResource(
2328 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2329 _Out_opt_ PULONGLONG Alignment
,
2330 _Out_opt_ PULONGLONG MinimumAddress
,
2331 _Out_opt_ PULONGLONG MaximumAddress
);
2336 RtlIoEncodeMemIoResource(
2337 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2339 _In_ ULONGLONG Length
,
2340 _In_ ULONGLONG Alignment
,
2341 _In_ ULONGLONG MinimumAddress
,
2342 _In_ ULONGLONG MaximumAddress
);
2347 RtlCmDecodeMemIoResource(
2348 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2349 _Out_opt_ PULONGLONG Start
);
2354 RtlFindClosestEncodableLength(
2355 _In_ ULONGLONG SourceLength
,
2356 _Out_ PULONGLONG TargetLength
);
2361 RtlCmEncodeMemIoResource(
2362 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2364 _In_ ULONGLONG Length
,
2365 _In_ ULONGLONG Start
);
2370 _IRQL_requires_max_(APC_LEVEL
)
2374 RtlRunOnceInitialize(
2375 _Out_ PRTL_RUN_ONCE RunOnce
);
2377 _IRQL_requires_max_(APC_LEVEL
)
2378 _Maybe_raises_SEH_exception_
2382 RtlRunOnceExecuteOnce(
2383 _Inout_ PRTL_RUN_ONCE RunOnce
,
2384 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2385 _Inout_opt_ PVOID Parameter
,
2386 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2388 _IRQL_requires_max_(APC_LEVEL
)
2389 _Must_inspect_result_
2393 RtlRunOnceBeginInitialize(
2394 _Inout_ PRTL_RUN_ONCE RunOnce
,
2396 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2398 _IRQL_requires_max_(APC_LEVEL
)
2403 _Inout_ PRTL_RUN_ONCE RunOnce
,
2405 _In_opt_ PVOID Context
);
2411 _In_ ULONG OSMajorVersion
,
2412 _In_ ULONG OSMinorVersion
,
2413 _In_ ULONG SpMajorVersion
,
2414 _In_ ULONG SpMinorVersion
,
2415 _Out_ PULONG ReturnedProductType
);
2423 _In_ ULONG NormForm
,
2424 _In_ PCWSTR SourceString
,
2425 _In_ LONG SourceStringLength
,
2426 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2427 _Inout_ PLONG DestinationStringLength
);
2432 RtlIsNormalizedString(
2433 _In_ ULONG NormForm
,
2434 _In_ PCWSTR SourceString
,
2435 _In_ LONG SourceStringLength
,
2436 _Out_ PBOOLEAN Normalized
);
2443 _In_ PCWSTR SourceString
,
2444 _In_ LONG SourceStringLength
,
2445 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2446 _Inout_ PLONG DestinationStringLength
);
2453 IN PCWSTR SourceString
,
2454 IN LONG SourceStringLength
,
2455 OUT PWSTR DestinationString
,
2456 IN OUT PLONG DestinationStringLength
);
2461 RtlIdnToNameprepUnicode(
2463 _In_ PCWSTR SourceString
,
2464 _In_ LONG SourceStringLength
,
2465 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2466 _Inout_ PLONG DestinationStringLength
);
2471 RtlCreateServiceSid(
2472 _In_ PUNICODE_STRING ServiceName
,
2473 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2474 _Inout_ PULONG ServiceSidLength
);
2479 RtlCompareAltitudes(
2480 _In_ PCUNICODE_STRING Altitude1
,
2481 _In_ PCUNICODE_STRING Altitude2
);
2485 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2487 #if (NTDDI_VERSION >= NTDDI_WIN7)
2490 _IRQL_requires_max_(PASSIVE_LEVEL
)
2491 _Must_inspect_result_
2496 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2497 PCHAR UTF8StringDestination
,
2498 _In_ ULONG UTF8StringMaxByteCount
,
2499 _Out_ PULONG UTF8StringActualByteCount
,
2500 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2501 _In_ ULONG UnicodeStringByteCount
);
2503 _IRQL_requires_max_(PASSIVE_LEVEL
)
2504 _Must_inspect_result_
2509 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2510 PWSTR UnicodeStringDestination
,
2511 _In_ ULONG UnicodeStringMaxByteCount
,
2512 _Out_ PULONG UnicodeStringActualByteCount
,
2513 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2514 _In_ ULONG UTF8StringByteCount
);
2519 RtlGetEnabledExtendedFeatures(
2520 IN ULONG64 FeatureMask
);
2525 _Must_inspect_result_
2530 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2531 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2533 _In_ _Reserved_ ULONG Flags
);
2539 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2540 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2545 RtlInsertEntryHashTable(
2546 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2547 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2548 _In_ ULONG_PTR Signature
,
2549 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2554 RtlRemoveEntryHashTable(
2555 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2556 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2557 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2559 _Must_inspect_result_
2561 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2563 RtlLookupEntryHashTable(
2564 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2565 _In_ ULONG_PTR Signature
,
2566 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2568 _Must_inspect_result_
2570 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2572 RtlGetNextEntryHashTable(
2573 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2574 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2579 RtlInitEnumerationHashTable(
2580 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2581 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2583 _Must_inspect_result_
2585 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2587 RtlEnumerateEntryHashTable(
2588 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2589 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2594 RtlEndEnumerationHashTable(
2595 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2596 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2601 RtlInitWeakEnumerationHashTable(
2602 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2603 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2605 _Must_inspect_result_
2607 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2609 RtlWeaklyEnumerateEntryHashTable(
2610 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2611 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2616 RtlEndWeakEnumerationHashTable(
2617 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2618 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2624 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2629 RtlContractHashTable(
2630 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2634 _IRQL_requires_max_(PASSIVE_LEVEL
)
2635 _Must_inspect_result_
2640 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2641 _In_ ULONG UTF8StringMaxByteCount
,
2642 _Out_ PULONG UTF8StringActualByteCount
,
2643 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2644 _In_ ULONG UnicodeStringByteCount
);
2646 _IRQL_requires_max_(PASSIVE_LEVEL
)
2647 _Must_inspect_result_
2652 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2653 _In_ ULONG UnicodeStringMaxByteCount
,
2654 _Out_ PULONG UnicodeStringActualByteCount
,
2655 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2656 _In_ ULONG UTF8StringByteCount
);
2658 _IRQL_requires_max_(APC_LEVEL
)
2663 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2666 _Out_ ULONG
*NumChanges
);
2671 RtlCreateVirtualAccountSid(
2672 _In_ PCUNICODE_STRING Name
,
2673 _In_ ULONG BaseSubAuthority
,
2674 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2675 _Inout_ PULONG SidLength
);
2678 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2682 #if !defined(MIDL_PASS)
2683 /* inline funftions */
2684 //DECLSPEC_DEPRECATED_DDK_WINXP
2688 RtlConvertLongToLargeInteger(
2689 _In_ LONG SignedInteger
)
2692 ret
.QuadPart
= SignedInteger
;
2696 //DECLSPEC_DEPRECATED_DDK_WINXP
2700 RtlConvertUlongToLargeInteger(
2701 _In_ ULONG UnsignedInteger
)
2704 ret
.QuadPart
= UnsignedInteger
;
2708 //DECLSPEC_DEPRECATED_DDK_WINXP
2712 RtlLargeIntegerShiftLeft(
2713 _In_ LARGE_INTEGER LargeInteger
,
2714 _In_ CCHAR ShiftCount
)
2716 LARGE_INTEGER Result
;
2718 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2722 //DECLSPEC_DEPRECATED_DDK_WINXP
2726 RtlLargeIntegerShiftRight(
2727 _In_ LARGE_INTEGER LargeInteger
,
2728 _In_ CCHAR ShiftCount
)
2730 LARGE_INTEGER Result
;
2732 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2736 //DECLSPEC_DEPRECATED_DDK
2740 RtlEnlargedUnsignedDivide(
2741 _In_ ULARGE_INTEGER Dividend
,
2743 _Out_opt_ PULONG Remainder
)
2746 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2747 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2750 //DECLSPEC_DEPRECATED_DDK
2754 RtlLargeIntegerNegate(
2755 _In_ LARGE_INTEGER Subtrahend
)
2757 LARGE_INTEGER Difference
;
2759 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2763 //DECLSPEC_DEPRECATED_DDK
2767 RtlLargeIntegerSubtract(
2768 _In_ LARGE_INTEGER Minuend
,
2769 _In_ LARGE_INTEGER Subtrahend
)
2771 LARGE_INTEGER Difference
;
2773 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2777 //DECLSPEC_DEPRECATED_DDK
2781 RtlEnlargedUnsignedMultiply(
2782 _In_ ULONG Multiplicand
,
2783 _In_ ULONG Multiplier
)
2786 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2790 //DECLSPEC_DEPRECATED_DDK
2794 RtlEnlargedIntegerMultiply(
2795 _In_ LONG Multiplicand
,
2796 _In_ LONG Multiplier
)
2799 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2803 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2804 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2805 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2808 RtlInitEmptyAnsiString(
2809 _Out_ PANSI_STRING AnsiString
,
2810 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2811 _In_ USHORT BufferSize
)
2813 AnsiString
->Length
= 0;
2814 AnsiString
->MaximumLength
= BufferSize
;
2815 AnsiString
->Buffer
= Buffer
;
2818 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2819 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2820 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2823 RtlInitEmptyUnicodeString(
2824 _Out_ PUNICODE_STRING UnicodeString
,
2825 _Writable_bytes_(BufferSize
)
2826 _When_(BufferSize
!= 0, _Notnull_
)
2827 __drv_aliasesMem PWSTR Buffer
,
2828 _In_ USHORT BufferSize
)
2830 UnicodeString
->Length
= 0;
2831 UnicodeString
->MaximumLength
= BufferSize
;
2832 UnicodeString
->Buffer
= Buffer
;
2836 #if defined(_AMD64_) || defined(_IA64_)
2843 RtlExtendedIntegerMultiply(
2844 _In_ LARGE_INTEGER Multiplicand
,
2845 _In_ LONG Multiplier
)
2848 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2855 RtlExtendedLargeIntegerDivide(
2856 _In_ LARGE_INTEGER Dividend
,
2858 _Out_opt_ PULONG Remainder
)
2861 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
2863 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2871 //DECLSPEC_DEPRECATED_DDK_WINXP
2875 RtlLargeIntegerDivide(
2876 _In_ LARGE_INTEGER Dividend
,
2877 _In_ LARGE_INTEGER Divisor
,
2878 _Out_opt_ PLARGE_INTEGER Remainder
)
2881 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
2883 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
2889 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2893 RtlLargeIntegerDivide(
2894 _In_ LARGE_INTEGER Dividend
,
2895 _In_ LARGE_INTEGER Divisor
,
2896 _Out_opt_ PLARGE_INTEGER Remainder
);
2901 #endif /* defined(_AMD64_) || defined(_IA64_) */
2905 #if defined(_AMD64_)
2907 #define MultiplyHigh __mulh
2908 #define UnsignedMultiplyHigh __umulh
2910 //DECLSPEC_DEPRECATED_DDK
2914 RtlExtendedMagicDivide(
2915 _In_ LARGE_INTEGER Dividend
,
2916 _In_ LARGE_INTEGER MagicDivisor
,
2917 _In_ CCHAR ShiftCount
)
2922 Pos
= (Dividend
.QuadPart
>= 0);
2923 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
2924 MagicDivisor
.QuadPart
);
2925 ret64
>>= ShiftCount
;
2926 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
2931 //DECLSPEC_DEPRECATED_DDK
2936 _In_ LARGE_INTEGER Addend1
,
2937 _In_ LARGE_INTEGER Addend2
)
2940 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
2945 * RtlLargeIntegerAnd(
2946 * IN OUT LARGE_INTEGER Result,
2947 * IN LARGE_INTEGER Source,
2948 * IN LARGE_INTEGER Mask);
2950 #define RtlLargeIntegerAnd(Result, Source, Mask) \
2951 Result.QuadPart = Source.QuadPart & Mask.QuadPart
2953 //DECLSPEC_DEPRECATED_DDK
2957 RtlLargeIntegerArithmeticShift(
2958 _In_ LARGE_INTEGER LargeInteger
,
2959 _In_ CCHAR ShiftCount
)
2962 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
2967 * RtlLargeIntegerEqualTo(
2968 * IN LARGE_INTEGER Operand1,
2969 * IN LARGE_INTEGER Operand2);
2971 #define RtlLargeIntegerEqualTo(X,Y) \
2972 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
2976 RtlSecureZeroMemory(
2977 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
2980 volatile char* vptr
= (volatile char*)Pointer
;
2981 #if defined(_M_AMD64)
2982 __stosb((PUCHAR
)vptr
, 0, Size
);
2984 char * endptr
= (char *)vptr
+ Size
;
2985 while (vptr
< endptr
) {
2992 #if defined(_M_AMD64)
2993 _Must_inspect_result_
2997 _In_ PRTL_BITMAP BitMapHeader
,
2998 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3000 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3003 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3004 #endif /* defined(_M_AMD64) */
3006 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3007 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3008 ((X).HighPart > (Y).HighPart) \
3011 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3012 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3013 ((X).HighPart > (Y).HighPart) \
3016 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3017 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3020 #define RtlLargeIntegerLessThan(X,Y) ( \
3021 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3022 ((X).HighPart < (Y).HighPart) \
3025 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3026 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3027 ((X).HighPart < (Y).HighPart) \
3030 #define RtlLargeIntegerGreaterThanZero(X) ( \
3031 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3032 ((X).HighPart > 0 ) \
3035 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3037 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3039 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3041 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3043 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3045 #endif /* !defined(MIDL_PASS) */
3047 /* Byte Swap Functions */
3048 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
3049 ((defined(_M_AMD64) || defined(_M_IA64)) \
3050 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
3052 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3053 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3054 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3060 #define ASSERT(exp) \
3062 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3064 #define ASSERTMSG(msg, exp) \
3066 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3068 #define RTL_SOFT_ASSERT(exp) \
3070 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3072 #define RTL_SOFT_ASSERTMSG(msg, exp) \
3074 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3076 #define RTL_VERIFY(exp) ASSERT(exp)
3077 #define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
3079 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
3080 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
3082 #if defined(_MSC_VER)
3084 #define NT_ASSERT(exp) \
3086 (__annotation(L"Debug", L"AssertFail", L#exp), \
3087 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3089 #define NT_ASSERTMSG(msg, exp) \
3091 (__annotation(L"Debug", L"AssertFail", L##msg), \
3092 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3094 #define NT_ASSERTMSGW(msg, exp) \
3096 (__annotation(L"Debug", L"AssertFail", msg), \
3097 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3099 #define NT_VERIFY NT_ASSERT
3100 #define NT_VERIFYMSG NT_ASSERTMSG
3101 #define NT_VERIFYMSGW NT_ASSERTMSGW
3105 /* GCC doesn't support __annotation (nor PDB) */
3106 #define NT_ASSERT(exp) \
3107 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
3109 #define NT_ASSERTMSG NT_ASSERT
3110 #define NT_ASSERTMSGW NT_ASSERT
3116 #define ASSERT(exp) ((VOID) 0)
3117 #define ASSERTMSG(msg, exp) ((VOID) 0)
3119 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3120 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3122 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3123 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3125 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3126 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3128 #define NT_ASSERT(exp) ((VOID)0)
3129 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
3130 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
3132 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
3133 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
3134 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
3138 #define InitializeListHead32(ListHead) (\
3139 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3141 #if !defined(_WINBASE_)
3143 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
3147 InitializeSListHead(
3148 _Out_ PSLIST_HEADER SListHead
);
3154 InitializeSListHead(
3155 _Out_ PSLIST_HEADER SListHead
)
3158 ULONG64 FeatureBits
;
3162 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3163 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3166 RtlZeroMemory(SListHead
, sizeof(SLIST_HEADER
));
3168 FeatureBits
= __getReg(CV_IA64_CPUID4
);
3169 if ((FeatureBits
& KF_16BYTE_INSTR
) != 0) {
3170 SListHead
->Header16
.HeaderType
= 1;
3171 SListHead
->Header16
.Init
= 1;
3180 #define InterlockedPopEntrySList(Head) \
3181 ExpInterlockedPopEntrySList(Head)
3183 #define InterlockedPushEntrySList(Head, Entry) \
3184 ExpInterlockedPushEntrySList(Head, Entry)
3186 #define InterlockedFlushSList(Head) \
3187 ExpInterlockedFlushSList(Head)
3189 #define QueryDepthSList(Head) \
3190 ExQueryDepthSList(Head)
3192 #else /* !defined(_WIN64) */
3197 InterlockedPopEntrySList(
3198 _Inout_ PSLIST_HEADER ListHead
);
3203 InterlockedPushEntrySList(
3204 _Inout_ PSLIST_HEADER ListHead
,
3205 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry
);
3207 #define InterlockedFlushSList(ListHead) \
3208 ExInterlockedFlushSList(ListHead)
3210 #define QueryDepthSList(Head) \
3211 ExQueryDepthSList(Head)
3213 #endif /* !defined(_WIN64) */
3215 #endif /* !defined(_WINBASE_) */
3217 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3218 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3219 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3220 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3221 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3222 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3223 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3224 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3225 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3226 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3227 (PCONTEXT_EX)(Context + 1), \
3231 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3232 _In_ ULONG Version
);
3235 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3236 _In_ ULONG Version
);
3238 #ifndef RtlIsNtDdiVersionAvailable
3239 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3242 #ifndef RtlIsServicePackVersionInstalled
3243 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3246 #define RtlInterlockedSetBits(Flags, Flag) \
3247 InterlockedOr((PLONG)(Flags), Flag)
3249 #define RtlInterlockedAndBits(Flags, Flag) \
3250 InterlockedAnd((PLONG)(Flags), Flag)
3252 #define RtlInterlockedClearBits(Flags, Flag) \
3253 RtlInterlockedAndBits(Flags, ~(Flag))
3255 #define RtlInterlockedXorBits(Flags, Flag) \
3256 InterlockedXor(Flags, Flag)
3258 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3259 (VOID) RtlInterlockedSetBits(Flags, Flag)
3261 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3262 (VOID) RtlInterlockedAndBits(Flags, Flag)
3264 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3265 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3271 #ifdef RTL_USE_AVL_TABLES
3273 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3274 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3275 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3276 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3277 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3278 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3279 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3280 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3281 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3282 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3283 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3285 #endif /* RTL_USE_AVL_TABLES */
3287 #define RtlInitializeSplayLinks(Links) { \
3288 PRTL_SPLAY_LINKS _SplayLinks; \
3289 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3290 _SplayLinks->Parent = _SplayLinks; \
3291 _SplayLinks->LeftChild = NULL; \
3292 _SplayLinks->RightChild = NULL; \
3295 #define RtlIsLeftChild(Links) \
3296 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3298 #define RtlIsRightChild(Links) \
3299 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3301 #define RtlRightChild(Links) \
3302 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3304 #define RtlIsRoot(Links) \
3305 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3307 #define RtlLeftChild(Links) \
3308 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3310 #define RtlParent(Links) \
3311 ((PRTL_SPLAY_LINKS)(Links))->Parent
3313 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3315 PRTL_SPLAY_LINKS _SplayParent; \
3316 PRTL_SPLAY_LINKS _SplayChild; \
3317 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3318 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3319 _SplayParent->LeftChild = _SplayChild; \
3320 _SplayChild->Parent = _SplayParent; \
3323 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3325 PRTL_SPLAY_LINKS _SplayParent; \
3326 PRTL_SPLAY_LINKS _SplayChild; \
3327 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3328 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3329 _SplayParent->RightChild = _SplayChild; \
3330 _SplayChild->Parent = _SplayParent; \
3333 #if !defined(MIDL_PASS)
3338 RtlConvertLongToLuid(
3344 Temp
.QuadPart
= Val
;
3345 Luid
.LowPart
= Temp
.u
.LowPart
;
3346 Luid
.HighPart
= Temp
.u
.HighPart
;
3353 RtlConvertUlongToLuid(
3363 #endif /* !defined(MIDL_PASS) */
3365 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3366 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3367 *CallersAddress = (PVOID)_ReturnAddress(); \
3368 *CallersCaller = NULL;
3370 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3374 RtlGetCallersAddress(
3375 _Out_ PVOID
*CallersAddress
,
3376 _Out_ PVOID
*CallersCaller
);
3380 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3382 #if (NTDDI_VERSION >= NTDDI_WIN7)
3387 RtlInitHashTableContext(
3388 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3390 Context
->ChainHead
= NULL
;
3391 Context
->PrevLinkage
= NULL
;
3397 RtlInitHashTableContextFromEnumerator(
3398 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3399 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3401 Context
->ChainHead
= Enumerator
->ChainHead
;
3402 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3408 RtlReleaseHashTableContext(
3409 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3411 UNREFERENCED_PARAMETER(Context
);
3418 RtlTotalBucketsHashTable(
3419 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3421 return HashTable
->TableSize
;
3427 RtlNonEmptyBucketsHashTable(
3428 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3430 return HashTable
->NonEmptyBuckets
;
3436 RtlEmptyBucketsHashTable(
3437 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3439 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3445 RtlTotalEntriesHashTable(
3446 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3448 return HashTable
->NumEntries
;
3454 RtlActiveEnumeratorsHashTable(
3455 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3457 return HashTable
->NumEnumerators
;
3460 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3462 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3467 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3468 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3470 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3471 RtlxUnicodeStringToOemSize(STRING) : \
3472 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3475 #define RtlOemStringToUnicodeSize(STRING) ( \
3476 NLS_MB_OEM_CODE_PAGE_TAG ? \
3477 RtlxOemStringToUnicodeSize(STRING) : \
3478 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3481 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3482 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3485 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3486 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))