1 /******************************************************************************
2 * Runtime Library Functions *
3 ******************************************************************************/
6 #define FAST_FAIL_LEGACY_GS_VIOLATION 0
7 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1
8 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
9 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3
10 #define FAST_FAIL_INCORRECT_STACK 4
11 #define FAST_FAIL_INVALID_ARG 5
12 #define FAST_FAIL_GS_COOKIE_INIT 6
13 #define FAST_FAIL_FATAL_APP_EXIT 7
14 #define FAST_FAIL_RANGE_CHECK_FAILURE 8
15 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9
16 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10
17 #define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11
18 #define FAST_FAIL_INVALID_FIBER_SWITCH 12
19 #define FAST_FAIL_INVALID_SET_OF_CONTEXT 13
20 #define FAST_FAIL_INVALID_REFERENCE_COUNT 14
21 #define FAST_FAIL_INVALID_JUMP_BUFFER 18
22 #define FAST_FAIL_MRDATA_MODIFIED 19
23 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF
34 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && (defined(_M_CEE_PURE) || defined(_M_CEE_SAFE))
35 #define NO_KERNEL_LIST_ENTRY_CHECKS
38 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
40 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
45 _Out_ PLIST_ENTRY ListHead
)
47 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
54 _In_
const LIST_ENTRY
* ListHead
)
56 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
61 RemoveEntryListUnsafe(
62 _In_ PLIST_ENTRY Entry
)
67 OldFlink
= Entry
->Flink
;
68 OldBlink
= Entry
->Blink
;
69 OldFlink
->Blink
= OldBlink
;
70 OldBlink
->Flink
= OldFlink
;
71 return (BOOLEAN
)(OldFlink
== OldBlink
);
74 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
82 UNREFERENCED_PARAMETER(P1
);
83 UNREFERENCED_PARAMETER(P2
);
84 UNREFERENCED_PARAMETER(P3
);
86 RtlFailFast(FAST_FAIL_CORRUPT_LIST_ENTRY
);
92 _In_ PLIST_ENTRY Entry
)
94 if (Entry
->Flink
->Blink
!= Entry
|| Entry
->Blink
->Flink
!= Entry
)
95 FatalListEntryError(Entry
->Blink
, Entry
, Entry
->Flink
);
102 _In_ PLIST_ENTRY Entry
)
104 PLIST_ENTRY OldFlink
;
105 PLIST_ENTRY OldBlink
;
107 OldFlink
= Entry
->Flink
;
108 OldBlink
= Entry
->Blink
;
109 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
110 if (OldFlink
->Blink
!= Entry
|| OldBlink
->Flink
!= Entry
)
111 FatalListEntryError(OldBlink
, Entry
, OldFlink
);
113 OldFlink
->Blink
= OldBlink
;
114 OldBlink
->Flink
= OldFlink
;
115 return (BOOLEAN
)(OldFlink
== OldBlink
);
121 _Inout_ PLIST_ENTRY ListHead
)
126 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
127 RtlpCheckListEntry(ListHead
);
129 Entry
= ListHead
->Flink
;
130 Flink
= Entry
->Flink
;
131 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
132 if (Entry
->Blink
!= ListHead
|| Flink
->Blink
!= Entry
)
133 FatalListEntryError(ListHead
, Entry
, Flink
);
135 ListHead
->Flink
= Flink
;
136 Flink
->Blink
= ListHead
;
143 _Inout_ PLIST_ENTRY ListHead
)
148 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
149 RtlpCheckListEntry(ListHead
);
151 Entry
= ListHead
->Blink
;
152 Blink
= Entry
->Blink
;
153 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
154 if (Blink
->Flink
!= Entry
|| Entry
->Flink
!= ListHead
)
155 FatalListEntryError(Blink
, Entry
, ListHead
);
157 ListHead
->Blink
= Blink
;
158 Blink
->Flink
= ListHead
;
165 _Inout_ PLIST_ENTRY ListHead
,
166 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
168 PLIST_ENTRY OldBlink
;
169 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
170 RtlpCheckListEntry(ListHead
);
172 OldBlink
= ListHead
->Blink
;
173 Entry
->Flink
= ListHead
;
174 Entry
->Blink
= OldBlink
;
175 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
176 if (OldBlink
->Flink
!= ListHead
)
177 FatalListEntryError(OldBlink
->Blink
, OldBlink
, ListHead
);
179 OldBlink
->Flink
= Entry
;
180 ListHead
->Blink
= Entry
;
186 _Inout_ PLIST_ENTRY ListHead
,
187 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
189 PLIST_ENTRY OldFlink
;
190 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
191 RtlpCheckListEntry(ListHead
);
193 OldFlink
= ListHead
->Flink
;
194 Entry
->Flink
= OldFlink
;
195 Entry
->Blink
= ListHead
;
196 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
197 if (OldFlink
->Blink
!= ListHead
)
198 FatalListEntryError(ListHead
, OldFlink
, OldFlink
->Flink
);
200 OldFlink
->Blink
= Entry
;
201 ListHead
->Flink
= Entry
;
207 _Inout_ PLIST_ENTRY ListHead
,
208 _Inout_ PLIST_ENTRY ListToAppend
)
210 PLIST_ENTRY ListEnd
= ListHead
->Blink
;
212 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
213 RtlpCheckListEntry(ListHead
);
214 RtlpCheckListEntry(ListToAppend
);
216 ListHead
->Blink
->Flink
= ListToAppend
;
217 ListHead
->Blink
= ListToAppend
->Blink
;
218 ListToAppend
->Blink
->Flink
= ListHead
;
219 ListToAppend
->Blink
= ListEnd
;
225 _Inout_ PSINGLE_LIST_ENTRY ListHead
)
227 PSINGLE_LIST_ENTRY FirstEntry
;
228 FirstEntry
= ListHead
->Next
;
229 if (FirstEntry
!= NULL
) {
230 ListHead
->Next
= FirstEntry
->Next
;
238 _Inout_ PSINGLE_LIST_ENTRY ListHead
,
239 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry
)
241 Entry
->Next
= ListHead
->Next
;
242 ListHead
->Next
= Entry
;
245 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
252 _In_ PVOID FailedAssertion
,
254 _In_ ULONG LineNumber
,
255 _In_opt_z_ PSTR Message
);
259 * IN VOID UNALIGNED *Destination,
260 * IN CONST VOID UNALIGNED *Source,
263 #define RtlCopyMemory(Destination, Source, Length) \
264 memcpy(Destination, Source, Length)
266 #define RtlCopyBytes RtlCopyMemory
268 #if defined(_M_AMD64)
272 RtlCopyMemoryNonTemporal(
273 _Out_writes_bytes_all_(Length
) VOID UNALIGNED
*Destination
,
274 _In_reads_bytes_(Length
) const VOID UNALIGNED
*Source
,
277 #define RtlCopyMemoryNonTemporal RtlCopyMemory
285 #define RtlEqualLuid(Luid1, Luid2) \
286 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
290 * IN VOID UNALIGNED *Destination,
291 * IN CONST VOID UNALIGNED *Source,
294 #define RtlEqualMemory(Destination, Source, Length) \
295 (!memcmp(Destination, Source, Length))
299 * IN VOID UNALIGNED *Destination,
303 #define RtlFillMemory(Destination, Length, Fill) \
304 memset(Destination, Fill, Length)
306 #define RtlFillBytes RtlFillMemory
308 _IRQL_requires_max_(PASSIVE_LEVEL
)
312 RtlFreeUnicodeString(
313 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
314 PUNICODE_STRING UnicodeString
);
316 _IRQL_requires_max_(PASSIVE_LEVEL
)
317 _Must_inspect_result_
322 _In_ PUNICODE_STRING GuidString
,
325 _IRQL_requires_max_(DISPATCH_LEVEL
)
326 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
327 _When_(SourceString
!= NULL
,
328 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
329 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
330 _When_(SourceString
== NULL
,
331 _At_(DestinationString
->Length
, _Post_equal_to_(0))
332 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
336 RtlInitUnicodeString(
337 _Out_ PUNICODE_STRING DestinationString
,
338 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
342 * IN VOID UNALIGNED *Destination,
343 * IN CONST VOID UNALIGNED *Source,
346 #define RtlMoveMemory(Destination, Source, Length) \
347 memmove(Destination, Source, Length)
349 _IRQL_requires_max_(PASSIVE_LEVEL
)
350 _Must_inspect_result_
356 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
357 PUNICODE_STRING GuidString
);
361 * IN VOID UNALIGNED *Destination,
364 #define RtlZeroMemory(Destination, Length) \
365 memset(Destination, 0, Length)
367 #define RtlZeroBytes RtlZeroMemory
370 #if (NTDDI_VERSION >= NTDDI_WIN2K)
373 _Must_inspect_result_
378 _In_ PRTL_BITMAP BitMapHeader
,
379 _In_ ULONG StartingIndex
,
382 _Must_inspect_result_
387 _In_ PRTL_BITMAP BitMapHeader
,
388 _In_ ULONG StartingIndex
,
391 _IRQL_requires_max_(PASSIVE_LEVEL
)
392 _Must_inspect_result_
396 RtlAnsiStringToUnicodeString(
397 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
398 _When_(!AllocateDestinationString
, _Inout_
)
399 PUNICODE_STRING DestinationString
,
400 _In_ PANSI_STRING SourceString
,
401 _In_ BOOLEAN AllocateDestinationString
);
403 _IRQL_requires_max_(PASSIVE_LEVEL
)
407 RtlxAnsiStringToUnicodeSize(
408 _In_ PCANSI_STRING AnsiString
);
410 #define RtlAnsiStringToUnicodeSize(String) ( \
411 NLS_MB_CODE_PAGE_TAG ? \
412 RtlxAnsiStringToUnicodeSize(String) : \
413 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
417 _Unchanged_(Destination
->MaximumLength
)
418 _Unchanged_(Destination
->Buffer
)
419 _When_(_Old_(Destination
->Length
) + Source
->Length
<= Destination
->MaximumLength
,
420 _At_(Destination
->Length
, _Post_equal_to_(_Old_(Destination
->Length
) + Source
->Length
))
421 _At_(return, _Out_range_(==, 0)))
422 _When_(_Old_(Destination
->Length
) + Source
->Length
> Destination
->MaximumLength
,
423 _Unchanged_(Destination
->Length
)
424 _At_(return, _Out_range_(<, 0)))
428 RtlAppendUnicodeStringToString(
429 _Inout_ PUNICODE_STRING Destination
,
430 _In_ PCUNICODE_STRING Source
);
433 _Unchanged_(Destination
->MaximumLength
)
434 _Unchanged_(Destination
->Buffer
)
435 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength,
436 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR)))
437 _At_(return, _Out_range_(==, 0)))
438 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength,
439 _Unchanged_(Destination->Length)
440 _At_(return, _Out_range_(<, 0))) */
444 RtlAppendUnicodeToString(
445 _Inout_ PUNICODE_STRING Destination
,
446 _In_opt_z_ PCWSTR Source
);
448 _IRQL_requires_max_(PASSIVE_LEVEL
)
449 _Must_inspect_result_
454 _In_ ULONG RelativeTo
,
461 _In_ PRTL_BITMAP BitMapHeader
);
467 _In_ PRTL_BITMAP BitMapHeader
,
468 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
469 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
);
471 _Must_inspect_result_
476 _In_
const VOID
*Source1
,
477 _In_
const VOID
*Source2
,
480 _IRQL_requires_max_(PASSIVE_LEVEL
)
481 _Must_inspect_result_
485 RtlCompareUnicodeString(
486 _In_ PCUNICODE_STRING String1
,
487 _In_ PCUNICODE_STRING String2
,
488 _In_ BOOLEAN CaseInSensitive
);
490 _IRQL_requires_max_(PASSIVE_LEVEL
)
491 _Must_inspect_result_
495 RtlCompareUnicodeStrings(
496 _In_reads_(String1Length
) PCWCH String1
,
497 _In_ SIZE_T String1Length
,
498 _In_reads_(String2Length
) PCWCH String2
,
499 _In_ SIZE_T String2Length
,
500 _In_ BOOLEAN CaseInSensitive
);
502 _Unchanged_(DestinationString
->Buffer
)
503 _Unchanged_(DestinationString
->MaximumLength
)
504 _At_(DestinationString
->Length
,
505 _When_(SourceString
->Length
> DestinationString
->MaximumLength
,
506 _Post_equal_to_(DestinationString
->MaximumLength
))
507 _When_(SourceString
->Length
<= DestinationString
->MaximumLength
,
508 _Post_equal_to_(SourceString
->Length
)))
512 RtlCopyUnicodeString(
513 _Inout_ PUNICODE_STRING DestinationString
,
514 _In_opt_ PCUNICODE_STRING SourceString
);
516 _IRQL_requires_max_(PASSIVE_LEVEL
)
520 RtlCreateRegistryKey(
521 _In_ ULONG RelativeTo
,
524 _IRQL_requires_max_(APC_LEVEL
)
528 RtlCreateSecurityDescriptor(
529 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
530 _In_ ULONG Revision
);
532 _IRQL_requires_max_(PASSIVE_LEVEL
)
536 RtlDeleteRegistryValue(
537 _In_ ULONG RelativeTo
,
539 _In_z_ PCWSTR ValueName
);
541 _IRQL_requires_max_(PASSIVE_LEVEL
)
542 _Must_inspect_result_
546 RtlEqualUnicodeString(
547 _In_ CONST UNICODE_STRING
*String1
,
548 _In_ CONST UNICODE_STRING
*String2
,
549 _In_ BOOLEAN CaseInSensitive
);
551 #if !defined(_AMD64_) && !defined(_IA64_)
555 RtlExtendedIntegerMultiply(
556 _In_ LARGE_INTEGER Multiplicand
,
557 _In_ LONG Multiplier
);
562 RtlExtendedLargeIntegerDivide(
563 _In_ LARGE_INTEGER Dividend
,
565 _Out_opt_ PULONG Remainder
);
568 #if defined(_X86_) || defined(_IA64_)
572 RtlExtendedMagicDivide(
573 _In_ LARGE_INTEGER Dividend
,
574 _In_ LARGE_INTEGER MagicDivisor
,
575 _In_ CCHAR ShiftCount
);
578 _IRQL_requires_max_(PASSIVE_LEVEL
)
583 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
584 PANSI_STRING AnsiString
);
586 _Success_(return != -1)
587 _Must_inspect_result_
592 _In_ PRTL_BITMAP BitMapHeader
,
593 _In_ ULONG NumberToFind
,
594 _In_ ULONG HintIndex
);
596 _Success_(return != -1)
600 RtlFindClearBitsAndSet(
601 _In_ PRTL_BITMAP BitMapHeader
,
602 _In_ ULONG NumberToFind
,
603 _In_ ULONG HintIndex
);
608 RtlFindFirstRunClear(
609 _In_ PRTL_BITMAP BitMapHeader
,
610 _Out_ PULONG StartingIndex
);
616 _In_ PRTL_BITMAP BitMapHeader
,
617 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
618 _In_range_(>, 0) ULONG SizeOfRunArray
,
619 _In_ BOOLEAN LocateLongestRuns
);
624 RtlFindLastBackwardRunClear(
625 _In_ PRTL_BITMAP BitMapHeader
,
626 _In_ ULONG FromIndex
,
627 _Out_ PULONG StartingRunIndex
);
629 _Success_(return != -1)
630 _Must_inspect_result_
634 RtlFindLeastSignificantBit(
640 RtlFindLongestRunClear(
641 _In_ PRTL_BITMAP BitMapHeader
,
642 _Out_ PULONG StartingIndex
);
644 _Success_(return != -1)
645 _Must_inspect_result_
649 RtlFindMostSignificantBit(
655 RtlFindNextForwardRunClear(
656 _In_ PRTL_BITMAP BitMapHeader
,
657 _In_ ULONG FromIndex
,
658 _Out_ PULONG StartingRunIndex
);
660 _Success_(return != -1)
661 _Must_inspect_result_
666 _In_ PRTL_BITMAP BitMapHeader
,
667 _In_ ULONG NumberToFind
,
668 _In_ ULONG HintIndex
);
670 _Success_(return != -1)
674 RtlFindSetBitsAndClear(
675 _In_ PRTL_BITMAP BitMapHeader
,
676 _In_ ULONG NumberToFind
,
677 _In_ ULONG HintIndex
);
679 _IRQL_requires_max_(DISPATCH_LEVEL
)
684 _Out_ PANSI_STRING DestinationString
,
685 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
687 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
688 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
693 _Out_ PRTL_BITMAP BitMapHeader
,
694 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
695 _In_opt_ ULONG SizeOfBitMap
);
697 _IRQL_requires_max_(DISPATCH_LEVEL
)
702 _Out_ PSTRING DestinationString
,
703 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
705 _IRQL_requires_max_(PASSIVE_LEVEL
)
706 _At_(String
->MaximumLength
, _Const_
)
710 RtlIntegerToUnicodeString(
713 _Inout_ PUNICODE_STRING String
);
715 _IRQL_requires_max_(PASSIVE_LEVEL
)
716 _At_(String
->MaximumLength
, _Const_
)
720 RtlInt64ToUnicodeString(
721 _In_ ULONGLONG Value
,
723 _Inout_ PUNICODE_STRING String
);
726 #define RtlIntPtrToUnicodeString(Value, Base, String) \
727 RtlInt64ToUnicodeString(Value, Base, String)
729 #define RtlIntPtrToUnicodeString(Value, Base, String) \
730 RtlIntegerToUnicodeString(Value, Base, String)
737 #define RtlIsZeroLuid(_L1) \
738 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
740 _IRQL_requires_max_(APC_LEVEL
)
744 RtlLengthSecurityDescriptor(
745 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
750 RtlNumberOfClearBits(
751 _In_ PRTL_BITMAP BitMapHeader
);
757 _In_ PRTL_BITMAP BitMapHeader
);
759 _IRQL_requires_max_(PASSIVE_LEVEL
)
763 RtlQueryRegistryValues(
764 _In_ ULONG RelativeTo
,
766 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
767 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
768 _In_opt_ PVOID Context
,
769 _In_opt_ PVOID Environment
);
771 #define SHORT_SIZE (sizeof(USHORT))
772 #define SHORT_MASK (SHORT_SIZE - 1)
773 #define LONG_SIZE (sizeof(LONG))
774 #define LONGLONG_SIZE (sizeof(LONGLONG))
775 #define LONG_MASK (LONG_SIZE - 1)
776 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
777 #define LOWBYTE_MASK 0x00FF
779 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
780 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
781 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
782 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
788 _In_ PRTL_BITMAP BitMapHeader
);
794 _In_ PRTL_BITMAP BitMapHeader
,
795 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
796 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
);
798 _IRQL_requires_max_(APC_LEVEL
)
802 RtlSetDaclSecurityDescriptor(
803 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
804 _In_ BOOLEAN DaclPresent
,
806 _In_opt_ BOOLEAN DaclDefaulted
);
815 #define RtlStoreUlong(Address,Value) \
816 *(ULONG UNALIGNED *)(Address) = (Value)
820 * IN OUT PULONGLONG Address,
823 #define RtlStoreUlonglong(Address,Value) \
824 *(ULONGLONG UNALIGNED *)(Address) = (Value)
828 * IN PUSHORT Address,
831 #define RtlStoreUshort(Address,Value) \
832 *(USHORT UNALIGNED *)(Address) = (Value)
836 * PUSHORT DestinationAddress,
837 * PUSHORT SourceAddress);
839 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
840 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
844 * PULONG DestinationAddress,
845 * PULONG SourceAddress);
847 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
848 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
852 #define RtlStoreUlong(Address,Value) \
853 if ((ULONG_PTR)(Address) & LONG_MASK) { \
854 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
855 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
856 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
857 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
860 *((PULONG)(Address)) = (ULONG) (Value); \
863 #define RtlStoreUlonglong(Address,Value) \
864 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
865 RtlStoreUlong((ULONG_PTR)(Address), \
866 (ULONGLONG)(Value) & 0xFFFFFFFF); \
867 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
868 (ULONGLONG)(Value) >> 32); \
870 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
873 #define RtlStoreUshort(Address,Value) \
874 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
875 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
876 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
879 *((PUSHORT) (Address)) = (USHORT)Value; \
882 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
883 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
885 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
886 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
890 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
893 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
894 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
896 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
897 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
898 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
899 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
903 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
906 #endif /* defined(_AMD64_) */
911 * IN OUT PULONG_PTR Address,
912 * IN ULONG_PTR Value);
914 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
916 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
919 _Success_(return!=FALSE
)
920 _Must_inspect_result_
925 _In_ PTIME_FIELDS TimeFields
,
926 _Out_ PLARGE_INTEGER Time
);
932 _In_ PLARGE_INTEGER Time
,
933 _Out_ PTIME_FIELDS TimeFields
);
944 RtlUlonglongByteSwap(
945 _In_ ULONGLONG Source
);
947 _When_(AllocateDestinationString
,
948 _At_(DestinationString
->MaximumLength
,
949 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
950 _When_(!AllocateDestinationString
,
951 _At_(DestinationString
->Buffer
, _Const_
)
952 _At_(DestinationString
->MaximumLength
, _Const_
))
953 _IRQL_requires_max_(PASSIVE_LEVEL
)
954 _When_(AllocateDestinationString
, _Must_inspect_result_
)
958 RtlUnicodeStringToAnsiString(
959 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
960 _When_(!AllocateDestinationString
, _Inout_
)
961 PANSI_STRING DestinationString
,
962 _In_ PCUNICODE_STRING SourceString
,
963 _In_ BOOLEAN AllocateDestinationString
);
965 _IRQL_requires_max_(PASSIVE_LEVEL
)
969 RtlxUnicodeStringToAnsiSize(
970 _In_ PCUNICODE_STRING UnicodeString
);
972 #define RtlUnicodeStringToAnsiSize(String) ( \
973 NLS_MB_CODE_PAGE_TAG ? \
974 RtlxUnicodeStringToAnsiSize(String) : \
975 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
978 _IRQL_requires_max_(PASSIVE_LEVEL
)
982 RtlUnicodeStringToInteger(
983 _In_ PCUNICODE_STRING String
,
987 _IRQL_requires_max_(PASSIVE_LEVEL
)
991 RtlUpcaseUnicodeChar(
992 _In_ WCHAR SourceCharacter
);
1000 _IRQL_requires_max_(APC_LEVEL
)
1001 _Must_inspect_result_
1005 RtlValidRelativeSecurityDescriptor(
1006 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1007 _In_ ULONG SecurityDescriptorLength
,
1008 _In_ SECURITY_INFORMATION RequiredInformation
);
1010 _IRQL_requires_max_(APC_LEVEL
)
1011 _Must_inspect_result_
1015 RtlValidSecurityDescriptor(
1016 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
1018 _IRQL_requires_max_(PASSIVE_LEVEL
)
1024 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
1025 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
1026 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
1027 PRTL_OSVERSIONINFOW lpVersionInformation
);
1029 _IRQL_requires_max_(PASSIVE_LEVEL
)
1030 _Must_inspect_result_
1034 RtlVerifyVersionInfo(
1035 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
1036 _In_ ULONG TypeMask
,
1037 _In_ ULONGLONG ConditionMask
);
1039 _IRQL_requires_max_(PASSIVE_LEVEL
)
1043 RtlWriteRegistryValue(
1044 _In_ ULONG RelativeTo
,
1046 _In_z_ PCWSTR ValueName
,
1047 _In_ ULONG ValueType
,
1048 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
1049 _In_ ULONG ValueLength
);
1054 #ifndef RTL_USE_AVL_TABLES
1059 RtlInitializeGenericTable(
1060 _Out_ PRTL_GENERIC_TABLE Table
,
1061 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
1062 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
1063 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
1064 _In_opt_ PVOID TableContext
);
1069 RtlInsertElementGenericTable(
1070 _In_ PRTL_GENERIC_TABLE Table
,
1071 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1072 _In_ CLONG BufferSize
,
1073 _Out_opt_ PBOOLEAN NewElement
);
1078 RtlInsertElementGenericTableFull(
1079 _In_ PRTL_GENERIC_TABLE Table
,
1080 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1081 _In_ CLONG BufferSize
,
1082 _Out_opt_ PBOOLEAN NewElement
,
1083 _In_ PVOID NodeOrParent
,
1084 _In_ TABLE_SEARCH_RESULT SearchResult
);
1089 RtlDeleteElementGenericTable(
1090 _In_ PRTL_GENERIC_TABLE Table
,
1093 _Must_inspect_result_
1097 RtlLookupElementGenericTable(
1098 _In_ PRTL_GENERIC_TABLE Table
,
1104 RtlLookupElementGenericTableFull(
1105 _In_ PRTL_GENERIC_TABLE Table
,
1107 _Out_ PVOID
*NodeOrParent
,
1108 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1110 _Must_inspect_result_
1114 RtlEnumerateGenericTable(
1115 _In_ PRTL_GENERIC_TABLE Table
,
1116 _In_ BOOLEAN Restart
);
1118 _Must_inspect_result_
1122 RtlEnumerateGenericTableWithoutSplaying(
1123 _In_ PRTL_GENERIC_TABLE Table
,
1124 _Inout_ PVOID
*RestartKey
);
1126 _Must_inspect_result_
1130 RtlGetElementGenericTable(
1131 _In_ PRTL_GENERIC_TABLE Table
,
1137 RtlNumberGenericTableElements(
1138 _In_ PRTL_GENERIC_TABLE Table
);
1140 _Must_inspect_result_
1144 RtlIsGenericTableEmpty(
1145 _In_ PRTL_GENERIC_TABLE Table
);
1147 #endif /* !RTL_USE_AVL_TABLES */
1149 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1155 _Inout_ PRTL_SPLAY_LINKS Links
);
1161 _In_ PRTL_SPLAY_LINKS Links
);
1167 _In_ PRTL_SPLAY_LINKS Links
,
1168 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1170 _Must_inspect_result_
1174 RtlSubtreeSuccessor(
1175 _In_ PRTL_SPLAY_LINKS Links
);
1177 _Must_inspect_result_
1181 RtlSubtreePredecessor(
1182 _In_ PRTL_SPLAY_LINKS Links
);
1184 _Must_inspect_result_
1189 _In_ PRTL_SPLAY_LINKS Links
);
1191 _Must_inspect_result_
1196 _In_ PRTL_SPLAY_LINKS Links
);
1198 _IRQL_requires_max_(PASSIVE_LEVEL
)
1199 _Must_inspect_result_
1203 RtlPrefixUnicodeString(
1204 _In_ PCUNICODE_STRING String1
,
1205 _In_ PCUNICODE_STRING String2
,
1206 _In_ BOOLEAN CaseInSensitive
);
1208 _IRQL_requires_max_(PASSIVE_LEVEL
)
1213 _Inout_ PSTRING DestinationString
,
1214 _In_
const STRING
*SourceString
);
1216 _IRQL_requires_max_(PASSIVE_LEVEL
)
1217 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1221 RtlUpcaseUnicodeString(
1222 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1223 _When_(!AllocateDestinationString
, _Inout_
)
1224 PUNICODE_STRING DestinationString
,
1225 _In_ PCUNICODE_STRING SourceString
,
1226 _In_ BOOLEAN AllocateDestinationString
);
1228 _IRQL_requires_max_(APC_LEVEL
)
1233 _Inout_ PACCESS_MASK AccessMask
,
1234 _In_ PGENERIC_MAPPING GenericMapping
);
1236 _IRQL_requires_max_(PASSIVE_LEVEL
)
1240 RtlVolumeDeviceToDosName(
1241 _In_ PVOID VolumeDeviceObject
,
1242 _Out_ PUNICODE_STRING DosName
);
1244 _IRQL_requires_max_(PASSIVE_LEVEL
)
1245 _Must_inspect_result_
1250 _In_
const STRING
*String1
,
1251 _In_
const STRING
*String2
,
1252 _In_ BOOLEAN CaseInSensitive
);
1258 _Out_ PSTRING DestinationString
,
1259 _In_opt_
const STRING
*SourceString
);
1261 _IRQL_requires_max_(PASSIVE_LEVEL
)
1262 _Must_inspect_result_
1267 _In_
const STRING
*String1
,
1268 _In_
const STRING
*String2
,
1269 _In_ BOOLEAN CaseInSensitive
);
1271 _IRQL_requires_max_(PASSIVE_LEVEL
)
1277 _In_opt_ ULONG Base
,
1278 _Out_ PULONG Value
);
1280 _IRQL_requires_max_(PASSIVE_LEVEL
)
1285 _In_ CHAR Character
);
1291 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1299 _Must_inspect_result_
1301 _Post_writable_byte_size_(Size
)
1306 _In_ HANDLE HeapHandle
,
1307 _In_opt_ ULONG Flags
,
1310 _Success_(return != 0)
1315 _In_ PVOID HeapHandle
,
1316 _In_opt_ ULONG Flags
,
1317 _In_ _Post_invalid_ PVOID BaseAddress
);
1323 _Out_ PCONTEXT ContextRecord
);
1325 _Ret_range_(<, MAXLONG
)
1330 _Inout_ PULONG Seed
);
1332 _IRQL_requires_max_(APC_LEVEL
)
1333 _Success_(return != 0)
1334 _Must_inspect_result_
1338 RtlCreateUnicodeString(
1339 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1340 PUNICODE_STRING DestinationString
,
1341 _In_z_ PCWSTR SourceString
);
1343 _IRQL_requires_max_(PASSIVE_LEVEL
)
1344 _Must_inspect_result_
1349 _In_
const STRING
*String1
,
1350 _In_
const STRING
*String2
,
1351 _In_ BOOLEAN CaseInsensitive
);
1353 _IRQL_requires_max_(APC_LEVEL
)
1357 RtlAppendStringToString(
1358 _Inout_ PSTRING Destination
,
1359 _In_
const STRING
*Source
);
1361 _IRQL_requires_max_(PASSIVE_LEVEL
)
1362 _Must_inspect_result_
1366 RtlOemStringToUnicodeString(
1367 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1368 _When_(!AllocateDestinationString
, _Inout_
)
1369 PUNICODE_STRING DestinationString
,
1370 _In_ PCOEM_STRING SourceString
,
1371 _In_ BOOLEAN AllocateDestinationString
);
1373 _IRQL_requires_max_(PASSIVE_LEVEL
)
1374 _Must_inspect_result_
1378 RtlUnicodeStringToOemString(
1379 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1380 _When_(!AllocateDestinationString
, _Inout_
)
1381 POEM_STRING DestinationString
,
1382 _In_ PCUNICODE_STRING SourceString
,
1383 _In_ BOOLEAN AllocateDestinationString
);
1385 _IRQL_requires_max_(PASSIVE_LEVEL
)
1386 _Must_inspect_result_
1390 RtlUpcaseUnicodeStringToOemString(
1391 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1392 _When_(!AllocateDestinationString
, _Inout_
)
1393 POEM_STRING DestinationString
,
1394 _In_ PCUNICODE_STRING SourceString
,
1395 _In_ BOOLEAN AllocateDestinationString
);
1397 _IRQL_requires_max_(PASSIVE_LEVEL
)
1398 _Must_inspect_result_
1402 RtlOemStringToCountedUnicodeString(
1403 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1404 _When_(!AllocateDestinationString
, _Inout_
)
1405 PUNICODE_STRING DestinationString
,
1406 _In_ PCOEM_STRING SourceString
,
1407 _In_ BOOLEAN AllocateDestinationString
);
1409 _IRQL_requires_max_(PASSIVE_LEVEL
)
1410 _Must_inspect_result_
1414 RtlUnicodeStringToCountedOemString(
1415 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1416 _When_(!AllocateDestinationString
, _Inout_
)
1417 POEM_STRING DestinationString
,
1418 _In_ PCUNICODE_STRING SourceString
,
1419 _In_ BOOLEAN AllocateDestinationString
);
1421 _IRQL_requires_max_(PASSIVE_LEVEL
)
1422 _Must_inspect_result_
1426 RtlUpcaseUnicodeStringToCountedOemString(
1427 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1428 _When_(!AllocateDestinationString
, _Inout_
)
1429 POEM_STRING DestinationString
,
1430 _In_ PCUNICODE_STRING SourceString
,
1431 _In_ BOOLEAN AllocateDestinationString
);
1433 _IRQL_requires_max_(PASSIVE_LEVEL
)
1434 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1438 RtlDowncaseUnicodeString(
1439 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1440 _When_(!AllocateDestinationString
, _Inout_
)
1441 PUNICODE_STRING UniDest
,
1442 _In_ PCUNICODE_STRING UniSource
,
1443 _In_ BOOLEAN AllocateDestinationString
);
1445 _IRQL_requires_max_(PASSIVE_LEVEL
)
1450 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1452 _IRQL_requires_max_(PASSIVE_LEVEL
)
1456 RtlxUnicodeStringToOemSize(
1457 _In_ PCUNICODE_STRING UnicodeString
);
1459 _IRQL_requires_max_(PASSIVE_LEVEL
)
1463 RtlxOemStringToUnicodeSize(
1464 _In_ PCOEM_STRING OemString
);
1466 _IRQL_requires_max_(PASSIVE_LEVEL
)
1470 RtlMultiByteToUnicodeN(
1471 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1472 _In_ ULONG MaxBytesInUnicodeString
,
1473 _Out_opt_ PULONG BytesInUnicodeString
,
1474 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1475 _In_ ULONG BytesInMultiByteString
);
1477 _IRQL_requires_max_(PASSIVE_LEVEL
)
1481 RtlMultiByteToUnicodeSize(
1482 _Out_ PULONG BytesInUnicodeString
,
1483 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1484 _In_ ULONG BytesInMultiByteString
);
1486 _IRQL_requires_max_(PASSIVE_LEVEL
)
1490 RtlUnicodeToMultiByteSize(
1491 _Out_ PULONG BytesInMultiByteString
,
1492 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1493 _In_ ULONG BytesInUnicodeString
);
1495 _IRQL_requires_max_(PASSIVE_LEVEL
)
1499 RtlUnicodeToMultiByteN(
1500 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1501 _In_ ULONG MaxBytesInMultiByteString
,
1502 _Out_opt_ PULONG BytesInMultiByteString
,
1503 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1504 _In_ ULONG BytesInUnicodeString
);
1506 _IRQL_requires_max_(PASSIVE_LEVEL
)
1510 RtlUpcaseUnicodeToMultiByteN(
1511 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1512 _In_ ULONG MaxBytesInMultiByteString
,
1513 _Out_opt_ PULONG BytesInMultiByteString
,
1514 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1515 _In_ ULONG BytesInUnicodeString
);
1517 _IRQL_requires_max_(PASSIVE_LEVEL
)
1522 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1523 _In_ ULONG MaxBytesInUnicodeString
,
1524 _Out_opt_ PULONG BytesInUnicodeString
,
1525 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1526 _In_ ULONG BytesInOemString
);
1528 _IRQL_requires_max_(PASSIVE_LEVEL
)
1533 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1534 _In_ ULONG MaxBytesInOemString
,
1535 _Out_opt_ PULONG BytesInOemString
,
1536 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1537 _In_ ULONG BytesInUnicodeString
);
1539 _IRQL_requires_max_(PASSIVE_LEVEL
)
1543 RtlUpcaseUnicodeToOemN(
1544 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1545 _In_ ULONG MaxBytesInOemString
,
1546 _Out_opt_ PULONG BytesInOemString
,
1547 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1548 _In_ ULONG BytesInUnicodeString
);
1550 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1551 _IRQL_requires_max_(PASSIVE_LEVEL
)
1555 RtlGenerate8dot3Name(
1556 _In_ PCUNICODE_STRING Name
,
1557 _In_ BOOLEAN AllowExtendedCharacters
,
1558 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1559 _Inout_ PUNICODE_STRING Name8dot3
);
1561 _IRQL_requires_max_(PASSIVE_LEVEL
)
1565 RtlGenerate8dot3Name(
1566 _In_ PCUNICODE_STRING Name
,
1567 _In_ BOOLEAN AllowExtendedCharacters
,
1568 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1569 _Inout_ PUNICODE_STRING Name8dot3
);
1572 _IRQL_requires_max_(PASSIVE_LEVEL
)
1573 _Must_inspect_result_
1577 RtlIsNameLegalDOS8Dot3(
1578 _In_ PCUNICODE_STRING Name
,
1579 _Inout_opt_ POEM_STRING OemName
,
1580 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1582 _IRQL_requires_max_(PASSIVE_LEVEL
)
1583 _Must_inspect_result_
1587 RtlIsValidOemCharacter(
1588 _Inout_ PWCHAR Char
);
1590 _IRQL_requires_max_(PASSIVE_LEVEL
)
1595 _Out_ PPREFIX_TABLE PrefixTable
);
1597 _IRQL_requires_max_(PASSIVE_LEVEL
)
1602 _In_ PPREFIX_TABLE PrefixTable
,
1603 _In_ __drv_aliasesMem PSTRING Prefix
,
1604 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1606 _IRQL_requires_max_(PASSIVE_LEVEL
)
1611 _In_ PPREFIX_TABLE PrefixTable
,
1612 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1614 _IRQL_requires_max_(PASSIVE_LEVEL
)
1615 _Must_inspect_result_
1620 _In_ PPREFIX_TABLE PrefixTable
,
1621 _In_ PSTRING FullName
);
1623 _IRQL_requires_max_(PASSIVE_LEVEL
)
1627 RtlInitializeUnicodePrefix(
1628 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1630 _IRQL_requires_max_(PASSIVE_LEVEL
)
1634 RtlInsertUnicodePrefix(
1635 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1636 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1637 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1639 _IRQL_requires_max_(PASSIVE_LEVEL
)
1643 RtlRemoveUnicodePrefix(
1644 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1645 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1647 _IRQL_requires_max_(PASSIVE_LEVEL
)
1648 _Must_inspect_result_
1650 PUNICODE_PREFIX_TABLE_ENTRY
1652 RtlFindUnicodePrefix(
1653 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1654 _In_ PUNICODE_STRING FullName
,
1655 _In_ ULONG CaseInsensitiveIndex
);
1657 _IRQL_requires_max_(PASSIVE_LEVEL
)
1658 _Must_inspect_result_
1660 PUNICODE_PREFIX_TABLE_ENTRY
1662 RtlNextUnicodePrefix(
1663 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1664 _In_ BOOLEAN Restart
);
1666 _Must_inspect_result_
1670 RtlCompareMemoryUlong(
1671 _In_reads_bytes_(Length
) PVOID Source
,
1673 _In_ ULONG Pattern
);
1675 _Success_(return != 0)
1679 RtlTimeToSecondsSince1980(
1680 _In_ PLARGE_INTEGER Time
,
1681 _Out_ PULONG ElapsedSeconds
);
1686 RtlSecondsSince1980ToTime(
1687 _In_ ULONG ElapsedSeconds
,
1688 _Out_ PLARGE_INTEGER Time
);
1690 _Success_(return != 0)
1691 _Must_inspect_result_
1695 RtlTimeToSecondsSince1970(
1696 _In_ PLARGE_INTEGER Time
,
1697 _Out_ PULONG ElapsedSeconds
);
1702 RtlSecondsSince1970ToTime(
1703 _In_ ULONG ElapsedSeconds
,
1704 _Out_ PLARGE_INTEGER Time
);
1706 _IRQL_requires_max_(APC_LEVEL
)
1707 _Must_inspect_result_
1714 _Must_inspect_result_
1722 _IRQL_requires_max_(APC_LEVEL
)
1723 _Must_inspect_result_
1731 _IRQL_requires_max_(APC_LEVEL
)
1735 RtlLengthRequiredSid(
1736 _In_ ULONG SubAuthorityCount
);
1742 _In_ _Post_invalid_ PSID Sid
);
1744 _Must_inspect_result_
1748 RtlAllocateAndInitializeSid(
1749 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1750 _In_ UCHAR SubAuthorityCount
,
1751 _In_ ULONG SubAuthority0
,
1752 _In_ ULONG SubAuthority1
,
1753 _In_ ULONG SubAuthority2
,
1754 _In_ ULONG SubAuthority3
,
1755 _In_ ULONG SubAuthority4
,
1756 _In_ ULONG SubAuthority5
,
1757 _In_ ULONG SubAuthority6
,
1758 _In_ ULONG SubAuthority7
,
1759 _Outptr_ PSID
*Sid
);
1761 _IRQL_requires_max_(APC_LEVEL
)
1767 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1768 _In_ UCHAR SubAuthorityCount
);
1775 _In_ ULONG SubAuthority
);
1777 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1784 _IRQL_requires_max_(APC_LEVEL
)
1789 _In_ ULONG DestinationSidLength
,
1790 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1791 _In_ PSID SourceSid
);
1793 _IRQL_requires_max_(APC_LEVEL
)
1797 RtlConvertSidToUnicodeString(
1798 _Inout_ PUNICODE_STRING UnicodeString
,
1800 _In_ BOOLEAN AllocateDestinationString
);
1802 _IRQL_requires_max_(APC_LEVEL
)
1807 _Out_ PLUID DestinationLuid
,
1808 _In_ PLUID SourceLuid
);
1810 _IRQL_requires_max_(APC_LEVEL
)
1815 _Out_writes_bytes_(AclLength
) PACL Acl
,
1816 _In_ ULONG AclLength
,
1817 _In_ ULONG AclRevision
);
1819 _IRQL_requires_max_(APC_LEVEL
)
1825 _In_ ULONG AceRevision
,
1826 _In_ ULONG StartingAceIndex
,
1827 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1828 _In_ ULONG AceListLength
);
1830 _IRQL_requires_max_(APC_LEVEL
)
1836 _In_ ULONG AceIndex
);
1843 _In_ ULONG AceIndex
,
1844 _Outptr_ PVOID
*Ace
);
1846 _IRQL_requires_max_(APC_LEVEL
)
1850 RtlAddAccessAllowedAce(
1852 _In_ ULONG AceRevision
,
1853 _In_ ACCESS_MASK AccessMask
,
1856 _IRQL_requires_max_(APC_LEVEL
)
1860 RtlAddAccessAllowedAceEx(
1862 _In_ ULONG AceRevision
,
1863 _In_ ULONG AceFlags
,
1864 _In_ ACCESS_MASK AccessMask
,
1867 _IRQL_requires_max_(APC_LEVEL
)
1871 RtlCreateSecurityDescriptorRelative(
1872 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1873 _In_ ULONG Revision
);
1878 RtlGetDaclSecurityDescriptor(
1879 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1880 _Out_ PBOOLEAN DaclPresent
,
1882 _Out_ PBOOLEAN DaclDefaulted
);
1884 _IRQL_requires_max_(APC_LEVEL
)
1888 RtlSetOwnerSecurityDescriptor(
1889 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1890 _In_opt_ PSID Owner
,
1891 _In_opt_ BOOLEAN OwnerDefaulted
);
1893 _IRQL_requires_max_(APC_LEVEL
)
1897 RtlGetOwnerSecurityDescriptor(
1898 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1900 _Out_ PBOOLEAN OwnerDefaulted
);
1902 _IRQL_requires_max_(APC_LEVEL
)
1903 _When_(Status
< 0, _Out_range_(>, 0))
1904 _When_(Status
>= 0, _Out_range_(==, 0))
1908 RtlNtStatusToDosError(
1909 _In_ NTSTATUS Status
);
1911 _IRQL_requires_max_(PASSIVE_LEVEL
)
1915 RtlCustomCPToUnicodeN(
1916 _In_ PCPTABLEINFO CustomCP
,
1917 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1918 _In_ ULONG MaxBytesInUnicodeString
,
1919 _Out_opt_ PULONG BytesInUnicodeString
,
1920 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1921 _In_ ULONG BytesInCustomCPString
);
1923 _IRQL_requires_max_(PASSIVE_LEVEL
)
1927 RtlUnicodeToCustomCPN(
1928 _In_ PCPTABLEINFO CustomCP
,
1929 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1930 _In_ ULONG MaxBytesInCustomCPString
,
1931 _Out_opt_ PULONG BytesInCustomCPString
,
1932 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1933 _In_ ULONG BytesInUnicodeString
);
1935 _IRQL_requires_max_(PASSIVE_LEVEL
)
1939 RtlUpcaseUnicodeToCustomCPN(
1940 _In_ PCPTABLEINFO CustomCP
,
1941 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1942 _In_ ULONG MaxBytesInCustomCPString
,
1943 _Out_opt_ PULONG BytesInCustomCPString
,
1944 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1945 _In_ ULONG BytesInUnicodeString
);
1947 _IRQL_requires_max_(PASSIVE_LEVEL
)
1951 RtlInitCodePageTable(
1952 _In_ PUSHORT TableBase
,
1953 _Out_ PCPTABLEINFO CodePageTable
);
1957 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1961 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1965 RtlPrefetchMemoryNonTemporal(
1967 _In_ SIZE_T Length
);
1972 #if (NTDDI_VERSION >= NTDDI_WINXP)
1980 _In_ PRTL_BITMAP BitMapHeader
,
1981 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1983 _IRQL_requires_max_(PASSIVE_LEVEL
)
1987 RtlDowncaseUnicodeChar(
1988 _In_ WCHAR SourceCharacter
);
1994 _In_ PRTL_BITMAP BitMapHeader
,
1995 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1997 _Must_inspect_result_
2002 _In_ PRTL_BITMAP BitMapHeader
,
2003 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2005 _IRQL_requires_max_(PASSIVE_LEVEL
)
2009 RtlHashUnicodeString(
2010 _In_ CONST UNICODE_STRING
*String
,
2011 _In_ BOOLEAN CaseInSensitive
,
2012 _In_ ULONG HashAlgorithm
,
2013 _Out_ PULONG HashValue
);
2022 RtlInitializeGenericTableAvl(
2023 _Out_ PRTL_AVL_TABLE Table
,
2024 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
2025 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
2026 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
2027 _In_opt_ PVOID TableContext
);
2032 RtlInsertElementGenericTableAvl(
2033 _In_ PRTL_AVL_TABLE Table
,
2034 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2035 _In_ CLONG BufferSize
,
2036 _Out_opt_ PBOOLEAN NewElement
);
2041 RtlInsertElementGenericTableFullAvl(
2042 _In_ PRTL_AVL_TABLE Table
,
2043 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2044 _In_ CLONG BufferSize
,
2045 _Out_opt_ PBOOLEAN NewElement
,
2046 _In_ PVOID NodeOrParent
,
2047 _In_ TABLE_SEARCH_RESULT SearchResult
);
2052 RtlDeleteElementGenericTableAvl(
2053 _In_ PRTL_AVL_TABLE Table
,
2056 _Must_inspect_result_
2060 RtlLookupElementGenericTableAvl(
2061 _In_ PRTL_AVL_TABLE Table
,
2067 RtlLookupElementGenericTableFullAvl(
2068 _In_ PRTL_AVL_TABLE Table
,
2070 _Out_ PVOID
*NodeOrParent
,
2071 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
2073 _Must_inspect_result_
2077 RtlEnumerateGenericTableAvl(
2078 _In_ PRTL_AVL_TABLE Table
,
2079 _In_ BOOLEAN Restart
);
2081 _Must_inspect_result_
2085 RtlEnumerateGenericTableWithoutSplayingAvl(
2086 _In_ PRTL_AVL_TABLE Table
,
2087 _Inout_ PVOID
*RestartKey
);
2089 _Must_inspect_result_
2093 RtlLookupFirstMatchingElementGenericTableAvl(
2094 _In_ PRTL_AVL_TABLE Table
,
2096 _Out_ PVOID
*RestartKey
);
2098 _Must_inspect_result_
2102 RtlEnumerateGenericTableLikeADirectory(
2103 _In_ PRTL_AVL_TABLE Table
,
2104 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
2105 _In_opt_ PVOID MatchData
,
2106 _In_ ULONG NextFlag
,
2107 _Inout_ PVOID
*RestartKey
,
2108 _Inout_ PULONG DeleteCount
,
2111 _Must_inspect_result_
2115 RtlGetElementGenericTableAvl(
2116 _In_ PRTL_AVL_TABLE Table
,
2122 RtlNumberGenericTableElementsAvl(
2123 _In_ PRTL_AVL_TABLE Table
);
2125 _Must_inspect_result_
2129 RtlIsGenericTableEmptyAvl(
2130 _In_ PRTL_AVL_TABLE Table
);
2135 _Must_inspect_result_
2141 _In_opt_ PVOID HeapBase
,
2142 _In_opt_ SIZE_T ReserveSize
,
2143 _In_opt_ SIZE_T CommitSize
,
2144 _In_opt_ PVOID Lock
,
2145 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2151 _In_ _Post_invalid_ PVOID HeapHandle
);
2156 RtlCaptureStackBackTrace(
2157 _In_ ULONG FramesToSkip
,
2158 _In_ ULONG FramesToCapture
,
2159 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2160 _Out_opt_ PULONG BackTraceHash
);
2162 _Ret_range_(<, MAXLONG
)
2167 _Inout_ PULONG Seed
);
2169 _IRQL_requires_max_(DISPATCH_LEVEL
)
2173 RtlInitUnicodeStringEx(
2174 _Out_ PUNICODE_STRING DestinationString
,
2175 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2177 _Must_inspect_result_
2181 RtlValidateUnicodeString(
2183 _In_ PCUNICODE_STRING String
);
2185 _IRQL_requires_max_(PASSIVE_LEVEL
)
2186 _Must_inspect_result_
2190 RtlDuplicateUnicodeString(
2192 _In_ PCUNICODE_STRING SourceString
,
2193 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2198 RtlGetCompressionWorkSpaceSize(
2199 _In_ USHORT CompressionFormatAndEngine
,
2200 _Out_ PULONG CompressBufferWorkSpaceSize
,
2201 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2207 _In_ USHORT CompressionFormatAndEngine
,
2208 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2209 _In_ ULONG UncompressedBufferSize
,
2210 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2211 _In_ ULONG CompressedBufferSize
,
2212 _In_ ULONG UncompressedChunkSize
,
2213 _Out_ PULONG FinalCompressedSize
,
2214 _In_ PVOID WorkSpace
);
2216 _IRQL_requires_max_(APC_LEVEL
)
2220 RtlDecompressBuffer(
2221 _In_ USHORT CompressionFormat
,
2222 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2223 _In_ ULONG UncompressedBufferSize
,
2224 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2225 _In_ ULONG CompressedBufferSize
,
2226 _Out_ PULONG FinalUncompressedSize
);
2228 _IRQL_requires_max_(APC_LEVEL
)
2232 RtlDecompressFragment(
2233 _In_ USHORT CompressionFormat
,
2234 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2235 _In_ ULONG UncompressedFragmentSize
,
2236 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2237 _In_ ULONG CompressedBufferSize
,
2238 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2239 _Out_ PULONG FinalUncompressedSize
,
2240 _In_ PVOID WorkSpace
);
2242 _IRQL_requires_max_(APC_LEVEL
)
2247 _In_ USHORT CompressionFormat
,
2248 _Inout_ PUCHAR
*CompressedBuffer
,
2249 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2250 _Out_ PUCHAR
*ChunkBuffer
,
2251 _Out_ PULONG ChunkSize
);
2253 _IRQL_requires_max_(APC_LEVEL
)
2258 _In_ USHORT CompressionFormat
,
2259 _Inout_ PUCHAR
*CompressedBuffer
,
2260 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2261 _Out_ PUCHAR
*ChunkBuffer
,
2262 _In_ ULONG ChunkSize
);
2264 _IRQL_requires_max_(APC_LEVEL
)
2268 RtlDecompressChunks(
2269 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2270 _In_ ULONG UncompressedBufferSize
,
2271 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2272 _In_ ULONG CompressedBufferSize
,
2273 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2274 _In_ ULONG CompressedTailSize
,
2275 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2277 _IRQL_requires_max_(APC_LEVEL
)
2282 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2283 _In_ ULONG UncompressedBufferSize
,
2284 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2285 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2286 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2287 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2288 _In_ PVOID WorkSpace
);
2290 _IRQL_requires_max_(APC_LEVEL
)
2292 PSID_IDENTIFIER_AUTHORITY
2294 RtlIdentifierAuthoritySid(
2300 RtlSubAuthorityCountSid(
2303 _When_(Status
< 0, _Out_range_(>, 0))
2304 _When_(Status
>= 0, _Out_range_(==, 0))
2308 RtlNtStatusToDosErrorNoTeb(
2309 _In_ NTSTATUS Status
);
2311 _IRQL_requires_max_(PASSIVE_LEVEL
)
2315 RtlCreateSystemVolumeInformationFolder(
2316 _In_ PCUNICODE_STRING VolumeRootPath
);
2318 #if defined(_M_AMD64)
2323 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2327 PULONG Address
= (PULONG
)Destination
;
2328 if ((Length
/= 4) != 0) {
2329 if (((ULONG64
)Address
& 4) != 0) {
2331 if ((Length
-= 1) == 0) {
2336 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2337 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2342 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2343 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2351 OUT PVOID Destination
,
2358 RtlFillMemoryUlonglong(
2359 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2361 _In_ ULONGLONG Pattern
);
2363 #endif /* defined(_M_AMD64) */
2366 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2369 #if (NTDDI_VERSION >= NTDDI_WS03)
2370 _IRQL_requires_max_(DISPATCH_LEVEL
)
2374 RtlInitAnsiStringEx(
2375 _Out_ PANSI_STRING DestinationString
,
2376 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2379 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2381 _IRQL_requires_max_(APC_LEVEL
)
2385 RtlGetSaclSecurityDescriptor(
2386 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2387 _Out_ PBOOLEAN SaclPresent
,
2389 _Out_ PBOOLEAN SaclDefaulted
);
2391 _IRQL_requires_max_(APC_LEVEL
)
2395 RtlSetGroupSecurityDescriptor(
2396 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2397 _In_opt_ PSID Group
,
2398 _In_opt_ BOOLEAN GroupDefaulted
);
2400 _IRQL_requires_max_(APC_LEVEL
)
2404 RtlGetGroupSecurityDescriptor(
2405 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2407 _Out_ PBOOLEAN GroupDefaulted
);
2409 _IRQL_requires_max_(APC_LEVEL
)
2413 RtlAbsoluteToSelfRelativeSD(
2414 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2415 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2416 _Inout_ PULONG BufferLength
);
2418 _IRQL_requires_max_(APC_LEVEL
)
2422 RtlSelfRelativeToAbsoluteSD(
2423 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2424 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2425 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2426 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2427 _Inout_ PULONG DaclSize
,
2428 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2429 _Inout_ PULONG SaclSize
,
2430 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2431 _Inout_ PULONG OwnerSize
,
2432 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2433 _Inout_ PULONG PrimaryGroupSize
);
2435 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2438 #if (NTDDI_VERSION >= NTDDI_VISTA)
2444 RtlNumberOfSetBitsUlongPtr(
2445 _In_ ULONG_PTR Target
);
2450 RtlIoDecodeMemIoResource(
2451 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2452 _Out_opt_ PULONGLONG Alignment
,
2453 _Out_opt_ PULONGLONG MinimumAddress
,
2454 _Out_opt_ PULONGLONG MaximumAddress
);
2459 RtlIoEncodeMemIoResource(
2460 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2462 _In_ ULONGLONG Length
,
2463 _In_ ULONGLONG Alignment
,
2464 _In_ ULONGLONG MinimumAddress
,
2465 _In_ ULONGLONG MaximumAddress
);
2470 RtlCmDecodeMemIoResource(
2471 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2472 _Out_opt_ PULONGLONG Start
);
2477 RtlFindClosestEncodableLength(
2478 _In_ ULONGLONG SourceLength
,
2479 _Out_ PULONGLONG TargetLength
);
2484 RtlCmEncodeMemIoResource(
2485 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2487 _In_ ULONGLONG Length
,
2488 _In_ ULONGLONG Start
);
2493 _IRQL_requires_max_(APC_LEVEL
)
2497 RtlRunOnceInitialize(
2498 _Out_ PRTL_RUN_ONCE RunOnce
);
2500 _IRQL_requires_max_(APC_LEVEL
)
2501 _Maybe_raises_SEH_exception_
2505 RtlRunOnceExecuteOnce(
2506 _Inout_ PRTL_RUN_ONCE RunOnce
,
2507 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2508 _Inout_opt_ PVOID Parameter
,
2509 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2511 _IRQL_requires_max_(APC_LEVEL
)
2512 _Must_inspect_result_
2516 RtlRunOnceBeginInitialize(
2517 _Inout_ PRTL_RUN_ONCE RunOnce
,
2519 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2521 _IRQL_requires_max_(APC_LEVEL
)
2526 _Inout_ PRTL_RUN_ONCE RunOnce
,
2528 _In_opt_ PVOID Context
);
2534 _In_ ULONG OSMajorVersion
,
2535 _In_ ULONG OSMinorVersion
,
2536 _In_ ULONG SpMajorVersion
,
2537 _In_ ULONG SpMinorVersion
,
2538 _Out_ PULONG ReturnedProductType
);
2546 _In_ ULONG NormForm
,
2547 _In_ PCWSTR SourceString
,
2548 _In_ LONG SourceStringLength
,
2549 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2550 _Inout_ PLONG DestinationStringLength
);
2555 RtlIsNormalizedString(
2556 _In_ ULONG NormForm
,
2557 _In_ PCWSTR SourceString
,
2558 _In_ LONG SourceStringLength
,
2559 _Out_ PBOOLEAN Normalized
);
2566 _In_ PCWSTR SourceString
,
2567 _In_ LONG SourceStringLength
,
2568 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2569 _Inout_ PLONG DestinationStringLength
);
2576 IN PCWSTR SourceString
,
2577 IN LONG SourceStringLength
,
2578 OUT PWSTR DestinationString
,
2579 IN OUT PLONG DestinationStringLength
);
2584 RtlIdnToNameprepUnicode(
2586 _In_ PCWSTR SourceString
,
2587 _In_ LONG SourceStringLength
,
2588 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2589 _Inout_ PLONG DestinationStringLength
);
2594 RtlCreateServiceSid(
2595 _In_ PUNICODE_STRING ServiceName
,
2596 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2597 _Inout_ PULONG ServiceSidLength
);
2602 RtlCompareAltitudes(
2603 _In_ PCUNICODE_STRING Altitude1
,
2604 _In_ PCUNICODE_STRING Altitude2
);
2608 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2610 #if (NTDDI_VERSION >= NTDDI_WIN7)
2613 _IRQL_requires_max_(PASSIVE_LEVEL
)
2614 _Must_inspect_result_
2619 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2620 PCHAR UTF8StringDestination
,
2621 _In_ ULONG UTF8StringMaxByteCount
,
2622 _Out_ PULONG UTF8StringActualByteCount
,
2623 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2624 _In_ ULONG UnicodeStringByteCount
);
2626 _IRQL_requires_max_(PASSIVE_LEVEL
)
2627 _Must_inspect_result_
2632 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2633 PWSTR UnicodeStringDestination
,
2634 _In_ ULONG UnicodeStringMaxByteCount
,
2635 _Out_ PULONG UnicodeStringActualByteCount
,
2636 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2637 _In_ ULONG UTF8StringByteCount
);
2642 RtlGetEnabledExtendedFeatures(
2643 IN ULONG64 FeatureMask
);
2648 _Must_inspect_result_
2653 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2654 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2656 _In_ _Reserved_ ULONG Flags
);
2662 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2663 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2668 RtlInsertEntryHashTable(
2669 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2670 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2671 _In_ ULONG_PTR Signature
,
2672 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2677 RtlRemoveEntryHashTable(
2678 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2679 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2680 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2682 _Must_inspect_result_
2684 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2686 RtlLookupEntryHashTable(
2687 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2688 _In_ ULONG_PTR Signature
,
2689 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2691 _Must_inspect_result_
2693 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2695 RtlGetNextEntryHashTable(
2696 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2697 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2702 RtlInitEnumerationHashTable(
2703 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2704 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2706 _Must_inspect_result_
2708 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2710 RtlEnumerateEntryHashTable(
2711 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2712 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2717 RtlEndEnumerationHashTable(
2718 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2719 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2724 RtlInitWeakEnumerationHashTable(
2725 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2726 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2728 _Must_inspect_result_
2730 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2732 RtlWeaklyEnumerateEntryHashTable(
2733 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2734 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2739 RtlEndWeakEnumerationHashTable(
2740 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2741 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2747 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2752 RtlContractHashTable(
2753 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2757 _IRQL_requires_max_(PASSIVE_LEVEL
)
2758 _Must_inspect_result_
2763 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2764 _In_ ULONG UTF8StringMaxByteCount
,
2765 _Out_ PULONG UTF8StringActualByteCount
,
2766 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2767 _In_ ULONG UnicodeStringByteCount
);
2769 _IRQL_requires_max_(PASSIVE_LEVEL
)
2770 _Must_inspect_result_
2775 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2776 _In_ ULONG UnicodeStringMaxByteCount
,
2777 _Out_ PULONG UnicodeStringActualByteCount
,
2778 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2779 _In_ ULONG UTF8StringByteCount
);
2781 _IRQL_requires_max_(APC_LEVEL
)
2786 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2789 _Out_ ULONG
*NumChanges
);
2794 RtlCreateVirtualAccountSid(
2795 _In_ PCUNICODE_STRING Name
,
2796 _In_ ULONG BaseSubAuthority
,
2797 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2798 _Inout_ PULONG SidLength
);
2801 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2805 #if !defined(MIDL_PASS)
2806 /* inline funftions */
2807 //DECLSPEC_DEPRECATED_DDK_WINXP
2811 RtlConvertLongToLargeInteger(
2812 _In_ LONG SignedInteger
)
2815 ret
.QuadPart
= SignedInteger
;
2819 //DECLSPEC_DEPRECATED_DDK_WINXP
2823 RtlConvertUlongToLargeInteger(
2824 _In_ ULONG UnsignedInteger
)
2827 ret
.QuadPart
= UnsignedInteger
;
2831 //DECLSPEC_DEPRECATED_DDK_WINXP
2835 RtlLargeIntegerShiftLeft(
2836 _In_ LARGE_INTEGER LargeInteger
,
2837 _In_ CCHAR ShiftCount
)
2839 LARGE_INTEGER Result
;
2841 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2845 //DECLSPEC_DEPRECATED_DDK_WINXP
2849 RtlLargeIntegerShiftRight(
2850 _In_ LARGE_INTEGER LargeInteger
,
2851 _In_ CCHAR ShiftCount
)
2853 LARGE_INTEGER Result
;
2855 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2859 //DECLSPEC_DEPRECATED_DDK
2863 RtlEnlargedUnsignedDivide(
2864 _In_ ULARGE_INTEGER Dividend
,
2866 _Out_opt_ PULONG Remainder
)
2869 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2870 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2873 //DECLSPEC_DEPRECATED_DDK
2877 RtlLargeIntegerNegate(
2878 _In_ LARGE_INTEGER Subtrahend
)
2880 LARGE_INTEGER Difference
;
2882 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2886 //DECLSPEC_DEPRECATED_DDK
2890 RtlLargeIntegerSubtract(
2891 _In_ LARGE_INTEGER Minuend
,
2892 _In_ LARGE_INTEGER Subtrahend
)
2894 LARGE_INTEGER Difference
;
2896 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2900 //DECLSPEC_DEPRECATED_DDK
2904 RtlEnlargedUnsignedMultiply(
2905 _In_ ULONG Multiplicand
,
2906 _In_ ULONG Multiplier
)
2909 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2913 //DECLSPEC_DEPRECATED_DDK
2917 RtlEnlargedIntegerMultiply(
2918 _In_ LONG Multiplicand
,
2919 _In_ LONG Multiplier
)
2922 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2926 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2927 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2928 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2931 RtlInitEmptyAnsiString(
2932 _Out_ PANSI_STRING AnsiString
,
2933 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2934 _In_ USHORT BufferSize
)
2936 AnsiString
->Length
= 0;
2937 AnsiString
->MaximumLength
= BufferSize
;
2938 AnsiString
->Buffer
= Buffer
;
2941 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2942 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2943 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2946 RtlInitEmptyUnicodeString(
2947 _Out_ PUNICODE_STRING UnicodeString
,
2948 _Writable_bytes_(BufferSize
)
2949 _When_(BufferSize
!= 0, _Notnull_
)
2950 __drv_aliasesMem PWSTR Buffer
,
2951 _In_ USHORT BufferSize
)
2953 UnicodeString
->Length
= 0;
2954 UnicodeString
->MaximumLength
= BufferSize
;
2955 UnicodeString
->Buffer
= Buffer
;
2959 #if defined(_AMD64_) || defined(_IA64_)
2966 RtlExtendedIntegerMultiply(
2967 _In_ LARGE_INTEGER Multiplicand
,
2968 _In_ LONG Multiplier
)
2971 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2978 RtlExtendedLargeIntegerDivide(
2979 _In_ LARGE_INTEGER Dividend
,
2981 _Out_opt_ PULONG Remainder
)
2984 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
2986 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2994 //DECLSPEC_DEPRECATED_DDK_WINXP
2998 RtlLargeIntegerDivide(
2999 _In_ LARGE_INTEGER Dividend
,
3000 _In_ LARGE_INTEGER Divisor
,
3001 _Out_opt_ PLARGE_INTEGER Remainder
)
3004 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
3006 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
3012 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3016 RtlLargeIntegerDivide(
3017 _In_ LARGE_INTEGER Dividend
,
3018 _In_ LARGE_INTEGER Divisor
,
3019 _Out_opt_ PLARGE_INTEGER Remainder
);
3024 #endif /* defined(_AMD64_) || defined(_IA64_) */
3028 #if defined(_AMD64_)
3030 #define MultiplyHigh __mulh
3031 #define UnsignedMultiplyHigh __umulh
3033 //DECLSPEC_DEPRECATED_DDK
3037 RtlExtendedMagicDivide(
3038 _In_ LARGE_INTEGER Dividend
,
3039 _In_ LARGE_INTEGER MagicDivisor
,
3040 _In_ CCHAR ShiftCount
)
3045 Pos
= (Dividend
.QuadPart
>= 0);
3046 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
3047 MagicDivisor
.QuadPart
);
3048 ret64
>>= ShiftCount
;
3049 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
3054 //DECLSPEC_DEPRECATED_DDK
3059 _In_ LARGE_INTEGER Addend1
,
3060 _In_ LARGE_INTEGER Addend2
)
3063 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
3068 * RtlLargeIntegerAnd(
3069 * IN OUT LARGE_INTEGER Result,
3070 * IN LARGE_INTEGER Source,
3071 * IN LARGE_INTEGER Mask);
3073 #define RtlLargeIntegerAnd(Result, Source, Mask) \
3074 Result.QuadPart = Source.QuadPart & Mask.QuadPart
3076 //DECLSPEC_DEPRECATED_DDK
3080 RtlLargeIntegerArithmeticShift(
3081 _In_ LARGE_INTEGER LargeInteger
,
3082 _In_ CCHAR ShiftCount
)
3085 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
3090 * RtlLargeIntegerEqualTo(
3091 * IN LARGE_INTEGER Operand1,
3092 * IN LARGE_INTEGER Operand2);
3094 #define RtlLargeIntegerEqualTo(X,Y) \
3095 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
3099 RtlSecureZeroMemory(
3100 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
3103 volatile char* vptr
= (volatile char*)Pointer
;
3104 #if defined(_M_AMD64)
3105 __stosb((PUCHAR
)vptr
, 0, Size
);
3107 char * endptr
= (char *)vptr
+ Size
;
3108 while (vptr
< endptr
) {
3115 #if defined(_M_AMD64)
3116 _Must_inspect_result_
3120 _In_ PRTL_BITMAP BitMapHeader
,
3121 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3123 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3126 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3127 #endif /* defined(_M_AMD64) */
3129 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3130 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3131 ((X).HighPart > (Y).HighPart) \
3134 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3135 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3136 ((X).HighPart > (Y).HighPart) \
3139 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3140 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3143 #define RtlLargeIntegerLessThan(X,Y) ( \
3144 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3145 ((X).HighPart < (Y).HighPart) \
3148 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3149 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3150 ((X).HighPart < (Y).HighPart) \
3153 #define RtlLargeIntegerGreaterThanZero(X) ( \
3154 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3155 ((X).HighPart > 0 ) \
3158 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3160 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3162 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3164 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3166 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3168 #endif /* !defined(MIDL_PASS) */
3170 /* Byte Swap Functions */
3171 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
3172 ((defined(_M_AMD64) || defined(_M_IA64)) \
3173 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
3175 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3176 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3177 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3183 #define RTL_VERIFY(exp) \
3185 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3187 #define RTL_VERIFYMSG(msg, exp) \
3189 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3191 #define RTL_SOFT_VERIFY(exp) \
3193 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3195 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3197 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3199 /* The ASSERTs must be cast to void to avoid warnings about unused results.
3200 * We also cannot invoke the VERIFY versions because the indirection messes
3201 * with stringify. */
3202 #define ASSERT(exp) \
3203 ((VOID)((!(exp)) ? \
3204 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE))
3206 #define ASSERTMSG(msg, exp) \
3207 ((VOID)((!(exp)) ? \
3208 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE))
3210 #define RTL_SOFT_ASSERT(exp) \
3211 ((VOID)((!(exp)) ? \
3212 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE))
3214 #define RTL_SOFT_ASSERTMSG(msg, exp) \
3215 ((VOID)((!(exp)) ? \
3216 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE))
3218 #if defined(_MSC_VER)
3219 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg)
3220 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg)
3222 # define __assert_annotationA(msg) \
3223 DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg)
3224 # define __assert_annotationW(msg) \
3225 DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg)
3228 #define NT_VERIFY(exp) \
3230 (__assert_annotationA(#exp), \
3231 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3233 #define NT_VERIFYMSG(msg, exp) \
3235 (__assert_annotationA(msg), \
3236 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3238 #define NT_VERIFYMSGW(msg, exp) \
3240 (__assert_annotationW(msg), \
3241 DbgRaiseAssertionFailure(), FALSE) : TRUE)
3243 /* Can't reuse verify, see above */
3244 #define NT_ASSERT(exp) \
3245 ((VOID)((!(exp)) ? \
3246 (__assert_annotationA(#exp), \
3247 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3249 #define NT_ASSERTMSG(msg, exp) \
3250 ((VOID)((!(exp)) ? \
3251 (__assert_annotationA(msg), \
3252 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3254 #define NT_ASSERTMSGW(msg, exp) \
3255 ((VOID)((!(exp)) ? \
3256 (__assert_annotationW(msg), \
3257 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3261 #define ASSERT(exp) ((VOID) 0)
3262 #define ASSERTMSG(msg, exp) ((VOID) 0)
3264 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3265 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3267 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3268 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3270 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3271 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3273 #define NT_ASSERT(exp) ((VOID)0)
3274 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
3275 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
3277 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
3278 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
3279 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
3283 #define InitializeListHead32(ListHead) (\
3284 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3286 #if !defined(_WINBASE_)
3288 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
3292 InitializeSListHead(
3293 _Out_ PSLIST_HEADER SListHead
);
3299 InitializeSListHead(
3300 _Out_ PSLIST_HEADER SListHead
)
3303 ULONG64 FeatureBits
;
3307 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3308 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3311 RtlZeroMemory(SListHead
, sizeof(SLIST_HEADER
));
3313 FeatureBits
= __getReg(CV_IA64_CPUID4
);
3314 if ((FeatureBits
& KF_16BYTE_INSTR
) != 0) {
3315 SListHead
->Header16
.HeaderType
= 1;
3316 SListHead
->Header16
.Init
= 1;
3325 #define InterlockedPopEntrySList(Head) \
3326 ExpInterlockedPopEntrySList(Head)
3328 #define InterlockedPushEntrySList(Head, Entry) \
3329 ExpInterlockedPushEntrySList(Head, Entry)
3331 #define InterlockedFlushSList(Head) \
3332 ExpInterlockedFlushSList(Head)
3334 #define QueryDepthSList(Head) \
3335 ExQueryDepthSList(Head)
3337 #else /* !defined(_WIN64) */
3342 InterlockedPopEntrySList(
3343 _Inout_ PSLIST_HEADER ListHead
);
3348 InterlockedPushEntrySList(
3349 _Inout_ PSLIST_HEADER ListHead
,
3350 _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry
);
3352 #define InterlockedFlushSList(ListHead) \
3353 ExInterlockedFlushSList(ListHead)
3355 #define QueryDepthSList(Head) \
3356 ExQueryDepthSList(Head)
3358 #endif /* !defined(_WIN64) */
3360 #endif /* !defined(_WINBASE_) */
3362 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3363 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3364 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3365 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3366 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3367 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3368 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3369 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3370 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3371 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3372 (PCONTEXT_EX)(Context + 1), \
3376 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3377 _In_ ULONG Version
);
3380 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3381 _In_ ULONG Version
);
3383 #ifndef RtlIsNtDdiVersionAvailable
3384 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3387 #ifndef RtlIsServicePackVersionInstalled
3388 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3391 #define RtlInterlockedSetBits(Flags, Flag) \
3392 InterlockedOr((PLONG)(Flags), Flag)
3394 #define RtlInterlockedAndBits(Flags, Flag) \
3395 InterlockedAnd((PLONG)(Flags), Flag)
3397 #define RtlInterlockedClearBits(Flags, Flag) \
3398 RtlInterlockedAndBits(Flags, ~(Flag))
3400 #define RtlInterlockedXorBits(Flags, Flag) \
3401 InterlockedXor(Flags, Flag)
3403 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3404 (VOID) RtlInterlockedSetBits(Flags, Flag)
3406 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3407 (VOID) RtlInterlockedAndBits(Flags, Flag)
3409 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3410 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3416 #ifdef RTL_USE_AVL_TABLES
3418 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3419 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3420 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3421 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3422 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3423 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3424 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3425 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3426 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3427 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3428 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3430 #endif /* RTL_USE_AVL_TABLES */
3432 #define RtlInitializeSplayLinks(Links) { \
3433 PRTL_SPLAY_LINKS _SplayLinks; \
3434 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3435 _SplayLinks->Parent = _SplayLinks; \
3436 _SplayLinks->LeftChild = NULL; \
3437 _SplayLinks->RightChild = NULL; \
3440 #define RtlIsLeftChild(Links) \
3441 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3443 #define RtlIsRightChild(Links) \
3444 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3446 #define RtlRightChild(Links) \
3447 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3449 #define RtlIsRoot(Links) \
3450 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3452 #define RtlLeftChild(Links) \
3453 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3455 #define RtlParent(Links) \
3456 ((PRTL_SPLAY_LINKS)(Links))->Parent
3458 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3460 PRTL_SPLAY_LINKS _SplayParent; \
3461 PRTL_SPLAY_LINKS _SplayChild; \
3462 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3463 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3464 _SplayParent->LeftChild = _SplayChild; \
3465 _SplayChild->Parent = _SplayParent; \
3468 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3470 PRTL_SPLAY_LINKS _SplayParent; \
3471 PRTL_SPLAY_LINKS _SplayChild; \
3472 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3473 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3474 _SplayParent->RightChild = _SplayChild; \
3475 _SplayChild->Parent = _SplayParent; \
3478 #if !defined(MIDL_PASS)
3483 RtlConvertLongToLuid(
3489 Temp
.QuadPart
= Val
;
3490 Luid
.LowPart
= Temp
.u
.LowPart
;
3491 Luid
.HighPart
= Temp
.u
.HighPart
;
3498 RtlConvertUlongToLuid(
3508 #endif /* !defined(MIDL_PASS) */
3510 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3511 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3512 *CallersAddress = (PVOID)_ReturnAddress(); \
3513 *CallersCaller = NULL;
3515 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3519 RtlGetCallersAddress(
3520 _Out_ PVOID
*CallersAddress
,
3521 _Out_ PVOID
*CallersCaller
);
3525 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3527 #if (NTDDI_VERSION >= NTDDI_WIN7)
3532 RtlInitHashTableContext(
3533 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3535 Context
->ChainHead
= NULL
;
3536 Context
->PrevLinkage
= NULL
;
3542 RtlInitHashTableContextFromEnumerator(
3543 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3544 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3546 Context
->ChainHead
= Enumerator
->ChainHead
;
3547 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3553 RtlReleaseHashTableContext(
3554 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3556 UNREFERENCED_PARAMETER(Context
);
3563 RtlTotalBucketsHashTable(
3564 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3566 return HashTable
->TableSize
;
3572 RtlNonEmptyBucketsHashTable(
3573 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3575 return HashTable
->NonEmptyBuckets
;
3581 RtlEmptyBucketsHashTable(
3582 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3584 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3590 RtlTotalEntriesHashTable(
3591 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3593 return HashTable
->NumEntries
;
3599 RtlActiveEnumeratorsHashTable(
3600 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3602 return HashTable
->NumEnumerators
;
3605 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3607 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3612 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3613 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3615 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3616 RtlxUnicodeStringToOemSize(STRING) : \
3617 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3620 #define RtlOemStringToUnicodeSize(STRING) ( \
3621 NLS_MB_OEM_CODE_PAGE_TAG ? \
3622 RtlxOemStringToUnicodeSize(STRING) : \
3623 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3626 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3627 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3630 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3631 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))