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(EXTRA_KERNEL_LIST_ENTRY_CHECKS) && defined(__REACTOS__)
39 #define EXTRA_KERNEL_LIST_ENTRY_CHECKS
42 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
44 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
49 _Out_ PLIST_ENTRY ListHead
)
51 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
58 _In_
const LIST_ENTRY
* ListHead
)
60 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
65 RemoveEntryListUnsafe(
66 _In_ PLIST_ENTRY Entry
)
71 OldFlink
= Entry
->Flink
;
72 OldBlink
= Entry
->Blink
;
73 OldFlink
->Blink
= OldBlink
;
74 OldBlink
->Flink
= OldFlink
;
75 return (BOOLEAN
)(OldFlink
== OldBlink
);
78 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
86 UNREFERENCED_PARAMETER(P1
);
87 UNREFERENCED_PARAMETER(P2
);
88 UNREFERENCED_PARAMETER(P3
);
90 RtlFailFast(FAST_FAIL_CORRUPT_LIST_ENTRY
);
96 _In_ PLIST_ENTRY Entry
)
98 if (Entry
->Flink
->Blink
!= Entry
|| Entry
->Blink
->Flink
!= Entry
)
99 FatalListEntryError(Entry
->Blink
, Entry
, Entry
->Flink
);
106 _In_ PLIST_ENTRY Entry
)
108 PLIST_ENTRY OldFlink
;
109 PLIST_ENTRY OldBlink
;
111 OldFlink
= Entry
->Flink
;
112 OldBlink
= Entry
->Blink
;
113 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
114 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS
115 if (OldFlink
== Entry
|| OldBlink
== Entry
)
116 FatalListEntryError(OldBlink
, Entry
, OldFlink
);
118 if (OldFlink
->Blink
!= Entry
|| OldBlink
->Flink
!= Entry
)
119 FatalListEntryError(OldBlink
, Entry
, OldFlink
);
121 OldFlink
->Blink
= OldBlink
;
122 OldBlink
->Flink
= OldFlink
;
123 return (BOOLEAN
)(OldFlink
== OldBlink
);
129 _Inout_ PLIST_ENTRY ListHead
)
134 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
135 RtlpCheckListEntry(ListHead
);
136 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS
137 if (ListHead
->Flink
== ListHead
|| ListHead
->Blink
== ListHead
)
138 FatalListEntryError(ListHead
->Blink
, ListHead
, ListHead
->Flink
);
141 Entry
= ListHead
->Flink
;
142 Flink
= Entry
->Flink
;
143 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
144 if (Entry
->Blink
!= ListHead
|| Flink
->Blink
!= Entry
)
145 FatalListEntryError(ListHead
, Entry
, Flink
);
147 ListHead
->Flink
= Flink
;
148 Flink
->Blink
= ListHead
;
155 _Inout_ PLIST_ENTRY ListHead
)
160 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
161 RtlpCheckListEntry(ListHead
);
162 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS
163 if (ListHead
->Flink
== ListHead
|| ListHead
->Blink
== ListHead
)
164 FatalListEntryError(ListHead
->Blink
, ListHead
, ListHead
->Flink
);
167 Entry
= ListHead
->Blink
;
168 Blink
= Entry
->Blink
;
169 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
170 if (Blink
->Flink
!= Entry
|| Entry
->Flink
!= ListHead
)
171 FatalListEntryError(Blink
, Entry
, ListHead
);
173 ListHead
->Blink
= Blink
;
174 Blink
->Flink
= ListHead
;
181 _Inout_ PLIST_ENTRY ListHead
,
182 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
184 PLIST_ENTRY OldBlink
;
185 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
186 RtlpCheckListEntry(ListHead
);
188 OldBlink
= ListHead
->Blink
;
189 Entry
->Flink
= ListHead
;
190 Entry
->Blink
= OldBlink
;
191 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
192 if (OldBlink
->Flink
!= ListHead
)
193 FatalListEntryError(OldBlink
->Blink
, OldBlink
, ListHead
);
195 OldBlink
->Flink
= Entry
;
196 ListHead
->Blink
= Entry
;
202 _Inout_ PLIST_ENTRY ListHead
,
203 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry
)
205 PLIST_ENTRY OldFlink
;
206 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
207 RtlpCheckListEntry(ListHead
);
209 OldFlink
= ListHead
->Flink
;
210 Entry
->Flink
= OldFlink
;
211 Entry
->Blink
= ListHead
;
212 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
213 if (OldFlink
->Blink
!= ListHead
)
214 FatalListEntryError(ListHead
, OldFlink
, OldFlink
->Flink
);
216 OldFlink
->Blink
= Entry
;
217 ListHead
->Flink
= Entry
;
223 _Inout_ PLIST_ENTRY ListHead
,
224 _Inout_ PLIST_ENTRY ListToAppend
)
226 PLIST_ENTRY ListEnd
= ListHead
->Blink
;
228 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
229 RtlpCheckListEntry(ListHead
);
230 RtlpCheckListEntry(ListToAppend
);
232 ListHead
->Blink
->Flink
= ListToAppend
;
233 ListHead
->Blink
= ListToAppend
->Blink
;
234 ListToAppend
->Blink
->Flink
= ListHead
;
235 ListToAppend
->Blink
= ListEnd
;
241 _Inout_ PSINGLE_LIST_ENTRY ListHead
)
243 PSINGLE_LIST_ENTRY FirstEntry
;
244 FirstEntry
= ListHead
->Next
;
245 if (FirstEntry
!= NULL
) {
246 ListHead
->Next
= FirstEntry
->Next
;
254 _Inout_ PSINGLE_LIST_ENTRY ListHead
,
255 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry
)
257 Entry
->Next
= ListHead
->Next
;
258 ListHead
->Next
= Entry
;
261 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
268 _In_ PVOID FailedAssertion
,
270 _In_ ULONG LineNumber
,
271 _In_opt_z_ PSTR Message
);
275 * IN VOID UNALIGNED *Destination,
276 * IN CONST VOID UNALIGNED *Source,
279 #define RtlCopyMemory(Destination, Source, Length) \
280 memcpy(Destination, Source, Length)
282 #define RtlCopyBytes RtlCopyMemory
284 #if defined(_M_AMD64)
288 RtlCopyMemoryNonTemporal(
289 _Out_writes_bytes_all_(Length
) VOID UNALIGNED
*Destination
,
290 _In_reads_bytes_(Length
) const VOID UNALIGNED
*Source
,
293 #define RtlCopyMemoryNonTemporal RtlCopyMemory
301 #define RtlEqualLuid(Luid1, Luid2) \
302 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
306 * IN VOID UNALIGNED *Destination,
307 * IN CONST VOID UNALIGNED *Source,
310 #define RtlEqualMemory(Destination, Source, Length) \
311 (!memcmp(Destination, Source, Length))
315 * IN VOID UNALIGNED *Destination,
319 #define RtlFillMemory(Destination, Length, Fill) \
320 memset(Destination, Fill, Length)
322 #define RtlFillBytes RtlFillMemory
324 _IRQL_requires_max_(PASSIVE_LEVEL
)
328 RtlFreeUnicodeString(
329 _Inout_
_At_(UnicodeString
->Buffer
, __drv_freesMem(Mem
))
330 PUNICODE_STRING UnicodeString
);
332 _IRQL_requires_max_(PASSIVE_LEVEL
)
333 _Must_inspect_result_
338 _In_ PUNICODE_STRING GuidString
,
341 _IRQL_requires_max_(DISPATCH_LEVEL
)
342 _At_(DestinationString
->Buffer
, _Post_equal_to_(SourceString
))
343 _When_(SourceString
!= NULL
,
344 _At_(DestinationString
->Length
, _Post_equal_to_(_String_length_(SourceString
) * sizeof(WCHAR
)))
345 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(DestinationString
->Length
+ sizeof(WCHAR
))))
346 _When_(SourceString
== NULL
,
347 _At_(DestinationString
->Length
, _Post_equal_to_(0))
348 _At_(DestinationString
->MaximumLength
, _Post_equal_to_(0)))
352 RtlInitUnicodeString(
353 _Out_ PUNICODE_STRING DestinationString
,
354 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
358 * IN VOID UNALIGNED *Destination,
359 * IN CONST VOID UNALIGNED *Source,
362 #define RtlMoveMemory(Destination, Source, Length) \
363 memmove(Destination, Source, Length)
365 _IRQL_requires_max_(PASSIVE_LEVEL
)
366 _Must_inspect_result_
372 _Out_
_At_(GuidString
->Buffer
, __drv_allocatesMem(Mem
))
373 PUNICODE_STRING GuidString
);
377 * IN VOID UNALIGNED *Destination,
380 #define RtlZeroMemory(Destination, Length) \
381 memset(Destination, 0, Length)
383 #define RtlZeroBytes RtlZeroMemory
386 #if (NTDDI_VERSION >= NTDDI_WIN2K)
389 _Must_inspect_result_
394 _In_ PRTL_BITMAP BitMapHeader
,
395 _In_ ULONG StartingIndex
,
398 _Must_inspect_result_
403 _In_ PRTL_BITMAP BitMapHeader
,
404 _In_ ULONG StartingIndex
,
407 _IRQL_requires_max_(PASSIVE_LEVEL
)
408 _Must_inspect_result_
412 RtlAnsiStringToUnicodeString(
413 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
414 _When_(!AllocateDestinationString
, _Inout_
)
415 PUNICODE_STRING DestinationString
,
416 _In_ PANSI_STRING SourceString
,
417 _In_ BOOLEAN AllocateDestinationString
);
419 _IRQL_requires_max_(PASSIVE_LEVEL
)
423 RtlxAnsiStringToUnicodeSize(
424 _In_ PCANSI_STRING AnsiString
);
426 #define RtlAnsiStringToUnicodeSize(String) ( \
427 NLS_MB_CODE_PAGE_TAG ? \
428 RtlxAnsiStringToUnicodeSize(String) : \
429 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
433 _Unchanged_(Destination
->MaximumLength
)
434 _Unchanged_(Destination
->Buffer
)
435 _When_(_Old_(Destination
->Length
) + Source
->Length
<= Destination
->MaximumLength
,
436 _At_(Destination
->Length
, _Post_equal_to_(_Old_(Destination
->Length
) + Source
->Length
))
437 _At_(return, _Out_range_(==, 0)))
438 _When_(_Old_(Destination
->Length
) + Source
->Length
> Destination
->MaximumLength
,
439 _Unchanged_(Destination
->Length
)
440 _At_(return, _Out_range_(<, 0)))
444 RtlAppendUnicodeStringToString(
445 _Inout_ PUNICODE_STRING Destination
,
446 _In_ PCUNICODE_STRING Source
);
449 _Unchanged_(Destination
->MaximumLength
)
450 _Unchanged_(Destination
->Buffer
)
451 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength,
452 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR)))
453 _At_(return, _Out_range_(==, 0)))
454 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength,
455 _Unchanged_(Destination->Length)
456 _At_(return, _Out_range_(<, 0))) */
460 RtlAppendUnicodeToString(
461 _Inout_ PUNICODE_STRING Destination
,
462 _In_opt_z_ PCWSTR Source
);
464 _IRQL_requires_max_(PASSIVE_LEVEL
)
465 _Must_inspect_result_
470 _In_ ULONG RelativeTo
,
477 _In_ PRTL_BITMAP BitMapHeader
);
483 _In_ PRTL_BITMAP BitMapHeader
,
484 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToClear
) ULONG StartingIndex
,
485 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToClear
);
487 _Must_inspect_result_
492 _In_
const VOID
*Source1
,
493 _In_
const VOID
*Source2
,
496 _IRQL_requires_max_(PASSIVE_LEVEL
)
497 _Must_inspect_result_
501 RtlCompareUnicodeString(
502 _In_ PCUNICODE_STRING String1
,
503 _In_ PCUNICODE_STRING String2
,
504 _In_ BOOLEAN CaseInSensitive
);
506 _IRQL_requires_max_(PASSIVE_LEVEL
)
507 _Must_inspect_result_
511 RtlCompareUnicodeStrings(
512 _In_reads_(String1Length
) PCWCH String1
,
513 _In_ SIZE_T String1Length
,
514 _In_reads_(String2Length
) PCWCH String2
,
515 _In_ SIZE_T String2Length
,
516 _In_ BOOLEAN CaseInSensitive
);
518 _Unchanged_(DestinationString
->Buffer
)
519 _Unchanged_(DestinationString
->MaximumLength
)
520 _At_(DestinationString
->Length
,
521 _When_(SourceString
->Length
> DestinationString
->MaximumLength
,
522 _Post_equal_to_(DestinationString
->MaximumLength
))
523 _When_(SourceString
->Length
<= DestinationString
->MaximumLength
,
524 _Post_equal_to_(SourceString
->Length
)))
528 RtlCopyUnicodeString(
529 _Inout_ PUNICODE_STRING DestinationString
,
530 _In_opt_ PCUNICODE_STRING SourceString
);
532 _IRQL_requires_max_(PASSIVE_LEVEL
)
536 RtlCreateRegistryKey(
537 _In_ ULONG RelativeTo
,
540 _IRQL_requires_max_(APC_LEVEL
)
544 RtlCreateSecurityDescriptor(
545 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
546 _In_ ULONG Revision
);
548 _IRQL_requires_max_(PASSIVE_LEVEL
)
552 RtlDeleteRegistryValue(
553 _In_ ULONG RelativeTo
,
555 _In_z_ PCWSTR ValueName
);
557 _IRQL_requires_max_(PASSIVE_LEVEL
)
558 _Must_inspect_result_
562 RtlEqualUnicodeString(
563 _In_ CONST UNICODE_STRING
*String1
,
564 _In_ CONST UNICODE_STRING
*String2
,
565 _In_ BOOLEAN CaseInSensitive
);
567 #if !defined(_AMD64_) && !defined(_IA64_)
571 RtlExtendedIntegerMultiply(
572 _In_ LARGE_INTEGER Multiplicand
,
573 _In_ LONG Multiplier
);
578 RtlExtendedLargeIntegerDivide(
579 _In_ LARGE_INTEGER Dividend
,
581 _Out_opt_ PULONG Remainder
);
584 #if defined(_X86_) || defined(_IA64_)
588 RtlExtendedMagicDivide(
589 _In_ LARGE_INTEGER Dividend
,
590 _In_ LARGE_INTEGER MagicDivisor
,
591 _In_ CCHAR ShiftCount
);
594 _IRQL_requires_max_(PASSIVE_LEVEL
)
599 _Inout_
_At_(AnsiString
->Buffer
, __drv_freesMem(Mem
))
600 PANSI_STRING AnsiString
);
602 _Success_(return != -1)
603 _Must_inspect_result_
608 _In_ PRTL_BITMAP BitMapHeader
,
609 _In_ ULONG NumberToFind
,
610 _In_ ULONG HintIndex
);
612 _Success_(return != -1)
616 RtlFindClearBitsAndSet(
617 _In_ PRTL_BITMAP BitMapHeader
,
618 _In_ ULONG NumberToFind
,
619 _In_ ULONG HintIndex
);
624 RtlFindFirstRunClear(
625 _In_ PRTL_BITMAP BitMapHeader
,
626 _Out_ PULONG StartingIndex
);
632 _In_ PRTL_BITMAP BitMapHeader
,
633 _Out_writes_to_(SizeOfRunArray
, return) PRTL_BITMAP_RUN RunArray
,
634 _In_range_(>, 0) ULONG SizeOfRunArray
,
635 _In_ BOOLEAN LocateLongestRuns
);
640 RtlFindLastBackwardRunClear(
641 _In_ PRTL_BITMAP BitMapHeader
,
642 _In_ ULONG FromIndex
,
643 _Out_ PULONG StartingRunIndex
);
645 _Success_(return != -1)
646 _Must_inspect_result_
650 RtlFindLeastSignificantBit(
656 RtlFindLongestRunClear(
657 _In_ PRTL_BITMAP BitMapHeader
,
658 _Out_ PULONG StartingIndex
);
660 _Success_(return != -1)
661 _Must_inspect_result_
665 RtlFindMostSignificantBit(
671 RtlFindNextForwardRunClear(
672 _In_ PRTL_BITMAP BitMapHeader
,
673 _In_ ULONG FromIndex
,
674 _Out_ PULONG StartingRunIndex
);
676 _Success_(return != -1)
677 _Must_inspect_result_
682 _In_ PRTL_BITMAP BitMapHeader
,
683 _In_ ULONG NumberToFind
,
684 _In_ ULONG HintIndex
);
686 _Success_(return != -1)
690 RtlFindSetBitsAndClear(
691 _In_ PRTL_BITMAP BitMapHeader
,
692 _In_ ULONG NumberToFind
,
693 _In_ ULONG HintIndex
);
695 _IRQL_requires_max_(DISPATCH_LEVEL
)
700 _Out_ PANSI_STRING DestinationString
,
701 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
703 _At_(BitMapHeader
->SizeOfBitMap
, _Post_equal_to_(SizeOfBitMap
))
704 _At_(BitMapHeader
->Buffer
, _Post_equal_to_(BitMapBuffer
))
709 _Out_ PRTL_BITMAP BitMapHeader
,
710 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer
,
711 _In_opt_ ULONG SizeOfBitMap
);
713 _IRQL_requires_max_(DISPATCH_LEVEL
)
718 _Out_ PSTRING DestinationString
,
719 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
721 _IRQL_requires_max_(PASSIVE_LEVEL
)
722 _At_(String
->MaximumLength
, _Const_
)
726 RtlIntegerToUnicodeString(
729 _Inout_ PUNICODE_STRING String
);
731 _IRQL_requires_max_(PASSIVE_LEVEL
)
732 _At_(String
->MaximumLength
, _Const_
)
736 RtlInt64ToUnicodeString(
737 _In_ ULONGLONG Value
,
739 _Inout_ PUNICODE_STRING String
);
742 #define RtlIntPtrToUnicodeString(Value, Base, String) \
743 RtlInt64ToUnicodeString(Value, Base, String)
745 #define RtlIntPtrToUnicodeString(Value, Base, String) \
746 RtlIntegerToUnicodeString(Value, Base, String)
753 #define RtlIsZeroLuid(_L1) \
754 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
756 _IRQL_requires_max_(APC_LEVEL
)
760 RtlLengthSecurityDescriptor(
761 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
766 RtlNumberOfClearBits(
767 _In_ PRTL_BITMAP BitMapHeader
);
773 _In_ PRTL_BITMAP BitMapHeader
);
775 _IRQL_requires_max_(PASSIVE_LEVEL
)
779 RtlQueryRegistryValues(
780 _In_ ULONG RelativeTo
,
782 _Inout_
_At_(*(*QueryTable
).EntryContext
, _Pre_unknown_
)
783 PRTL_QUERY_REGISTRY_TABLE QueryTable
,
784 _In_opt_ PVOID Context
,
785 _In_opt_ PVOID Environment
);
787 #define SHORT_SIZE (sizeof(USHORT))
788 #define SHORT_MASK (SHORT_SIZE - 1)
789 #define LONG_SIZE (sizeof(LONG))
790 #define LONGLONG_SIZE (sizeof(LONGLONG))
791 #define LONG_MASK (LONG_SIZE - 1)
792 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
793 #define LOWBYTE_MASK 0x00FF
795 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
796 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
797 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
798 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
804 _In_ PRTL_BITMAP BitMapHeader
);
810 _In_ PRTL_BITMAP BitMapHeader
,
811 _In_range_(0, BitMapHeader
->SizeOfBitMap
- NumberToSet
) ULONG StartingIndex
,
812 _In_range_(0, BitMapHeader
->SizeOfBitMap
- StartingIndex
) ULONG NumberToSet
);
814 _IRQL_requires_max_(APC_LEVEL
)
818 RtlSetDaclSecurityDescriptor(
819 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
820 _In_ BOOLEAN DaclPresent
,
822 _In_opt_ BOOLEAN DaclDefaulted
);
831 #define RtlStoreUlong(Address,Value) \
832 *(ULONG UNALIGNED *)(Address) = (Value)
836 * IN OUT PULONGLONG Address,
839 #define RtlStoreUlonglong(Address,Value) \
840 *(ULONGLONG UNALIGNED *)(Address) = (Value)
844 * IN PUSHORT Address,
847 #define RtlStoreUshort(Address,Value) \
848 *(USHORT UNALIGNED *)(Address) = (Value)
852 * PUSHORT DestinationAddress,
853 * PUSHORT SourceAddress);
855 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
856 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
860 * PULONG DestinationAddress,
861 * PULONG SourceAddress);
863 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
864 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
868 #define RtlStoreUlong(Address,Value) \
869 if ((ULONG_PTR)(Address) & LONG_MASK) { \
870 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
871 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
872 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
873 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
876 *((PULONG)(Address)) = (ULONG) (Value); \
879 #define RtlStoreUlonglong(Address,Value) \
880 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
881 RtlStoreUlong((ULONG_PTR)(Address), \
882 (ULONGLONG)(Value) & 0xFFFFFFFF); \
883 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
884 (ULONGLONG)(Value) >> 32); \
886 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
889 #define RtlStoreUshort(Address,Value) \
890 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
891 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
892 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
895 *((PUSHORT) (Address)) = (USHORT)Value; \
898 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
899 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
901 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
902 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
906 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
909 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
910 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
912 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
913 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
914 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
915 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
919 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
922 #endif /* defined(_AMD64_) */
927 * IN OUT PULONG_PTR Address,
928 * IN ULONG_PTR Value);
930 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
932 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
935 _Success_(return!=FALSE
)
936 _Must_inspect_result_
941 _In_ PTIME_FIELDS TimeFields
,
942 _Out_ PLARGE_INTEGER Time
);
948 _In_ PLARGE_INTEGER Time
,
949 _Out_ PTIME_FIELDS TimeFields
);
966 RtlUlonglongByteSwap(
967 _In_ ULONGLONG Source
);
969 _When_(AllocateDestinationString
,
970 _At_(DestinationString
->MaximumLength
,
971 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
972 _When_(!AllocateDestinationString
,
973 _At_(DestinationString
->Buffer
, _Const_
)
974 _At_(DestinationString
->MaximumLength
, _Const_
))
975 _IRQL_requires_max_(PASSIVE_LEVEL
)
976 _When_(AllocateDestinationString
, _Must_inspect_result_
)
980 RtlUnicodeStringToAnsiString(
981 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
982 _When_(!AllocateDestinationString
, _Inout_
)
983 PANSI_STRING DestinationString
,
984 _In_ PCUNICODE_STRING SourceString
,
985 _In_ BOOLEAN AllocateDestinationString
);
987 _IRQL_requires_max_(PASSIVE_LEVEL
)
988 _Must_inspect_result_
992 RtlUpcaseUnicodeStringToAnsiString(
993 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
994 _When_(!AllocateDestinationString
, _Inout_
)
995 PANSI_STRING DestinationString
,
996 _In_ PCUNICODE_STRING SourceString
,
997 _In_ BOOLEAN AllocateDestinationString
);
999 _IRQL_requires_max_(PASSIVE_LEVEL
)
1003 RtlxUnicodeStringToAnsiSize(
1004 _In_ PCUNICODE_STRING UnicodeString
);
1006 #define RtlUnicodeStringToAnsiSize(String) ( \
1007 NLS_MB_CODE_PAGE_TAG ? \
1008 RtlxUnicodeStringToAnsiSize(String) : \
1009 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1012 _IRQL_requires_max_(PASSIVE_LEVEL
)
1016 RtlUnicodeStringToInteger(
1017 _In_ PCUNICODE_STRING String
,
1018 _In_opt_ ULONG Base
,
1019 _Out_ PULONG Value
);
1021 _IRQL_requires_max_(PASSIVE_LEVEL
)
1025 RtlUpcaseUnicodeChar(
1026 _In_ WCHAR SourceCharacter
);
1028 _IRQL_requires_max_(APC_LEVEL
)
1029 _Must_inspect_result_
1033 RtlValidRelativeSecurityDescriptor(
1034 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1035 _In_ ULONG SecurityDescriptorLength
,
1036 _In_ SECURITY_INFORMATION RequiredInformation
);
1038 _IRQL_requires_max_(APC_LEVEL
)
1039 _Must_inspect_result_
1043 RtlValidSecurityDescriptor(
1044 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
1046 _IRQL_requires_max_(PASSIVE_LEVEL
)
1052 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
1053 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
1054 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
1055 PRTL_OSVERSIONINFOW lpVersionInformation
);
1057 _IRQL_requires_max_(PASSIVE_LEVEL
)
1058 _Must_inspect_result_
1062 RtlVerifyVersionInfo(
1063 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
1064 _In_ ULONG TypeMask
,
1065 _In_ ULONGLONG ConditionMask
);
1067 _IRQL_requires_max_(PASSIVE_LEVEL
)
1071 RtlWriteRegistryValue(
1072 _In_ ULONG RelativeTo
,
1074 _In_z_ PCWSTR ValueName
,
1075 _In_ ULONG ValueType
,
1076 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
1077 _In_ ULONG ValueLength
);
1082 #ifndef RTL_USE_AVL_TABLES
1087 RtlInitializeGenericTable(
1088 _Out_ PRTL_GENERIC_TABLE Table
,
1089 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
1090 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
1091 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
1092 _In_opt_ PVOID TableContext
);
1097 RtlInsertElementGenericTable(
1098 _In_ PRTL_GENERIC_TABLE Table
,
1099 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1100 _In_ CLONG BufferSize
,
1101 _Out_opt_ PBOOLEAN NewElement
);
1106 RtlInsertElementGenericTableFull(
1107 _In_ PRTL_GENERIC_TABLE Table
,
1108 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1109 _In_ CLONG BufferSize
,
1110 _Out_opt_ PBOOLEAN NewElement
,
1111 _In_ PVOID NodeOrParent
,
1112 _In_ TABLE_SEARCH_RESULT SearchResult
);
1117 RtlDeleteElementGenericTable(
1118 _In_ PRTL_GENERIC_TABLE Table
,
1121 _Must_inspect_result_
1125 RtlLookupElementGenericTable(
1126 _In_ PRTL_GENERIC_TABLE Table
,
1132 RtlLookupElementGenericTableFull(
1133 _In_ PRTL_GENERIC_TABLE Table
,
1135 _Out_ PVOID
*NodeOrParent
,
1136 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1138 _Must_inspect_result_
1142 RtlEnumerateGenericTable(
1143 _In_ PRTL_GENERIC_TABLE Table
,
1144 _In_ BOOLEAN Restart
);
1146 _Must_inspect_result_
1150 RtlEnumerateGenericTableWithoutSplaying(
1151 _In_ PRTL_GENERIC_TABLE Table
,
1152 _Inout_ PVOID
*RestartKey
);
1154 _Must_inspect_result_
1158 RtlGetElementGenericTable(
1159 _In_ PRTL_GENERIC_TABLE Table
,
1165 RtlNumberGenericTableElements(
1166 _In_ PRTL_GENERIC_TABLE Table
);
1168 _Must_inspect_result_
1172 RtlIsGenericTableEmpty(
1173 _In_ PRTL_GENERIC_TABLE Table
);
1175 #endif /* !RTL_USE_AVL_TABLES */
1177 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1183 _Inout_ PRTL_SPLAY_LINKS Links
);
1189 _In_ PRTL_SPLAY_LINKS Links
);
1195 _In_ PRTL_SPLAY_LINKS Links
,
1196 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1198 _Must_inspect_result_
1202 RtlSubtreeSuccessor(
1203 _In_ PRTL_SPLAY_LINKS Links
);
1205 _Must_inspect_result_
1209 RtlSubtreePredecessor(
1210 _In_ PRTL_SPLAY_LINKS Links
);
1212 _Must_inspect_result_
1217 _In_ PRTL_SPLAY_LINKS Links
);
1219 _Must_inspect_result_
1224 _In_ PRTL_SPLAY_LINKS Links
);
1226 _IRQL_requires_max_(PASSIVE_LEVEL
)
1227 _Must_inspect_result_
1231 RtlPrefixUnicodeString(
1232 _In_ PCUNICODE_STRING String1
,
1233 _In_ PCUNICODE_STRING String2
,
1234 _In_ BOOLEAN CaseInSensitive
);
1236 _IRQL_requires_max_(PASSIVE_LEVEL
)
1241 _Inout_ PSTRING DestinationString
,
1242 _In_
const STRING
*SourceString
);
1244 _IRQL_requires_max_(PASSIVE_LEVEL
)
1245 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1249 RtlUpcaseUnicodeString(
1250 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1251 _When_(!AllocateDestinationString
, _Inout_
)
1252 PUNICODE_STRING DestinationString
,
1253 _In_ PCUNICODE_STRING SourceString
,
1254 _In_ BOOLEAN AllocateDestinationString
);
1256 _IRQL_requires_max_(APC_LEVEL
)
1261 _Inout_ PACCESS_MASK AccessMask
,
1262 _In_ PGENERIC_MAPPING GenericMapping
);
1264 _IRQL_requires_max_(PASSIVE_LEVEL
)
1268 RtlVolumeDeviceToDosName(
1269 _In_ PVOID VolumeDeviceObject
,
1270 _Out_ PUNICODE_STRING DosName
);
1272 _IRQL_requires_max_(PASSIVE_LEVEL
)
1273 _Must_inspect_result_
1278 _In_
const STRING
*String1
,
1279 _In_
const STRING
*String2
,
1280 _In_ BOOLEAN CaseInSensitive
);
1286 _Out_ PSTRING DestinationString
,
1287 _In_opt_
const STRING
*SourceString
);
1289 _IRQL_requires_max_(PASSIVE_LEVEL
)
1290 _Must_inspect_result_
1295 _In_
const STRING
*String1
,
1296 _In_
const STRING
*String2
,
1297 _In_ BOOLEAN CaseInSensitive
);
1299 _IRQL_requires_max_(PASSIVE_LEVEL
)
1305 _In_opt_ ULONG Base
,
1306 _Out_ PULONG Value
);
1308 _IRQL_requires_max_(PASSIVE_LEVEL
)
1313 _In_ CHAR Character
);
1319 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1327 _Must_inspect_result_
1329 _Post_writable_byte_size_(Size
)
1334 _In_ HANDLE HeapHandle
,
1335 _In_opt_ ULONG Flags
,
1338 _Success_(return != 0)
1343 _In_ PVOID HeapHandle
,
1344 _In_opt_ ULONG Flags
,
1345 _In_ _Post_invalid_ PVOID BaseAddress
);
1351 _Out_ PCONTEXT ContextRecord
);
1353 _Ret_range_(<, MAXLONG
)
1358 _Inout_ PULONG Seed
);
1360 _IRQL_requires_max_(APC_LEVEL
)
1361 _Success_(return != 0)
1362 _Must_inspect_result_
1366 RtlCreateUnicodeString(
1367 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1368 PUNICODE_STRING DestinationString
,
1369 _In_z_ PCWSTR SourceString
);
1371 _IRQL_requires_max_(PASSIVE_LEVEL
)
1372 _Must_inspect_result_
1377 _In_
const STRING
*String1
,
1378 _In_
const STRING
*String2
,
1379 _In_ BOOLEAN CaseInsensitive
);
1381 _IRQL_requires_max_(APC_LEVEL
)
1385 RtlAppendStringToString(
1386 _Inout_ PSTRING Destination
,
1387 _In_
const STRING
*Source
);
1389 _IRQL_requires_max_(PASSIVE_LEVEL
)
1390 _Must_inspect_result_
1394 RtlOemStringToUnicodeString(
1395 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1396 _When_(!AllocateDestinationString
, _Inout_
)
1397 PUNICODE_STRING DestinationString
,
1398 _In_ PCOEM_STRING SourceString
,
1399 _In_ BOOLEAN AllocateDestinationString
);
1401 _IRQL_requires_max_(PASSIVE_LEVEL
)
1402 _Must_inspect_result_
1406 RtlUnicodeStringToOemString(
1407 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1408 _When_(!AllocateDestinationString
, _Inout_
)
1409 POEM_STRING DestinationString
,
1410 _In_ PCUNICODE_STRING SourceString
,
1411 _In_ BOOLEAN AllocateDestinationString
);
1413 _IRQL_requires_max_(PASSIVE_LEVEL
)
1414 _Must_inspect_result_
1418 RtlUpcaseUnicodeStringToOemString(
1419 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1420 _When_(!AllocateDestinationString
, _Inout_
)
1421 POEM_STRING DestinationString
,
1422 _In_ PCUNICODE_STRING SourceString
,
1423 _In_ BOOLEAN AllocateDestinationString
);
1425 _IRQL_requires_max_(PASSIVE_LEVEL
)
1426 _Must_inspect_result_
1430 RtlOemStringToCountedUnicodeString(
1431 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1432 _When_(!AllocateDestinationString
, _Inout_
)
1433 PUNICODE_STRING DestinationString
,
1434 _In_ PCOEM_STRING SourceString
,
1435 _In_ BOOLEAN AllocateDestinationString
);
1437 _IRQL_requires_max_(PASSIVE_LEVEL
)
1438 _Must_inspect_result_
1442 RtlUnicodeStringToCountedOemString(
1443 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1444 _When_(!AllocateDestinationString
, _Inout_
)
1445 POEM_STRING DestinationString
,
1446 _In_ PCUNICODE_STRING SourceString
,
1447 _In_ BOOLEAN AllocateDestinationString
);
1449 _IRQL_requires_max_(PASSIVE_LEVEL
)
1450 _Must_inspect_result_
1454 RtlUpcaseUnicodeStringToCountedOemString(
1455 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1456 _When_(!AllocateDestinationString
, _Inout_
)
1457 POEM_STRING DestinationString
,
1458 _In_ PCUNICODE_STRING SourceString
,
1459 _In_ BOOLEAN AllocateDestinationString
);
1461 _IRQL_requires_max_(PASSIVE_LEVEL
)
1462 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1466 RtlDowncaseUnicodeString(
1467 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1468 _When_(!AllocateDestinationString
, _Inout_
)
1469 PUNICODE_STRING UniDest
,
1470 _In_ PCUNICODE_STRING UniSource
,
1471 _In_ BOOLEAN AllocateDestinationString
);
1473 _IRQL_requires_max_(PASSIVE_LEVEL
)
1478 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1480 _IRQL_requires_max_(PASSIVE_LEVEL
)
1484 RtlxUnicodeStringToOemSize(
1485 _In_ PCUNICODE_STRING UnicodeString
);
1487 _IRQL_requires_max_(PASSIVE_LEVEL
)
1491 RtlxOemStringToUnicodeSize(
1492 _In_ PCOEM_STRING OemString
);
1494 _IRQL_requires_max_(PASSIVE_LEVEL
)
1498 RtlMultiByteToUnicodeN(
1499 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1500 _In_ ULONG MaxBytesInUnicodeString
,
1501 _Out_opt_ PULONG BytesInUnicodeString
,
1502 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1503 _In_ ULONG BytesInMultiByteString
);
1505 _IRQL_requires_max_(PASSIVE_LEVEL
)
1509 RtlMultiByteToUnicodeSize(
1510 _Out_ PULONG BytesInUnicodeString
,
1511 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1512 _In_ ULONG BytesInMultiByteString
);
1514 _IRQL_requires_max_(PASSIVE_LEVEL
)
1518 RtlUnicodeToMultiByteSize(
1519 _Out_ PULONG BytesInMultiByteString
,
1520 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1521 _In_ ULONG BytesInUnicodeString
);
1523 _IRQL_requires_max_(PASSIVE_LEVEL
)
1527 RtlUnicodeToMultiByteN(
1528 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1529 _In_ ULONG MaxBytesInMultiByteString
,
1530 _Out_opt_ PULONG BytesInMultiByteString
,
1531 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1532 _In_ ULONG BytesInUnicodeString
);
1534 _IRQL_requires_max_(PASSIVE_LEVEL
)
1538 RtlUpcaseUnicodeToMultiByteN(
1539 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1540 _In_ ULONG MaxBytesInMultiByteString
,
1541 _Out_opt_ PULONG BytesInMultiByteString
,
1542 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1543 _In_ ULONG BytesInUnicodeString
);
1545 _IRQL_requires_max_(PASSIVE_LEVEL
)
1550 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1551 _In_ ULONG MaxBytesInUnicodeString
,
1552 _Out_opt_ PULONG BytesInUnicodeString
,
1553 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1554 _In_ ULONG BytesInOemString
);
1556 _IRQL_requires_max_(PASSIVE_LEVEL
)
1561 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1562 _In_ ULONG MaxBytesInOemString
,
1563 _Out_opt_ PULONG BytesInOemString
,
1564 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1565 _In_ ULONG BytesInUnicodeString
);
1567 _IRQL_requires_max_(PASSIVE_LEVEL
)
1571 RtlUpcaseUnicodeToOemN(
1572 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1573 _In_ ULONG MaxBytesInOemString
,
1574 _Out_opt_ PULONG BytesInOemString
,
1575 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1576 _In_ ULONG BytesInUnicodeString
);
1578 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1579 _IRQL_requires_max_(PASSIVE_LEVEL
)
1583 RtlGenerate8dot3Name(
1584 _In_ PCUNICODE_STRING Name
,
1585 _In_ BOOLEAN AllowExtendedCharacters
,
1586 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1587 _Inout_ PUNICODE_STRING Name8dot3
);
1589 _IRQL_requires_max_(PASSIVE_LEVEL
)
1593 RtlGenerate8dot3Name(
1594 _In_ PCUNICODE_STRING Name
,
1595 _In_ BOOLEAN AllowExtendedCharacters
,
1596 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1597 _Inout_ PUNICODE_STRING Name8dot3
);
1600 _IRQL_requires_max_(PASSIVE_LEVEL
)
1601 _Must_inspect_result_
1605 RtlIsNameLegalDOS8Dot3(
1606 _In_ PCUNICODE_STRING Name
,
1607 _Inout_opt_ POEM_STRING OemName
,
1608 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1610 _IRQL_requires_max_(PASSIVE_LEVEL
)
1611 _Must_inspect_result_
1615 RtlIsValidOemCharacter(
1616 _Inout_ PWCHAR Char
);
1618 _IRQL_requires_max_(PASSIVE_LEVEL
)
1623 _Out_ PPREFIX_TABLE PrefixTable
);
1625 _IRQL_requires_max_(PASSIVE_LEVEL
)
1630 _In_ PPREFIX_TABLE PrefixTable
,
1631 _In_ __drv_aliasesMem PSTRING Prefix
,
1632 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1634 _IRQL_requires_max_(PASSIVE_LEVEL
)
1639 _In_ PPREFIX_TABLE PrefixTable
,
1640 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1642 _IRQL_requires_max_(PASSIVE_LEVEL
)
1643 _Must_inspect_result_
1648 _In_ PPREFIX_TABLE PrefixTable
,
1649 _In_ PSTRING FullName
);
1651 _IRQL_requires_max_(PASSIVE_LEVEL
)
1655 RtlInitializeUnicodePrefix(
1656 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1658 _IRQL_requires_max_(PASSIVE_LEVEL
)
1662 RtlInsertUnicodePrefix(
1663 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1664 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1665 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1667 _IRQL_requires_max_(PASSIVE_LEVEL
)
1671 RtlRemoveUnicodePrefix(
1672 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1673 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1675 _IRQL_requires_max_(PASSIVE_LEVEL
)
1676 _Must_inspect_result_
1678 PUNICODE_PREFIX_TABLE_ENTRY
1680 RtlFindUnicodePrefix(
1681 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1682 _In_ PUNICODE_STRING FullName
,
1683 _In_ ULONG CaseInsensitiveIndex
);
1685 _IRQL_requires_max_(PASSIVE_LEVEL
)
1686 _Must_inspect_result_
1688 PUNICODE_PREFIX_TABLE_ENTRY
1690 RtlNextUnicodePrefix(
1691 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1692 _In_ BOOLEAN Restart
);
1694 _Must_inspect_result_
1698 RtlCompareMemoryUlong(
1699 _In_reads_bytes_(Length
) PVOID Source
,
1701 _In_ ULONG Pattern
);
1703 _Success_(return != 0)
1707 RtlTimeToSecondsSince1980(
1708 _In_ PLARGE_INTEGER Time
,
1709 _Out_ PULONG ElapsedSeconds
);
1714 RtlSecondsSince1980ToTime(
1715 _In_ ULONG ElapsedSeconds
,
1716 _Out_ PLARGE_INTEGER Time
);
1718 _Success_(return != 0)
1719 _Must_inspect_result_
1723 RtlTimeToSecondsSince1970(
1724 _In_ PLARGE_INTEGER Time
,
1725 _Out_ PULONG ElapsedSeconds
);
1730 RtlSecondsSince1970ToTime(
1731 _In_ ULONG ElapsedSeconds
,
1732 _Out_ PLARGE_INTEGER Time
);
1734 _IRQL_requires_max_(APC_LEVEL
)
1735 _Must_inspect_result_
1742 _Must_inspect_result_
1750 _IRQL_requires_max_(APC_LEVEL
)
1751 _Must_inspect_result_
1759 _IRQL_requires_max_(APC_LEVEL
)
1763 RtlLengthRequiredSid(
1764 _In_ ULONG SubAuthorityCount
);
1770 _In_ _Post_invalid_ PSID Sid
);
1772 _Must_inspect_result_
1776 RtlAllocateAndInitializeSid(
1777 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1778 _In_ UCHAR SubAuthorityCount
,
1779 _In_ ULONG SubAuthority0
,
1780 _In_ ULONG SubAuthority1
,
1781 _In_ ULONG SubAuthority2
,
1782 _In_ ULONG SubAuthority3
,
1783 _In_ ULONG SubAuthority4
,
1784 _In_ ULONG SubAuthority5
,
1785 _In_ ULONG SubAuthority6
,
1786 _In_ ULONG SubAuthority7
,
1787 _Outptr_ PSID
*Sid
);
1789 _IRQL_requires_max_(APC_LEVEL
)
1795 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1796 _In_ UCHAR SubAuthorityCount
);
1803 _In_ ULONG SubAuthority
);
1805 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1812 _IRQL_requires_max_(APC_LEVEL
)
1817 _In_ ULONG DestinationSidLength
,
1818 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1819 _In_ PSID SourceSid
);
1821 _IRQL_requires_max_(APC_LEVEL
)
1825 RtlConvertSidToUnicodeString(
1826 _Inout_ PUNICODE_STRING UnicodeString
,
1828 _In_ BOOLEAN AllocateDestinationString
);
1830 _IRQL_requires_max_(APC_LEVEL
)
1835 _Out_ PLUID DestinationLuid
,
1836 _In_ PLUID SourceLuid
);
1838 _IRQL_requires_max_(APC_LEVEL
)
1843 _Out_writes_bytes_(AclLength
) PACL Acl
,
1844 _In_ ULONG AclLength
,
1845 _In_ ULONG AclRevision
);
1847 _IRQL_requires_max_(APC_LEVEL
)
1853 _In_ ULONG AceRevision
,
1854 _In_ ULONG StartingAceIndex
,
1855 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1856 _In_ ULONG AceListLength
);
1858 _IRQL_requires_max_(APC_LEVEL
)
1864 _In_ ULONG AceIndex
);
1871 _In_ ULONG AceIndex
,
1872 _Outptr_ PVOID
*Ace
);
1874 _IRQL_requires_max_(APC_LEVEL
)
1878 RtlAddAccessAllowedAce(
1880 _In_ ULONG AceRevision
,
1881 _In_ ACCESS_MASK AccessMask
,
1884 _IRQL_requires_max_(APC_LEVEL
)
1888 RtlAddAccessAllowedAceEx(
1890 _In_ ULONG AceRevision
,
1891 _In_ ULONG AceFlags
,
1892 _In_ ACCESS_MASK AccessMask
,
1895 _IRQL_requires_max_(APC_LEVEL
)
1899 RtlCreateSecurityDescriptorRelative(
1900 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1901 _In_ ULONG Revision
);
1906 RtlGetDaclSecurityDescriptor(
1907 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1908 _Out_ PBOOLEAN DaclPresent
,
1910 _Out_ PBOOLEAN DaclDefaulted
);
1912 _IRQL_requires_max_(APC_LEVEL
)
1916 RtlSetOwnerSecurityDescriptor(
1917 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1918 _In_opt_ PSID Owner
,
1919 _In_opt_ BOOLEAN OwnerDefaulted
);
1921 _IRQL_requires_max_(APC_LEVEL
)
1925 RtlGetOwnerSecurityDescriptor(
1926 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1928 _Out_ PBOOLEAN OwnerDefaulted
);
1930 _IRQL_requires_max_(APC_LEVEL
)
1931 _When_(Status
< 0, _Out_range_(>, 0))
1932 _When_(Status
>= 0, _Out_range_(==, 0))
1936 RtlNtStatusToDosError(
1937 _In_ NTSTATUS Status
);
1939 _IRQL_requires_max_(PASSIVE_LEVEL
)
1943 RtlCustomCPToUnicodeN(
1944 _In_ PCPTABLEINFO CustomCP
,
1945 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1946 _In_ ULONG MaxBytesInUnicodeString
,
1947 _Out_opt_ PULONG BytesInUnicodeString
,
1948 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1949 _In_ ULONG BytesInCustomCPString
);
1951 _IRQL_requires_max_(PASSIVE_LEVEL
)
1955 RtlUnicodeToCustomCPN(
1956 _In_ PCPTABLEINFO CustomCP
,
1957 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1958 _In_ ULONG MaxBytesInCustomCPString
,
1959 _Out_opt_ PULONG BytesInCustomCPString
,
1960 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1961 _In_ ULONG BytesInUnicodeString
);
1963 _IRQL_requires_max_(PASSIVE_LEVEL
)
1967 RtlUpcaseUnicodeToCustomCPN(
1968 _In_ PCPTABLEINFO CustomCP
,
1969 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1970 _In_ ULONG MaxBytesInCustomCPString
,
1971 _Out_opt_ PULONG BytesInCustomCPString
,
1972 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1973 _In_ ULONG BytesInUnicodeString
);
1975 _IRQL_requires_max_(PASSIVE_LEVEL
)
1979 RtlInitCodePageTable(
1980 _In_ PUSHORT TableBase
,
1981 _Out_ PCPTABLEINFO CodePageTable
);
1985 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1989 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1993 RtlPrefetchMemoryNonTemporal(
1995 _In_ SIZE_T Length
);
2000 #if (NTDDI_VERSION >= NTDDI_WINXP)
2008 _In_ PRTL_BITMAP BitMapHeader
,
2009 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2011 _IRQL_requires_max_(PASSIVE_LEVEL
)
2015 RtlDowncaseUnicodeChar(
2016 _In_ WCHAR SourceCharacter
);
2022 _In_ PRTL_BITMAP BitMapHeader
,
2023 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2025 _Must_inspect_result_
2030 _In_ PRTL_BITMAP BitMapHeader
,
2031 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2033 _IRQL_requires_max_(PASSIVE_LEVEL
)
2037 RtlHashUnicodeString(
2038 _In_ CONST UNICODE_STRING
*String
,
2039 _In_ BOOLEAN CaseInSensitive
,
2040 _In_ ULONG HashAlgorithm
,
2041 _Out_ PULONG HashValue
);
2050 RtlInitializeGenericTableAvl(
2051 _Out_ PRTL_AVL_TABLE Table
,
2052 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
2053 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
2054 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
2055 _In_opt_ PVOID TableContext
);
2060 RtlInsertElementGenericTableAvl(
2061 _In_ PRTL_AVL_TABLE Table
,
2062 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2063 _In_ CLONG BufferSize
,
2064 _Out_opt_ PBOOLEAN NewElement
);
2069 RtlInsertElementGenericTableFullAvl(
2070 _In_ PRTL_AVL_TABLE Table
,
2071 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2072 _In_ CLONG BufferSize
,
2073 _Out_opt_ PBOOLEAN NewElement
,
2074 _In_ PVOID NodeOrParent
,
2075 _In_ TABLE_SEARCH_RESULT SearchResult
);
2080 RtlDeleteElementGenericTableAvl(
2081 _In_ PRTL_AVL_TABLE Table
,
2084 _Must_inspect_result_
2088 RtlLookupElementGenericTableAvl(
2089 _In_ PRTL_AVL_TABLE Table
,
2095 RtlLookupElementGenericTableFullAvl(
2096 _In_ PRTL_AVL_TABLE Table
,
2098 _Out_ PVOID
*NodeOrParent
,
2099 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
2101 _Must_inspect_result_
2105 RtlEnumerateGenericTableAvl(
2106 _In_ PRTL_AVL_TABLE Table
,
2107 _In_ BOOLEAN Restart
);
2109 _Must_inspect_result_
2113 RtlEnumerateGenericTableWithoutSplayingAvl(
2114 _In_ PRTL_AVL_TABLE Table
,
2115 _Inout_ PVOID
*RestartKey
);
2117 _Must_inspect_result_
2121 RtlLookupFirstMatchingElementGenericTableAvl(
2122 _In_ PRTL_AVL_TABLE Table
,
2124 _Out_ PVOID
*RestartKey
);
2126 _Must_inspect_result_
2130 RtlEnumerateGenericTableLikeADirectory(
2131 _In_ PRTL_AVL_TABLE Table
,
2132 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
2133 _In_opt_ PVOID MatchData
,
2134 _In_ ULONG NextFlag
,
2135 _Inout_ PVOID
*RestartKey
,
2136 _Inout_ PULONG DeleteCount
,
2139 _Must_inspect_result_
2143 RtlGetElementGenericTableAvl(
2144 _In_ PRTL_AVL_TABLE Table
,
2150 RtlNumberGenericTableElementsAvl(
2151 _In_ PRTL_AVL_TABLE Table
);
2153 _Must_inspect_result_
2157 RtlIsGenericTableEmptyAvl(
2158 _In_ PRTL_AVL_TABLE Table
);
2163 _Must_inspect_result_
2169 _In_opt_ PVOID HeapBase
,
2170 _In_opt_ SIZE_T ReserveSize
,
2171 _In_opt_ SIZE_T CommitSize
,
2172 _In_opt_ PVOID Lock
,
2173 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2179 _In_ _Post_invalid_ PVOID HeapHandle
);
2184 RtlCaptureStackBackTrace(
2185 _In_ ULONG FramesToSkip
,
2186 _In_ ULONG FramesToCapture
,
2187 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2188 _Out_opt_ PULONG BackTraceHash
);
2190 _Ret_range_(<, MAXLONG
)
2195 _Inout_ PULONG Seed
);
2197 _IRQL_requires_max_(DISPATCH_LEVEL
)
2201 RtlInitUnicodeStringEx(
2202 _Out_ PUNICODE_STRING DestinationString
,
2203 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2205 _Must_inspect_result_
2209 RtlValidateUnicodeString(
2211 _In_ PCUNICODE_STRING String
);
2213 _IRQL_requires_max_(PASSIVE_LEVEL
)
2214 _Must_inspect_result_
2218 RtlDuplicateUnicodeString(
2220 _In_ PCUNICODE_STRING SourceString
,
2221 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2226 RtlGetCompressionWorkSpaceSize(
2227 _In_ USHORT CompressionFormatAndEngine
,
2228 _Out_ PULONG CompressBufferWorkSpaceSize
,
2229 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2235 _In_ USHORT CompressionFormatAndEngine
,
2236 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2237 _In_ ULONG UncompressedBufferSize
,
2238 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2239 _In_ ULONG CompressedBufferSize
,
2240 _In_ ULONG UncompressedChunkSize
,
2241 _Out_ PULONG FinalCompressedSize
,
2242 _In_ PVOID WorkSpace
);
2244 _IRQL_requires_max_(APC_LEVEL
)
2248 RtlDecompressBuffer(
2249 _In_ USHORT CompressionFormat
,
2250 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2251 _In_ ULONG UncompressedBufferSize
,
2252 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2253 _In_ ULONG CompressedBufferSize
,
2254 _Out_ PULONG FinalUncompressedSize
);
2256 _IRQL_requires_max_(APC_LEVEL
)
2260 RtlDecompressFragment(
2261 _In_ USHORT CompressionFormat
,
2262 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2263 _In_ ULONG UncompressedFragmentSize
,
2264 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2265 _In_ ULONG CompressedBufferSize
,
2266 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2267 _Out_ PULONG FinalUncompressedSize
,
2268 _In_ PVOID WorkSpace
);
2270 _IRQL_requires_max_(APC_LEVEL
)
2275 _In_ USHORT CompressionFormat
,
2276 _Inout_ PUCHAR
*CompressedBuffer
,
2277 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2278 _Out_ PUCHAR
*ChunkBuffer
,
2279 _Out_ PULONG ChunkSize
);
2281 _IRQL_requires_max_(APC_LEVEL
)
2286 _In_ USHORT CompressionFormat
,
2287 _Inout_ PUCHAR
*CompressedBuffer
,
2288 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2289 _Out_ PUCHAR
*ChunkBuffer
,
2290 _In_ ULONG ChunkSize
);
2292 _IRQL_requires_max_(APC_LEVEL
)
2296 RtlDecompressChunks(
2297 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2298 _In_ ULONG UncompressedBufferSize
,
2299 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2300 _In_ ULONG CompressedBufferSize
,
2301 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2302 _In_ ULONG CompressedTailSize
,
2303 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2305 _IRQL_requires_max_(APC_LEVEL
)
2310 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2311 _In_ ULONG UncompressedBufferSize
,
2312 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2313 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2314 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2315 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2316 _In_ PVOID WorkSpace
);
2318 _IRQL_requires_max_(APC_LEVEL
)
2320 PSID_IDENTIFIER_AUTHORITY
2322 RtlIdentifierAuthoritySid(
2328 RtlSubAuthorityCountSid(
2331 _When_(Status
< 0, _Out_range_(>, 0))
2332 _When_(Status
>= 0, _Out_range_(==, 0))
2336 RtlNtStatusToDosErrorNoTeb(
2337 _In_ NTSTATUS Status
);
2339 _IRQL_requires_max_(PASSIVE_LEVEL
)
2343 RtlCreateSystemVolumeInformationFolder(
2344 _In_ PCUNICODE_STRING VolumeRootPath
);
2346 #if defined(_M_AMD64)
2351 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2355 PULONG Address
= (PULONG
)Destination
;
2356 if ((Length
/= 4) != 0) {
2357 if (((ULONG64
)Address
& 4) != 0) {
2359 if ((Length
-= 1) == 0) {
2364 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2365 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2370 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2371 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2379 OUT PVOID Destination
,
2386 RtlFillMemoryUlonglong(
2387 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2389 _In_ ULONGLONG Pattern
);
2391 #endif /* defined(_M_AMD64) */
2394 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2397 #if (NTDDI_VERSION >= NTDDI_WS03)
2398 _IRQL_requires_max_(DISPATCH_LEVEL
)
2402 RtlInitAnsiStringEx(
2403 _Out_ PANSI_STRING DestinationString
,
2404 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2407 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2409 _IRQL_requires_max_(APC_LEVEL
)
2413 RtlGetSaclSecurityDescriptor(
2414 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2415 _Out_ PBOOLEAN SaclPresent
,
2417 _Out_ PBOOLEAN SaclDefaulted
);
2419 _IRQL_requires_max_(APC_LEVEL
)
2423 RtlSetGroupSecurityDescriptor(
2424 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2425 _In_opt_ PSID Group
,
2426 _In_opt_ BOOLEAN GroupDefaulted
);
2428 _IRQL_requires_max_(APC_LEVEL
)
2432 RtlGetGroupSecurityDescriptor(
2433 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2435 _Out_ PBOOLEAN GroupDefaulted
);
2437 _IRQL_requires_max_(APC_LEVEL
)
2441 RtlAbsoluteToSelfRelativeSD(
2442 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2443 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2444 _Inout_ PULONG BufferLength
);
2446 _IRQL_requires_max_(APC_LEVEL
)
2450 RtlSelfRelativeToAbsoluteSD(
2451 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2452 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2453 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2454 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2455 _Inout_ PULONG DaclSize
,
2456 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2457 _Inout_ PULONG SaclSize
,
2458 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2459 _Inout_ PULONG OwnerSize
,
2460 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2461 _Inout_ PULONG PrimaryGroupSize
);
2463 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2466 #if (NTDDI_VERSION >= NTDDI_VISTA)
2472 RtlNumberOfSetBitsUlongPtr(
2473 _In_ ULONG_PTR Target
);
2478 RtlIoDecodeMemIoResource(
2479 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2480 _Out_opt_ PULONGLONG Alignment
,
2481 _Out_opt_ PULONGLONG MinimumAddress
,
2482 _Out_opt_ PULONGLONG MaximumAddress
);
2487 RtlIoEncodeMemIoResource(
2488 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2490 _In_ ULONGLONG Length
,
2491 _In_ ULONGLONG Alignment
,
2492 _In_ ULONGLONG MinimumAddress
,
2493 _In_ ULONGLONG MaximumAddress
);
2498 RtlCmDecodeMemIoResource(
2499 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2500 _Out_opt_ PULONGLONG Start
);
2505 RtlFindClosestEncodableLength(
2506 _In_ ULONGLONG SourceLength
,
2507 _Out_ PULONGLONG TargetLength
);
2512 RtlCmEncodeMemIoResource(
2513 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2515 _In_ ULONGLONG Length
,
2516 _In_ ULONGLONG Start
);
2521 _IRQL_requires_max_(APC_LEVEL
)
2525 RtlRunOnceInitialize(
2526 _Out_ PRTL_RUN_ONCE RunOnce
);
2528 _IRQL_requires_max_(APC_LEVEL
)
2529 _Maybe_raises_SEH_exception_
2533 RtlRunOnceExecuteOnce(
2534 _Inout_ PRTL_RUN_ONCE RunOnce
,
2535 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2536 _Inout_opt_ PVOID Parameter
,
2537 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2539 _IRQL_requires_max_(APC_LEVEL
)
2540 _Must_inspect_result_
2544 RtlRunOnceBeginInitialize(
2545 _Inout_ PRTL_RUN_ONCE RunOnce
,
2547 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2549 _IRQL_requires_max_(APC_LEVEL
)
2554 _Inout_ PRTL_RUN_ONCE RunOnce
,
2556 _In_opt_ PVOID Context
);
2562 _In_ ULONG OSMajorVersion
,
2563 _In_ ULONG OSMinorVersion
,
2564 _In_ ULONG SpMajorVersion
,
2565 _In_ ULONG SpMinorVersion
,
2566 _Out_ PULONG ReturnedProductType
);
2574 _In_ ULONG NormForm
,
2575 _In_ PCWSTR SourceString
,
2576 _In_ LONG SourceStringLength
,
2577 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2578 _Inout_ PLONG DestinationStringLength
);
2583 RtlIsNormalizedString(
2584 _In_ ULONG NormForm
,
2585 _In_ PCWSTR SourceString
,
2586 _In_ LONG SourceStringLength
,
2587 _Out_ PBOOLEAN Normalized
);
2594 _In_ PCWSTR SourceString
,
2595 _In_ LONG SourceStringLength
,
2596 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2597 _Inout_ PLONG DestinationStringLength
);
2604 IN PCWSTR SourceString
,
2605 IN LONG SourceStringLength
,
2606 OUT PWSTR DestinationString
,
2607 IN OUT PLONG DestinationStringLength
);
2612 RtlIdnToNameprepUnicode(
2614 _In_ PCWSTR SourceString
,
2615 _In_ LONG SourceStringLength
,
2616 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2617 _Inout_ PLONG DestinationStringLength
);
2622 RtlCreateServiceSid(
2623 _In_ PUNICODE_STRING ServiceName
,
2624 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2625 _Inout_ PULONG ServiceSidLength
);
2630 RtlCompareAltitudes(
2631 _In_ PCUNICODE_STRING Altitude1
,
2632 _In_ PCUNICODE_STRING Altitude2
);
2636 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2638 #if (NTDDI_VERSION >= NTDDI_WIN7)
2641 _IRQL_requires_max_(PASSIVE_LEVEL
)
2642 _Must_inspect_result_
2647 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2648 PCHAR UTF8StringDestination
,
2649 _In_ ULONG UTF8StringMaxByteCount
,
2650 _Out_ PULONG UTF8StringActualByteCount
,
2651 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2652 _In_ ULONG UnicodeStringByteCount
);
2654 _IRQL_requires_max_(PASSIVE_LEVEL
)
2655 _Must_inspect_result_
2660 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2661 PWSTR UnicodeStringDestination
,
2662 _In_ ULONG UnicodeStringMaxByteCount
,
2663 _Out_ PULONG UnicodeStringActualByteCount
,
2664 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2665 _In_ ULONG UTF8StringByteCount
);
2670 RtlGetEnabledExtendedFeatures(
2671 IN ULONG64 FeatureMask
);
2676 _Must_inspect_result_
2681 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2682 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2684 _In_ _Reserved_ ULONG Flags
);
2690 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2691 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2696 RtlInsertEntryHashTable(
2697 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2698 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2699 _In_ ULONG_PTR Signature
,
2700 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2705 RtlRemoveEntryHashTable(
2706 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2707 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2708 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2710 _Must_inspect_result_
2712 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2714 RtlLookupEntryHashTable(
2715 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2716 _In_ ULONG_PTR Signature
,
2717 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2719 _Must_inspect_result_
2721 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2723 RtlGetNextEntryHashTable(
2724 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2725 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2730 RtlInitEnumerationHashTable(
2731 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2732 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2734 _Must_inspect_result_
2736 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2738 RtlEnumerateEntryHashTable(
2739 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2740 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2745 RtlEndEnumerationHashTable(
2746 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2747 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2752 RtlInitWeakEnumerationHashTable(
2753 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2754 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2756 _Must_inspect_result_
2758 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2760 RtlWeaklyEnumerateEntryHashTable(
2761 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2762 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2767 RtlEndWeakEnumerationHashTable(
2768 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2769 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2775 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2780 RtlContractHashTable(
2781 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2785 _IRQL_requires_max_(PASSIVE_LEVEL
)
2786 _Must_inspect_result_
2791 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2792 _In_ ULONG UTF8StringMaxByteCount
,
2793 _Out_ PULONG UTF8StringActualByteCount
,
2794 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2795 _In_ ULONG UnicodeStringByteCount
);
2797 _IRQL_requires_max_(PASSIVE_LEVEL
)
2798 _Must_inspect_result_
2803 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2804 _In_ ULONG UnicodeStringMaxByteCount
,
2805 _Out_ PULONG UnicodeStringActualByteCount
,
2806 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2807 _In_ ULONG UTF8StringByteCount
);
2809 _IRQL_requires_max_(APC_LEVEL
)
2814 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2817 _Out_ ULONG
*NumChanges
);
2822 RtlCreateVirtualAccountSid(
2823 _In_ PCUNICODE_STRING Name
,
2824 _In_ ULONG BaseSubAuthority
,
2825 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2826 _Inout_ PULONG SidLength
);
2829 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2833 #if !defined(MIDL_PASS)
2834 /* inline funftions */
2835 //DECLSPEC_DEPRECATED_DDK_WINXP
2839 RtlConvertLongToLargeInteger(
2840 _In_ LONG SignedInteger
)
2843 ret
.QuadPart
= SignedInteger
;
2847 //DECLSPEC_DEPRECATED_DDK_WINXP
2851 RtlConvertUlongToLargeInteger(
2852 _In_ ULONG UnsignedInteger
)
2855 ret
.QuadPart
= UnsignedInteger
;
2859 //DECLSPEC_DEPRECATED_DDK_WINXP
2863 RtlLargeIntegerShiftLeft(
2864 _In_ LARGE_INTEGER LargeInteger
,
2865 _In_ CCHAR ShiftCount
)
2867 LARGE_INTEGER Result
;
2869 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2873 //DECLSPEC_DEPRECATED_DDK_WINXP
2877 RtlLargeIntegerShiftRight(
2878 _In_ LARGE_INTEGER LargeInteger
,
2879 _In_ CCHAR ShiftCount
)
2881 LARGE_INTEGER Result
;
2883 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2887 //DECLSPEC_DEPRECATED_DDK
2891 RtlEnlargedUnsignedDivide(
2892 _In_ ULARGE_INTEGER Dividend
,
2894 _Out_opt_ PULONG Remainder
)
2897 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2898 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2901 //DECLSPEC_DEPRECATED_DDK
2905 RtlLargeIntegerNegate(
2906 _In_ LARGE_INTEGER Subtrahend
)
2908 LARGE_INTEGER Difference
;
2910 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2914 //DECLSPEC_DEPRECATED_DDK
2918 RtlLargeIntegerSubtract(
2919 _In_ LARGE_INTEGER Minuend
,
2920 _In_ LARGE_INTEGER Subtrahend
)
2922 LARGE_INTEGER Difference
;
2924 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2928 //DECLSPEC_DEPRECATED_DDK
2932 RtlEnlargedUnsignedMultiply(
2933 _In_ ULONG Multiplicand
,
2934 _In_ ULONG Multiplier
)
2937 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2941 //DECLSPEC_DEPRECATED_DDK
2945 RtlEnlargedIntegerMultiply(
2946 _In_ LONG Multiplicand
,
2947 _In_ LONG Multiplier
)
2950 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2954 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2955 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2956 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2959 RtlInitEmptyAnsiString(
2960 _Out_ PANSI_STRING AnsiString
,
2961 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2962 _In_ USHORT BufferSize
)
2964 AnsiString
->Length
= 0;
2965 AnsiString
->MaximumLength
= BufferSize
;
2966 AnsiString
->Buffer
= Buffer
;
2969 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2970 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2971 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2974 RtlInitEmptyUnicodeString(
2975 _Out_ PUNICODE_STRING UnicodeString
,
2976 _Writable_bytes_(BufferSize
)
2977 _When_(BufferSize
!= 0, _Notnull_
)
2978 __drv_aliasesMem PWSTR Buffer
,
2979 _In_ USHORT BufferSize
)
2981 UnicodeString
->Length
= 0;
2982 UnicodeString
->MaximumLength
= BufferSize
;
2983 UnicodeString
->Buffer
= Buffer
;
2987 #if defined(_AMD64_) || defined(_IA64_)
2994 RtlExtendedIntegerMultiply(
2995 _In_ LARGE_INTEGER Multiplicand
,
2996 _In_ LONG Multiplier
)
2999 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
3006 RtlExtendedLargeIntegerDivide(
3007 _In_ LARGE_INTEGER Dividend
,
3009 _Out_opt_ PULONG Remainder
)
3012 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3014 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3022 //DECLSPEC_DEPRECATED_DDK_WINXP
3026 RtlLargeIntegerDivide(
3027 _In_ LARGE_INTEGER Dividend
,
3028 _In_ LARGE_INTEGER Divisor
,
3029 _Out_opt_ PLARGE_INTEGER Remainder
)
3032 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
3034 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
3040 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3044 RtlLargeIntegerDivide(
3045 _In_ LARGE_INTEGER Dividend
,
3046 _In_ LARGE_INTEGER Divisor
,
3047 _Out_opt_ PLARGE_INTEGER Remainder
);
3052 #endif /* defined(_AMD64_) || defined(_IA64_) */
3056 #if defined(_AMD64_)
3058 #define MultiplyHigh __mulh
3059 #define UnsignedMultiplyHigh __umulh
3061 //DECLSPEC_DEPRECATED_DDK
3065 RtlExtendedMagicDivide(
3066 _In_ LARGE_INTEGER Dividend
,
3067 _In_ LARGE_INTEGER MagicDivisor
,
3068 _In_ CCHAR ShiftCount
)
3073 Pos
= (Dividend
.QuadPart
>= 0);
3074 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
3075 MagicDivisor
.QuadPart
);
3076 ret64
>>= ShiftCount
;
3077 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
3082 //DECLSPEC_DEPRECATED_DDK
3087 _In_ LARGE_INTEGER Addend1
,
3088 _In_ LARGE_INTEGER Addend2
)
3091 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
3096 * RtlLargeIntegerAnd(
3097 * IN OUT LARGE_INTEGER Result,
3098 * IN LARGE_INTEGER Source,
3099 * IN LARGE_INTEGER Mask);
3101 #define RtlLargeIntegerAnd(Result, Source, Mask) \
3102 Result.QuadPart = Source.QuadPart & Mask.QuadPart
3104 //DECLSPEC_DEPRECATED_DDK
3108 RtlLargeIntegerArithmeticShift(
3109 _In_ LARGE_INTEGER LargeInteger
,
3110 _In_ CCHAR ShiftCount
)
3113 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
3118 * RtlLargeIntegerEqualTo(
3119 * IN LARGE_INTEGER Operand1,
3120 * IN LARGE_INTEGER Operand2);
3122 #define RtlLargeIntegerEqualTo(X,Y) \
3123 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
3127 RtlSecureZeroMemory(
3128 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
3131 volatile char* vptr
= (volatile char*)Pointer
;
3132 #if defined(_M_AMD64)
3133 __stosb((PUCHAR
)vptr
, 0, Size
);
3135 char * endptr
= (char *)vptr
+ Size
;
3136 while (vptr
< endptr
) {
3143 #if defined(_M_AMD64)
3144 _Must_inspect_result_
3148 _In_ PRTL_BITMAP BitMapHeader
,
3149 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3151 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3154 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3155 #endif /* defined(_M_AMD64) */
3157 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3158 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3159 ((X).HighPart > (Y).HighPart) \
3162 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3163 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3164 ((X).HighPart > (Y).HighPart) \
3167 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3168 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3171 #define RtlLargeIntegerLessThan(X,Y) ( \
3172 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3173 ((X).HighPart < (Y).HighPart) \
3176 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3177 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3178 ((X).HighPart < (Y).HighPart) \
3181 #define RtlLargeIntegerGreaterThanZero(X) ( \
3182 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3183 ((X).HighPart > 0 ) \
3186 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3188 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3190 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3192 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3194 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3196 #endif /* !defined(MIDL_PASS) */
3198 /* Byte Swap Functions */
3199 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3200 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3201 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3203 #if defined(_MSC_VER) && !defined(__clang__)
3204 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg)
3205 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg)
3207 # define __assert_annotationA(msg) \
3208 DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg)
3209 # define __assert_annotationW(msg) \
3210 DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg)
3214 # define NT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp)
3216 # define NT_ANALYSIS_ASSUME(_exp) ((void)0)
3218 # define NT_ANALYSIS_ASSUME(_exp) __noop(_exp)
3221 #define NT_ASSERT_ACTION(exp) \
3222 (NT_ANALYSIS_ASSUME(exp), \
3224 (__assert_annotationA(#exp), \
3225 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3227 #define NT_ASSERTMSG_ACTION(msg, exp) \
3228 (NT_ANALYSIS_ASSUME(exp), \
3230 (__assert_annotationA(msg), \
3231 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3233 #define NT_ASSERTMSGW_ACTION(msg, exp) \
3234 (NT_ANALYSIS_ASSUME(exp), \
3236 (__assert_annotationW(msg), \
3237 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3241 #define RTL_VERIFY(exp) \
3243 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3245 #define RTL_VERIFYMSG(msg, exp) \
3247 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3249 #define RTL_SOFT_VERIFY(exp) \
3251 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3253 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3255 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3257 /* The ASSERTs must be cast to void to avoid warnings about unused results. */
3258 #define ASSERT (void)RTL_VERIFY
3259 #define ASSERTMSG (void)RTL_VERIFYMSG
3260 #define RTL_SOFT_ASSERT (void)RTL_SOFT_VERIFY
3261 #define RTL_SOFT_ASSERTMSG (void)RTL_SOFT_VERIFYMSG
3263 #define NT_VERIFY NT_ASSERT_ACTION
3264 #define NT_VERIFYMSG NT_ASSERTMSG_ACTION
3265 #define NT_VERIFYMSGW NT_ASSERTMSGW_ACTION
3267 #define NT_ASSERT_ASSUME (void)NT_ASSERT_ACTION
3268 #define NT_ASSERTMSG_ASSUME (void)NT_ASSERTMSG_ACTION
3269 #define NT_ASSERTMSGW_ASSUME (void)NT_ASSERTMSGW_ACTION
3271 #define NT_ASSERT_NOASSUME (void)NT_ASSERT_ACTION
3272 #define NT_ASSERTMSG_NOASSUME (void)NT_ASSERTMSG_ACTION
3273 #define NT_ASSERTMSGW_NOASSUME (void)NT_ASSERTMSGW_ACTION
3277 #define ASSERT(exp) ((void)0)
3278 #define ASSERTMSG(msg, exp) ((void)0)
3280 #define RTL_SOFT_ASSERT(exp) ((void)0)
3281 #define RTL_SOFT_ASSERTMSG(msg, exp) ((void)0)
3283 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3284 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3286 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3287 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3289 #define NT_VERIFY(exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3290 #define NT_VERIFYMSG(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3291 #define NT_VERIFYMSGW(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3293 #define NT_ASSERT_ASSUME(exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3294 #define NT_ASSERTMSG_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3295 #define NT_ASSERTMSGW_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3297 #define NT_ASSERT_NOASSUME(exp) ((void)0)
3298 #define NT_ASSERTMSG_NOASSUME(msg, exp) ((void)0)
3299 #define NT_ASSERTMSGW_NOASSUME(msg, exp) ((void)0)
3303 #define NT_FRE_ASSERT (void)NT_ASSERT_ACTION
3304 #define NT_FRE_ASSERTMSG (void)NT_ASSERTMSG_ACTION
3305 #define NT_FRE_ASSERTMSGW (void)NT_ASSERTMSGW_ACTION
3307 #ifdef NT_ASSERT_ALWAYS_ASSUMES
3308 # define NT_ASSERT NT_ASSERT_ASSUME
3309 # define NT_ASSERTMSG NT_ASSERTMSG_ASSUME
3310 # define NT_ASSERTMSGW NT_ASSERTMSGW_ASSUME
3312 # define NT_ASSERT NT_ASSERT_NOASSUME
3313 # define NT_ASSERTMSG NT_ASSERTMSG_NOASSUME
3314 # define NT_ASSERTMSGW NT_ASSERTMSGW_NOASSUME
3315 #endif /* NT_ASSERT_ALWAYS_ASSUMES */
3317 #if defined(_MSC_VER) && (defined(__REACTOS__) || defined(ASSERT_ALWAYS_NT_ASSERT)) && !defined(_BLDR_)
3319 #define ASSERT NT_ASSERT
3321 #define ASSERTMSG NT_ASSERTMSG
3323 #define ASSERTMSGW NT_ASSERTMSGW
3325 #define RTL_VERIFY NT_VERIFY
3328 #define InitializeListHead32(ListHead) (\
3329 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3331 #if !defined(_WINBASE_)
3333 #if defined(_WIN64) && !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || !defined(_NTOSP_))
3337 InitializeSListHead(
3338 _Out_ PSLIST_HEADER SListHead
);
3340 #else /* defined(_WIN64) && ... */
3343 _IRQL_requires_max_(APC_LEVEL
)
3349 _In_ NTSTATUS Status
);
3353 InitializeSListHead(
3354 _Out_ PSLIST_HEADER SListHead
)
3357 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3358 ExRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3361 SListHead
->Region
= (ULONG_PTR
)SListHead
& VRN_MASK
;
3363 SListHead
->Region
= 0;
3366 SListHead
->Alignment
= 0;
3369 #endif /* defined(_WIN64) && ... */
3376 InterlockedPushEntrySList(
3377 _Inout_ PSLIST_HEADER SListHead
,
3378 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry
);
3383 InterlockedPopEntrySList(
3384 _Inout_ PSLIST_HEADER SListHead
);
3386 #define InterlockedFlushSList(SListHead) \
3387 ExInterlockedFlushSList(SListHead)
3391 #define InterlockedPushEntrySList(SListHead, SListEntry) \
3392 ExpInterlockedPushEntrySList(SListHead, SListEntry)
3394 #define InterlockedPopEntrySList(SListHead) \
3395 ExpInterlockedPopEntrySList(SListHead)
3397 #define InterlockedFlushSList(SListHead) \
3398 ExpInterlockedFlushSList(SListHead)
3402 #define QueryDepthSList(SListHead) \
3403 ExQueryDepthSList(SListHead)
3405 #endif /* !defined(_WINBASE_) */
3407 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3408 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3409 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3410 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3411 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3412 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3413 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3414 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3415 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3416 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3417 (PCONTEXT_EX)(Context + 1), \
3421 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3422 _In_ ULONG Version
);
3425 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3426 _In_ ULONG Version
);
3428 #ifndef RtlIsNtDdiVersionAvailable
3429 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3432 #ifndef RtlIsServicePackVersionInstalled
3433 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3436 #define RtlInterlockedSetBits(Flags, Flag) \
3437 InterlockedOr((PLONG)(Flags), Flag)
3439 #define RtlInterlockedAndBits(Flags, Flag) \
3440 InterlockedAnd((PLONG)(Flags), Flag)
3442 #define RtlInterlockedClearBits(Flags, Flag) \
3443 RtlInterlockedAndBits(Flags, ~(Flag))
3445 #define RtlInterlockedXorBits(Flags, Flag) \
3446 InterlockedXor(Flags, Flag)
3448 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3449 (VOID) RtlInterlockedSetBits(Flags, Flag)
3451 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3452 (VOID) RtlInterlockedAndBits(Flags, Flag)
3454 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3455 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3461 #ifdef RTL_USE_AVL_TABLES
3463 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3464 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3465 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3466 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3467 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3468 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3469 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3470 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3471 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3472 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3473 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3475 #endif /* RTL_USE_AVL_TABLES */
3477 #define RtlInitializeSplayLinks(Links) { \
3478 PRTL_SPLAY_LINKS _SplayLinks; \
3479 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3480 _SplayLinks->Parent = _SplayLinks; \
3481 _SplayLinks->LeftChild = NULL; \
3482 _SplayLinks->RightChild = NULL; \
3485 #define RtlIsLeftChild(Links) \
3486 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3488 #define RtlIsRightChild(Links) \
3489 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3491 #define RtlRightChild(Links) \
3492 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3494 #define RtlIsRoot(Links) \
3495 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3497 #define RtlLeftChild(Links) \
3498 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3500 #define RtlParent(Links) \
3501 ((PRTL_SPLAY_LINKS)(Links))->Parent
3503 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3505 PRTL_SPLAY_LINKS _SplayParent; \
3506 PRTL_SPLAY_LINKS _SplayChild; \
3507 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3508 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3509 _SplayParent->LeftChild = _SplayChild; \
3510 _SplayChild->Parent = _SplayParent; \
3513 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3515 PRTL_SPLAY_LINKS _SplayParent; \
3516 PRTL_SPLAY_LINKS _SplayChild; \
3517 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3518 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3519 _SplayParent->RightChild = _SplayChild; \
3520 _SplayChild->Parent = _SplayParent; \
3523 #if !defined(MIDL_PASS)
3528 RtlConvertLongToLuid(
3534 Temp
.QuadPart
= Val
;
3535 Luid
.LowPart
= Temp
.u
.LowPart
;
3536 Luid
.HighPart
= Temp
.u
.HighPart
;
3543 RtlConvertUlongToLuid(
3553 #endif /* !defined(MIDL_PASS) */
3555 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3556 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3557 *CallersAddress = (PVOID)_ReturnAddress(); \
3558 *CallersCaller = NULL;
3560 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3564 RtlGetCallersAddress(
3565 _Out_ PVOID
*CallersAddress
,
3566 _Out_ PVOID
*CallersCaller
);
3570 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3572 #if (NTDDI_VERSION >= NTDDI_WIN7)
3577 RtlInitHashTableContext(
3578 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3580 Context
->ChainHead
= NULL
;
3581 Context
->PrevLinkage
= NULL
;
3587 RtlInitHashTableContextFromEnumerator(
3588 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3589 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3591 Context
->ChainHead
= Enumerator
->ChainHead
;
3592 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3598 RtlReleaseHashTableContext(
3599 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3601 UNREFERENCED_PARAMETER(Context
);
3608 RtlTotalBucketsHashTable(
3609 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3611 return HashTable
->TableSize
;
3617 RtlNonEmptyBucketsHashTable(
3618 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3620 return HashTable
->NonEmptyBuckets
;
3626 RtlEmptyBucketsHashTable(
3627 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3629 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3635 RtlTotalEntriesHashTable(
3636 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3638 return HashTable
->NumEntries
;
3644 RtlActiveEnumeratorsHashTable(
3645 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3647 return HashTable
->NumEnumerators
;
3650 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3652 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3657 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3658 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3660 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3661 RtlxUnicodeStringToOemSize(STRING) : \
3662 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3665 #define RtlOemStringToUnicodeSize(STRING) ( \
3666 NLS_MB_OEM_CODE_PAGE_TAG ? \
3667 RtlxOemStringToUnicodeSize(STRING) : \
3668 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3671 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3672 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3675 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3676 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))