1 /******************************************************************************
2 * Runtime Library Functions *
3 ******************************************************************************/
7 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
9 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
14 _Out_ PLIST_ENTRY ListHead
)
16 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
23 _In_
const LIST_ENTRY
* ListHead
)
25 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
31 _In_ PLIST_ENTRY Entry
)
36 OldFlink
= Entry
->Flink
;
37 OldBlink
= Entry
->Blink
;
38 OldFlink
->Blink
= OldBlink
;
39 OldBlink
->Flink
= OldFlink
;
40 return (BOOLEAN
)(OldFlink
== OldBlink
);
46 _Inout_ PLIST_ENTRY ListHead
)
51 Entry
= ListHead
->Flink
;
53 ListHead
->Flink
= Flink
;
54 Flink
->Blink
= ListHead
;
61 _Inout_ PLIST_ENTRY ListHead
)
66 Entry
= ListHead
->Blink
;
68 ListHead
->Blink
= Blink
;
69 Blink
->Flink
= ListHead
;
76 _Inout_ PLIST_ENTRY ListHead
,
77 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
80 OldBlink
= ListHead
->Blink
;
81 Entry
->Flink
= ListHead
;
82 Entry
->Blink
= OldBlink
;
83 OldBlink
->Flink
= Entry
;
84 ListHead
->Blink
= Entry
;
90 _Inout_ PLIST_ENTRY ListHead
,
91 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
94 OldFlink
= ListHead
->Flink
;
95 Entry
->Flink
= OldFlink
;
96 Entry
->Blink
= ListHead
;
97 OldFlink
->Blink
= Entry
;
98 ListHead
->Flink
= Entry
;
104 _Inout_ PLIST_ENTRY ListHead
,
105 _Inout_ PLIST_ENTRY ListToAppend
)
107 PLIST_ENTRY ListEnd
= ListHead
->Blink
;
109 ListHead
->Blink
->Flink
= ListToAppend
;
110 ListHead
->Blink
= ListToAppend
->Blink
;
111 ListToAppend
->Blink
->Flink
= ListHead
;
112 ListToAppend
->Blink
= ListEnd
;
118 _Inout_ PSINGLE_LIST_ENTRY ListHead
)
120 PSINGLE_LIST_ENTRY FirstEntry
;
121 FirstEntry
= ListHead
->Next
;
122 if (FirstEntry
!= NULL
) {
123 ListHead
->Next
= FirstEntry
->Next
;
131 _Inout_ PSINGLE_LIST_ENTRY ListHead
,
132 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry
)
134 Entry
->Next
= ListHead
->Next
;
135 ListHead
->Next
= Entry
;
138 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
145 _In_ PVOID FailedAssertion
,
147 _In_ ULONG LineNumber
,
148 _In_opt_ PSTR Message
);
152 * IN VOID UNALIGNED *Destination,
153 * IN CONST VOID UNALIGNED *Source,
156 #define RtlCopyMemory(Destination, Source, Length) \
157 memcpy(Destination, Source, Length)
159 #define RtlCopyBytes RtlCopyMemory
161 #if defined(_M_AMD64)
165 RtlCopyMemoryNonTemporal(
166 _Out_writes_bytes_all_(Length
) VOID UNALIGNED
*Destination
,
167 _In_reads_bytes_(Length
) const VOID UNALIGNED
*Source
,
170 #define RtlCopyMemoryNonTemporal RtlCopyMemory
178 #define RtlEqualLuid(Luid1, Luid2) \
179 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
183 * IN VOID UNALIGNED *Destination,
184 * IN CONST VOID UNALIGNED *Source,
187 #define RtlEqualMemory(Destination, Source, Length) \
188 (!memcmp(Destination, Source, Length))
192 * IN VOID UNALIGNED *Destination,
196 #define RtlFillMemory(Destination, Length, Fill) \
197 memset(Destination, Fill, Length)
199 #define RtlFillBytes RtlFillMemory
201 _IRQL_requires_max_(PASSIVE_LEVEL
)
205 RtlFreeUnicodeString(
206 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
207 PUNICODE_STRING UnicodeString
);
209 _IRQL_requires_max_(PASSIVE_LEVEL
)
210 _Must_inspect_result_
215 _In_ PUNICODE_STRING GuidString
,
218 _IRQL_requires_max_(DISPATCH_LEVEL
)
219 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
220 //_At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
221 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
)))
225 RtlInitUnicodeString(
226 _Out_ PUNICODE_STRING DestinationString
,
227 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
231 * IN VOID UNALIGNED *Destination,
232 * IN CONST VOID UNALIGNED *Source,
235 #define RtlMoveMemory(Destination, Source, Length) \
236 memmove(Destination, Source, Length)
238 _IRQL_requires_max_(PASSIVE_LEVEL
)
239 _Must_inspect_result_
245 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
246 PUNICODE_STRING GuidString
);
250 * IN VOID UNALIGNED *Destination,
253 #define RtlZeroMemory(Destination, Length) \
254 memset(Destination, 0, Length)
256 #define RtlZeroBytes RtlZeroMemory
259 #if (NTDDI_VERSION >= NTDDI_WIN2K)
262 _Must_inspect_result_
267 _In_ PRTL_BITMAP BitMapHeader
,
268 _In_ ULONG StartingIndex
,
271 _Must_inspect_result_
276 _In_ PRTL_BITMAP BitMapHeader
,
277 _In_ ULONG StartingIndex
,
280 _IRQL_requires_max_(PASSIVE_LEVEL
)
281 _Must_inspect_result_
285 RtlAnsiStringToUnicodeString(
286 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
287 _When_(!AllocateDestinationString
, _Inout_
)
288 PUNICODE_STRING DestinationString
,
289 _In_ PANSI_STRING SourceString
,
290 _In_ BOOLEAN AllocateDestinationString
);
292 _IRQL_requires_max_(PASSIVE_LEVEL
)
296 RtlxAnsiStringToUnicodeSize(
297 _In_ PCANSI_STRING AnsiString
);
299 #define RtlAnsiStringToUnicodeSize(String) ( \
300 NLS_MB_CODE_PAGE_TAG ? \
301 RtlxAnsiStringToUnicodeSize(String) : \
302 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
306 _Unchanged_(Destination
->MaximumLength
)
307 _Unchanged_(Destination
->Buffer
)
308 _When_(_Old_(Destination
->Length
) + Source
->Length
<= Destination
->MaximumLength
,
309 _At_(Destination
->Length
, _Post_equal_to_(_Old_(Destination
->Length
) + Source
->Length
))
310 _At_(return, _Out_range_(==, 0)))
311 _When_(_Old_(Destination
->Length
) + Source
->Length
> Destination
->MaximumLength
,
312 _Unchanged_(Destination
->Length
)
313 _At_(return, _Out_range_(<, 0)))
317 RtlAppendUnicodeStringToString(
318 _Inout_ PUNICODE_STRING Destination
,
319 _In_ PCUNICODE_STRING Source
);
322 _Unchanged_(Destination
->MaximumLength
)
323 _Unchanged_(Destination
->Buffer
)
324 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength,
325 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR)))
326 _At_(return, _Out_range_(==, 0)))
327 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength,
328 _Unchanged_(Destination->Length)
329 _At_(return, _Out_range_(<, 0))) */
333 RtlAppendUnicodeToString(
334 _Inout_ PUNICODE_STRING Destination
,
335 _In_opt_z_ PCWSTR Source
);
337 _IRQL_requires_max_(PASSIVE_LEVEL
)
338 _Must_inspect_result_
343 _In_ ULONG RelativeTo
,
350 _In_ PRTL_BITMAP BitMapHeader
);
356 _In_ PRTL_BITMAP BitMapHeader
,
357 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
358 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
);
360 _Must_inspect_result_
365 _In_
const VOID
*Source1
,
366 _In_
const VOID
*Source2
,
369 _IRQL_requires_max_(PASSIVE_LEVEL
)
370 _Must_inspect_result_
374 RtlCompareUnicodeString(
375 _In_ PCUNICODE_STRING String1
,
376 _In_ PCUNICODE_STRING String2
,
377 _In_ BOOLEAN CaseInSensitive
);
379 _IRQL_requires_max_(PASSIVE_LEVEL
)
380 _Must_inspect_result_
384 RtlCompareUnicodeStrings(
385 _In_reads_(String1Length
) PCWCH String1
,
386 _In_ SIZE_T String1Length
,
387 _In_reads_(String2Length
) PCWCH String2
,
388 _In_ SIZE_T String2Length
,
389 _In_ BOOLEAN CaseInSensitive
);
391 _Unchanged_(DestinationString
->Buffer
)
392 _Unchanged_(DestinationString
->MaximumLength
)
393 _At_(DestinationString
->Length
,
394 _When_(SourceString
->Length
> DestinationString
->MaximumLength
,
395 _Post_equal_to_(DestinationString
->MaximumLength
))
396 _When_(SourceString
->Length
<= DestinationString
->MaximumLength
,
397 _Post_equal_to_(SourceString
->Length
)))
401 RtlCopyUnicodeString(
402 _Inout_ PUNICODE_STRING DestinationString
,
403 _In_opt_ PCUNICODE_STRING SourceString
);
405 _IRQL_requires_max_(PASSIVE_LEVEL
)
409 RtlCreateRegistryKey(
410 _In_ ULONG RelativeTo
,
413 _IRQL_requires_max_(APC_LEVEL
)
417 RtlCreateSecurityDescriptor(
418 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
419 _In_ ULONG Revision
);
421 _IRQL_requires_max_(PASSIVE_LEVEL
)
425 RtlDeleteRegistryValue(
426 _In_ ULONG RelativeTo
,
428 _In_z_ PCWSTR ValueName
);
430 _IRQL_requires_max_(PASSIVE_LEVEL
)
431 _Must_inspect_result_
435 RtlEqualUnicodeString(
436 _In_ CONST UNICODE_STRING
*String1
,
437 _In_ CONST UNICODE_STRING
*String2
,
438 _In_ BOOLEAN CaseInSensitive
);
440 #if !defined(_AMD64_) && !defined(_IA64_)
444 RtlExtendedIntegerMultiply(
445 _In_ LARGE_INTEGER Multiplicand
,
446 _In_ LONG Multiplier
);
451 RtlExtendedLargeIntegerDivide(
452 _In_ LARGE_INTEGER Dividend
,
454 _Out_opt_ PULONG Remainder
);
457 #if defined(_X86_) || defined(_IA64_)
461 RtlExtendedMagicDivide(
462 _In_ LARGE_INTEGER Dividend
,
463 _In_ LARGE_INTEGER MagicDivisor
,
464 _In_ CCHAR ShiftCount
);
467 _IRQL_requires_max_(PASSIVE_LEVEL
)
472 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
473 PANSI_STRING AnsiString
);
475 _Success_(return != -1)
476 _Must_inspect_result_
481 _In_ PRTL_BITMAP BitMapHeader
,
482 _In_ ULONG NumberToFind
,
483 _In_ ULONG HintIndex
);
485 _Success_(return != -1)
489 RtlFindClearBitsAndSet(
490 _In_ PRTL_BITMAP BitMapHeader
,
491 _In_ ULONG NumberToFind
,
492 _In_ ULONG HintIndex
);
497 RtlFindFirstRunClear(
498 _In_ PRTL_BITMAP BitMapHeader
,
499 _Out_ PULONG StartingIndex
);
505 _In_ PRTL_BITMAP BitMapHeader
,
506 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
507 _In_range_(>, 0) ULONG SizeOfRunArray
,
508 _In_ BOOLEAN LocateLongestRuns
);
513 RtlFindLastBackwardRunClear(
514 _In_ PRTL_BITMAP BitMapHeader
,
515 _In_ ULONG FromIndex
,
516 _Out_ PULONG StartingRunIndex
);
518 _Success_(return != -1)
519 _Must_inspect_result_
523 RtlFindLeastSignificantBit(
529 RtlFindLongestRunClear(
530 _In_ PRTL_BITMAP BitMapHeader
,
531 _Out_ PULONG StartingIndex
);
533 _Success_(return != -1)
534 _Must_inspect_result_
538 RtlFindMostSignificantBit(
544 RtlFindNextForwardRunClear(
545 _In_ PRTL_BITMAP BitMapHeader
,
546 _In_ ULONG FromIndex
,
547 _Out_ PULONG StartingRunIndex
);
549 _Success_(return != -1)
550 _Must_inspect_result_
555 _In_ PRTL_BITMAP BitMapHeader
,
556 _In_ ULONG NumberToFind
,
557 _In_ ULONG HintIndex
);
559 _Success_(return != -1)
563 RtlFindSetBitsAndClear(
564 _In_ PRTL_BITMAP BitMapHeader
,
565 _In_ ULONG NumberToFind
,
566 _In_ ULONG HintIndex
);
568 _IRQL_requires_max_(DISPATCH_LEVEL
)
573 _Out_ PANSI_STRING DestinationString
,
574 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
580 _Out_ PRTL_BITMAP BitMapHeader
,
581 _In_ __drv_aliasesMem PULONG BitMapBuffer
,
582 _In_ ULONG SizeOfBitMap
);
584 _IRQL_requires_max_(DISPATCH_LEVEL
)
589 _Out_ PSTRING DestinationString
,
590 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
592 _IRQL_requires_max_(PASSIVE_LEVEL
)
593 _At_(String
->MaximumLength
, _Const_
)
597 RtlIntegerToUnicodeString(
600 _Inout_ PUNICODE_STRING String
);
602 _IRQL_requires_max_(PASSIVE_LEVEL
)
603 _At_(String
->MaximumLength
, _Const_
)
607 RtlInt64ToUnicodeString(
608 _In_ ULONGLONG Value
,
610 _Inout_ PUNICODE_STRING String
);
613 #define RtlIntPtrToUnicodeString(Value, Base, String) \
614 RtlInt64ToUnicodeString(Value, Base, String)
616 #define RtlIntPtrToUnicodeString(Value, Base, String) \
617 RtlIntegerToUnicodeString(Value, Base, String)
624 #define RtlIsZeroLuid(_L1) \
625 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
627 _IRQL_requires_max_(APC_LEVEL
)
631 RtlLengthSecurityDescriptor(
632 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
637 RtlNumberOfClearBits(
638 _In_ PRTL_BITMAP BitMapHeader
);
644 _In_ PRTL_BITMAP BitMapHeader
);
646 _IRQL_requires_max_(PASSIVE_LEVEL
)
650 RtlQueryRegistryValues(
651 _In_ ULONG RelativeTo
,
653 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Post_valid_
)
654 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
655 _In_opt_ PVOID Context
,
656 _In_opt_ PVOID Environment
);
658 #define SHORT_SIZE (sizeof(USHORT))
659 #define SHORT_MASK (SHORT_SIZE - 1)
660 #define LONG_SIZE (sizeof(LONG))
661 #define LONGLONG_SIZE (sizeof(LONGLONG))
662 #define LONG_MASK (LONG_SIZE - 1)
663 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
664 #define LOWBYTE_MASK 0x00FF
666 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
667 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
668 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
669 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
675 _In_ PRTL_BITMAP BitMapHeader
);
681 _In_ PRTL_BITMAP BitMapHeader
,
682 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
683 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
);
685 _IRQL_requires_max_(APC_LEVEL
)
689 RtlSetDaclSecurityDescriptor(
690 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
691 _In_ BOOLEAN DaclPresent
,
693 _In_opt_ BOOLEAN DaclDefaulted
);
702 #define RtlStoreUlong(Address,Value) \
703 *(ULONG UNALIGNED *)(Address) = (Value)
707 * IN OUT PULONGLONG Address,
710 #define RtlStoreUlonglong(Address,Value) \
711 *(ULONGLONG UNALIGNED *)(Address) = (Value)
715 * IN PUSHORT Address,
718 #define RtlStoreUshort(Address,Value) \
719 *(USHORT UNALIGNED *)(Address) = (Value)
723 * PUSHORT DestinationAddress,
724 * PUSHORT SourceAddress);
726 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
727 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
731 * PULONG DestinationAddress,
732 * PULONG SourceAddress);
734 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
735 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
739 #define RtlStoreUlong(Address,Value) \
740 if ((ULONG_PTR)(Address) & LONG_MASK) { \
741 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
742 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
743 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
744 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
747 *((PULONG)(Address)) = (ULONG) (Value); \
750 #define RtlStoreUlonglong(Address,Value) \
751 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
752 RtlStoreUlong((ULONG_PTR)(Address), \
753 (ULONGLONG)(Value) & 0xFFFFFFFF); \
754 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
755 (ULONGLONG)(Value) >> 32); \
757 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
760 #define RtlStoreUshort(Address,Value) \
761 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
762 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
763 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
766 *((PUSHORT) (Address)) = (USHORT)Value; \
769 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
770 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
772 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
773 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
777 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
780 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
781 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
783 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
784 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
785 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
786 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
790 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
793 #endif /* defined(_AMD64_) */
798 * IN OUT PULONG_PTR Address,
799 * IN ULONG_PTR Value);
801 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
803 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
806 _Success_(return != 0)
811 _In_ PTIME_FIELDS TimeFields
,
812 _Out_ PLARGE_INTEGER Time
);
818 _In_ PLARGE_INTEGER Time
,
819 _Out_ PTIME_FIELDS TimeFields
);
830 RtlUlonglongByteSwap(
831 _In_ ULONGLONG Source
);
833 _When_(AllocateDestinationString
,
834 _At_(DestinationString
->MaximumLength
,
835 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
836 _When_(!AllocateDestinationString
,
837 _At_(DestinationString
->Buffer
, _Const_
)
838 _At_(DestinationString
->MaximumLength
, _Const_
))
839 _IRQL_requires_max_(PASSIVE_LEVEL
)
840 _When_(AllocateDestinationString
, _Must_inspect_result_
)
844 RtlUnicodeStringToAnsiString(
845 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
846 _When_(!AllocateDestinationString
, _Inout_
)
847 PANSI_STRING DestinationString
,
848 _In_ PCUNICODE_STRING SourceString
,
849 _In_ BOOLEAN AllocateDestinationString
);
851 _IRQL_requires_max_(PASSIVE_LEVEL
)
855 RtlxUnicodeStringToAnsiSize(
856 _In_ PCUNICODE_STRING UnicodeString
);
858 #define RtlUnicodeStringToAnsiSize(String) ( \
859 NLS_MB_CODE_PAGE_TAG ? \
860 RtlxUnicodeStringToAnsiSize(String) : \
861 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
864 _IRQL_requires_max_(PASSIVE_LEVEL
)
868 RtlUnicodeStringToInteger(
869 _In_ PCUNICODE_STRING String
,
873 _IRQL_requires_max_(PASSIVE_LEVEL
)
877 RtlUpcaseUnicodeChar(
878 _In_ WCHAR SourceCharacter
);
886 _IRQL_requires_max_(APC_LEVEL
)
887 _Must_inspect_result_
891 RtlValidRelativeSecurityDescriptor(
892 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
893 _In_ ULONG SecurityDescriptorLength
,
894 _In_ SECURITY_INFORMATION RequiredInformation
);
896 _IRQL_requires_max_(APC_LEVEL
)
897 _Must_inspect_result_
901 RtlValidSecurityDescriptor(
902 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
904 _IRQL_requires_max_(PASSIVE_LEVEL
)
908 RtlWriteRegistryValue(
909 _In_ ULONG RelativeTo
,
911 _In_z_ PCWSTR ValueName
,
912 _In_ ULONG ValueType
,
913 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
914 _In_ ULONG ValueLength
);
919 #ifndef RTL_USE_AVL_TABLES
924 RtlInitializeGenericTable(
925 _Out_ PRTL_GENERIC_TABLE Table
,
926 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
927 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
928 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
929 _In_opt_ PVOID TableContext
);
934 RtlInsertElementGenericTable(
935 _In_ PRTL_GENERIC_TABLE Table
,
936 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
937 _In_ CLONG BufferSize
,
938 _Out_opt_ PBOOLEAN NewElement
);
943 RtlInsertElementGenericTableFull(
944 _In_ PRTL_GENERIC_TABLE Table
,
945 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
946 _In_ CLONG BufferSize
,
947 _Out_opt_ PBOOLEAN NewElement
,
948 _In_ PVOID NodeOrParent
,
949 _In_ TABLE_SEARCH_RESULT SearchResult
);
954 RtlDeleteElementGenericTable(
955 _In_ PRTL_GENERIC_TABLE Table
,
958 _Must_inspect_result_
962 RtlLookupElementGenericTable(
963 _In_ PRTL_GENERIC_TABLE Table
,
969 RtlLookupElementGenericTableFull(
970 _In_ PRTL_GENERIC_TABLE Table
,
972 _Out_ PVOID
*NodeOrParent
,
973 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
975 _Must_inspect_result_
979 RtlEnumerateGenericTable(
980 _In_ PRTL_GENERIC_TABLE Table
,
981 _In_ BOOLEAN Restart
);
983 _Must_inspect_result_
987 RtlEnumerateGenericTableWithoutSplaying(
988 _In_ PRTL_GENERIC_TABLE Table
,
989 _Inout_ PVOID
*RestartKey
);
991 _Must_inspect_result_
995 RtlGetElementGenericTable(
996 _In_ PRTL_GENERIC_TABLE Table
,
1002 RtlNumberGenericTableElements(
1003 _In_ PRTL_GENERIC_TABLE Table
);
1005 _Must_inspect_result_
1009 RtlIsGenericTableEmpty(
1010 _In_ PRTL_GENERIC_TABLE Table
);
1012 #endif /* !RTL_USE_AVL_TABLES */
1014 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1020 _Inout_ PRTL_SPLAY_LINKS Links
);
1026 _In_ PRTL_SPLAY_LINKS Links
);
1032 _In_ PRTL_SPLAY_LINKS Links
,
1033 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1035 _Must_inspect_result_
1039 RtlSubtreeSuccessor(
1040 _In_ PRTL_SPLAY_LINKS Links
);
1042 _Must_inspect_result_
1046 RtlSubtreePredecessor(
1047 _In_ PRTL_SPLAY_LINKS Links
);
1049 _Must_inspect_result_
1054 _In_ PRTL_SPLAY_LINKS Links
);
1056 _Must_inspect_result_
1061 _In_ PRTL_SPLAY_LINKS Links
);
1063 _IRQL_requires_max_(PASSIVE_LEVEL
)
1064 _Must_inspect_result_
1068 RtlPrefixUnicodeString(
1069 _In_ PCUNICODE_STRING String1
,
1070 _In_ PCUNICODE_STRING String2
,
1071 _In_ BOOLEAN CaseInSensitive
);
1073 _IRQL_requires_max_(PASSIVE_LEVEL
)
1078 _Inout_ PSTRING DestinationString
,
1079 _In_
const PSTRING SourceString
);
1081 _IRQL_requires_max_(PASSIVE_LEVEL
)
1082 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1086 RtlUpcaseUnicodeString(
1087 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1088 _When_(!AllocateDestinationString
, _Inout_
)
1089 PUNICODE_STRING DestinationString
,
1090 _In_ PCUNICODE_STRING SourceString
,
1091 _In_ BOOLEAN AllocateDestinationString
);
1093 _IRQL_requires_max_(APC_LEVEL
)
1098 _Inout_ PACCESS_MASK AccessMask
,
1099 _In_ PGENERIC_MAPPING GenericMapping
);
1101 _IRQL_requires_max_(PASSIVE_LEVEL
)
1105 RtlVolumeDeviceToDosName(
1106 _In_ PVOID VolumeDeviceObject
,
1107 _Out_ PUNICODE_STRING DosName
);
1113 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
);
1118 RtlVerifyVersionInfo(
1119 IN PRTL_OSVERSIONINFOEXW VersionInfo
,
1121 IN ULONGLONG ConditionMask
);
1123 _IRQL_requires_max_(PASSIVE_LEVEL
)
1124 _Must_inspect_result_
1129 _In_
const PSTRING String1
,
1130 _In_
const PSTRING String2
,
1131 _In_ BOOLEAN CaseInSensitive
);
1137 _Out_ PSTRING DestinationString
,
1138 _In_opt_
const PSTRING SourceString
);
1140 _IRQL_requires_max_(PASSIVE_LEVEL
)
1141 _Must_inspect_result_
1146 _In_
const PSTRING String1
,
1147 _In_
const PSTRING String2
,
1148 _In_ BOOLEAN CaseInSensitive
);
1150 _IRQL_requires_max_(PASSIVE_LEVEL
)
1156 _In_opt_ ULONG Base
,
1157 _Out_ PULONG Value
);
1159 _IRQL_requires_max_(PASSIVE_LEVEL
)
1164 _In_ CHAR Character
);
1170 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1178 _Must_inspect_result_
1180 _Post_writable_byte_size_(Size
)
1185 _In_ HANDLE HeapHandle
,
1186 _In_opt_ ULONG Flags
,
1189 _Success_(return != 0)
1194 _In_ PVOID HeapHandle
,
1195 _In_opt_ ULONG Flags
,
1196 _In_ _Post_invalid_ PVOID BaseAddress
);
1202 _Out_ PCONTEXT ContextRecord
);
1204 _Ret_range_(<, MAXLONG
)
1209 _Inout_ PULONG Seed
);
1211 _IRQL_requires_max_(APC_LEVEL
)
1212 _Success_(return != 0)
1213 _Must_inspect_result_
1217 RtlCreateUnicodeString(
1218 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1219 PUNICODE_STRING DestinationString
,
1220 _In_z_ PCWSTR SourceString
);
1222 _IRQL_requires_max_(APC_LEVEL
)
1226 RtlAppendStringToString(
1227 _Inout_ PSTRING Destination
,
1228 _In_
const STRING
*Source
);
1230 _IRQL_requires_max_(PASSIVE_LEVEL
)
1231 _Must_inspect_result_
1235 RtlOemStringToUnicodeString(
1236 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1237 _When_(!AllocateDestinationString
, _Inout_
)
1238 PUNICODE_STRING DestinationString
,
1239 _In_ PCOEM_STRING SourceString
,
1240 _In_ BOOLEAN AllocateDestinationString
);
1242 _IRQL_requires_max_(PASSIVE_LEVEL
)
1243 _Must_inspect_result_
1247 RtlUnicodeStringToOemString(
1248 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1249 _When_(!AllocateDestinationString
, _Inout_
)
1250 POEM_STRING DestinationString
,
1251 _In_ PCUNICODE_STRING SourceString
,
1252 _In_ BOOLEAN AllocateDestinationString
);
1254 _IRQL_requires_max_(PASSIVE_LEVEL
)
1255 _Must_inspect_result_
1259 RtlUpcaseUnicodeStringToOemString(
1260 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1261 _When_(!AllocateDestinationString
, _Inout_
)
1262 POEM_STRING DestinationString
,
1263 _In_ PCUNICODE_STRING SourceString
,
1264 _In_ BOOLEAN AllocateDestinationString
);
1266 _IRQL_requires_max_(PASSIVE_LEVEL
)
1267 _Must_inspect_result_
1271 RtlOemStringToCountedUnicodeString(
1272 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1273 _When_(!AllocateDestinationString
, _Inout_
)
1274 PUNICODE_STRING DestinationString
,
1275 _In_ PCOEM_STRING SourceString
,
1276 _In_ BOOLEAN AllocateDestinationString
);
1278 _IRQL_requires_max_(PASSIVE_LEVEL
)
1279 _Must_inspect_result_
1283 RtlUnicodeStringToCountedOemString(
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 RtlUpcaseUnicodeStringToCountedOemString(
1296 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1297 _When_(!AllocateDestinationString
, _Inout_
)
1298 POEM_STRING DestinationString
,
1299 _In_ PCUNICODE_STRING SourceString
,
1300 _In_ BOOLEAN AllocateDestinationString
);
1302 _IRQL_requires_max_(PASSIVE_LEVEL
)
1303 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1307 RtlDowncaseUnicodeString(
1308 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1309 _When_(!AllocateDestinationString
, _Inout_
)
1310 PUNICODE_STRING UniDest
,
1311 _In_ PCUNICODE_STRING UniSource
,
1312 _In_ BOOLEAN AllocateDestinationString
);
1314 _IRQL_requires_max_(PASSIVE_LEVEL
)
1319 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1321 _IRQL_requires_max_(PASSIVE_LEVEL
)
1325 RtlxUnicodeStringToOemSize(
1326 _In_ PCUNICODE_STRING UnicodeString
);
1328 _IRQL_requires_max_(PASSIVE_LEVEL
)
1332 RtlxOemStringToUnicodeSize(
1333 _In_ PCOEM_STRING OemString
);
1335 _IRQL_requires_max_(PASSIVE_LEVEL
)
1339 RtlMultiByteToUnicodeN(
1340 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1341 _In_ ULONG MaxBytesInUnicodeString
,
1342 _Out_opt_ PULONG BytesInUnicodeString
,
1343 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1344 _In_ ULONG BytesInMultiByteString
);
1346 _IRQL_requires_max_(PASSIVE_LEVEL
)
1350 RtlMultiByteToUnicodeSize(
1351 _Out_ PULONG BytesInUnicodeString
,
1352 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1353 _In_ ULONG BytesInMultiByteString
);
1355 _IRQL_requires_max_(PASSIVE_LEVEL
)
1359 RtlUnicodeToMultiByteSize(
1360 _Out_ PULONG BytesInMultiByteString
,
1361 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1362 _In_ ULONG BytesInUnicodeString
);
1364 _IRQL_requires_max_(PASSIVE_LEVEL
)
1368 RtlUnicodeToMultiByteN(
1369 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1370 _In_ ULONG MaxBytesInMultiByteString
,
1371 _Out_opt_ PULONG BytesInMultiByteString
,
1372 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1373 _In_ ULONG BytesInUnicodeString
);
1375 _IRQL_requires_max_(PASSIVE_LEVEL
)
1379 RtlUpcaseUnicodeToMultiByteN(
1380 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1381 _In_ ULONG MaxBytesInMultiByteString
,
1382 _Out_opt_ PULONG BytesInMultiByteString
,
1383 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1384 _In_ ULONG BytesInUnicodeString
);
1386 _IRQL_requires_max_(PASSIVE_LEVEL
)
1391 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1392 _In_ ULONG MaxBytesInUnicodeString
,
1393 _Out_opt_ PULONG BytesInUnicodeString
,
1394 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1395 _In_ ULONG BytesInOemString
);
1397 _IRQL_requires_max_(PASSIVE_LEVEL
)
1402 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1403 _In_ ULONG MaxBytesInOemString
,
1404 _Out_opt_ PULONG BytesInOemString
,
1405 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1406 _In_ ULONG BytesInUnicodeString
);
1408 _IRQL_requires_max_(PASSIVE_LEVEL
)
1412 RtlUpcaseUnicodeToOemN(
1413 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1414 _In_ ULONG MaxBytesInOemString
,
1415 _Out_opt_ PULONG BytesInOemString
,
1416 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1417 _In_ ULONG BytesInUnicodeString
);
1419 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1420 _IRQL_requires_max_(PASSIVE_LEVEL
)
1424 RtlGenerate8dot3Name(
1425 _In_ PCUNICODE_STRING Name
,
1426 _In_ BOOLEAN AllowExtendedCharacters
,
1427 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1428 _Inout_ PUNICODE_STRING Name8dot3
);
1430 _IRQL_requires_max_(PASSIVE_LEVEL
)
1434 RtlGenerate8dot3Name(
1435 _In_ PCUNICODE_STRING Name
,
1436 _In_ BOOLEAN AllowExtendedCharacters
,
1437 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1438 _Inout_ PUNICODE_STRING Name8dot3
);
1441 _IRQL_requires_max_(PASSIVE_LEVEL
)
1442 _Must_inspect_result_
1446 RtlIsNameLegalDOS8Dot3(
1447 _In_ PCUNICODE_STRING Name
,
1448 _Inout_opt_ POEM_STRING OemName
,
1449 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1451 _IRQL_requires_max_(PASSIVE_LEVEL
)
1452 _Must_inspect_result_
1456 RtlIsValidOemCharacter(
1457 _Inout_ PWCHAR Char
);
1459 _IRQL_requires_max_(PASSIVE_LEVEL
)
1464 _Out_ PPREFIX_TABLE PrefixTable
);
1466 _IRQL_requires_max_(PASSIVE_LEVEL
)
1471 _In_ PPREFIX_TABLE PrefixTable
,
1472 _In_ __drv_aliasesMem PSTRING Prefix
,
1473 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1475 _IRQL_requires_max_(PASSIVE_LEVEL
)
1480 _In_ PPREFIX_TABLE PrefixTable
,
1481 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1483 _IRQL_requires_max_(PASSIVE_LEVEL
)
1484 _Must_inspect_result_
1489 _In_ PPREFIX_TABLE PrefixTable
,
1490 _In_ PSTRING FullName
);
1492 _IRQL_requires_max_(PASSIVE_LEVEL
)
1496 RtlInitializeUnicodePrefix(
1497 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1499 _IRQL_requires_max_(PASSIVE_LEVEL
)
1503 RtlInsertUnicodePrefix(
1504 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1505 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1506 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1508 _IRQL_requires_max_(PASSIVE_LEVEL
)
1512 RtlRemoveUnicodePrefix(
1513 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1514 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1516 _IRQL_requires_max_(PASSIVE_LEVEL
)
1517 _Must_inspect_result_
1519 PUNICODE_PREFIX_TABLE_ENTRY
1521 RtlFindUnicodePrefix(
1522 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1523 _In_ PUNICODE_STRING FullName
,
1524 _In_ ULONG CaseInsensitiveIndex
);
1526 _IRQL_requires_max_(PASSIVE_LEVEL
)
1527 _Must_inspect_result_
1529 PUNICODE_PREFIX_TABLE_ENTRY
1531 RtlNextUnicodePrefix(
1532 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1533 _In_ BOOLEAN Restart
);
1535 _Must_inspect_result_
1539 RtlCompareMemoryUlong(
1540 _In_reads_bytes_(Length
) PVOID Source
,
1542 _In_ ULONG Pattern
);
1544 _Success_(return != 0)
1548 RtlTimeToSecondsSince1980(
1549 _In_ PLARGE_INTEGER Time
,
1550 _Out_ PULONG ElapsedSeconds
);
1555 RtlSecondsSince1980ToTime(
1556 _In_ ULONG ElapsedSeconds
,
1557 _Out_ PLARGE_INTEGER Time
);
1559 _Success_(return != 0)
1563 RtlTimeToSecondsSince1970(
1564 _In_ PLARGE_INTEGER Time
,
1565 _Out_ PULONG ElapsedSeconds
);
1570 RtlSecondsSince1970ToTime(
1571 _In_ ULONG ElapsedSeconds
,
1572 _Out_ PLARGE_INTEGER Time
);
1574 _IRQL_requires_max_(APC_LEVEL
)
1575 _Must_inspect_result_
1582 _Must_inspect_result_
1590 _IRQL_requires_max_(APC_LEVEL
)
1591 _Must_inspect_result_
1599 _IRQL_requires_max_(APC_LEVEL
)
1603 RtlLengthRequiredSid(
1604 _In_ ULONG SubAuthorityCount
);
1610 _In_ _Post_invalid_ PSID Sid
);
1612 _Must_inspect_result_
1616 RtlAllocateAndInitializeSid(
1617 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1618 _In_ UCHAR SubAuthorityCount
,
1619 _In_ ULONG SubAuthority0
,
1620 _In_ ULONG SubAuthority1
,
1621 _In_ ULONG SubAuthority2
,
1622 _In_ ULONG SubAuthority3
,
1623 _In_ ULONG SubAuthority4
,
1624 _In_ ULONG SubAuthority5
,
1625 _In_ ULONG SubAuthority6
,
1626 _In_ ULONG SubAuthority7
,
1627 _Outptr_ PSID
*Sid
);
1629 _IRQL_requires_max_(APC_LEVEL
)
1635 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1636 _In_ UCHAR SubAuthorityCount
);
1643 _In_ ULONG SubAuthority
);
1645 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1652 _IRQL_requires_max_(APC_LEVEL
)
1658 _Out_writes_bytes_(Length
) PSID Destination
,
1661 _IRQL_requires_max_(APC_LEVEL
)
1665 RtlConvertSidToUnicodeString(
1666 _Inout_ PUNICODE_STRING UnicodeString
,
1668 _In_ BOOLEAN AllocateDestinationString
);
1670 _IRQL_requires_max_(APC_LEVEL
)
1675 _Out_ PLUID DestinationLuid
,
1676 _In_ PLUID SourceLuid
);
1678 _IRQL_requires_max_(APC_LEVEL
)
1683 _Out_writes_bytes_(AclLength
) PACL Acl
,
1684 _In_ ULONG AclLength
,
1685 _In_ ULONG AclRevision
);
1687 _IRQL_requires_max_(APC_LEVEL
)
1693 _In_ ULONG AceRevision
,
1694 _In_ ULONG StartingAceIndex
,
1695 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1696 _In_ ULONG AceListLength
);
1698 _IRQL_requires_max_(APC_LEVEL
)
1704 _In_ ULONG AceIndex
);
1711 _In_ ULONG AceIndex
,
1712 _Outptr_ PVOID
*Ace
);
1714 _IRQL_requires_max_(APC_LEVEL
)
1718 RtlAddAccessAllowedAce(
1720 _In_ ULONG AceRevision
,
1721 _In_ ACCESS_MASK AccessMask
,
1724 _IRQL_requires_max_(APC_LEVEL
)
1728 RtlAddAccessAllowedAceEx(
1730 _In_ ULONG AceRevision
,
1731 _In_ ULONG AceFlags
,
1732 _In_ ACCESS_MASK AccessMask
,
1735 _IRQL_requires_max_(APC_LEVEL
)
1739 RtlCreateSecurityDescriptorRelative(
1740 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1741 _In_ ULONG Revision
);
1746 RtlGetDaclSecurityDescriptor(
1747 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1748 _Out_ PBOOLEAN DaclPresent
,
1750 _Out_ PBOOLEAN DaclDefaulted
);
1752 _IRQL_requires_max_(APC_LEVEL
)
1756 RtlSetOwnerSecurityDescriptor(
1757 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1758 _In_opt_ PSID Owner
,
1759 _In_opt_ BOOLEAN OwnerDefaulted
);
1761 _IRQL_requires_max_(APC_LEVEL
)
1765 RtlGetOwnerSecurityDescriptor(
1766 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1768 _Out_ PBOOLEAN OwnerDefaulted
);
1770 _IRQL_requires_max_(APC_LEVEL
)
1771 _When_(Status
< 0, _Out_range_(>, 0))
1772 _When_(Status
>= 0, _Out_range_(==, 0))
1776 RtlNtStatusToDosError(
1777 _In_ NTSTATUS Status
);
1779 _IRQL_requires_max_(PASSIVE_LEVEL
)
1783 RtlCustomCPToUnicodeN(
1784 _In_ PCPTABLEINFO CustomCP
,
1785 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1786 _In_ ULONG MaxBytesInUnicodeString
,
1787 _Out_opt_ PULONG BytesInUnicodeString
,
1788 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1789 _In_ ULONG BytesInCustomCPString
);
1791 _IRQL_requires_max_(PASSIVE_LEVEL
)
1795 RtlUnicodeToCustomCPN(
1796 _In_ PCPTABLEINFO CustomCP
,
1797 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1798 _In_ ULONG MaxBytesInCustomCPString
,
1799 _Out_opt_ PULONG BytesInCustomCPString
,
1800 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1801 _In_ ULONG BytesInUnicodeString
);
1803 _IRQL_requires_max_(PASSIVE_LEVEL
)
1807 RtlUpcaseUnicodeToCustomCPN(
1808 _In_ PCPTABLEINFO CustomCP
,
1809 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1810 _In_ ULONG MaxBytesInCustomCPString
,
1811 _Out_opt_ PULONG BytesInCustomCPString
,
1812 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1813 _In_ ULONG BytesInUnicodeString
);
1815 _IRQL_requires_max_(PASSIVE_LEVEL
)
1819 RtlInitCodePageTable(
1820 _In_ PUSHORT TableBase
,
1821 _Inout_ PCPTABLEINFO CodePageTable
);
1825 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1829 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1833 RtlPrefetchMemoryNonTemporal(
1835 _In_ SIZE_T Length
);
1840 #if (NTDDI_VERSION >= NTDDI_WINXP)
1848 _In_ PRTL_BITMAP BitMapHeader
,
1849 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1851 _IRQL_requires_max_(PASSIVE_LEVEL
)
1855 RtlDowncaseUnicodeChar(
1856 _In_ WCHAR SourceCharacter
);
1862 _In_ PRTL_BITMAP BitMapHeader
,
1863 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1865 _Must_inspect_result_
1870 _In_ PRTL_BITMAP BitMapHeader
,
1871 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1873 _IRQL_requires_max_(PASSIVE_LEVEL
)
1877 RtlHashUnicodeString(
1878 _In_ CONST UNICODE_STRING
*String
,
1879 _In_ BOOLEAN CaseInSensitive
,
1880 _In_ ULONG HashAlgorithm
,
1881 _Out_ PULONG HashValue
);
1890 RtlInitializeGenericTableAvl(
1891 _Out_ PRTL_AVL_TABLE Table
,
1892 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
1893 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
1894 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
1895 _In_opt_ PVOID TableContext
);
1900 RtlInsertElementGenericTableAvl(
1901 _In_ PRTL_AVL_TABLE Table
,
1902 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1903 _In_ CLONG BufferSize
,
1904 _Out_opt_ PBOOLEAN NewElement
);
1909 RtlInsertElementGenericTableFullAvl(
1910 _In_ PRTL_AVL_TABLE Table
,
1911 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1912 _In_ CLONG BufferSize
,
1913 _Out_opt_ PBOOLEAN NewElement
,
1914 _In_ PVOID NodeOrParent
,
1915 _In_ TABLE_SEARCH_RESULT SearchResult
);
1920 RtlDeleteElementGenericTableAvl(
1921 _In_ PRTL_AVL_TABLE Table
,
1924 _Must_inspect_result_
1928 RtlLookupElementGenericTableAvl(
1929 _In_ PRTL_AVL_TABLE Table
,
1935 RtlLookupElementGenericTableFullAvl(
1936 _In_ PRTL_AVL_TABLE Table
,
1938 _Out_ PVOID
*NodeOrParent
,
1939 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1941 _Must_inspect_result_
1945 RtlEnumerateGenericTableAvl(
1946 _In_ PRTL_AVL_TABLE Table
,
1947 _In_ BOOLEAN Restart
);
1949 _Must_inspect_result_
1953 RtlEnumerateGenericTableWithoutSplayingAvl(
1954 _In_ PRTL_AVL_TABLE Table
,
1955 _Inout_ PVOID
*RestartKey
);
1957 _Must_inspect_result_
1961 RtlLookupFirstMatchingElementGenericTableAvl(
1962 _In_ PRTL_AVL_TABLE Table
,
1964 _Out_ PVOID
*RestartKey
);
1966 _Must_inspect_result_
1970 RtlEnumerateGenericTableLikeADirectory(
1971 _In_ PRTL_AVL_TABLE Table
,
1972 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
1973 _In_opt_ PVOID MatchData
,
1974 _In_ ULONG NextFlag
,
1975 _Inout_ PVOID
*RestartKey
,
1976 _Inout_ PULONG DeleteCount
,
1979 _Must_inspect_result_
1983 RtlGetElementGenericTableAvl(
1984 _In_ PRTL_AVL_TABLE Table
,
1990 RtlNumberGenericTableElementsAvl(
1991 _In_ PRTL_AVL_TABLE Table
);
1993 _Must_inspect_result_
1997 RtlIsGenericTableEmptyAvl(
1998 _In_ PRTL_AVL_TABLE Table
);
2003 _Must_inspect_result_
2009 _In_opt_ PVOID HeapBase
,
2010 _In_opt_ SIZE_T ReserveSize
,
2011 _In_opt_ SIZE_T CommitSize
,
2012 _In_opt_ PVOID Lock
,
2013 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2019 _In_ _Post_invalid_ PVOID HeapHandle
);
2024 RtlCaptureStackBackTrace(
2025 _In_ ULONG FramesToSkip
,
2026 _In_ ULONG FramesToCapture
,
2027 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2028 _Out_opt_ PULONG BackTraceHash
);
2030 _Ret_range_(<, MAXLONG
)
2035 _Inout_ PULONG Seed
);
2037 _IRQL_requires_max_(DISPATCH_LEVEL
)
2041 RtlInitUnicodeStringEx(
2042 _Out_ PUNICODE_STRING DestinationString
,
2043 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2045 _Must_inspect_result_
2049 RtlValidateUnicodeString(
2051 _In_ PCUNICODE_STRING String
);
2053 _IRQL_requires_max_(PASSIVE_LEVEL
)
2054 _Must_inspect_result_
2058 RtlDuplicateUnicodeString(
2060 _In_ PCUNICODE_STRING SourceString
,
2061 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2066 RtlGetCompressionWorkSpaceSize(
2067 _In_ USHORT CompressionFormatAndEngine
,
2068 _Out_ PULONG CompressBufferWorkSpaceSize
,
2069 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2075 _In_ USHORT CompressionFormatAndEngine
,
2076 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2077 _In_ ULONG UncompressedBufferSize
,
2078 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2079 _In_ ULONG CompressedBufferSize
,
2080 _In_ ULONG UncompressedChunkSize
,
2081 _Out_ PULONG FinalCompressedSize
,
2082 _In_ PVOID WorkSpace
);
2084 _IRQL_requires_max_(APC_LEVEL
)
2088 RtlDecompressBuffer(
2089 _In_ USHORT CompressionFormat
,
2090 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2091 _In_ ULONG UncompressedBufferSize
,
2092 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2093 _In_ ULONG CompressedBufferSize
,
2094 _Out_ PULONG FinalUncompressedSize
);
2096 _IRQL_requires_max_(APC_LEVEL
)
2100 RtlDecompressFragment(
2101 _In_ USHORT CompressionFormat
,
2102 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2103 _In_ ULONG UncompressedFragmentSize
,
2104 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2105 _In_ ULONG CompressedBufferSize
,
2106 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2107 _Out_ PULONG FinalUncompressedSize
,
2108 _In_ PVOID WorkSpace
);
2110 _IRQL_requires_max_(APC_LEVEL
)
2115 _In_ USHORT CompressionFormat
,
2116 _Inout_ PUCHAR
*CompressedBuffer
,
2117 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2118 _Out_ PUCHAR
*ChunkBuffer
,
2119 _Out_ PULONG ChunkSize
);
2121 _IRQL_requires_max_(APC_LEVEL
)
2126 _In_ USHORT CompressionFormat
,
2127 _Inout_ PUCHAR
*CompressedBuffer
,
2128 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2129 _Out_ PUCHAR
*ChunkBuffer
,
2130 _In_ ULONG ChunkSize
);
2132 _IRQL_requires_max_(APC_LEVEL
)
2136 RtlDecompressChunks(
2137 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2138 _In_ ULONG UncompressedBufferSize
,
2139 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2140 _In_ ULONG CompressedBufferSize
,
2141 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2142 _In_ ULONG CompressedTailSize
,
2143 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2145 _IRQL_requires_max_(APC_LEVEL
)
2150 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2151 _In_ ULONG UncompressedBufferSize
,
2152 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2153 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2154 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2155 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2156 _In_ PVOID WorkSpace
);
2158 _IRQL_requires_max_(APC_LEVEL
)
2160 PSID_IDENTIFIER_AUTHORITY
2162 RtlIdentifierAuthoritySid(
2168 RtlSubAuthorityCountSid(
2171 _When_(Status
< 0, _Out_range_(>, 0))
2172 _When_(Status
>= 0, _Out_range_(==, 0))
2176 RtlNtStatusToDosErrorNoTeb(
2177 _In_ NTSTATUS Status
);
2179 _IRQL_requires_max_(PASSIVE_LEVEL
)
2183 RtlCreateSystemVolumeInformationFolder(
2184 _In_ PCUNICODE_STRING VolumeRootPath
);
2186 #if defined(_M_AMD64)
2191 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2195 PULONG Address
= (PULONG
)Destination
;
2196 if ((Length
/= 4) != 0) {
2197 if (((ULONG64
)Address
& 4) != 0) {
2199 if ((Length
-= 1) == 0) {
2204 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2205 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2210 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2211 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2219 OUT PVOID Destination
,
2226 RtlFillMemoryUlonglong(
2227 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2229 _In_ ULONGLONG Pattern
);
2231 #endif /* defined(_M_AMD64) */
2234 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2237 #if (NTDDI_VERSION >= NTDDI_WS03)
2238 _IRQL_requires_max_(DISPATCH_LEVEL
)
2242 RtlInitAnsiStringEx(
2243 _Out_ PANSI_STRING DestinationString
,
2244 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2247 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2249 _IRQL_requires_max_(APC_LEVEL
)
2253 RtlGetSaclSecurityDescriptor(
2254 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2255 _Out_ PBOOLEAN SaclPresent
,
2257 _Out_ PBOOLEAN SaclDefaulted
);
2259 _IRQL_requires_max_(APC_LEVEL
)
2263 RtlSetGroupSecurityDescriptor(
2264 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2265 _In_opt_ PSID Group
,
2266 _In_opt_ BOOLEAN GroupDefaulted
);
2268 _IRQL_requires_max_(APC_LEVEL
)
2272 RtlGetGroupSecurityDescriptor(
2273 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2275 _Out_ PBOOLEAN GroupDefaulted
);
2277 _IRQL_requires_max_(APC_LEVEL
)
2281 RtlAbsoluteToSelfRelativeSD(
2282 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2283 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2284 _Inout_ PULONG BufferLength
);
2286 _IRQL_requires_max_(APC_LEVEL
)
2290 RtlSelfRelativeToAbsoluteSD(
2291 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2292 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2293 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2294 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2295 _Inout_ PULONG DaclSize
,
2296 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2297 _Inout_ PULONG SaclSize
,
2298 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2299 _Inout_ PULONG OwnerSize
,
2300 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2301 _Inout_ PULONG PrimaryGroupSize
);
2303 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2306 #if (NTDDI_VERSION >= NTDDI_VISTA)
2312 RtlNumberOfSetBitsUlongPtr(
2313 _In_ ULONG_PTR Target
);
2318 RtlIoDecodeMemIoResource(
2319 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2320 _Out_opt_ PULONGLONG Alignment
,
2321 _Out_opt_ PULONGLONG MinimumAddress
,
2322 _Out_opt_ PULONGLONG MaximumAddress
);
2327 RtlIoEncodeMemIoResource(
2328 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2330 _In_ ULONGLONG Length
,
2331 _In_ ULONGLONG Alignment
,
2332 _In_ ULONGLONG MinimumAddress
,
2333 _In_ ULONGLONG MaximumAddress
);
2338 RtlCmDecodeMemIoResource(
2339 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2340 _Out_opt_ PULONGLONG Start
);
2345 RtlFindClosestEncodableLength(
2346 _In_ ULONGLONG SourceLength
,
2347 _Out_ PULONGLONG TargetLength
);
2352 RtlCmEncodeMemIoResource(
2353 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2355 _In_ ULONGLONG Length
,
2356 _In_ ULONGLONG Start
);
2361 _IRQL_requires_max_(APC_LEVEL
)
2365 RtlRunOnceInitialize(
2366 _Out_ PRTL_RUN_ONCE RunOnce
);
2368 _IRQL_requires_max_(APC_LEVEL
)
2369 _Maybe_raises_SEH_exception_
2373 RtlRunOnceExecuteOnce(
2374 _Inout_ PRTL_RUN_ONCE RunOnce
,
2375 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2376 _Inout_opt_ PVOID Parameter
,
2377 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2379 _IRQL_requires_max_(APC_LEVEL
)
2380 _Must_inspect_result_
2384 RtlRunOnceBeginInitialize(
2385 _Inout_ PRTL_RUN_ONCE RunOnce
,
2387 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2389 _IRQL_requires_max_(APC_LEVEL
)
2394 _Inout_ PRTL_RUN_ONCE RunOnce
,
2396 _In_opt_ PVOID Context
);
2402 _In_ ULONG OSMajorVersion
,
2403 _In_ ULONG OSMinorVersion
,
2404 _In_ ULONG SpMajorVersion
,
2405 _In_ ULONG SpMinorVersion
,
2406 _Out_ PULONG ReturnedProductType
);
2414 _In_ ULONG NormForm
,
2415 _In_ PCWSTR SourceString
,
2416 _In_ LONG SourceStringLength
,
2417 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2418 _Inout_ PLONG DestinationStringLength
);
2423 RtlIsNormalizedString(
2424 _In_ ULONG NormForm
,
2425 _In_ PCWSTR SourceString
,
2426 _In_ LONG SourceStringLength
,
2427 _Out_ PBOOLEAN Normalized
);
2434 _In_ PCWSTR SourceString
,
2435 _In_ LONG SourceStringLength
,
2436 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2437 _Inout_ PLONG DestinationStringLength
);
2444 IN PCWSTR SourceString
,
2445 IN LONG SourceStringLength
,
2446 OUT PWSTR DestinationString
,
2447 IN OUT PLONG DestinationStringLength
);
2452 RtlIdnToNameprepUnicode(
2454 _In_ PCWSTR SourceString
,
2455 _In_ LONG SourceStringLength
,
2456 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2457 _Inout_ PLONG DestinationStringLength
);
2462 RtlCreateServiceSid(
2463 _In_ PUNICODE_STRING ServiceName
,
2464 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2465 _Inout_ PULONG ServiceSidLength
);
2470 RtlCompareAltitudes(
2471 _In_ PCUNICODE_STRING Altitude1
,
2472 _In_ PCUNICODE_STRING Altitude2
);
2476 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2478 #if (NTDDI_VERSION >= NTDDI_WIN7)
2481 _IRQL_requires_max_(PASSIVE_LEVEL
)
2482 _Must_inspect_result_
2487 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2488 PCHAR UTF8StringDestination
,
2489 _In_ ULONG UTF8StringMaxByteCount
,
2490 _Out_ PULONG UTF8StringActualByteCount
,
2491 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2492 _In_ ULONG UnicodeStringByteCount
);
2494 _IRQL_requires_max_(PASSIVE_LEVEL
)
2495 _Must_inspect_result_
2500 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2501 PWSTR UnicodeStringDestination
,
2502 _In_ ULONG UnicodeStringMaxByteCount
,
2503 _Out_ PULONG UnicodeStringActualByteCount
,
2504 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2505 _In_ ULONG UTF8StringByteCount
);
2510 RtlGetEnabledExtendedFeatures(
2511 IN ULONG64 FeatureMask
);
2516 _Must_inspect_result_
2521 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2522 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2524 _In_ _Reserved_ ULONG Flags
);
2530 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2531 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2536 RtlInsertEntryHashTable(
2537 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2538 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2539 _In_ ULONG_PTR Signature
,
2540 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2545 RtlRemoveEntryHashTable(
2546 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2547 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2548 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2550 _Must_inspect_result_
2552 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2554 RtlLookupEntryHashTable(
2555 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2556 _In_ ULONG_PTR Signature
,
2557 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2559 _Must_inspect_result_
2561 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2563 RtlGetNextEntryHashTable(
2564 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2565 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2570 RtlInitEnumerationHashTable(
2571 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2572 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2574 _Must_inspect_result_
2576 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2578 RtlEnumerateEntryHashTable(
2579 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2580 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2585 RtlEndEnumerationHashTable(
2586 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2587 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2592 RtlInitWeakEnumerationHashTable(
2593 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2594 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2596 _Must_inspect_result_
2598 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2600 RtlWeaklyEnumerateEntryHashTable(
2601 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2602 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2607 RtlEndWeakEnumerationHashTable(
2608 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2609 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2615 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2620 RtlContractHashTable(
2621 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2625 _IRQL_requires_max_(PASSIVE_LEVEL
)
2626 _Must_inspect_result_
2631 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2632 _In_ ULONG UTF8StringMaxByteCount
,
2633 _Out_ PULONG UTF8StringActualByteCount
,
2634 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2635 _In_ ULONG UnicodeStringByteCount
);
2637 _IRQL_requires_max_(PASSIVE_LEVEL
)
2638 _Must_inspect_result_
2643 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2644 _In_ ULONG UnicodeStringMaxByteCount
,
2645 _Out_ PULONG UnicodeStringActualByteCount
,
2646 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2647 _In_ ULONG UTF8StringByteCount
);
2649 _IRQL_requires_max_(APC_LEVEL
)
2654 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2657 _Out_ ULONG
*NumChanges
);
2662 RtlCreateVirtualAccountSid(
2663 _In_ PCUNICODE_STRING Name
,
2664 _In_ ULONG BaseSubAuthority
,
2665 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2666 _Inout_ PULONG SidLength
);
2669 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2673 #if !defined(MIDL_PASS)
2674 /* inline funftions */
2675 //DECLSPEC_DEPRECATED_DDK_WINXP
2679 RtlConvertLongToLargeInteger(
2680 _In_ LONG SignedInteger
)
2683 ret
.QuadPart
= SignedInteger
;
2687 //DECLSPEC_DEPRECATED_DDK_WINXP
2691 RtlConvertUlongToLargeInteger(
2692 _In_ ULONG UnsignedInteger
)
2695 ret
.QuadPart
= UnsignedInteger
;
2699 //DECLSPEC_DEPRECATED_DDK_WINXP
2703 RtlLargeIntegerShiftLeft(
2704 _In_ LARGE_INTEGER LargeInteger
,
2705 _In_ CCHAR ShiftCount
)
2707 LARGE_INTEGER Result
;
2709 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2713 //DECLSPEC_DEPRECATED_DDK_WINXP
2717 RtlLargeIntegerShiftRight(
2718 _In_ LARGE_INTEGER LargeInteger
,
2719 _In_ CCHAR ShiftCount
)
2721 LARGE_INTEGER Result
;
2723 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2727 //DECLSPEC_DEPRECATED_DDK
2731 RtlEnlargedUnsignedDivide(
2732 _In_ ULARGE_INTEGER Dividend
,
2734 _Out_opt_ PULONG Remainder
)
2737 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2738 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2741 //DECLSPEC_DEPRECATED_DDK
2745 RtlLargeIntegerNegate(
2746 _In_ LARGE_INTEGER Subtrahend
)
2748 LARGE_INTEGER Difference
;
2750 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2754 //DECLSPEC_DEPRECATED_DDK
2758 RtlLargeIntegerSubtract(
2759 _In_ LARGE_INTEGER Minuend
,
2760 _In_ LARGE_INTEGER Subtrahend
)
2762 LARGE_INTEGER Difference
;
2764 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2768 //DECLSPEC_DEPRECATED_DDK
2772 RtlEnlargedUnsignedMultiply(
2773 _In_ ULONG Multiplicand
,
2774 _In_ ULONG Multiplier
)
2777 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2781 //DECLSPEC_DEPRECATED_DDK
2785 RtlEnlargedIntegerMultiply(
2786 _In_ LONG Multiplicand
,
2787 _In_ LONG Multiplier
)
2790 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2794 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2795 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2796 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2799 RtlInitEmptyAnsiString(
2800 _Out_ PANSI_STRING AnsiString
,
2801 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2802 _In_ USHORT BufferSize
)
2804 AnsiString
->Length
= 0;
2805 AnsiString
->MaximumLength
= BufferSize
;
2806 AnsiString
->Buffer
= Buffer
;
2809 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2810 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2811 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2814 RtlInitEmptyUnicodeString(
2815 _Out_ PUNICODE_STRING UnicodeString
,
2816 _Writable_bytes_(BufferSize
)
2817 _When_(BufferSize
!= 0, _Notnull_
)
2818 __drv_aliasesMem PWSTR Buffer
,
2819 _In_ USHORT BufferSize
)
2821 UnicodeString
->Length
= 0;
2822 UnicodeString
->MaximumLength
= BufferSize
;
2823 UnicodeString
->Buffer
= Buffer
;
2827 #if defined(_AMD64_) || defined(_IA64_)
2834 RtlExtendedIntegerMultiply(
2835 _In_ LARGE_INTEGER Multiplicand
,
2836 _In_ LONG Multiplier
)
2839 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2846 RtlExtendedLargeIntegerDivide(
2847 _In_ LARGE_INTEGER Dividend
,
2849 _Out_opt_ PULONG Remainder
)
2852 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
2854 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2862 //DECLSPEC_DEPRECATED_DDK_WINXP
2866 RtlLargeIntegerDivide(
2867 _In_ LARGE_INTEGER Dividend
,
2868 _In_ LARGE_INTEGER Divisor
,
2869 _Out_opt_ PLARGE_INTEGER Remainder
)
2872 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
2874 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
2880 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2884 RtlLargeIntegerDivide(
2885 _In_ LARGE_INTEGER Dividend
,
2886 _In_ LARGE_INTEGER Divisor
,
2887 _Out_opt_ PLARGE_INTEGER Remainder
);
2892 #endif /* defined(_AMD64_) || defined(_IA64_) */
2896 #if defined(_AMD64_)
2898 #define MultiplyHigh __mulh
2899 #define UnsignedMultiplyHigh __umulh
2901 //DECLSPEC_DEPRECATED_DDK
2905 RtlExtendedMagicDivide(
2906 _In_ LARGE_INTEGER Dividend
,
2907 _In_ LARGE_INTEGER MagicDivisor
,
2908 _In_ CCHAR ShiftCount
)
2913 Pos
= (Dividend
.QuadPart
>= 0);
2914 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
2915 MagicDivisor
.QuadPart
);
2916 ret64
>>= ShiftCount
;
2917 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
2922 //DECLSPEC_DEPRECATED_DDK
2927 _In_ LARGE_INTEGER Addend1
,
2928 _In_ LARGE_INTEGER Addend2
)
2931 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
2936 * RtlLargeIntegerAnd(
2937 * IN OUT LARGE_INTEGER Result,
2938 * IN LARGE_INTEGER Source,
2939 * IN LARGE_INTEGER Mask);
2941 #define RtlLargeIntegerAnd(Result, Source, Mask) \
2942 Result.QuadPart = Source.QuadPart & Mask.QuadPart
2944 //DECLSPEC_DEPRECATED_DDK
2948 RtlLargeIntegerArithmeticShift(
2949 _In_ LARGE_INTEGER LargeInteger
,
2950 _In_ CCHAR ShiftCount
)
2953 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
2958 * RtlLargeIntegerEqualTo(
2959 * IN LARGE_INTEGER Operand1,
2960 * IN LARGE_INTEGER Operand2);
2962 #define RtlLargeIntegerEqualTo(X,Y) \
2963 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
2967 RtlSecureZeroMemory(
2968 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
2971 volatile char* vptr
= (volatile char*)Pointer
;
2972 #if defined(_M_AMD64)
2973 __stosb((PUCHAR
)vptr
, 0, Size
);
2975 char * endptr
= (char *)vptr
+ Size
;
2976 while (vptr
< endptr
) {
2983 #if defined(_M_AMD64)
2984 _Must_inspect_result_
2988 _In_ PRTL_BITMAP BitMapHeader
,
2989 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
2991 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
2994 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
2995 #endif /* defined(_M_AMD64) */
2997 #define RtlLargeIntegerGreaterThan(X,Y) ( \
2998 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
2999 ((X).HighPart > (Y).HighPart) \
3002 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3003 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3004 ((X).HighPart > (Y).HighPart) \
3007 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3008 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3011 #define RtlLargeIntegerLessThan(X,Y) ( \
3012 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3013 ((X).HighPart < (Y).HighPart) \
3016 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3017 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3018 ((X).HighPart < (Y).HighPart) \
3021 #define RtlLargeIntegerGreaterThanZero(X) ( \
3022 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3023 ((X).HighPart > 0 ) \
3026 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3028 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3030 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3032 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3034 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3036 #endif /* !defined(MIDL_PASS) */
3038 /* Byte Swap Functions */
3039 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
3040 ((defined(_M_AMD64) || defined(_M_IA64)) \
3041 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
3043 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3044 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3045 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3051 #define ASSERT(exp) \
3053 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3055 #define ASSERTMSG(msg, exp) \
3057 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3059 #define RTL_SOFT_ASSERT(exp) \
3061 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3063 #define RTL_SOFT_ASSERTMSG(msg, exp) \
3065 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3067 #define RTL_VERIFY(exp) ASSERT(exp)
3068 #define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
3070 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
3071 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
3073 #if defined(_MSC_VER)
3075 #define NT_ASSERT(exp) \
3077 (__annotation(L"Debug", L"AssertFail", L#exp), \
3078 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3080 #define NT_ASSERTMSG(msg, exp) \
3082 (__annotation(L"Debug", L"AssertFail", L##msg), \
3083 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3085 #define NT_ASSERTMSGW(msg, exp) \
3087 (__annotation(L"Debug", L"AssertFail", msg), \
3088 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3090 #define NT_VERIFY NT_ASSERT
3091 #define NT_VERIFYMSG NT_ASSERTMSG
3092 #define NT_VERIFYMSGW NT_ASSERTMSGW
3096 /* GCC doesn't support __annotation (nor PDB) */
3097 #define NT_ASSERT(exp) \
3098 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
3100 #define NT_ASSERTMSG NT_ASSERT
3101 #define NT_ASSERTMSGW NT_ASSERT
3107 #define ASSERT(exp) ((VOID) 0)
3108 #define ASSERTMSG(msg, exp) ((VOID) 0)
3110 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3111 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3113 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3114 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3116 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3117 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3119 #define NT_ASSERT(exp) ((VOID)0)
3120 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
3121 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
3123 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
3124 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
3125 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
3129 #define InitializeListHead32(ListHead) (\
3130 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3132 #if !defined(_WINBASE_)
3134 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
3138 InitializeSListHead(
3139 _Out_ PSLIST_HEADER SListHead
);
3145 InitializeSListHead(
3146 _Out_ PSLIST_HEADER SListHead
)
3149 ULONG64 FeatureBits
;
3153 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3154 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3157 RtlZeroMemory(SListHead
, sizeof(SLIST_HEADER
));
3159 FeatureBits
= __getReg(CV_IA64_CPUID4
);
3160 if ((FeatureBits
& KF_16BYTE_INSTR
) != 0) {
3161 SListHead
->Header16
.HeaderType
= 1;
3162 SListHead
->Header16
.Init
= 1;
3171 #define InterlockedPopEntrySList(Head) \
3172 ExpInterlockedPopEntrySList(Head)
3174 #define InterlockedPushEntrySList(Head, Entry) \
3175 ExpInterlockedPushEntrySList(Head, Entry)
3177 #define InterlockedFlushSList(Head) \
3178 ExpInterlockedFlushSList(Head)
3180 #define QueryDepthSList(Head) \
3181 ExQueryDepthSList(Head)
3183 #else /* !defined(_WIN64) */
3188 InterlockedPopEntrySList(
3189 _Inout_ PSLIST_HEADER ListHead
);
3194 InterlockedPushEntrySList(
3195 _Inout_ PSLIST_HEADER ListHead
,
3196 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry
);
3198 #define InterlockedFlushSList(ListHead) \
3199 ExInterlockedFlushSList(ListHead)
3201 #define QueryDepthSList(Head) \
3202 ExQueryDepthSList(Head)
3204 #endif /* !defined(_WIN64) */
3206 #endif /* !defined(_WINBASE_) */
3208 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3209 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3210 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3211 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3212 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3213 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3214 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3215 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3216 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3217 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3218 (PCONTEXT_EX)(Context + 1), \
3222 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3223 _In_ ULONG Version
);
3226 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3227 _In_ ULONG Version
);
3229 #ifndef RtlIsNtDdiVersionAvailable
3230 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3233 #ifndef RtlIsServicePackVersionInstalled
3234 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3237 #define RtlInterlockedSetBits(Flags, Flag) \
3238 InterlockedOr((PLONG)(Flags), Flag)
3240 #define RtlInterlockedAndBits(Flags, Flag) \
3241 InterlockedAnd((PLONG)(Flags), Flag)
3243 #define RtlInterlockedClearBits(Flags, Flag) \
3244 RtlInterlockedAndBits(Flags, ~(Flag))
3246 #define RtlInterlockedXorBits(Flags, Flag) \
3247 InterlockedXor(Flags, Flag)
3249 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3250 (VOID) RtlInterlockedSetBits(Flags, Flag)
3252 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3253 (VOID) RtlInterlockedAndBits(Flags, Flag)
3255 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3256 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3262 #ifdef RTL_USE_AVL_TABLES
3264 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3265 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3266 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3267 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3268 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3269 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3270 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3271 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3272 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3273 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3274 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3276 #endif /* RTL_USE_AVL_TABLES */
3278 #define RtlInitializeSplayLinks(Links) { \
3279 PRTL_SPLAY_LINKS _SplayLinks; \
3280 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3281 _SplayLinks->Parent = _SplayLinks; \
3282 _SplayLinks->LeftChild = NULL; \
3283 _SplayLinks->RightChild = NULL; \
3286 #define RtlIsLeftChild(Links) \
3287 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3289 #define RtlIsRightChild(Links) \
3290 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3292 #define RtlRightChild(Links) \
3293 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3295 #define RtlIsRoot(Links) \
3296 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3298 #define RtlLeftChild(Links) \
3299 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3301 #define RtlParent(Links) \
3302 ((PRTL_SPLAY_LINKS)(Links))->Parent
3304 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3306 PRTL_SPLAY_LINKS _SplayParent; \
3307 PRTL_SPLAY_LINKS _SplayChild; \
3308 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3309 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3310 _SplayParent->LeftChild = _SplayChild; \
3311 _SplayChild->Parent = _SplayParent; \
3314 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3316 PRTL_SPLAY_LINKS _SplayParent; \
3317 PRTL_SPLAY_LINKS _SplayChild; \
3318 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3319 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3320 _SplayParent->RightChild = _SplayChild; \
3321 _SplayChild->Parent = _SplayParent; \
3324 #if !defined(MIDL_PASS)
3329 RtlConvertLongToLuid(
3335 Temp
.QuadPart
= Val
;
3336 Luid
.LowPart
= Temp
.u
.LowPart
;
3337 Luid
.HighPart
= Temp
.u
.HighPart
;
3344 RtlConvertUlongToLuid(
3354 #endif /* !defined(MIDL_PASS) */
3356 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3357 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3358 *CallersAddress = (PVOID)_ReturnAddress(); \
3359 *CallersCaller = NULL;
3361 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3365 RtlGetCallersAddress(
3366 _Out_ PVOID
*CallersAddress
,
3367 _Out_ PVOID
*CallersCaller
);
3371 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3373 #if (NTDDI_VERSION >= NTDDI_WIN7)
3378 RtlInitHashTableContext(
3379 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3381 Context
->ChainHead
= NULL
;
3382 Context
->PrevLinkage
= NULL
;
3388 RtlInitHashTableContextFromEnumerator(
3389 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3390 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3392 Context
->ChainHead
= Enumerator
->ChainHead
;
3393 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3399 RtlReleaseHashTableContext(
3400 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3402 UNREFERENCED_PARAMETER(Context
);
3409 RtlTotalBucketsHashTable(
3410 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3412 return HashTable
->TableSize
;
3418 RtlNonEmptyBucketsHashTable(
3419 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3421 return HashTable
->NonEmptyBuckets
;
3427 RtlEmptyBucketsHashTable(
3428 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3430 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3436 RtlTotalEntriesHashTable(
3437 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3439 return HashTable
->NumEntries
;
3445 RtlActiveEnumeratorsHashTable(
3446 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3448 return HashTable
->NumEnumerators
;
3451 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3453 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3458 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3459 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3461 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3462 RtlxUnicodeStringToOemSize(STRING) : \
3463 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3466 #define RtlOemStringToUnicodeSize(STRING) ( \
3467 NLS_MB_OEM_CODE_PAGE_TAG ? \
3468 RtlxOemStringToUnicodeSize(STRING) : \
3469 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3472 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3473 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3476 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3477 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))