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 PSTRING 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 PSTRING String1
,
1144 _In_
const PSTRING String2
,
1145 _In_ BOOLEAN CaseInSensitive
);
1151 _Out_ PSTRING DestinationString
,
1152 _In_opt_
const PSTRING SourceString
);
1154 _IRQL_requires_max_(PASSIVE_LEVEL
)
1155 _Must_inspect_result_
1160 _In_
const PSTRING String1
,
1161 _In_
const PSTRING 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_(APC_LEVEL
)
1240 RtlAppendStringToString(
1241 _Inout_ PSTRING Destination
,
1242 _In_
const STRING
*Source
);
1244 _IRQL_requires_max_(PASSIVE_LEVEL
)
1245 _Must_inspect_result_
1249 RtlOemStringToUnicodeString(
1250 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1251 _When_(!AllocateDestinationString
, _Inout_
)
1252 PUNICODE_STRING DestinationString
,
1253 _In_ PCOEM_STRING SourceString
,
1254 _In_ BOOLEAN AllocateDestinationString
);
1256 _IRQL_requires_max_(PASSIVE_LEVEL
)
1257 _Must_inspect_result_
1261 RtlUnicodeStringToOemString(
1262 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1263 _When_(!AllocateDestinationString
, _Inout_
)
1264 POEM_STRING DestinationString
,
1265 _In_ PCUNICODE_STRING SourceString
,
1266 _In_ BOOLEAN AllocateDestinationString
);
1268 _IRQL_requires_max_(PASSIVE_LEVEL
)
1269 _Must_inspect_result_
1273 RtlUpcaseUnicodeStringToOemString(
1274 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1275 _When_(!AllocateDestinationString
, _Inout_
)
1276 POEM_STRING DestinationString
,
1277 _In_ PCUNICODE_STRING SourceString
,
1278 _In_ BOOLEAN AllocateDestinationString
);
1280 _IRQL_requires_max_(PASSIVE_LEVEL
)
1281 _Must_inspect_result_
1285 RtlOemStringToCountedUnicodeString(
1286 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1287 _When_(!AllocateDestinationString
, _Inout_
)
1288 PUNICODE_STRING DestinationString
,
1289 _In_ PCOEM_STRING SourceString
,
1290 _In_ BOOLEAN AllocateDestinationString
);
1292 _IRQL_requires_max_(PASSIVE_LEVEL
)
1293 _Must_inspect_result_
1297 RtlUnicodeStringToCountedOemString(
1298 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1299 _When_(!AllocateDestinationString
, _Inout_
)
1300 POEM_STRING DestinationString
,
1301 _In_ PCUNICODE_STRING SourceString
,
1302 _In_ BOOLEAN AllocateDestinationString
);
1304 _IRQL_requires_max_(PASSIVE_LEVEL
)
1305 _Must_inspect_result_
1309 RtlUpcaseUnicodeStringToCountedOemString(
1310 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1311 _When_(!AllocateDestinationString
, _Inout_
)
1312 POEM_STRING DestinationString
,
1313 _In_ PCUNICODE_STRING SourceString
,
1314 _In_ BOOLEAN AllocateDestinationString
);
1316 _IRQL_requires_max_(PASSIVE_LEVEL
)
1317 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1321 RtlDowncaseUnicodeString(
1322 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1323 _When_(!AllocateDestinationString
, _Inout_
)
1324 PUNICODE_STRING UniDest
,
1325 _In_ PCUNICODE_STRING UniSource
,
1326 _In_ BOOLEAN AllocateDestinationString
);
1328 _IRQL_requires_max_(PASSIVE_LEVEL
)
1333 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1335 _IRQL_requires_max_(PASSIVE_LEVEL
)
1339 RtlxUnicodeStringToOemSize(
1340 _In_ PCUNICODE_STRING UnicodeString
);
1342 _IRQL_requires_max_(PASSIVE_LEVEL
)
1346 RtlxOemStringToUnicodeSize(
1347 _In_ PCOEM_STRING OemString
);
1349 _IRQL_requires_max_(PASSIVE_LEVEL
)
1353 RtlMultiByteToUnicodeN(
1354 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1355 _In_ ULONG MaxBytesInUnicodeString
,
1356 _Out_opt_ PULONG BytesInUnicodeString
,
1357 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1358 _In_ ULONG BytesInMultiByteString
);
1360 _IRQL_requires_max_(PASSIVE_LEVEL
)
1364 RtlMultiByteToUnicodeSize(
1365 _Out_ PULONG BytesInUnicodeString
,
1366 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1367 _In_ ULONG BytesInMultiByteString
);
1369 _IRQL_requires_max_(PASSIVE_LEVEL
)
1373 RtlUnicodeToMultiByteSize(
1374 _Out_ PULONG BytesInMultiByteString
,
1375 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1376 _In_ ULONG BytesInUnicodeString
);
1378 _IRQL_requires_max_(PASSIVE_LEVEL
)
1382 RtlUnicodeToMultiByteN(
1383 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1384 _In_ ULONG MaxBytesInMultiByteString
,
1385 _Out_opt_ PULONG BytesInMultiByteString
,
1386 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1387 _In_ ULONG BytesInUnicodeString
);
1389 _IRQL_requires_max_(PASSIVE_LEVEL
)
1393 RtlUpcaseUnicodeToMultiByteN(
1394 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1395 _In_ ULONG MaxBytesInMultiByteString
,
1396 _Out_opt_ PULONG BytesInMultiByteString
,
1397 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1398 _In_ ULONG BytesInUnicodeString
);
1400 _IRQL_requires_max_(PASSIVE_LEVEL
)
1405 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1406 _In_ ULONG MaxBytesInUnicodeString
,
1407 _Out_opt_ PULONG BytesInUnicodeString
,
1408 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1409 _In_ ULONG BytesInOemString
);
1411 _IRQL_requires_max_(PASSIVE_LEVEL
)
1416 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1417 _In_ ULONG MaxBytesInOemString
,
1418 _Out_opt_ PULONG BytesInOemString
,
1419 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1420 _In_ ULONG BytesInUnicodeString
);
1422 _IRQL_requires_max_(PASSIVE_LEVEL
)
1426 RtlUpcaseUnicodeToOemN(
1427 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1428 _In_ ULONG MaxBytesInOemString
,
1429 _Out_opt_ PULONG BytesInOemString
,
1430 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1431 _In_ ULONG BytesInUnicodeString
);
1433 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1434 _IRQL_requires_max_(PASSIVE_LEVEL
)
1438 RtlGenerate8dot3Name(
1439 _In_ PCUNICODE_STRING Name
,
1440 _In_ BOOLEAN AllowExtendedCharacters
,
1441 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1442 _Inout_ PUNICODE_STRING Name8dot3
);
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
);
1455 _IRQL_requires_max_(PASSIVE_LEVEL
)
1456 _Must_inspect_result_
1460 RtlIsNameLegalDOS8Dot3(
1461 _In_ PCUNICODE_STRING Name
,
1462 _Inout_opt_ POEM_STRING OemName
,
1463 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1465 _IRQL_requires_max_(PASSIVE_LEVEL
)
1466 _Must_inspect_result_
1470 RtlIsValidOemCharacter(
1471 _Inout_ PWCHAR Char
);
1473 _IRQL_requires_max_(PASSIVE_LEVEL
)
1478 _Out_ PPREFIX_TABLE PrefixTable
);
1480 _IRQL_requires_max_(PASSIVE_LEVEL
)
1485 _In_ PPREFIX_TABLE PrefixTable
,
1486 _In_ __drv_aliasesMem PSTRING Prefix
,
1487 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1489 _IRQL_requires_max_(PASSIVE_LEVEL
)
1494 _In_ PPREFIX_TABLE PrefixTable
,
1495 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1497 _IRQL_requires_max_(PASSIVE_LEVEL
)
1498 _Must_inspect_result_
1503 _In_ PPREFIX_TABLE PrefixTable
,
1504 _In_ PSTRING FullName
);
1506 _IRQL_requires_max_(PASSIVE_LEVEL
)
1510 RtlInitializeUnicodePrefix(
1511 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1513 _IRQL_requires_max_(PASSIVE_LEVEL
)
1517 RtlInsertUnicodePrefix(
1518 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1519 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1520 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1522 _IRQL_requires_max_(PASSIVE_LEVEL
)
1526 RtlRemoveUnicodePrefix(
1527 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1528 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1530 _IRQL_requires_max_(PASSIVE_LEVEL
)
1531 _Must_inspect_result_
1533 PUNICODE_PREFIX_TABLE_ENTRY
1535 RtlFindUnicodePrefix(
1536 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1537 _In_ PUNICODE_STRING FullName
,
1538 _In_ ULONG CaseInsensitiveIndex
);
1540 _IRQL_requires_max_(PASSIVE_LEVEL
)
1541 _Must_inspect_result_
1543 PUNICODE_PREFIX_TABLE_ENTRY
1545 RtlNextUnicodePrefix(
1546 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1547 _In_ BOOLEAN Restart
);
1549 _Must_inspect_result_
1553 RtlCompareMemoryUlong(
1554 _In_reads_bytes_(Length
) PVOID Source
,
1556 _In_ ULONG Pattern
);
1558 _Success_(return != 0)
1562 RtlTimeToSecondsSince1980(
1563 _In_ PLARGE_INTEGER Time
,
1564 _Out_ PULONG ElapsedSeconds
);
1569 RtlSecondsSince1980ToTime(
1570 _In_ ULONG ElapsedSeconds
,
1571 _Out_ PLARGE_INTEGER Time
);
1573 _Success_(return != 0)
1574 _Must_inspect_result_
1578 RtlTimeToSecondsSince1970(
1579 _In_ PLARGE_INTEGER Time
,
1580 _Out_ PULONG ElapsedSeconds
);
1585 RtlSecondsSince1970ToTime(
1586 _In_ ULONG ElapsedSeconds
,
1587 _Out_ PLARGE_INTEGER Time
);
1589 _IRQL_requires_max_(APC_LEVEL
)
1590 _Must_inspect_result_
1597 _Must_inspect_result_
1605 _IRQL_requires_max_(APC_LEVEL
)
1606 _Must_inspect_result_
1614 _IRQL_requires_max_(APC_LEVEL
)
1618 RtlLengthRequiredSid(
1619 _In_ ULONG SubAuthorityCount
);
1625 _In_ _Post_invalid_ PSID Sid
);
1627 _Must_inspect_result_
1631 RtlAllocateAndInitializeSid(
1632 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1633 _In_ UCHAR SubAuthorityCount
,
1634 _In_ ULONG SubAuthority0
,
1635 _In_ ULONG SubAuthority1
,
1636 _In_ ULONG SubAuthority2
,
1637 _In_ ULONG SubAuthority3
,
1638 _In_ ULONG SubAuthority4
,
1639 _In_ ULONG SubAuthority5
,
1640 _In_ ULONG SubAuthority6
,
1641 _In_ ULONG SubAuthority7
,
1642 _Outptr_ PSID
*Sid
);
1644 _IRQL_requires_max_(APC_LEVEL
)
1650 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1651 _In_ UCHAR SubAuthorityCount
);
1658 _In_ ULONG SubAuthority
);
1660 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1667 _IRQL_requires_max_(APC_LEVEL
)
1672 _In_ ULONG DestinationSidLength
,
1673 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1674 _In_ PSID SourceSid
);
1676 _IRQL_requires_max_(APC_LEVEL
)
1680 RtlConvertSidToUnicodeString(
1681 _Inout_ PUNICODE_STRING UnicodeString
,
1683 _In_ BOOLEAN AllocateDestinationString
);
1685 _IRQL_requires_max_(APC_LEVEL
)
1690 _Out_ PLUID DestinationLuid
,
1691 _In_ PLUID SourceLuid
);
1693 _IRQL_requires_max_(APC_LEVEL
)
1698 _Out_writes_bytes_(AclLength
) PACL Acl
,
1699 _In_ ULONG AclLength
,
1700 _In_ ULONG AclRevision
);
1702 _IRQL_requires_max_(APC_LEVEL
)
1708 _In_ ULONG AceRevision
,
1709 _In_ ULONG StartingAceIndex
,
1710 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1711 _In_ ULONG AceListLength
);
1713 _IRQL_requires_max_(APC_LEVEL
)
1719 _In_ ULONG AceIndex
);
1726 _In_ ULONG AceIndex
,
1727 _Outptr_ PVOID
*Ace
);
1729 _IRQL_requires_max_(APC_LEVEL
)
1733 RtlAddAccessAllowedAce(
1735 _In_ ULONG AceRevision
,
1736 _In_ ACCESS_MASK AccessMask
,
1739 _IRQL_requires_max_(APC_LEVEL
)
1743 RtlAddAccessAllowedAceEx(
1745 _In_ ULONG AceRevision
,
1746 _In_ ULONG AceFlags
,
1747 _In_ ACCESS_MASK AccessMask
,
1750 _IRQL_requires_max_(APC_LEVEL
)
1754 RtlCreateSecurityDescriptorRelative(
1755 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1756 _In_ ULONG Revision
);
1761 RtlGetDaclSecurityDescriptor(
1762 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1763 _Out_ PBOOLEAN DaclPresent
,
1765 _Out_ PBOOLEAN DaclDefaulted
);
1767 _IRQL_requires_max_(APC_LEVEL
)
1771 RtlSetOwnerSecurityDescriptor(
1772 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1773 _In_opt_ PSID Owner
,
1774 _In_opt_ BOOLEAN OwnerDefaulted
);
1776 _IRQL_requires_max_(APC_LEVEL
)
1780 RtlGetOwnerSecurityDescriptor(
1781 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1783 _Out_ PBOOLEAN OwnerDefaulted
);
1785 _IRQL_requires_max_(APC_LEVEL
)
1786 _When_(Status
< 0, _Out_range_(>, 0))
1787 _When_(Status
>= 0, _Out_range_(==, 0))
1791 RtlNtStatusToDosError(
1792 _In_ NTSTATUS Status
);
1794 _IRQL_requires_max_(PASSIVE_LEVEL
)
1798 RtlCustomCPToUnicodeN(
1799 _In_ PCPTABLEINFO CustomCP
,
1800 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1801 _In_ ULONG MaxBytesInUnicodeString
,
1802 _Out_opt_ PULONG BytesInUnicodeString
,
1803 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1804 _In_ ULONG BytesInCustomCPString
);
1806 _IRQL_requires_max_(PASSIVE_LEVEL
)
1810 RtlUnicodeToCustomCPN(
1811 _In_ PCPTABLEINFO CustomCP
,
1812 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1813 _In_ ULONG MaxBytesInCustomCPString
,
1814 _Out_opt_ PULONG BytesInCustomCPString
,
1815 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1816 _In_ ULONG BytesInUnicodeString
);
1818 _IRQL_requires_max_(PASSIVE_LEVEL
)
1822 RtlUpcaseUnicodeToCustomCPN(
1823 _In_ PCPTABLEINFO CustomCP
,
1824 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1825 _In_ ULONG MaxBytesInCustomCPString
,
1826 _Out_opt_ PULONG BytesInCustomCPString
,
1827 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1828 _In_ ULONG BytesInUnicodeString
);
1830 _IRQL_requires_max_(PASSIVE_LEVEL
)
1834 RtlInitCodePageTable(
1835 _In_ PUSHORT TableBase
,
1836 _Out_ PCPTABLEINFO CodePageTable
);
1840 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1844 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1848 RtlPrefetchMemoryNonTemporal(
1850 _In_ SIZE_T Length
);
1855 #if (NTDDI_VERSION >= NTDDI_WINXP)
1863 _In_ PRTL_BITMAP BitMapHeader
,
1864 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1866 _IRQL_requires_max_(PASSIVE_LEVEL
)
1870 RtlDowncaseUnicodeChar(
1871 _In_ WCHAR SourceCharacter
);
1877 _In_ PRTL_BITMAP BitMapHeader
,
1878 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1880 _Must_inspect_result_
1885 _In_ PRTL_BITMAP BitMapHeader
,
1886 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1888 _IRQL_requires_max_(PASSIVE_LEVEL
)
1892 RtlHashUnicodeString(
1893 _In_ CONST UNICODE_STRING
*String
,
1894 _In_ BOOLEAN CaseInSensitive
,
1895 _In_ ULONG HashAlgorithm
,
1896 _Out_ PULONG HashValue
);
1905 RtlInitializeGenericTableAvl(
1906 _Out_ PRTL_AVL_TABLE Table
,
1907 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
1908 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
1909 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
1910 _In_opt_ PVOID TableContext
);
1915 RtlInsertElementGenericTableAvl(
1916 _In_ PRTL_AVL_TABLE Table
,
1917 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1918 _In_ CLONG BufferSize
,
1919 _Out_opt_ PBOOLEAN NewElement
);
1924 RtlInsertElementGenericTableFullAvl(
1925 _In_ PRTL_AVL_TABLE Table
,
1926 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1927 _In_ CLONG BufferSize
,
1928 _Out_opt_ PBOOLEAN NewElement
,
1929 _In_ PVOID NodeOrParent
,
1930 _In_ TABLE_SEARCH_RESULT SearchResult
);
1935 RtlDeleteElementGenericTableAvl(
1936 _In_ PRTL_AVL_TABLE Table
,
1939 _Must_inspect_result_
1943 RtlLookupElementGenericTableAvl(
1944 _In_ PRTL_AVL_TABLE Table
,
1950 RtlLookupElementGenericTableFullAvl(
1951 _In_ PRTL_AVL_TABLE Table
,
1953 _Out_ PVOID
*NodeOrParent
,
1954 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1956 _Must_inspect_result_
1960 RtlEnumerateGenericTableAvl(
1961 _In_ PRTL_AVL_TABLE Table
,
1962 _In_ BOOLEAN Restart
);
1964 _Must_inspect_result_
1968 RtlEnumerateGenericTableWithoutSplayingAvl(
1969 _In_ PRTL_AVL_TABLE Table
,
1970 _Inout_ PVOID
*RestartKey
);
1972 _Must_inspect_result_
1976 RtlLookupFirstMatchingElementGenericTableAvl(
1977 _In_ PRTL_AVL_TABLE Table
,
1979 _Out_ PVOID
*RestartKey
);
1981 _Must_inspect_result_
1985 RtlEnumerateGenericTableLikeADirectory(
1986 _In_ PRTL_AVL_TABLE Table
,
1987 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
1988 _In_opt_ PVOID MatchData
,
1989 _In_ ULONG NextFlag
,
1990 _Inout_ PVOID
*RestartKey
,
1991 _Inout_ PULONG DeleteCount
,
1994 _Must_inspect_result_
1998 RtlGetElementGenericTableAvl(
1999 _In_ PRTL_AVL_TABLE Table
,
2005 RtlNumberGenericTableElementsAvl(
2006 _In_ PRTL_AVL_TABLE Table
);
2008 _Must_inspect_result_
2012 RtlIsGenericTableEmptyAvl(
2013 _In_ PRTL_AVL_TABLE Table
);
2018 _Must_inspect_result_
2024 _In_opt_ PVOID HeapBase
,
2025 _In_opt_ SIZE_T ReserveSize
,
2026 _In_opt_ SIZE_T CommitSize
,
2027 _In_opt_ PVOID Lock
,
2028 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2034 _In_ _Post_invalid_ PVOID HeapHandle
);
2039 RtlCaptureStackBackTrace(
2040 _In_ ULONG FramesToSkip
,
2041 _In_ ULONG FramesToCapture
,
2042 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2043 _Out_opt_ PULONG BackTraceHash
);
2045 _Ret_range_(<, MAXLONG
)
2050 _Inout_ PULONG Seed
);
2052 _IRQL_requires_max_(DISPATCH_LEVEL
)
2056 RtlInitUnicodeStringEx(
2057 _Out_ PUNICODE_STRING DestinationString
,
2058 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2060 _Must_inspect_result_
2064 RtlValidateUnicodeString(
2066 _In_ PCUNICODE_STRING String
);
2068 _IRQL_requires_max_(PASSIVE_LEVEL
)
2069 _Must_inspect_result_
2073 RtlDuplicateUnicodeString(
2075 _In_ PCUNICODE_STRING SourceString
,
2076 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2081 RtlGetCompressionWorkSpaceSize(
2082 _In_ USHORT CompressionFormatAndEngine
,
2083 _Out_ PULONG CompressBufferWorkSpaceSize
,
2084 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2090 _In_ USHORT CompressionFormatAndEngine
,
2091 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2092 _In_ ULONG UncompressedBufferSize
,
2093 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2094 _In_ ULONG CompressedBufferSize
,
2095 _In_ ULONG UncompressedChunkSize
,
2096 _Out_ PULONG FinalCompressedSize
,
2097 _In_ PVOID WorkSpace
);
2099 _IRQL_requires_max_(APC_LEVEL
)
2103 RtlDecompressBuffer(
2104 _In_ USHORT CompressionFormat
,
2105 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2106 _In_ ULONG UncompressedBufferSize
,
2107 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2108 _In_ ULONG CompressedBufferSize
,
2109 _Out_ PULONG FinalUncompressedSize
);
2111 _IRQL_requires_max_(APC_LEVEL
)
2115 RtlDecompressFragment(
2116 _In_ USHORT CompressionFormat
,
2117 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2118 _In_ ULONG UncompressedFragmentSize
,
2119 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2120 _In_ ULONG CompressedBufferSize
,
2121 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2122 _Out_ PULONG FinalUncompressedSize
,
2123 _In_ PVOID WorkSpace
);
2125 _IRQL_requires_max_(APC_LEVEL
)
2130 _In_ USHORT CompressionFormat
,
2131 _Inout_ PUCHAR
*CompressedBuffer
,
2132 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2133 _Out_ PUCHAR
*ChunkBuffer
,
2134 _Out_ PULONG ChunkSize
);
2136 _IRQL_requires_max_(APC_LEVEL
)
2141 _In_ USHORT CompressionFormat
,
2142 _Inout_ PUCHAR
*CompressedBuffer
,
2143 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2144 _Out_ PUCHAR
*ChunkBuffer
,
2145 _In_ ULONG ChunkSize
);
2147 _IRQL_requires_max_(APC_LEVEL
)
2151 RtlDecompressChunks(
2152 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2153 _In_ ULONG UncompressedBufferSize
,
2154 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2155 _In_ ULONG CompressedBufferSize
,
2156 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2157 _In_ ULONG CompressedTailSize
,
2158 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2160 _IRQL_requires_max_(APC_LEVEL
)
2165 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2166 _In_ ULONG UncompressedBufferSize
,
2167 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2168 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2169 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2170 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2171 _In_ PVOID WorkSpace
);
2173 _IRQL_requires_max_(APC_LEVEL
)
2175 PSID_IDENTIFIER_AUTHORITY
2177 RtlIdentifierAuthoritySid(
2183 RtlSubAuthorityCountSid(
2186 _When_(Status
< 0, _Out_range_(>, 0))
2187 _When_(Status
>= 0, _Out_range_(==, 0))
2191 RtlNtStatusToDosErrorNoTeb(
2192 _In_ NTSTATUS Status
);
2194 _IRQL_requires_max_(PASSIVE_LEVEL
)
2198 RtlCreateSystemVolumeInformationFolder(
2199 _In_ PCUNICODE_STRING VolumeRootPath
);
2201 #if defined(_M_AMD64)
2206 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2210 PULONG Address
= (PULONG
)Destination
;
2211 if ((Length
/= 4) != 0) {
2212 if (((ULONG64
)Address
& 4) != 0) {
2214 if ((Length
-= 1) == 0) {
2219 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2220 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2225 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2226 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2234 OUT PVOID Destination
,
2241 RtlFillMemoryUlonglong(
2242 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2244 _In_ ULONGLONG Pattern
);
2246 #endif /* defined(_M_AMD64) */
2249 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2252 #if (NTDDI_VERSION >= NTDDI_WS03)
2253 _IRQL_requires_max_(DISPATCH_LEVEL
)
2257 RtlInitAnsiStringEx(
2258 _Out_ PANSI_STRING DestinationString
,
2259 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2262 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2264 _IRQL_requires_max_(APC_LEVEL
)
2268 RtlGetSaclSecurityDescriptor(
2269 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2270 _Out_ PBOOLEAN SaclPresent
,
2272 _Out_ PBOOLEAN SaclDefaulted
);
2274 _IRQL_requires_max_(APC_LEVEL
)
2278 RtlSetGroupSecurityDescriptor(
2279 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2280 _In_opt_ PSID Group
,
2281 _In_opt_ BOOLEAN GroupDefaulted
);
2283 _IRQL_requires_max_(APC_LEVEL
)
2287 RtlGetGroupSecurityDescriptor(
2288 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2290 _Out_ PBOOLEAN GroupDefaulted
);
2292 _IRQL_requires_max_(APC_LEVEL
)
2296 RtlAbsoluteToSelfRelativeSD(
2297 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2298 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2299 _Inout_ PULONG BufferLength
);
2301 _IRQL_requires_max_(APC_LEVEL
)
2305 RtlSelfRelativeToAbsoluteSD(
2306 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2307 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2308 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2309 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2310 _Inout_ PULONG DaclSize
,
2311 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2312 _Inout_ PULONG SaclSize
,
2313 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2314 _Inout_ PULONG OwnerSize
,
2315 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2316 _Inout_ PULONG PrimaryGroupSize
);
2318 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2321 #if (NTDDI_VERSION >= NTDDI_VISTA)
2327 RtlNumberOfSetBitsUlongPtr(
2328 _In_ ULONG_PTR Target
);
2333 RtlIoDecodeMemIoResource(
2334 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2335 _Out_opt_ PULONGLONG Alignment
,
2336 _Out_opt_ PULONGLONG MinimumAddress
,
2337 _Out_opt_ PULONGLONG MaximumAddress
);
2342 RtlIoEncodeMemIoResource(
2343 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2345 _In_ ULONGLONG Length
,
2346 _In_ ULONGLONG Alignment
,
2347 _In_ ULONGLONG MinimumAddress
,
2348 _In_ ULONGLONG MaximumAddress
);
2353 RtlCmDecodeMemIoResource(
2354 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2355 _Out_opt_ PULONGLONG Start
);
2360 RtlFindClosestEncodableLength(
2361 _In_ ULONGLONG SourceLength
,
2362 _Out_ PULONGLONG TargetLength
);
2367 RtlCmEncodeMemIoResource(
2368 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2370 _In_ ULONGLONG Length
,
2371 _In_ ULONGLONG Start
);
2376 _IRQL_requires_max_(APC_LEVEL
)
2380 RtlRunOnceInitialize(
2381 _Out_ PRTL_RUN_ONCE RunOnce
);
2383 _IRQL_requires_max_(APC_LEVEL
)
2384 _Maybe_raises_SEH_exception_
2388 RtlRunOnceExecuteOnce(
2389 _Inout_ PRTL_RUN_ONCE RunOnce
,
2390 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2391 _Inout_opt_ PVOID Parameter
,
2392 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2394 _IRQL_requires_max_(APC_LEVEL
)
2395 _Must_inspect_result_
2399 RtlRunOnceBeginInitialize(
2400 _Inout_ PRTL_RUN_ONCE RunOnce
,
2402 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2404 _IRQL_requires_max_(APC_LEVEL
)
2409 _Inout_ PRTL_RUN_ONCE RunOnce
,
2411 _In_opt_ PVOID Context
);
2417 _In_ ULONG OSMajorVersion
,
2418 _In_ ULONG OSMinorVersion
,
2419 _In_ ULONG SpMajorVersion
,
2420 _In_ ULONG SpMinorVersion
,
2421 _Out_ PULONG ReturnedProductType
);
2429 _In_ ULONG NormForm
,
2430 _In_ PCWSTR SourceString
,
2431 _In_ LONG SourceStringLength
,
2432 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2433 _Inout_ PLONG DestinationStringLength
);
2438 RtlIsNormalizedString(
2439 _In_ ULONG NormForm
,
2440 _In_ PCWSTR SourceString
,
2441 _In_ LONG SourceStringLength
,
2442 _Out_ PBOOLEAN Normalized
);
2449 _In_ PCWSTR SourceString
,
2450 _In_ LONG SourceStringLength
,
2451 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2452 _Inout_ PLONG DestinationStringLength
);
2459 IN PCWSTR SourceString
,
2460 IN LONG SourceStringLength
,
2461 OUT PWSTR DestinationString
,
2462 IN OUT PLONG DestinationStringLength
);
2467 RtlIdnToNameprepUnicode(
2469 _In_ PCWSTR SourceString
,
2470 _In_ LONG SourceStringLength
,
2471 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2472 _Inout_ PLONG DestinationStringLength
);
2477 RtlCreateServiceSid(
2478 _In_ PUNICODE_STRING ServiceName
,
2479 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2480 _Inout_ PULONG ServiceSidLength
);
2485 RtlCompareAltitudes(
2486 _In_ PCUNICODE_STRING Altitude1
,
2487 _In_ PCUNICODE_STRING Altitude2
);
2491 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2493 #if (NTDDI_VERSION >= NTDDI_WIN7)
2496 _IRQL_requires_max_(PASSIVE_LEVEL
)
2497 _Must_inspect_result_
2502 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2503 PCHAR UTF8StringDestination
,
2504 _In_ ULONG UTF8StringMaxByteCount
,
2505 _Out_ PULONG UTF8StringActualByteCount
,
2506 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2507 _In_ ULONG UnicodeStringByteCount
);
2509 _IRQL_requires_max_(PASSIVE_LEVEL
)
2510 _Must_inspect_result_
2515 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2516 PWSTR UnicodeStringDestination
,
2517 _In_ ULONG UnicodeStringMaxByteCount
,
2518 _Out_ PULONG UnicodeStringActualByteCount
,
2519 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2520 _In_ ULONG UTF8StringByteCount
);
2525 RtlGetEnabledExtendedFeatures(
2526 IN ULONG64 FeatureMask
);
2531 _Must_inspect_result_
2536 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2537 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2539 _In_ _Reserved_ ULONG Flags
);
2545 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2546 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2551 RtlInsertEntryHashTable(
2552 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2553 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2554 _In_ ULONG_PTR Signature
,
2555 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2560 RtlRemoveEntryHashTable(
2561 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2562 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2563 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2565 _Must_inspect_result_
2567 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2569 RtlLookupEntryHashTable(
2570 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2571 _In_ ULONG_PTR Signature
,
2572 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2574 _Must_inspect_result_
2576 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2578 RtlGetNextEntryHashTable(
2579 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2580 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2585 RtlInitEnumerationHashTable(
2586 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2587 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2589 _Must_inspect_result_
2591 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2593 RtlEnumerateEntryHashTable(
2594 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2595 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2600 RtlEndEnumerationHashTable(
2601 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2602 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2607 RtlInitWeakEnumerationHashTable(
2608 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2609 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2611 _Must_inspect_result_
2613 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2615 RtlWeaklyEnumerateEntryHashTable(
2616 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2617 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2622 RtlEndWeakEnumerationHashTable(
2623 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2624 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2630 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2635 RtlContractHashTable(
2636 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2640 _IRQL_requires_max_(PASSIVE_LEVEL
)
2641 _Must_inspect_result_
2646 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2647 _In_ ULONG UTF8StringMaxByteCount
,
2648 _Out_ PULONG UTF8StringActualByteCount
,
2649 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2650 _In_ ULONG UnicodeStringByteCount
);
2652 _IRQL_requires_max_(PASSIVE_LEVEL
)
2653 _Must_inspect_result_
2658 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2659 _In_ ULONG UnicodeStringMaxByteCount
,
2660 _Out_ PULONG UnicodeStringActualByteCount
,
2661 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2662 _In_ ULONG UTF8StringByteCount
);
2664 _IRQL_requires_max_(APC_LEVEL
)
2669 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2672 _Out_ ULONG
*NumChanges
);
2677 RtlCreateVirtualAccountSid(
2678 _In_ PCUNICODE_STRING Name
,
2679 _In_ ULONG BaseSubAuthority
,
2680 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2681 _Inout_ PULONG SidLength
);
2684 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2688 #if !defined(MIDL_PASS)
2689 /* inline funftions */
2690 //DECLSPEC_DEPRECATED_DDK_WINXP
2694 RtlConvertLongToLargeInteger(
2695 _In_ LONG SignedInteger
)
2698 ret
.QuadPart
= SignedInteger
;
2702 //DECLSPEC_DEPRECATED_DDK_WINXP
2706 RtlConvertUlongToLargeInteger(
2707 _In_ ULONG UnsignedInteger
)
2710 ret
.QuadPart
= UnsignedInteger
;
2714 //DECLSPEC_DEPRECATED_DDK_WINXP
2718 RtlLargeIntegerShiftLeft(
2719 _In_ LARGE_INTEGER LargeInteger
,
2720 _In_ CCHAR ShiftCount
)
2722 LARGE_INTEGER Result
;
2724 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2728 //DECLSPEC_DEPRECATED_DDK_WINXP
2732 RtlLargeIntegerShiftRight(
2733 _In_ LARGE_INTEGER LargeInteger
,
2734 _In_ CCHAR ShiftCount
)
2736 LARGE_INTEGER Result
;
2738 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2742 //DECLSPEC_DEPRECATED_DDK
2746 RtlEnlargedUnsignedDivide(
2747 _In_ ULARGE_INTEGER Dividend
,
2749 _Out_opt_ PULONG Remainder
)
2752 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2753 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2756 //DECLSPEC_DEPRECATED_DDK
2760 RtlLargeIntegerNegate(
2761 _In_ LARGE_INTEGER Subtrahend
)
2763 LARGE_INTEGER Difference
;
2765 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2769 //DECLSPEC_DEPRECATED_DDK
2773 RtlLargeIntegerSubtract(
2774 _In_ LARGE_INTEGER Minuend
,
2775 _In_ LARGE_INTEGER Subtrahend
)
2777 LARGE_INTEGER Difference
;
2779 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2783 //DECLSPEC_DEPRECATED_DDK
2787 RtlEnlargedUnsignedMultiply(
2788 _In_ ULONG Multiplicand
,
2789 _In_ ULONG Multiplier
)
2792 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2796 //DECLSPEC_DEPRECATED_DDK
2800 RtlEnlargedIntegerMultiply(
2801 _In_ LONG Multiplicand
,
2802 _In_ LONG Multiplier
)
2805 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2809 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2810 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2811 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2814 RtlInitEmptyAnsiString(
2815 _Out_ PANSI_STRING AnsiString
,
2816 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2817 _In_ USHORT BufferSize
)
2819 AnsiString
->Length
= 0;
2820 AnsiString
->MaximumLength
= BufferSize
;
2821 AnsiString
->Buffer
= Buffer
;
2824 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2825 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2826 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2829 RtlInitEmptyUnicodeString(
2830 _Out_ PUNICODE_STRING UnicodeString
,
2831 _Writable_bytes_(BufferSize
)
2832 _When_(BufferSize
!= 0, _Notnull_
)
2833 __drv_aliasesMem PWSTR Buffer
,
2834 _In_ USHORT BufferSize
)
2836 UnicodeString
->Length
= 0;
2837 UnicodeString
->MaximumLength
= BufferSize
;
2838 UnicodeString
->Buffer
= Buffer
;
2842 #if defined(_AMD64_) || defined(_IA64_)
2849 RtlExtendedIntegerMultiply(
2850 _In_ LARGE_INTEGER Multiplicand
,
2851 _In_ LONG Multiplier
)
2854 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2861 RtlExtendedLargeIntegerDivide(
2862 _In_ LARGE_INTEGER Dividend
,
2864 _Out_opt_ PULONG Remainder
)
2867 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
2869 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2877 //DECLSPEC_DEPRECATED_DDK_WINXP
2881 RtlLargeIntegerDivide(
2882 _In_ LARGE_INTEGER Dividend
,
2883 _In_ LARGE_INTEGER Divisor
,
2884 _Out_opt_ PLARGE_INTEGER Remainder
)
2887 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
2889 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
2895 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2899 RtlLargeIntegerDivide(
2900 _In_ LARGE_INTEGER Dividend
,
2901 _In_ LARGE_INTEGER Divisor
,
2902 _Out_opt_ PLARGE_INTEGER Remainder
);
2907 #endif /* defined(_AMD64_) || defined(_IA64_) */
2911 #if defined(_AMD64_)
2913 #define MultiplyHigh __mulh
2914 #define UnsignedMultiplyHigh __umulh
2916 //DECLSPEC_DEPRECATED_DDK
2920 RtlExtendedMagicDivide(
2921 _In_ LARGE_INTEGER Dividend
,
2922 _In_ LARGE_INTEGER MagicDivisor
,
2923 _In_ CCHAR ShiftCount
)
2928 Pos
= (Dividend
.QuadPart
>= 0);
2929 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
2930 MagicDivisor
.QuadPart
);
2931 ret64
>>= ShiftCount
;
2932 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
2937 //DECLSPEC_DEPRECATED_DDK
2942 _In_ LARGE_INTEGER Addend1
,
2943 _In_ LARGE_INTEGER Addend2
)
2946 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
2951 * RtlLargeIntegerAnd(
2952 * IN OUT LARGE_INTEGER Result,
2953 * IN LARGE_INTEGER Source,
2954 * IN LARGE_INTEGER Mask);
2956 #define RtlLargeIntegerAnd(Result, Source, Mask) \
2957 Result.QuadPart = Source.QuadPart & Mask.QuadPart
2959 //DECLSPEC_DEPRECATED_DDK
2963 RtlLargeIntegerArithmeticShift(
2964 _In_ LARGE_INTEGER LargeInteger
,
2965 _In_ CCHAR ShiftCount
)
2968 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
2973 * RtlLargeIntegerEqualTo(
2974 * IN LARGE_INTEGER Operand1,
2975 * IN LARGE_INTEGER Operand2);
2977 #define RtlLargeIntegerEqualTo(X,Y) \
2978 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
2982 RtlSecureZeroMemory(
2983 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
2986 volatile char* vptr
= (volatile char*)Pointer
;
2987 #if defined(_M_AMD64)
2988 __stosb((PUCHAR
)vptr
, 0, Size
);
2990 char * endptr
= (char *)vptr
+ Size
;
2991 while (vptr
< endptr
) {
2998 #if defined(_M_AMD64)
2999 _Must_inspect_result_
3003 _In_ PRTL_BITMAP BitMapHeader
,
3004 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3006 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3009 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3010 #endif /* defined(_M_AMD64) */
3012 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3013 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3014 ((X).HighPart > (Y).HighPart) \
3017 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3018 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3019 ((X).HighPart > (Y).HighPart) \
3022 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3023 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3026 #define RtlLargeIntegerLessThan(X,Y) ( \
3027 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3028 ((X).HighPart < (Y).HighPart) \
3031 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3032 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3033 ((X).HighPart < (Y).HighPart) \
3036 #define RtlLargeIntegerGreaterThanZero(X) ( \
3037 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3038 ((X).HighPart > 0 ) \
3041 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3043 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3045 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3047 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3049 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3051 #endif /* !defined(MIDL_PASS) */
3053 /* Byte Swap Functions */
3054 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
3055 ((defined(_M_AMD64) || defined(_M_IA64)) \
3056 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
3058 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3059 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3060 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3066 #define RTL_VERIFY(exp) \
3068 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3070 #define RTL_VERIFYMSG(msg, exp) \
3072 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3074 #define RTL_SOFT_VERIFY(exp) \
3076 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3078 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3080 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3082 #define ASSERT(exp) ((void)RTL_VERIFY(exp))
3083 #define ASSERTMSG(msg, exp) ((void)RTL_VERIFYMSG(msg, exp))
3085 #define RTL_SOFT_ASSERT(exp) ((void)RTL_SOFT_VERIFY(exp))
3086 #define RTL_SOFT_ASSERTMSG(msg, exp) ((void)RTL_SOFT_VERIFYMSG(msg, exp))
3088 #if defined(_MSC_VER)
3089 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg)
3090 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg)
3092 # define __assert_annotationA(msg) \
3093 DbgPrint("Assertion %s(%d): %s", __FILE__, __LINE__, msg)
3094 # define __assert_annotationW(msg) \
3095 DbgPrint("Assertion %s(%d): %S", __FILE__, __LINE__, msg)
3098 #define NT_VERIFY(exp) \
3100 (__assert_annotationA(#exp), \
3101 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3103 #define NT_VERIFYMSG(msg, exp) \
3105 (__assert_annotationA(msg), \
3106 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3108 #define NT_VERIFYMSGW(msg, exp) \
3110 (__assert_annotationW(msg), \
3111 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3113 #define NT_ASSERT(exp) ((void)NT_VERIFY(exp))
3114 #define NT_ASSERTMSG(msg, exp) ((void)NT_VERIFYMSG(msg, exp))
3115 #define NT_ASSERTMSGW(msg, exp) ((void)NT_VERIFYMSGW(msg, exp))
3119 #define ASSERT(exp) ((VOID) 0)
3120 #define ASSERTMSG(msg, exp) ((VOID) 0)
3122 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3123 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3125 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3126 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3128 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3129 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3131 #define NT_ASSERT(exp) ((VOID)0)
3132 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
3133 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
3135 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
3136 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
3137 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
3141 #define InitializeListHead32(ListHead) (\
3142 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3144 #if !defined(_WINBASE_)
3146 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
3150 InitializeSListHead(
3151 _Out_ PSLIST_HEADER SListHead
);
3157 InitializeSListHead(
3158 _Out_ PSLIST_HEADER SListHead
)
3161 ULONG64 FeatureBits
;
3165 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3166 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3169 RtlZeroMemory(SListHead
, sizeof(SLIST_HEADER
));
3171 FeatureBits
= __getReg(CV_IA64_CPUID4
);
3172 if ((FeatureBits
& KF_16BYTE_INSTR
) != 0) {
3173 SListHead
->Header16
.HeaderType
= 1;
3174 SListHead
->Header16
.Init
= 1;
3183 #define InterlockedPopEntrySList(Head) \
3184 ExpInterlockedPopEntrySList(Head)
3186 #define InterlockedPushEntrySList(Head, Entry) \
3187 ExpInterlockedPushEntrySList(Head, Entry)
3189 #define InterlockedFlushSList(Head) \
3190 ExpInterlockedFlushSList(Head)
3192 #define QueryDepthSList(Head) \
3193 ExQueryDepthSList(Head)
3195 #else /* !defined(_WIN64) */
3200 InterlockedPopEntrySList(
3201 _Inout_ PSLIST_HEADER ListHead
);
3206 InterlockedPushEntrySList(
3207 _Inout_ PSLIST_HEADER ListHead
,
3208 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry
);
3210 #define InterlockedFlushSList(ListHead) \
3211 ExInterlockedFlushSList(ListHead)
3213 #define QueryDepthSList(Head) \
3214 ExQueryDepthSList(Head)
3216 #endif /* !defined(_WIN64) */
3218 #endif /* !defined(_WINBASE_) */
3220 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3221 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3222 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3223 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3224 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3225 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3226 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3227 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3228 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3229 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3230 (PCONTEXT_EX)(Context + 1), \
3234 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3235 _In_ ULONG Version
);
3238 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3239 _In_ ULONG Version
);
3241 #ifndef RtlIsNtDdiVersionAvailable
3242 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3245 #ifndef RtlIsServicePackVersionInstalled
3246 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3249 #define RtlInterlockedSetBits(Flags, Flag) \
3250 InterlockedOr((PLONG)(Flags), Flag)
3252 #define RtlInterlockedAndBits(Flags, Flag) \
3253 InterlockedAnd((PLONG)(Flags), Flag)
3255 #define RtlInterlockedClearBits(Flags, Flag) \
3256 RtlInterlockedAndBits(Flags, ~(Flag))
3258 #define RtlInterlockedXorBits(Flags, Flag) \
3259 InterlockedXor(Flags, Flag)
3261 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3262 (VOID) RtlInterlockedSetBits(Flags, Flag)
3264 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3265 (VOID) RtlInterlockedAndBits(Flags, Flag)
3267 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3268 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3274 #ifdef RTL_USE_AVL_TABLES
3276 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3277 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3278 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3279 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3280 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3281 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3282 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3283 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3284 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3285 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3286 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3288 #endif /* RTL_USE_AVL_TABLES */
3290 #define RtlInitializeSplayLinks(Links) { \
3291 PRTL_SPLAY_LINKS _SplayLinks; \
3292 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3293 _SplayLinks->Parent = _SplayLinks; \
3294 _SplayLinks->LeftChild = NULL; \
3295 _SplayLinks->RightChild = NULL; \
3298 #define RtlIsLeftChild(Links) \
3299 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3301 #define RtlIsRightChild(Links) \
3302 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3304 #define RtlRightChild(Links) \
3305 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3307 #define RtlIsRoot(Links) \
3308 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3310 #define RtlLeftChild(Links) \
3311 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3313 #define RtlParent(Links) \
3314 ((PRTL_SPLAY_LINKS)(Links))->Parent
3316 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3318 PRTL_SPLAY_LINKS _SplayParent; \
3319 PRTL_SPLAY_LINKS _SplayChild; \
3320 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3321 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3322 _SplayParent->LeftChild = _SplayChild; \
3323 _SplayChild->Parent = _SplayParent; \
3326 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3328 PRTL_SPLAY_LINKS _SplayParent; \
3329 PRTL_SPLAY_LINKS _SplayChild; \
3330 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3331 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3332 _SplayParent->RightChild = _SplayChild; \
3333 _SplayChild->Parent = _SplayParent; \
3336 #if !defined(MIDL_PASS)
3341 RtlConvertLongToLuid(
3347 Temp
.QuadPart
= Val
;
3348 Luid
.LowPart
= Temp
.u
.LowPart
;
3349 Luid
.HighPart
= Temp
.u
.HighPart
;
3356 RtlConvertUlongToLuid(
3366 #endif /* !defined(MIDL_PASS) */
3368 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3369 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3370 *CallersAddress = (PVOID)_ReturnAddress(); \
3371 *CallersCaller = NULL;
3373 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3377 RtlGetCallersAddress(
3378 _Out_ PVOID
*CallersAddress
,
3379 _Out_ PVOID
*CallersCaller
);
3383 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3385 #if (NTDDI_VERSION >= NTDDI_WIN7)
3390 RtlInitHashTableContext(
3391 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3393 Context
->ChainHead
= NULL
;
3394 Context
->PrevLinkage
= NULL
;
3400 RtlInitHashTableContextFromEnumerator(
3401 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3402 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3404 Context
->ChainHead
= Enumerator
->ChainHead
;
3405 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3411 RtlReleaseHashTableContext(
3412 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3414 UNREFERENCED_PARAMETER(Context
);
3421 RtlTotalBucketsHashTable(
3422 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3424 return HashTable
->TableSize
;
3430 RtlNonEmptyBucketsHashTable(
3431 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3433 return HashTable
->NonEmptyBuckets
;
3439 RtlEmptyBucketsHashTable(
3440 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3442 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3448 RtlTotalEntriesHashTable(
3449 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3451 return HashTable
->NumEntries
;
3457 RtlActiveEnumeratorsHashTable(
3458 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3460 return HashTable
->NumEnumerators
;
3463 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3465 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3470 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3471 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3473 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3474 RtlxUnicodeStringToOemSize(STRING) : \
3475 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3478 #define RtlOemStringToUnicodeSize(STRING) ( \
3479 NLS_MB_OEM_CODE_PAGE_TAG ? \
3480 RtlxOemStringToUnicodeSize(STRING) : \
3481 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3484 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3485 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3488 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3489 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))