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_z_ 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 _When_(SourceString
!= NULL
,
221 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
222 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
223 _When_(SourceString
== NULL
,
224 _At_(DestinationString
->Length
, _Post_equal_to_(0))
225 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
229 RtlInitUnicodeString(
230 _Out_ PUNICODE_STRING DestinationString
,
231 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
235 * IN VOID UNALIGNED *Destination,
236 * IN CONST VOID UNALIGNED *Source,
239 #define RtlMoveMemory(Destination, Source, Length) \
240 memmove(Destination, Source, Length)
242 _IRQL_requires_max_(PASSIVE_LEVEL
)
243 _Must_inspect_result_
249 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
250 PUNICODE_STRING GuidString
);
254 * IN VOID UNALIGNED *Destination,
257 #define RtlZeroMemory(Destination, Length) \
258 memset(Destination, 0, Length)
260 #define RtlZeroBytes RtlZeroMemory
263 #if (NTDDI_VERSION >= NTDDI_WIN2K)
266 _Must_inspect_result_
271 _In_ PRTL_BITMAP BitMapHeader
,
272 _In_ ULONG StartingIndex
,
275 _Must_inspect_result_
280 _In_ PRTL_BITMAP BitMapHeader
,
281 _In_ ULONG StartingIndex
,
284 _IRQL_requires_max_(PASSIVE_LEVEL
)
285 _Must_inspect_result_
289 RtlAnsiStringToUnicodeString(
290 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
291 _When_(!AllocateDestinationString
, _Inout_
)
292 PUNICODE_STRING DestinationString
,
293 _In_ PANSI_STRING SourceString
,
294 _In_ BOOLEAN AllocateDestinationString
);
296 _IRQL_requires_max_(PASSIVE_LEVEL
)
300 RtlxAnsiStringToUnicodeSize(
301 _In_ PCANSI_STRING AnsiString
);
303 #define RtlAnsiStringToUnicodeSize(String) ( \
304 NLS_MB_CODE_PAGE_TAG ? \
305 RtlxAnsiStringToUnicodeSize(String) : \
306 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
310 _Unchanged_(Destination
->MaximumLength
)
311 _Unchanged_(Destination
->Buffer
)
312 _When_(_Old_(Destination
->Length
) + Source
->Length
<= Destination
->MaximumLength
,
313 _At_(Destination
->Length
, _Post_equal_to_(_Old_(Destination
->Length
) + Source
->Length
))
314 _At_(return, _Out_range_(==, 0)))
315 _When_(_Old_(Destination
->Length
) + Source
->Length
> Destination
->MaximumLength
,
316 _Unchanged_(Destination
->Length
)
317 _At_(return, _Out_range_(<, 0)))
321 RtlAppendUnicodeStringToString(
322 _Inout_ PUNICODE_STRING Destination
,
323 _In_ PCUNICODE_STRING Source
);
326 _Unchanged_(Destination
->MaximumLength
)
327 _Unchanged_(Destination
->Buffer
)
328 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength,
329 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR)))
330 _At_(return, _Out_range_(==, 0)))
331 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength,
332 _Unchanged_(Destination->Length)
333 _At_(return, _Out_range_(<, 0))) */
337 RtlAppendUnicodeToString(
338 _Inout_ PUNICODE_STRING Destination
,
339 _In_opt_z_ PCWSTR Source
);
341 _IRQL_requires_max_(PASSIVE_LEVEL
)
342 _Must_inspect_result_
347 _In_ ULONG RelativeTo
,
354 _In_ PRTL_BITMAP BitMapHeader
);
360 _In_ PRTL_BITMAP BitMapHeader
,
361 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
362 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
);
364 _Must_inspect_result_
369 _In_
const VOID
*Source1
,
370 _In_
const VOID
*Source2
,
373 _IRQL_requires_max_(PASSIVE_LEVEL
)
374 _Must_inspect_result_
378 RtlCompareUnicodeString(
379 _In_ PCUNICODE_STRING String1
,
380 _In_ PCUNICODE_STRING String2
,
381 _In_ BOOLEAN CaseInSensitive
);
383 _IRQL_requires_max_(PASSIVE_LEVEL
)
384 _Must_inspect_result_
388 RtlCompareUnicodeStrings(
389 _In_reads_(String1Length
) PCWCH String1
,
390 _In_ SIZE_T String1Length
,
391 _In_reads_(String2Length
) PCWCH String2
,
392 _In_ SIZE_T String2Length
,
393 _In_ BOOLEAN CaseInSensitive
);
395 _Unchanged_(DestinationString
->Buffer
)
396 _Unchanged_(DestinationString
->MaximumLength
)
397 _At_(DestinationString
->Length
,
398 _When_(SourceString
->Length
> DestinationString
->MaximumLength
,
399 _Post_equal_to_(DestinationString
->MaximumLength
))
400 _When_(SourceString
->Length
<= DestinationString
->MaximumLength
,
401 _Post_equal_to_(SourceString
->Length
)))
405 RtlCopyUnicodeString(
406 _Inout_ PUNICODE_STRING DestinationString
,
407 _In_opt_ PCUNICODE_STRING SourceString
);
409 _IRQL_requires_max_(PASSIVE_LEVEL
)
413 RtlCreateRegistryKey(
414 _In_ ULONG RelativeTo
,
417 _IRQL_requires_max_(APC_LEVEL
)
421 RtlCreateSecurityDescriptor(
422 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
423 _In_ ULONG Revision
);
425 _IRQL_requires_max_(PASSIVE_LEVEL
)
429 RtlDeleteRegistryValue(
430 _In_ ULONG RelativeTo
,
432 _In_z_ PCWSTR ValueName
);
434 _IRQL_requires_max_(PASSIVE_LEVEL
)
435 _Must_inspect_result_
439 RtlEqualUnicodeString(
440 _In_ CONST UNICODE_STRING
*String1
,
441 _In_ CONST UNICODE_STRING
*String2
,
442 _In_ BOOLEAN CaseInSensitive
);
444 #if !defined(_AMD64_) && !defined(_IA64_)
448 RtlExtendedIntegerMultiply(
449 _In_ LARGE_INTEGER Multiplicand
,
450 _In_ LONG Multiplier
);
455 RtlExtendedLargeIntegerDivide(
456 _In_ LARGE_INTEGER Dividend
,
458 _Out_opt_ PULONG Remainder
);
461 #if defined(_X86_) || defined(_IA64_)
465 RtlExtendedMagicDivide(
466 _In_ LARGE_INTEGER Dividend
,
467 _In_ LARGE_INTEGER MagicDivisor
,
468 _In_ CCHAR ShiftCount
);
471 _IRQL_requires_max_(PASSIVE_LEVEL
)
476 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
477 PANSI_STRING AnsiString
);
479 _Success_(return != -1)
480 _Must_inspect_result_
485 _In_ PRTL_BITMAP BitMapHeader
,
486 _In_ ULONG NumberToFind
,
487 _In_ ULONG HintIndex
);
489 _Success_(return != -1)
493 RtlFindClearBitsAndSet(
494 _In_ PRTL_BITMAP BitMapHeader
,
495 _In_ ULONG NumberToFind
,
496 _In_ ULONG HintIndex
);
501 RtlFindFirstRunClear(
502 _In_ PRTL_BITMAP BitMapHeader
,
503 _Out_ PULONG StartingIndex
);
509 _In_ PRTL_BITMAP BitMapHeader
,
510 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
511 _In_range_(>, 0) ULONG SizeOfRunArray
,
512 _In_ BOOLEAN LocateLongestRuns
);
517 RtlFindLastBackwardRunClear(
518 _In_ PRTL_BITMAP BitMapHeader
,
519 _In_ ULONG FromIndex
,
520 _Out_ PULONG StartingRunIndex
);
522 _Success_(return != -1)
523 _Must_inspect_result_
527 RtlFindLeastSignificantBit(
533 RtlFindLongestRunClear(
534 _In_ PRTL_BITMAP BitMapHeader
,
535 _Out_ PULONG StartingIndex
);
537 _Success_(return != -1)
538 _Must_inspect_result_
542 RtlFindMostSignificantBit(
548 RtlFindNextForwardRunClear(
549 _In_ PRTL_BITMAP BitMapHeader
,
550 _In_ ULONG FromIndex
,
551 _Out_ PULONG StartingRunIndex
);
553 _Success_(return != -1)
554 _Must_inspect_result_
559 _In_ PRTL_BITMAP BitMapHeader
,
560 _In_ ULONG NumberToFind
,
561 _In_ ULONG HintIndex
);
563 _Success_(return != -1)
567 RtlFindSetBitsAndClear(
568 _In_ PRTL_BITMAP BitMapHeader
,
569 _In_ ULONG NumberToFind
,
570 _In_ ULONG HintIndex
);
572 _IRQL_requires_max_(DISPATCH_LEVEL
)
577 _Out_ PANSI_STRING DestinationString
,
578 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
580 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
581 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
586 _Out_ PRTL_BITMAP BitMapHeader
,
587 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
588 _In_opt_ ULONG SizeOfBitMap
);
590 _IRQL_requires_max_(DISPATCH_LEVEL
)
595 _Out_ PSTRING DestinationString
,
596 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
598 _IRQL_requires_max_(PASSIVE_LEVEL
)
599 _At_(String
->MaximumLength
, _Const_
)
603 RtlIntegerToUnicodeString(
606 _Inout_ PUNICODE_STRING String
);
608 _IRQL_requires_max_(PASSIVE_LEVEL
)
609 _At_(String
->MaximumLength
, _Const_
)
613 RtlInt64ToUnicodeString(
614 _In_ ULONGLONG Value
,
616 _Inout_ PUNICODE_STRING String
);
619 #define RtlIntPtrToUnicodeString(Value, Base, String) \
620 RtlInt64ToUnicodeString(Value, Base, String)
622 #define RtlIntPtrToUnicodeString(Value, Base, String) \
623 RtlIntegerToUnicodeString(Value, Base, String)
630 #define RtlIsZeroLuid(_L1) \
631 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
633 _IRQL_requires_max_(APC_LEVEL
)
637 RtlLengthSecurityDescriptor(
638 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
643 RtlNumberOfClearBits(
644 _In_ PRTL_BITMAP BitMapHeader
);
650 _In_ PRTL_BITMAP BitMapHeader
);
652 _IRQL_requires_max_(PASSIVE_LEVEL
)
656 RtlQueryRegistryValues(
657 _In_ ULONG RelativeTo
,
659 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
660 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
661 _In_opt_ PVOID Context
,
662 _In_opt_ PVOID Environment
);
664 #define SHORT_SIZE (sizeof(USHORT))
665 #define SHORT_MASK (SHORT_SIZE - 1)
666 #define LONG_SIZE (sizeof(LONG))
667 #define LONGLONG_SIZE (sizeof(LONGLONG))
668 #define LONG_MASK (LONG_SIZE - 1)
669 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
670 #define LOWBYTE_MASK 0x00FF
672 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
673 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
674 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
675 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
681 _In_ PRTL_BITMAP BitMapHeader
);
687 _In_ PRTL_BITMAP BitMapHeader
,
688 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
689 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
);
691 _IRQL_requires_max_(APC_LEVEL
)
695 RtlSetDaclSecurityDescriptor(
696 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
697 _In_ BOOLEAN DaclPresent
,
699 _In_opt_ BOOLEAN DaclDefaulted
);
708 #define RtlStoreUlong(Address,Value) \
709 *(ULONG UNALIGNED *)(Address) = (Value)
713 * IN OUT PULONGLONG Address,
716 #define RtlStoreUlonglong(Address,Value) \
717 *(ULONGLONG UNALIGNED *)(Address) = (Value)
721 * IN PUSHORT Address,
724 #define RtlStoreUshort(Address,Value) \
725 *(USHORT UNALIGNED *)(Address) = (Value)
729 * PUSHORT DestinationAddress,
730 * PUSHORT SourceAddress);
732 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
733 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
737 * PULONG DestinationAddress,
738 * PULONG SourceAddress);
740 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
741 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
745 #define RtlStoreUlong(Address,Value) \
746 if ((ULONG_PTR)(Address) & LONG_MASK) { \
747 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
748 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
749 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
750 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
753 *((PULONG)(Address)) = (ULONG) (Value); \
756 #define RtlStoreUlonglong(Address,Value) \
757 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
758 RtlStoreUlong((ULONG_PTR)(Address), \
759 (ULONGLONG)(Value) & 0xFFFFFFFF); \
760 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
761 (ULONGLONG)(Value) >> 32); \
763 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
766 #define RtlStoreUshort(Address,Value) \
767 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
768 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
769 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
772 *((PUSHORT) (Address)) = (USHORT)Value; \
775 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
776 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
778 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
779 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
783 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
786 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
787 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
789 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
790 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
791 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
792 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
796 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
799 #endif /* defined(_AMD64_) */
804 * IN OUT PULONG_PTR Address,
805 * IN ULONG_PTR Value);
807 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
809 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
812 _Success_(return!=FALSE
)
813 _Must_inspect_result_
818 _In_ PTIME_FIELDS TimeFields
,
819 _Out_ PLARGE_INTEGER Time
);
825 _In_ PLARGE_INTEGER Time
,
826 _Out_ PTIME_FIELDS TimeFields
);
837 RtlUlonglongByteSwap(
838 _In_ ULONGLONG Source
);
840 _When_(AllocateDestinationString
,
841 _At_(DestinationString
->MaximumLength
,
842 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
843 _When_(!AllocateDestinationString
,
844 _At_(DestinationString
->Buffer
, _Const_
)
845 _At_(DestinationString
->MaximumLength
, _Const_
))
846 _IRQL_requires_max_(PASSIVE_LEVEL
)
847 _When_(AllocateDestinationString
, _Must_inspect_result_
)
851 RtlUnicodeStringToAnsiString(
852 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
853 _When_(!AllocateDestinationString
, _Inout_
)
854 PANSI_STRING DestinationString
,
855 _In_ PCUNICODE_STRING SourceString
,
856 _In_ BOOLEAN AllocateDestinationString
);
858 _IRQL_requires_max_(PASSIVE_LEVEL
)
862 RtlxUnicodeStringToAnsiSize(
863 _In_ PCUNICODE_STRING UnicodeString
);
865 #define RtlUnicodeStringToAnsiSize(String) ( \
866 NLS_MB_CODE_PAGE_TAG ? \
867 RtlxUnicodeStringToAnsiSize(String) : \
868 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
871 _IRQL_requires_max_(PASSIVE_LEVEL
)
875 RtlUnicodeStringToInteger(
876 _In_ PCUNICODE_STRING String
,
880 _IRQL_requires_max_(PASSIVE_LEVEL
)
884 RtlUpcaseUnicodeChar(
885 _In_ WCHAR SourceCharacter
);
893 _IRQL_requires_max_(APC_LEVEL
)
894 _Must_inspect_result_
898 RtlValidRelativeSecurityDescriptor(
899 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
900 _In_ ULONG SecurityDescriptorLength
,
901 _In_ SECURITY_INFORMATION RequiredInformation
);
903 _IRQL_requires_max_(APC_LEVEL
)
904 _Must_inspect_result_
908 RtlValidSecurityDescriptor(
909 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
911 _IRQL_requires_max_(PASSIVE_LEVEL
)
917 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
918 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
919 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
920 PRTL_OSVERSIONINFOW lpVersionInformation
);
922 _IRQL_requires_max_(PASSIVE_LEVEL
)
923 _Must_inspect_result_
927 RtlVerifyVersionInfo(
928 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
930 _In_ ULONGLONG ConditionMask
);
932 _IRQL_requires_max_(PASSIVE_LEVEL
)
936 RtlWriteRegistryValue(
937 _In_ ULONG RelativeTo
,
939 _In_z_ PCWSTR ValueName
,
940 _In_ ULONG ValueType
,
941 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
942 _In_ ULONG ValueLength
);
947 #ifndef RTL_USE_AVL_TABLES
952 RtlInitializeGenericTable(
953 _Out_ PRTL_GENERIC_TABLE Table
,
954 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
955 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
956 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
957 _In_opt_ PVOID TableContext
);
962 RtlInsertElementGenericTable(
963 _In_ PRTL_GENERIC_TABLE Table
,
964 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
965 _In_ CLONG BufferSize
,
966 _Out_opt_ PBOOLEAN NewElement
);
971 RtlInsertElementGenericTableFull(
972 _In_ PRTL_GENERIC_TABLE Table
,
973 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
974 _In_ CLONG BufferSize
,
975 _Out_opt_ PBOOLEAN NewElement
,
976 _In_ PVOID NodeOrParent
,
977 _In_ TABLE_SEARCH_RESULT SearchResult
);
982 RtlDeleteElementGenericTable(
983 _In_ PRTL_GENERIC_TABLE Table
,
986 _Must_inspect_result_
990 RtlLookupElementGenericTable(
991 _In_ PRTL_GENERIC_TABLE Table
,
997 RtlLookupElementGenericTableFull(
998 _In_ PRTL_GENERIC_TABLE Table
,
1000 _Out_ PVOID
*NodeOrParent
,
1001 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1003 _Must_inspect_result_
1007 RtlEnumerateGenericTable(
1008 _In_ PRTL_GENERIC_TABLE Table
,
1009 _In_ BOOLEAN Restart
);
1011 _Must_inspect_result_
1015 RtlEnumerateGenericTableWithoutSplaying(
1016 _In_ PRTL_GENERIC_TABLE Table
,
1017 _Inout_ PVOID
*RestartKey
);
1019 _Must_inspect_result_
1023 RtlGetElementGenericTable(
1024 _In_ PRTL_GENERIC_TABLE Table
,
1030 RtlNumberGenericTableElements(
1031 _In_ PRTL_GENERIC_TABLE Table
);
1033 _Must_inspect_result_
1037 RtlIsGenericTableEmpty(
1038 _In_ PRTL_GENERIC_TABLE Table
);
1040 #endif /* !RTL_USE_AVL_TABLES */
1042 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1048 _Inout_ PRTL_SPLAY_LINKS Links
);
1054 _In_ PRTL_SPLAY_LINKS Links
);
1060 _In_ PRTL_SPLAY_LINKS Links
,
1061 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1063 _Must_inspect_result_
1067 RtlSubtreeSuccessor(
1068 _In_ PRTL_SPLAY_LINKS Links
);
1070 _Must_inspect_result_
1074 RtlSubtreePredecessor(
1075 _In_ PRTL_SPLAY_LINKS Links
);
1077 _Must_inspect_result_
1082 _In_ PRTL_SPLAY_LINKS Links
);
1084 _Must_inspect_result_
1089 _In_ PRTL_SPLAY_LINKS Links
);
1091 _IRQL_requires_max_(PASSIVE_LEVEL
)
1092 _Must_inspect_result_
1096 RtlPrefixUnicodeString(
1097 _In_ PCUNICODE_STRING String1
,
1098 _In_ PCUNICODE_STRING String2
,
1099 _In_ BOOLEAN CaseInSensitive
);
1101 _IRQL_requires_max_(PASSIVE_LEVEL
)
1106 _Inout_ PSTRING DestinationString
,
1107 _In_
const STRING
*SourceString
);
1109 _IRQL_requires_max_(PASSIVE_LEVEL
)
1110 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1114 RtlUpcaseUnicodeString(
1115 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1116 _When_(!AllocateDestinationString
, _Inout_
)
1117 PUNICODE_STRING DestinationString
,
1118 _In_ PCUNICODE_STRING SourceString
,
1119 _In_ BOOLEAN AllocateDestinationString
);
1121 _IRQL_requires_max_(APC_LEVEL
)
1126 _Inout_ PACCESS_MASK AccessMask
,
1127 _In_ PGENERIC_MAPPING GenericMapping
);
1129 _IRQL_requires_max_(PASSIVE_LEVEL
)
1133 RtlVolumeDeviceToDosName(
1134 _In_ PVOID VolumeDeviceObject
,
1135 _Out_ PUNICODE_STRING DosName
);
1137 _IRQL_requires_max_(PASSIVE_LEVEL
)
1138 _Must_inspect_result_
1143 _In_
const STRING
*String1
,
1144 _In_
const STRING
*String2
,
1145 _In_ BOOLEAN CaseInSensitive
);
1151 _Out_ PSTRING DestinationString
,
1152 _In_opt_
const STRING
*SourceString
);
1154 _IRQL_requires_max_(PASSIVE_LEVEL
)
1155 _Must_inspect_result_
1160 _In_
const STRING
*String1
,
1161 _In_
const STRING
*String2
,
1162 _In_ BOOLEAN CaseInSensitive
);
1164 _IRQL_requires_max_(PASSIVE_LEVEL
)
1170 _In_opt_ ULONG Base
,
1171 _Out_ PULONG Value
);
1173 _IRQL_requires_max_(PASSIVE_LEVEL
)
1178 _In_ CHAR Character
);
1184 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1192 _Must_inspect_result_
1194 _Post_writable_byte_size_(Size
)
1199 _In_ HANDLE HeapHandle
,
1200 _In_opt_ ULONG Flags
,
1203 _Success_(return != 0)
1208 _In_ PVOID HeapHandle
,
1209 _In_opt_ ULONG Flags
,
1210 _In_ _Post_invalid_ PVOID BaseAddress
);
1216 _Out_ PCONTEXT ContextRecord
);
1218 _Ret_range_(<, MAXLONG
)
1223 _Inout_ PULONG Seed
);
1225 _IRQL_requires_max_(APC_LEVEL
)
1226 _Success_(return != 0)
1227 _Must_inspect_result_
1231 RtlCreateUnicodeString(
1232 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1233 PUNICODE_STRING DestinationString
,
1234 _In_z_ PCWSTR SourceString
);
1236 _IRQL_requires_max_(PASSIVE_LEVEL
)
1237 _Must_inspect_result_
1242 _In_
const STRING
*String1
,
1243 _In_
const STRING
*String2
,
1244 _In_ BOOLEAN CaseInsensitive
);
1246 _IRQL_requires_max_(APC_LEVEL
)
1250 RtlAppendStringToString(
1251 _Inout_ PSTRING Destination
,
1252 _In_
const STRING
*Source
);
1254 _IRQL_requires_max_(PASSIVE_LEVEL
)
1255 _Must_inspect_result_
1259 RtlOemStringToUnicodeString(
1260 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1261 _When_(!AllocateDestinationString
, _Inout_
)
1262 PUNICODE_STRING DestinationString
,
1263 _In_ PCOEM_STRING SourceString
,
1264 _In_ BOOLEAN AllocateDestinationString
);
1266 _IRQL_requires_max_(PASSIVE_LEVEL
)
1267 _Must_inspect_result_
1271 RtlUnicodeStringToOemString(
1272 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1273 _When_(!AllocateDestinationString
, _Inout_
)
1274 POEM_STRING DestinationString
,
1275 _In_ PCUNICODE_STRING SourceString
,
1276 _In_ BOOLEAN AllocateDestinationString
);
1278 _IRQL_requires_max_(PASSIVE_LEVEL
)
1279 _Must_inspect_result_
1283 RtlUpcaseUnicodeStringToOemString(
1284 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1285 _When_(!AllocateDestinationString
, _Inout_
)
1286 POEM_STRING DestinationString
,
1287 _In_ PCUNICODE_STRING SourceString
,
1288 _In_ BOOLEAN AllocateDestinationString
);
1290 _IRQL_requires_max_(PASSIVE_LEVEL
)
1291 _Must_inspect_result_
1295 RtlOemStringToCountedUnicodeString(
1296 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1297 _When_(!AllocateDestinationString
, _Inout_
)
1298 PUNICODE_STRING DestinationString
,
1299 _In_ PCOEM_STRING SourceString
,
1300 _In_ BOOLEAN AllocateDestinationString
);
1302 _IRQL_requires_max_(PASSIVE_LEVEL
)
1303 _Must_inspect_result_
1307 RtlUnicodeStringToCountedOemString(
1308 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1309 _When_(!AllocateDestinationString
, _Inout_
)
1310 POEM_STRING DestinationString
,
1311 _In_ PCUNICODE_STRING SourceString
,
1312 _In_ BOOLEAN AllocateDestinationString
);
1314 _IRQL_requires_max_(PASSIVE_LEVEL
)
1315 _Must_inspect_result_
1319 RtlUpcaseUnicodeStringToCountedOemString(
1320 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1321 _When_(!AllocateDestinationString
, _Inout_
)
1322 POEM_STRING DestinationString
,
1323 _In_ PCUNICODE_STRING SourceString
,
1324 _In_ BOOLEAN AllocateDestinationString
);
1326 _IRQL_requires_max_(PASSIVE_LEVEL
)
1327 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1331 RtlDowncaseUnicodeString(
1332 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1333 _When_(!AllocateDestinationString
, _Inout_
)
1334 PUNICODE_STRING UniDest
,
1335 _In_ PCUNICODE_STRING UniSource
,
1336 _In_ BOOLEAN AllocateDestinationString
);
1338 _IRQL_requires_max_(PASSIVE_LEVEL
)
1343 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1345 _IRQL_requires_max_(PASSIVE_LEVEL
)
1349 RtlxUnicodeStringToOemSize(
1350 _In_ PCUNICODE_STRING UnicodeString
);
1352 _IRQL_requires_max_(PASSIVE_LEVEL
)
1356 RtlxOemStringToUnicodeSize(
1357 _In_ PCOEM_STRING OemString
);
1359 _IRQL_requires_max_(PASSIVE_LEVEL
)
1363 RtlMultiByteToUnicodeN(
1364 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1365 _In_ ULONG MaxBytesInUnicodeString
,
1366 _Out_opt_ PULONG BytesInUnicodeString
,
1367 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1368 _In_ ULONG BytesInMultiByteString
);
1370 _IRQL_requires_max_(PASSIVE_LEVEL
)
1374 RtlMultiByteToUnicodeSize(
1375 _Out_ PULONG BytesInUnicodeString
,
1376 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1377 _In_ ULONG BytesInMultiByteString
);
1379 _IRQL_requires_max_(PASSIVE_LEVEL
)
1383 RtlUnicodeToMultiByteSize(
1384 _Out_ PULONG BytesInMultiByteString
,
1385 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1386 _In_ ULONG BytesInUnicodeString
);
1388 _IRQL_requires_max_(PASSIVE_LEVEL
)
1392 RtlUnicodeToMultiByteN(
1393 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1394 _In_ ULONG MaxBytesInMultiByteString
,
1395 _Out_opt_ PULONG BytesInMultiByteString
,
1396 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1397 _In_ ULONG BytesInUnicodeString
);
1399 _IRQL_requires_max_(PASSIVE_LEVEL
)
1403 RtlUpcaseUnicodeToMultiByteN(
1404 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1405 _In_ ULONG MaxBytesInMultiByteString
,
1406 _Out_opt_ PULONG BytesInMultiByteString
,
1407 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1408 _In_ ULONG BytesInUnicodeString
);
1410 _IRQL_requires_max_(PASSIVE_LEVEL
)
1415 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1416 _In_ ULONG MaxBytesInUnicodeString
,
1417 _Out_opt_ PULONG BytesInUnicodeString
,
1418 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1419 _In_ ULONG BytesInOemString
);
1421 _IRQL_requires_max_(PASSIVE_LEVEL
)
1426 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1427 _In_ ULONG MaxBytesInOemString
,
1428 _Out_opt_ PULONG BytesInOemString
,
1429 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1430 _In_ ULONG BytesInUnicodeString
);
1432 _IRQL_requires_max_(PASSIVE_LEVEL
)
1436 RtlUpcaseUnicodeToOemN(
1437 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1438 _In_ ULONG MaxBytesInOemString
,
1439 _Out_opt_ PULONG BytesInOemString
,
1440 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1441 _In_ ULONG BytesInUnicodeString
);
1443 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1444 _IRQL_requires_max_(PASSIVE_LEVEL
)
1448 RtlGenerate8dot3Name(
1449 _In_ PCUNICODE_STRING Name
,
1450 _In_ BOOLEAN AllowExtendedCharacters
,
1451 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1452 _Inout_ PUNICODE_STRING Name8dot3
);
1454 _IRQL_requires_max_(PASSIVE_LEVEL
)
1458 RtlGenerate8dot3Name(
1459 _In_ PCUNICODE_STRING Name
,
1460 _In_ BOOLEAN AllowExtendedCharacters
,
1461 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1462 _Inout_ PUNICODE_STRING Name8dot3
);
1465 _IRQL_requires_max_(PASSIVE_LEVEL
)
1466 _Must_inspect_result_
1470 RtlIsNameLegalDOS8Dot3(
1471 _In_ PCUNICODE_STRING Name
,
1472 _Inout_opt_ POEM_STRING OemName
,
1473 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1475 _IRQL_requires_max_(PASSIVE_LEVEL
)
1476 _Must_inspect_result_
1480 RtlIsValidOemCharacter(
1481 _Inout_ PWCHAR Char
);
1483 _IRQL_requires_max_(PASSIVE_LEVEL
)
1488 _Out_ PPREFIX_TABLE PrefixTable
);
1490 _IRQL_requires_max_(PASSIVE_LEVEL
)
1495 _In_ PPREFIX_TABLE PrefixTable
,
1496 _In_ __drv_aliasesMem PSTRING Prefix
,
1497 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1499 _IRQL_requires_max_(PASSIVE_LEVEL
)
1504 _In_ PPREFIX_TABLE PrefixTable
,
1505 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1507 _IRQL_requires_max_(PASSIVE_LEVEL
)
1508 _Must_inspect_result_
1513 _In_ PPREFIX_TABLE PrefixTable
,
1514 _In_ PSTRING FullName
);
1516 _IRQL_requires_max_(PASSIVE_LEVEL
)
1520 RtlInitializeUnicodePrefix(
1521 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1523 _IRQL_requires_max_(PASSIVE_LEVEL
)
1527 RtlInsertUnicodePrefix(
1528 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1529 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1530 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1532 _IRQL_requires_max_(PASSIVE_LEVEL
)
1536 RtlRemoveUnicodePrefix(
1537 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1538 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1540 _IRQL_requires_max_(PASSIVE_LEVEL
)
1541 _Must_inspect_result_
1543 PUNICODE_PREFIX_TABLE_ENTRY
1545 RtlFindUnicodePrefix(
1546 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1547 _In_ PUNICODE_STRING FullName
,
1548 _In_ ULONG CaseInsensitiveIndex
);
1550 _IRQL_requires_max_(PASSIVE_LEVEL
)
1551 _Must_inspect_result_
1553 PUNICODE_PREFIX_TABLE_ENTRY
1555 RtlNextUnicodePrefix(
1556 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1557 _In_ BOOLEAN Restart
);
1559 _Must_inspect_result_
1563 RtlCompareMemoryUlong(
1564 _In_reads_bytes_(Length
) PVOID Source
,
1566 _In_ ULONG Pattern
);
1568 _Success_(return != 0)
1572 RtlTimeToSecondsSince1980(
1573 _In_ PLARGE_INTEGER Time
,
1574 _Out_ PULONG ElapsedSeconds
);
1579 RtlSecondsSince1980ToTime(
1580 _In_ ULONG ElapsedSeconds
,
1581 _Out_ PLARGE_INTEGER Time
);
1583 _Success_(return != 0)
1584 _Must_inspect_result_
1588 RtlTimeToSecondsSince1970(
1589 _In_ PLARGE_INTEGER Time
,
1590 _Out_ PULONG ElapsedSeconds
);
1595 RtlSecondsSince1970ToTime(
1596 _In_ ULONG ElapsedSeconds
,
1597 _Out_ PLARGE_INTEGER Time
);
1599 _IRQL_requires_max_(APC_LEVEL
)
1600 _Must_inspect_result_
1607 _Must_inspect_result_
1615 _IRQL_requires_max_(APC_LEVEL
)
1616 _Must_inspect_result_
1624 _IRQL_requires_max_(APC_LEVEL
)
1628 RtlLengthRequiredSid(
1629 _In_ ULONG SubAuthorityCount
);
1635 _In_ _Post_invalid_ PSID Sid
);
1637 _Must_inspect_result_
1641 RtlAllocateAndInitializeSid(
1642 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1643 _In_ UCHAR SubAuthorityCount
,
1644 _In_ ULONG SubAuthority0
,
1645 _In_ ULONG SubAuthority1
,
1646 _In_ ULONG SubAuthority2
,
1647 _In_ ULONG SubAuthority3
,
1648 _In_ ULONG SubAuthority4
,
1649 _In_ ULONG SubAuthority5
,
1650 _In_ ULONG SubAuthority6
,
1651 _In_ ULONG SubAuthority7
,
1652 _Outptr_ PSID
*Sid
);
1654 _IRQL_requires_max_(APC_LEVEL
)
1660 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1661 _In_ UCHAR SubAuthorityCount
);
1668 _In_ ULONG SubAuthority
);
1670 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1677 _IRQL_requires_max_(APC_LEVEL
)
1682 _In_ ULONG DestinationSidLength
,
1683 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1684 _In_ PSID SourceSid
);
1686 _IRQL_requires_max_(APC_LEVEL
)
1690 RtlConvertSidToUnicodeString(
1691 _Inout_ PUNICODE_STRING UnicodeString
,
1693 _In_ BOOLEAN AllocateDestinationString
);
1695 _IRQL_requires_max_(APC_LEVEL
)
1700 _Out_ PLUID DestinationLuid
,
1701 _In_ PLUID SourceLuid
);
1703 _IRQL_requires_max_(APC_LEVEL
)
1708 _Out_writes_bytes_(AclLength
) PACL Acl
,
1709 _In_ ULONG AclLength
,
1710 _In_ ULONG AclRevision
);
1712 _IRQL_requires_max_(APC_LEVEL
)
1718 _In_ ULONG AceRevision
,
1719 _In_ ULONG StartingAceIndex
,
1720 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1721 _In_ ULONG AceListLength
);
1723 _IRQL_requires_max_(APC_LEVEL
)
1729 _In_ ULONG AceIndex
);
1736 _In_ ULONG AceIndex
,
1737 _Outptr_ PVOID
*Ace
);
1739 _IRQL_requires_max_(APC_LEVEL
)
1743 RtlAddAccessAllowedAce(
1745 _In_ ULONG AceRevision
,
1746 _In_ ACCESS_MASK AccessMask
,
1749 _IRQL_requires_max_(APC_LEVEL
)
1753 RtlAddAccessAllowedAceEx(
1755 _In_ ULONG AceRevision
,
1756 _In_ ULONG AceFlags
,
1757 _In_ ACCESS_MASK AccessMask
,
1760 _IRQL_requires_max_(APC_LEVEL
)
1764 RtlCreateSecurityDescriptorRelative(
1765 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1766 _In_ ULONG Revision
);
1771 RtlGetDaclSecurityDescriptor(
1772 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1773 _Out_ PBOOLEAN DaclPresent
,
1775 _Out_ PBOOLEAN DaclDefaulted
);
1777 _IRQL_requires_max_(APC_LEVEL
)
1781 RtlSetOwnerSecurityDescriptor(
1782 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1783 _In_opt_ PSID Owner
,
1784 _In_opt_ BOOLEAN OwnerDefaulted
);
1786 _IRQL_requires_max_(APC_LEVEL
)
1790 RtlGetOwnerSecurityDescriptor(
1791 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1793 _Out_ PBOOLEAN OwnerDefaulted
);
1795 _IRQL_requires_max_(APC_LEVEL
)
1796 _When_(Status
< 0, _Out_range_(>, 0))
1797 _When_(Status
>= 0, _Out_range_(==, 0))
1801 RtlNtStatusToDosError(
1802 _In_ NTSTATUS Status
);
1804 _IRQL_requires_max_(PASSIVE_LEVEL
)
1808 RtlCustomCPToUnicodeN(
1809 _In_ PCPTABLEINFO CustomCP
,
1810 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1811 _In_ ULONG MaxBytesInUnicodeString
,
1812 _Out_opt_ PULONG BytesInUnicodeString
,
1813 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1814 _In_ ULONG BytesInCustomCPString
);
1816 _IRQL_requires_max_(PASSIVE_LEVEL
)
1820 RtlUnicodeToCustomCPN(
1821 _In_ PCPTABLEINFO CustomCP
,
1822 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1823 _In_ ULONG MaxBytesInCustomCPString
,
1824 _Out_opt_ PULONG BytesInCustomCPString
,
1825 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1826 _In_ ULONG BytesInUnicodeString
);
1828 _IRQL_requires_max_(PASSIVE_LEVEL
)
1832 RtlUpcaseUnicodeToCustomCPN(
1833 _In_ PCPTABLEINFO CustomCP
,
1834 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1835 _In_ ULONG MaxBytesInCustomCPString
,
1836 _Out_opt_ PULONG BytesInCustomCPString
,
1837 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1838 _In_ ULONG BytesInUnicodeString
);
1840 _IRQL_requires_max_(PASSIVE_LEVEL
)
1844 RtlInitCodePageTable(
1845 _In_ PUSHORT TableBase
,
1846 _Out_ PCPTABLEINFO CodePageTable
);
1850 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1854 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1858 RtlPrefetchMemoryNonTemporal(
1860 _In_ SIZE_T Length
);
1865 #if (NTDDI_VERSION >= NTDDI_WINXP)
1873 _In_ PRTL_BITMAP BitMapHeader
,
1874 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1876 _IRQL_requires_max_(PASSIVE_LEVEL
)
1880 RtlDowncaseUnicodeChar(
1881 _In_ WCHAR SourceCharacter
);
1887 _In_ PRTL_BITMAP BitMapHeader
,
1888 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1890 _Must_inspect_result_
1895 _In_ PRTL_BITMAP BitMapHeader
,
1896 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1898 _IRQL_requires_max_(PASSIVE_LEVEL
)
1902 RtlHashUnicodeString(
1903 _In_ CONST UNICODE_STRING
*String
,
1904 _In_ BOOLEAN CaseInSensitive
,
1905 _In_ ULONG HashAlgorithm
,
1906 _Out_ PULONG HashValue
);
1915 RtlInitializeGenericTableAvl(
1916 _Out_ PRTL_AVL_TABLE Table
,
1917 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
1918 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
1919 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
1920 _In_opt_ PVOID TableContext
);
1925 RtlInsertElementGenericTableAvl(
1926 _In_ PRTL_AVL_TABLE Table
,
1927 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1928 _In_ CLONG BufferSize
,
1929 _Out_opt_ PBOOLEAN NewElement
);
1934 RtlInsertElementGenericTableFullAvl(
1935 _In_ PRTL_AVL_TABLE Table
,
1936 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1937 _In_ CLONG BufferSize
,
1938 _Out_opt_ PBOOLEAN NewElement
,
1939 _In_ PVOID NodeOrParent
,
1940 _In_ TABLE_SEARCH_RESULT SearchResult
);
1945 RtlDeleteElementGenericTableAvl(
1946 _In_ PRTL_AVL_TABLE Table
,
1949 _Must_inspect_result_
1953 RtlLookupElementGenericTableAvl(
1954 _In_ PRTL_AVL_TABLE Table
,
1960 RtlLookupElementGenericTableFullAvl(
1961 _In_ PRTL_AVL_TABLE Table
,
1963 _Out_ PVOID
*NodeOrParent
,
1964 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1966 _Must_inspect_result_
1970 RtlEnumerateGenericTableAvl(
1971 _In_ PRTL_AVL_TABLE Table
,
1972 _In_ BOOLEAN Restart
);
1974 _Must_inspect_result_
1978 RtlEnumerateGenericTableWithoutSplayingAvl(
1979 _In_ PRTL_AVL_TABLE Table
,
1980 _Inout_ PVOID
*RestartKey
);
1982 _Must_inspect_result_
1986 RtlLookupFirstMatchingElementGenericTableAvl(
1987 _In_ PRTL_AVL_TABLE Table
,
1989 _Out_ PVOID
*RestartKey
);
1991 _Must_inspect_result_
1995 RtlEnumerateGenericTableLikeADirectory(
1996 _In_ PRTL_AVL_TABLE Table
,
1997 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
1998 _In_opt_ PVOID MatchData
,
1999 _In_ ULONG NextFlag
,
2000 _Inout_ PVOID
*RestartKey
,
2001 _Inout_ PULONG DeleteCount
,
2004 _Must_inspect_result_
2008 RtlGetElementGenericTableAvl(
2009 _In_ PRTL_AVL_TABLE Table
,
2015 RtlNumberGenericTableElementsAvl(
2016 _In_ PRTL_AVL_TABLE Table
);
2018 _Must_inspect_result_
2022 RtlIsGenericTableEmptyAvl(
2023 _In_ PRTL_AVL_TABLE Table
);
2028 _Must_inspect_result_
2034 _In_opt_ PVOID HeapBase
,
2035 _In_opt_ SIZE_T ReserveSize
,
2036 _In_opt_ SIZE_T CommitSize
,
2037 _In_opt_ PVOID Lock
,
2038 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2044 _In_ _Post_invalid_ PVOID HeapHandle
);
2049 RtlCaptureStackBackTrace(
2050 _In_ ULONG FramesToSkip
,
2051 _In_ ULONG FramesToCapture
,
2052 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2053 _Out_opt_ PULONG BackTraceHash
);
2055 _Ret_range_(<, MAXLONG
)
2060 _Inout_ PULONG Seed
);
2062 _IRQL_requires_max_(DISPATCH_LEVEL
)
2066 RtlInitUnicodeStringEx(
2067 _Out_ PUNICODE_STRING DestinationString
,
2068 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2070 _Must_inspect_result_
2074 RtlValidateUnicodeString(
2076 _In_ PCUNICODE_STRING String
);
2078 _IRQL_requires_max_(PASSIVE_LEVEL
)
2079 _Must_inspect_result_
2083 RtlDuplicateUnicodeString(
2085 _In_ PCUNICODE_STRING SourceString
,
2086 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2091 RtlGetCompressionWorkSpaceSize(
2092 _In_ USHORT CompressionFormatAndEngine
,
2093 _Out_ PULONG CompressBufferWorkSpaceSize
,
2094 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2100 _In_ USHORT CompressionFormatAndEngine
,
2101 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2102 _In_ ULONG UncompressedBufferSize
,
2103 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2104 _In_ ULONG CompressedBufferSize
,
2105 _In_ ULONG UncompressedChunkSize
,
2106 _Out_ PULONG FinalCompressedSize
,
2107 _In_ PVOID WorkSpace
);
2109 _IRQL_requires_max_(APC_LEVEL
)
2113 RtlDecompressBuffer(
2114 _In_ USHORT CompressionFormat
,
2115 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2116 _In_ ULONG UncompressedBufferSize
,
2117 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2118 _In_ ULONG CompressedBufferSize
,
2119 _Out_ PULONG FinalUncompressedSize
);
2121 _IRQL_requires_max_(APC_LEVEL
)
2125 RtlDecompressFragment(
2126 _In_ USHORT CompressionFormat
,
2127 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2128 _In_ ULONG UncompressedFragmentSize
,
2129 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2130 _In_ ULONG CompressedBufferSize
,
2131 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2132 _Out_ PULONG FinalUncompressedSize
,
2133 _In_ PVOID WorkSpace
);
2135 _IRQL_requires_max_(APC_LEVEL
)
2140 _In_ USHORT CompressionFormat
,
2141 _Inout_ PUCHAR
*CompressedBuffer
,
2142 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2143 _Out_ PUCHAR
*ChunkBuffer
,
2144 _Out_ PULONG ChunkSize
);
2146 _IRQL_requires_max_(APC_LEVEL
)
2151 _In_ USHORT CompressionFormat
,
2152 _Inout_ PUCHAR
*CompressedBuffer
,
2153 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2154 _Out_ PUCHAR
*ChunkBuffer
,
2155 _In_ ULONG ChunkSize
);
2157 _IRQL_requires_max_(APC_LEVEL
)
2161 RtlDecompressChunks(
2162 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2163 _In_ ULONG UncompressedBufferSize
,
2164 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2165 _In_ ULONG CompressedBufferSize
,
2166 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2167 _In_ ULONG CompressedTailSize
,
2168 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2170 _IRQL_requires_max_(APC_LEVEL
)
2175 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2176 _In_ ULONG UncompressedBufferSize
,
2177 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2178 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2179 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2180 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2181 _In_ PVOID WorkSpace
);
2183 _IRQL_requires_max_(APC_LEVEL
)
2185 PSID_IDENTIFIER_AUTHORITY
2187 RtlIdentifierAuthoritySid(
2193 RtlSubAuthorityCountSid(
2196 _When_(Status
< 0, _Out_range_(>, 0))
2197 _When_(Status
>= 0, _Out_range_(==, 0))
2201 RtlNtStatusToDosErrorNoTeb(
2202 _In_ NTSTATUS Status
);
2204 _IRQL_requires_max_(PASSIVE_LEVEL
)
2208 RtlCreateSystemVolumeInformationFolder(
2209 _In_ PCUNICODE_STRING VolumeRootPath
);
2211 #if defined(_M_AMD64)
2216 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2220 PULONG Address
= (PULONG
)Destination
;
2221 if ((Length
/= 4) != 0) {
2222 if (((ULONG64
)Address
& 4) != 0) {
2224 if ((Length
-= 1) == 0) {
2229 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2230 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2235 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2236 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2244 OUT PVOID Destination
,
2251 RtlFillMemoryUlonglong(
2252 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2254 _In_ ULONGLONG Pattern
);
2256 #endif /* defined(_M_AMD64) */
2259 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2262 #if (NTDDI_VERSION >= NTDDI_WS03)
2263 _IRQL_requires_max_(DISPATCH_LEVEL
)
2267 RtlInitAnsiStringEx(
2268 _Out_ PANSI_STRING DestinationString
,
2269 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2272 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2274 _IRQL_requires_max_(APC_LEVEL
)
2278 RtlGetSaclSecurityDescriptor(
2279 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2280 _Out_ PBOOLEAN SaclPresent
,
2282 _Out_ PBOOLEAN SaclDefaulted
);
2284 _IRQL_requires_max_(APC_LEVEL
)
2288 RtlSetGroupSecurityDescriptor(
2289 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2290 _In_opt_ PSID Group
,
2291 _In_opt_ BOOLEAN GroupDefaulted
);
2293 _IRQL_requires_max_(APC_LEVEL
)
2297 RtlGetGroupSecurityDescriptor(
2298 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2300 _Out_ PBOOLEAN GroupDefaulted
);
2302 _IRQL_requires_max_(APC_LEVEL
)
2306 RtlAbsoluteToSelfRelativeSD(
2307 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2308 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2309 _Inout_ PULONG BufferLength
);
2311 _IRQL_requires_max_(APC_LEVEL
)
2315 RtlSelfRelativeToAbsoluteSD(
2316 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2317 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2318 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2319 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2320 _Inout_ PULONG DaclSize
,
2321 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2322 _Inout_ PULONG SaclSize
,
2323 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2324 _Inout_ PULONG OwnerSize
,
2325 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2326 _Inout_ PULONG PrimaryGroupSize
);
2328 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2331 #if (NTDDI_VERSION >= NTDDI_VISTA)
2337 RtlNumberOfSetBitsUlongPtr(
2338 _In_ ULONG_PTR Target
);
2343 RtlIoDecodeMemIoResource(
2344 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2345 _Out_opt_ PULONGLONG Alignment
,
2346 _Out_opt_ PULONGLONG MinimumAddress
,
2347 _Out_opt_ PULONGLONG MaximumAddress
);
2352 RtlIoEncodeMemIoResource(
2353 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2355 _In_ ULONGLONG Length
,
2356 _In_ ULONGLONG Alignment
,
2357 _In_ ULONGLONG MinimumAddress
,
2358 _In_ ULONGLONG MaximumAddress
);
2363 RtlCmDecodeMemIoResource(
2364 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2365 _Out_opt_ PULONGLONG Start
);
2370 RtlFindClosestEncodableLength(
2371 _In_ ULONGLONG SourceLength
,
2372 _Out_ PULONGLONG TargetLength
);
2377 RtlCmEncodeMemIoResource(
2378 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2380 _In_ ULONGLONG Length
,
2381 _In_ ULONGLONG Start
);
2386 _IRQL_requires_max_(APC_LEVEL
)
2390 RtlRunOnceInitialize(
2391 _Out_ PRTL_RUN_ONCE RunOnce
);
2393 _IRQL_requires_max_(APC_LEVEL
)
2394 _Maybe_raises_SEH_exception_
2398 RtlRunOnceExecuteOnce(
2399 _Inout_ PRTL_RUN_ONCE RunOnce
,
2400 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2401 _Inout_opt_ PVOID Parameter
,
2402 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2404 _IRQL_requires_max_(APC_LEVEL
)
2405 _Must_inspect_result_
2409 RtlRunOnceBeginInitialize(
2410 _Inout_ PRTL_RUN_ONCE RunOnce
,
2412 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2414 _IRQL_requires_max_(APC_LEVEL
)
2419 _Inout_ PRTL_RUN_ONCE RunOnce
,
2421 _In_opt_ PVOID Context
);
2427 _In_ ULONG OSMajorVersion
,
2428 _In_ ULONG OSMinorVersion
,
2429 _In_ ULONG SpMajorVersion
,
2430 _In_ ULONG SpMinorVersion
,
2431 _Out_ PULONG ReturnedProductType
);
2439 _In_ ULONG NormForm
,
2440 _In_ PCWSTR SourceString
,
2441 _In_ LONG SourceStringLength
,
2442 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2443 _Inout_ PLONG DestinationStringLength
);
2448 RtlIsNormalizedString(
2449 _In_ ULONG NormForm
,
2450 _In_ PCWSTR SourceString
,
2451 _In_ LONG SourceStringLength
,
2452 _Out_ PBOOLEAN Normalized
);
2459 _In_ PCWSTR SourceString
,
2460 _In_ LONG SourceStringLength
,
2461 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2462 _Inout_ PLONG DestinationStringLength
);
2469 IN PCWSTR SourceString
,
2470 IN LONG SourceStringLength
,
2471 OUT PWSTR DestinationString
,
2472 IN OUT PLONG DestinationStringLength
);
2477 RtlIdnToNameprepUnicode(
2479 _In_ PCWSTR SourceString
,
2480 _In_ LONG SourceStringLength
,
2481 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2482 _Inout_ PLONG DestinationStringLength
);
2487 RtlCreateServiceSid(
2488 _In_ PUNICODE_STRING ServiceName
,
2489 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2490 _Inout_ PULONG ServiceSidLength
);
2495 RtlCompareAltitudes(
2496 _In_ PCUNICODE_STRING Altitude1
,
2497 _In_ PCUNICODE_STRING Altitude2
);
2501 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2503 #if (NTDDI_VERSION >= NTDDI_WIN7)
2506 _IRQL_requires_max_(PASSIVE_LEVEL
)
2507 _Must_inspect_result_
2512 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2513 PCHAR UTF8StringDestination
,
2514 _In_ ULONG UTF8StringMaxByteCount
,
2515 _Out_ PULONG UTF8StringActualByteCount
,
2516 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2517 _In_ ULONG UnicodeStringByteCount
);
2519 _IRQL_requires_max_(PASSIVE_LEVEL
)
2520 _Must_inspect_result_
2525 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2526 PWSTR UnicodeStringDestination
,
2527 _In_ ULONG UnicodeStringMaxByteCount
,
2528 _Out_ PULONG UnicodeStringActualByteCount
,
2529 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2530 _In_ ULONG UTF8StringByteCount
);
2535 RtlGetEnabledExtendedFeatures(
2536 IN ULONG64 FeatureMask
);
2541 _Must_inspect_result_
2546 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2547 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2549 _In_ _Reserved_ ULONG Flags
);
2555 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2556 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2561 RtlInsertEntryHashTable(
2562 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2563 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2564 _In_ ULONG_PTR Signature
,
2565 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2570 RtlRemoveEntryHashTable(
2571 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2572 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2573 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2575 _Must_inspect_result_
2577 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2579 RtlLookupEntryHashTable(
2580 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2581 _In_ ULONG_PTR Signature
,
2582 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2584 _Must_inspect_result_
2586 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2588 RtlGetNextEntryHashTable(
2589 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2590 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2595 RtlInitEnumerationHashTable(
2596 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2597 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2599 _Must_inspect_result_
2601 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2603 RtlEnumerateEntryHashTable(
2604 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2605 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2610 RtlEndEnumerationHashTable(
2611 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2612 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2617 RtlInitWeakEnumerationHashTable(
2618 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2619 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2621 _Must_inspect_result_
2623 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2625 RtlWeaklyEnumerateEntryHashTable(
2626 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2627 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2632 RtlEndWeakEnumerationHashTable(
2633 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2634 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2640 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2645 RtlContractHashTable(
2646 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2650 _IRQL_requires_max_(PASSIVE_LEVEL
)
2651 _Must_inspect_result_
2656 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2657 _In_ ULONG UTF8StringMaxByteCount
,
2658 _Out_ PULONG UTF8StringActualByteCount
,
2659 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2660 _In_ ULONG UnicodeStringByteCount
);
2662 _IRQL_requires_max_(PASSIVE_LEVEL
)
2663 _Must_inspect_result_
2668 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2669 _In_ ULONG UnicodeStringMaxByteCount
,
2670 _Out_ PULONG UnicodeStringActualByteCount
,
2671 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2672 _In_ ULONG UTF8StringByteCount
);
2674 _IRQL_requires_max_(APC_LEVEL
)
2679 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2682 _Out_ ULONG
*NumChanges
);
2687 RtlCreateVirtualAccountSid(
2688 _In_ PCUNICODE_STRING Name
,
2689 _In_ ULONG BaseSubAuthority
,
2690 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2691 _Inout_ PULONG SidLength
);
2694 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2698 #if !defined(MIDL_PASS)
2699 /* inline funftions */
2700 //DECLSPEC_DEPRECATED_DDK_WINXP
2704 RtlConvertLongToLargeInteger(
2705 _In_ LONG SignedInteger
)
2708 ret
.QuadPart
= SignedInteger
;
2712 //DECLSPEC_DEPRECATED_DDK_WINXP
2716 RtlConvertUlongToLargeInteger(
2717 _In_ ULONG UnsignedInteger
)
2720 ret
.QuadPart
= UnsignedInteger
;
2724 //DECLSPEC_DEPRECATED_DDK_WINXP
2728 RtlLargeIntegerShiftLeft(
2729 _In_ LARGE_INTEGER LargeInteger
,
2730 _In_ CCHAR ShiftCount
)
2732 LARGE_INTEGER Result
;
2734 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2738 //DECLSPEC_DEPRECATED_DDK_WINXP
2742 RtlLargeIntegerShiftRight(
2743 _In_ LARGE_INTEGER LargeInteger
,
2744 _In_ CCHAR ShiftCount
)
2746 LARGE_INTEGER Result
;
2748 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2752 //DECLSPEC_DEPRECATED_DDK
2756 RtlEnlargedUnsignedDivide(
2757 _In_ ULARGE_INTEGER Dividend
,
2759 _Out_opt_ PULONG Remainder
)
2762 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2763 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2766 //DECLSPEC_DEPRECATED_DDK
2770 RtlLargeIntegerNegate(
2771 _In_ LARGE_INTEGER Subtrahend
)
2773 LARGE_INTEGER Difference
;
2775 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2779 //DECLSPEC_DEPRECATED_DDK
2783 RtlLargeIntegerSubtract(
2784 _In_ LARGE_INTEGER Minuend
,
2785 _In_ LARGE_INTEGER Subtrahend
)
2787 LARGE_INTEGER Difference
;
2789 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2793 //DECLSPEC_DEPRECATED_DDK
2797 RtlEnlargedUnsignedMultiply(
2798 _In_ ULONG Multiplicand
,
2799 _In_ ULONG Multiplier
)
2802 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2806 //DECLSPEC_DEPRECATED_DDK
2810 RtlEnlargedIntegerMultiply(
2811 _In_ LONG Multiplicand
,
2812 _In_ LONG Multiplier
)
2815 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2819 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2820 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2821 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2824 RtlInitEmptyAnsiString(
2825 _Out_ PANSI_STRING AnsiString
,
2826 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2827 _In_ USHORT BufferSize
)
2829 AnsiString
->Length
= 0;
2830 AnsiString
->MaximumLength
= BufferSize
;
2831 AnsiString
->Buffer
= Buffer
;
2834 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2835 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2836 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2839 RtlInitEmptyUnicodeString(
2840 _Out_ PUNICODE_STRING UnicodeString
,
2841 _Writable_bytes_(BufferSize
)
2842 _When_(BufferSize
!= 0, _Notnull_
)
2843 __drv_aliasesMem PWSTR Buffer
,
2844 _In_ USHORT BufferSize
)
2846 UnicodeString
->Length
= 0;
2847 UnicodeString
->MaximumLength
= BufferSize
;
2848 UnicodeString
->Buffer
= Buffer
;
2852 #if defined(_AMD64_) || defined(_IA64_)
2859 RtlExtendedIntegerMultiply(
2860 _In_ LARGE_INTEGER Multiplicand
,
2861 _In_ LONG Multiplier
)
2864 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2871 RtlExtendedLargeIntegerDivide(
2872 _In_ LARGE_INTEGER Dividend
,
2874 _Out_opt_ PULONG Remainder
)
2877 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
2879 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2887 //DECLSPEC_DEPRECATED_DDK_WINXP
2891 RtlLargeIntegerDivide(
2892 _In_ LARGE_INTEGER Dividend
,
2893 _In_ LARGE_INTEGER Divisor
,
2894 _Out_opt_ PLARGE_INTEGER Remainder
)
2897 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
2899 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
2905 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2909 RtlLargeIntegerDivide(
2910 _In_ LARGE_INTEGER Dividend
,
2911 _In_ LARGE_INTEGER Divisor
,
2912 _Out_opt_ PLARGE_INTEGER Remainder
);
2917 #endif /* defined(_AMD64_) || defined(_IA64_) */
2921 #if defined(_AMD64_)
2923 #define MultiplyHigh __mulh
2924 #define UnsignedMultiplyHigh __umulh
2926 //DECLSPEC_DEPRECATED_DDK
2930 RtlExtendedMagicDivide(
2931 _In_ LARGE_INTEGER Dividend
,
2932 _In_ LARGE_INTEGER MagicDivisor
,
2933 _In_ CCHAR ShiftCount
)
2938 Pos
= (Dividend
.QuadPart
>= 0);
2939 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
2940 MagicDivisor
.QuadPart
);
2941 ret64
>>= ShiftCount
;
2942 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
2947 //DECLSPEC_DEPRECATED_DDK
2952 _In_ LARGE_INTEGER Addend1
,
2953 _In_ LARGE_INTEGER Addend2
)
2956 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
2961 * RtlLargeIntegerAnd(
2962 * IN OUT LARGE_INTEGER Result,
2963 * IN LARGE_INTEGER Source,
2964 * IN LARGE_INTEGER Mask);
2966 #define RtlLargeIntegerAnd(Result, Source, Mask) \
2967 Result.QuadPart = Source.QuadPart & Mask.QuadPart
2969 //DECLSPEC_DEPRECATED_DDK
2973 RtlLargeIntegerArithmeticShift(
2974 _In_ LARGE_INTEGER LargeInteger
,
2975 _In_ CCHAR ShiftCount
)
2978 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
2983 * RtlLargeIntegerEqualTo(
2984 * IN LARGE_INTEGER Operand1,
2985 * IN LARGE_INTEGER Operand2);
2987 #define RtlLargeIntegerEqualTo(X,Y) \
2988 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
2992 RtlSecureZeroMemory(
2993 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
2996 volatile char* vptr
= (volatile char*)Pointer
;
2997 #if defined(_M_AMD64)
2998 __stosb((PUCHAR
)vptr
, 0, Size
);
3000 char * endptr
= (char *)vptr
+ Size
;
3001 while (vptr
< endptr
) {
3008 #if defined(_M_AMD64)
3009 _Must_inspect_result_
3013 _In_ PRTL_BITMAP BitMapHeader
,
3014 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3016 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3019 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3020 #endif /* defined(_M_AMD64) */
3022 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3023 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3024 ((X).HighPart > (Y).HighPart) \
3027 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3028 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3029 ((X).HighPart > (Y).HighPart) \
3032 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3033 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3036 #define RtlLargeIntegerLessThan(X,Y) ( \
3037 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3038 ((X).HighPart < (Y).HighPart) \
3041 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3042 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3043 ((X).HighPart < (Y).HighPart) \
3046 #define RtlLargeIntegerGreaterThanZero(X) ( \
3047 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3048 ((X).HighPart > 0 ) \
3051 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3053 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3055 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3057 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3059 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3061 #endif /* !defined(MIDL_PASS) */
3063 /* Byte Swap Functions */
3064 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
3065 ((defined(_M_AMD64) || defined(_M_IA64)) \
3066 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
3068 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3069 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3070 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3076 #define RTL_VERIFY(exp) \
3078 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3080 #define RTL_VERIFYMSG(msg, exp) \
3082 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3084 #define RTL_SOFT_VERIFY(exp) \
3086 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3088 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3090 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3092 /* The ASSERTs must be cast to void to avoid warnings about unused results.
3093 * We also cannot invoke the VERIFY versions because the indirection messes
3094 * with stringify. */
3095 #define ASSERT(exp) \
3096 ((VOID)((!(exp)) ? \
3097 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE))
3099 #define ASSERTMSG(msg, exp) \
3100 ((VOID)((!(exp)) ? \
3101 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE))
3103 #define RTL_SOFT_ASSERT(exp) \
3104 ((VOID)((!(exp)) ? \
3105 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE))
3107 #define RTL_SOFT_ASSERTMSG(msg, exp) \
3108 ((VOID)((!(exp)) ? \
3109 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE))
3111 #if defined(_MSC_VER)
3112 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg)
3113 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg)
3115 # define __assert_annotationA(msg) \
3116 DbgPrint("Assertion %s(%d): %s", __FILE__, __LINE__, msg)
3117 # define __assert_annotationW(msg) \
3118 DbgPrint("Assertion %s(%d): %S", __FILE__, __LINE__, msg)
3121 #define NT_VERIFY(exp) \
3123 (__assert_annotationA(#exp), \
3124 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3126 #define NT_VERIFYMSG(msg, exp) \
3128 (__assert_annotationA(msg), \
3129 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3131 #define NT_VERIFYMSGW(msg, exp) \
3133 (__assert_annotationW(msg), \
3134 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3136 #define NT_ASSERT(exp) ((void)NT_VERIFY(exp))
3137 #define NT_ASSERTMSG(msg, exp) ((void)NT_VERIFYMSG(msg, exp))
3138 #define NT_ASSERTMSGW(msg, exp) ((void)NT_VERIFYMSGW(msg, exp))
3142 #define ASSERT(exp) ((VOID) 0)
3143 #define ASSERTMSG(msg, exp) ((VOID) 0)
3145 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3146 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3148 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3149 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3151 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3152 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3154 #define NT_ASSERT(exp) ((VOID)0)
3155 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
3156 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
3158 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
3159 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
3160 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
3164 #define InitializeListHead32(ListHead) (\
3165 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3167 #if !defined(_WINBASE_)
3169 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
3173 InitializeSListHead(
3174 _Out_ PSLIST_HEADER SListHead
);
3180 InitializeSListHead(
3181 _Out_ PSLIST_HEADER SListHead
)
3184 ULONG64 FeatureBits
;
3188 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3189 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3192 RtlZeroMemory(SListHead
, sizeof(SLIST_HEADER
));
3194 FeatureBits
= __getReg(CV_IA64_CPUID4
);
3195 if ((FeatureBits
& KF_16BYTE_INSTR
) != 0) {
3196 SListHead
->Header16
.HeaderType
= 1;
3197 SListHead
->Header16
.Init
= 1;
3206 #define InterlockedPopEntrySList(Head) \
3207 ExpInterlockedPopEntrySList(Head)
3209 #define InterlockedPushEntrySList(Head, Entry) \
3210 ExpInterlockedPushEntrySList(Head, Entry)
3212 #define InterlockedFlushSList(Head) \
3213 ExpInterlockedFlushSList(Head)
3215 #define QueryDepthSList(Head) \
3216 ExQueryDepthSList(Head)
3218 #else /* !defined(_WIN64) */
3223 InterlockedPopEntrySList(
3224 _Inout_ PSLIST_HEADER ListHead
);
3229 InterlockedPushEntrySList(
3230 _Inout_ PSLIST_HEADER ListHead
,
3231 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry
);
3233 #define InterlockedFlushSList(ListHead) \
3234 ExInterlockedFlushSList(ListHead)
3236 #define QueryDepthSList(Head) \
3237 ExQueryDepthSList(Head)
3239 #endif /* !defined(_WIN64) */
3241 #endif /* !defined(_WINBASE_) */
3243 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3244 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3245 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3246 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3247 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3248 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3249 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3250 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3251 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3252 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3253 (PCONTEXT_EX)(Context + 1), \
3257 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3258 _In_ ULONG Version
);
3261 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3262 _In_ ULONG Version
);
3264 #ifndef RtlIsNtDdiVersionAvailable
3265 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3268 #ifndef RtlIsServicePackVersionInstalled
3269 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3272 #define RtlInterlockedSetBits(Flags, Flag) \
3273 InterlockedOr((PLONG)(Flags), Flag)
3275 #define RtlInterlockedAndBits(Flags, Flag) \
3276 InterlockedAnd((PLONG)(Flags), Flag)
3278 #define RtlInterlockedClearBits(Flags, Flag) \
3279 RtlInterlockedAndBits(Flags, ~(Flag))
3281 #define RtlInterlockedXorBits(Flags, Flag) \
3282 InterlockedXor(Flags, Flag)
3284 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3285 (VOID) RtlInterlockedSetBits(Flags, Flag)
3287 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3288 (VOID) RtlInterlockedAndBits(Flags, Flag)
3290 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3291 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3297 #ifdef RTL_USE_AVL_TABLES
3299 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3300 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3301 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3302 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3303 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3304 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3305 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3306 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3307 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3308 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3309 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3311 #endif /* RTL_USE_AVL_TABLES */
3313 #define RtlInitializeSplayLinks(Links) { \
3314 PRTL_SPLAY_LINKS _SplayLinks; \
3315 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3316 _SplayLinks->Parent = _SplayLinks; \
3317 _SplayLinks->LeftChild = NULL; \
3318 _SplayLinks->RightChild = NULL; \
3321 #define RtlIsLeftChild(Links) \
3322 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3324 #define RtlIsRightChild(Links) \
3325 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3327 #define RtlRightChild(Links) \
3328 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3330 #define RtlIsRoot(Links) \
3331 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3333 #define RtlLeftChild(Links) \
3334 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3336 #define RtlParent(Links) \
3337 ((PRTL_SPLAY_LINKS)(Links))->Parent
3339 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3341 PRTL_SPLAY_LINKS _SplayParent; \
3342 PRTL_SPLAY_LINKS _SplayChild; \
3343 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3344 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3345 _SplayParent->LeftChild = _SplayChild; \
3346 _SplayChild->Parent = _SplayParent; \
3349 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3351 PRTL_SPLAY_LINKS _SplayParent; \
3352 PRTL_SPLAY_LINKS _SplayChild; \
3353 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3354 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3355 _SplayParent->RightChild = _SplayChild; \
3356 _SplayChild->Parent = _SplayParent; \
3359 #if !defined(MIDL_PASS)
3364 RtlConvertLongToLuid(
3370 Temp
.QuadPart
= Val
;
3371 Luid
.LowPart
= Temp
.u
.LowPart
;
3372 Luid
.HighPart
= Temp
.u
.HighPart
;
3379 RtlConvertUlongToLuid(
3389 #endif /* !defined(MIDL_PASS) */
3391 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3392 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3393 *CallersAddress = (PVOID)_ReturnAddress(); \
3394 *CallersCaller = NULL;
3396 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3400 RtlGetCallersAddress(
3401 _Out_ PVOID
*CallersAddress
,
3402 _Out_ PVOID
*CallersCaller
);
3406 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3408 #if (NTDDI_VERSION >= NTDDI_WIN7)
3413 RtlInitHashTableContext(
3414 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3416 Context
->ChainHead
= NULL
;
3417 Context
->PrevLinkage
= NULL
;
3423 RtlInitHashTableContextFromEnumerator(
3424 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3425 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3427 Context
->ChainHead
= Enumerator
->ChainHead
;
3428 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3434 RtlReleaseHashTableContext(
3435 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3437 UNREFERENCED_PARAMETER(Context
);
3444 RtlTotalBucketsHashTable(
3445 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3447 return HashTable
->TableSize
;
3453 RtlNonEmptyBucketsHashTable(
3454 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3456 return HashTable
->NonEmptyBuckets
;
3462 RtlEmptyBucketsHashTable(
3463 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3465 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3471 RtlTotalEntriesHashTable(
3472 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3474 return HashTable
->NumEntries
;
3480 RtlActiveEnumeratorsHashTable(
3481 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3483 return HashTable
->NumEnumerators
;
3486 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3488 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3493 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3494 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3496 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3497 RtlxUnicodeStringToOemSize(STRING) : \
3498 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3501 #define RtlOemStringToUnicodeSize(STRING) ( \
3502 NLS_MB_OEM_CODE_PAGE_TAG ? \
3503 RtlxOemStringToUnicodeSize(STRING) : \
3504 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3507 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3508 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3511 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3512 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))