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
);
960 RtlUlonglongByteSwap(
961 _In_ ULONGLONG Source
);
963 _When_(AllocateDestinationString
,
964 _At_(DestinationString
->MaximumLength
,
965 _Out_range_(<=, (SourceString
->MaximumLength
/ sizeof(WCHAR
)))))
966 _When_(!AllocateDestinationString
,
967 _At_(DestinationString
->Buffer
, _Const_
)
968 _At_(DestinationString
->MaximumLength
, _Const_
))
969 _IRQL_requires_max_(PASSIVE_LEVEL
)
970 _When_(AllocateDestinationString
, _Must_inspect_result_
)
974 RtlUnicodeStringToAnsiString(
975 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
976 _When_(!AllocateDestinationString
, _Inout_
)
977 PANSI_STRING DestinationString
,
978 _In_ PCUNICODE_STRING SourceString
,
979 _In_ BOOLEAN AllocateDestinationString
);
981 _IRQL_requires_max_(PASSIVE_LEVEL
)
985 RtlxUnicodeStringToAnsiSize(
986 _In_ PCUNICODE_STRING UnicodeString
);
988 #define RtlUnicodeStringToAnsiSize(String) ( \
989 NLS_MB_CODE_PAGE_TAG ? \
990 RtlxUnicodeStringToAnsiSize(String) : \
991 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
994 _IRQL_requires_max_(PASSIVE_LEVEL
)
998 RtlUnicodeStringToInteger(
999 _In_ PCUNICODE_STRING String
,
1000 _In_opt_ ULONG Base
,
1001 _Out_ PULONG Value
);
1003 _IRQL_requires_max_(PASSIVE_LEVEL
)
1007 RtlUpcaseUnicodeChar(
1008 _In_ WCHAR SourceCharacter
);
1014 _In_ USHORT Source
);
1016 _IRQL_requires_max_(APC_LEVEL
)
1017 _Must_inspect_result_
1021 RtlValidRelativeSecurityDescriptor(
1022 _In_reads_bytes_(SecurityDescriptorLength
) PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1023 _In_ ULONG SecurityDescriptorLength
,
1024 _In_ SECURITY_INFORMATION RequiredInformation
);
1026 _IRQL_requires_max_(APC_LEVEL
)
1027 _Must_inspect_result_
1031 RtlValidSecurityDescriptor(
1032 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
);
1034 _IRQL_requires_max_(PASSIVE_LEVEL
)
1040 _At_(lpVersionInformation
->dwOSVersionInfoSize
, _Pre_ _Valid_
)
1041 _When_(lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
),
1042 _At_((PRTL_OSVERSIONINFOEXW
)lpVersionInformation
, _Out_
))
1043 PRTL_OSVERSIONINFOW lpVersionInformation
);
1045 _IRQL_requires_max_(PASSIVE_LEVEL
)
1046 _Must_inspect_result_
1050 RtlVerifyVersionInfo(
1051 _In_ PRTL_OSVERSIONINFOEXW VersionInfo
,
1052 _In_ ULONG TypeMask
,
1053 _In_ ULONGLONG ConditionMask
);
1055 _IRQL_requires_max_(PASSIVE_LEVEL
)
1059 RtlWriteRegistryValue(
1060 _In_ ULONG RelativeTo
,
1062 _In_z_ PCWSTR ValueName
,
1063 _In_ ULONG ValueType
,
1064 _In_reads_bytes_opt_(ValueLength
) PVOID ValueData
,
1065 _In_ ULONG ValueLength
);
1070 #ifndef RTL_USE_AVL_TABLES
1075 RtlInitializeGenericTable(
1076 _Out_ PRTL_GENERIC_TABLE Table
,
1077 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine
,
1078 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine
,
1079 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
,
1080 _In_opt_ PVOID TableContext
);
1085 RtlInsertElementGenericTable(
1086 _In_ PRTL_GENERIC_TABLE Table
,
1087 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1088 _In_ CLONG BufferSize
,
1089 _Out_opt_ PBOOLEAN NewElement
);
1094 RtlInsertElementGenericTableFull(
1095 _In_ PRTL_GENERIC_TABLE Table
,
1096 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
1097 _In_ CLONG BufferSize
,
1098 _Out_opt_ PBOOLEAN NewElement
,
1099 _In_ PVOID NodeOrParent
,
1100 _In_ TABLE_SEARCH_RESULT SearchResult
);
1105 RtlDeleteElementGenericTable(
1106 _In_ PRTL_GENERIC_TABLE Table
,
1109 _Must_inspect_result_
1113 RtlLookupElementGenericTable(
1114 _In_ PRTL_GENERIC_TABLE Table
,
1120 RtlLookupElementGenericTableFull(
1121 _In_ PRTL_GENERIC_TABLE Table
,
1123 _Out_ PVOID
*NodeOrParent
,
1124 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
1126 _Must_inspect_result_
1130 RtlEnumerateGenericTable(
1131 _In_ PRTL_GENERIC_TABLE Table
,
1132 _In_ BOOLEAN Restart
);
1134 _Must_inspect_result_
1138 RtlEnumerateGenericTableWithoutSplaying(
1139 _In_ PRTL_GENERIC_TABLE Table
,
1140 _Inout_ PVOID
*RestartKey
);
1142 _Must_inspect_result_
1146 RtlGetElementGenericTable(
1147 _In_ PRTL_GENERIC_TABLE Table
,
1153 RtlNumberGenericTableElements(
1154 _In_ PRTL_GENERIC_TABLE Table
);
1156 _Must_inspect_result_
1160 RtlIsGenericTableEmpty(
1161 _In_ PRTL_GENERIC_TABLE Table
);
1163 #endif /* !RTL_USE_AVL_TABLES */
1165 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1171 _Inout_ PRTL_SPLAY_LINKS Links
);
1177 _In_ PRTL_SPLAY_LINKS Links
);
1183 _In_ PRTL_SPLAY_LINKS Links
,
1184 _Inout_ PRTL_SPLAY_LINKS
*Root
);
1186 _Must_inspect_result_
1190 RtlSubtreeSuccessor(
1191 _In_ PRTL_SPLAY_LINKS Links
);
1193 _Must_inspect_result_
1197 RtlSubtreePredecessor(
1198 _In_ PRTL_SPLAY_LINKS Links
);
1200 _Must_inspect_result_
1205 _In_ PRTL_SPLAY_LINKS Links
);
1207 _Must_inspect_result_
1212 _In_ PRTL_SPLAY_LINKS Links
);
1214 _IRQL_requires_max_(PASSIVE_LEVEL
)
1215 _Must_inspect_result_
1219 RtlPrefixUnicodeString(
1220 _In_ PCUNICODE_STRING String1
,
1221 _In_ PCUNICODE_STRING String2
,
1222 _In_ BOOLEAN CaseInSensitive
);
1224 _IRQL_requires_max_(PASSIVE_LEVEL
)
1229 _Inout_ PSTRING DestinationString
,
1230 _In_
const STRING
*SourceString
);
1232 _IRQL_requires_max_(PASSIVE_LEVEL
)
1233 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1237 RtlUpcaseUnicodeString(
1238 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1239 _When_(!AllocateDestinationString
, _Inout_
)
1240 PUNICODE_STRING DestinationString
,
1241 _In_ PCUNICODE_STRING SourceString
,
1242 _In_ BOOLEAN AllocateDestinationString
);
1244 _IRQL_requires_max_(APC_LEVEL
)
1249 _Inout_ PACCESS_MASK AccessMask
,
1250 _In_ PGENERIC_MAPPING GenericMapping
);
1252 _IRQL_requires_max_(PASSIVE_LEVEL
)
1256 RtlVolumeDeviceToDosName(
1257 _In_ PVOID VolumeDeviceObject
,
1258 _Out_ PUNICODE_STRING DosName
);
1260 _IRQL_requires_max_(PASSIVE_LEVEL
)
1261 _Must_inspect_result_
1266 _In_
const STRING
*String1
,
1267 _In_
const STRING
*String2
,
1268 _In_ BOOLEAN CaseInSensitive
);
1274 _Out_ PSTRING DestinationString
,
1275 _In_opt_
const STRING
*SourceString
);
1277 _IRQL_requires_max_(PASSIVE_LEVEL
)
1278 _Must_inspect_result_
1283 _In_
const STRING
*String1
,
1284 _In_
const STRING
*String2
,
1285 _In_ BOOLEAN CaseInSensitive
);
1287 _IRQL_requires_max_(PASSIVE_LEVEL
)
1293 _In_opt_ ULONG Base
,
1294 _Out_ PULONG Value
);
1296 _IRQL_requires_max_(PASSIVE_LEVEL
)
1301 _In_ CHAR Character
);
1307 _Out_writes_(Count
- (Flags
>> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT
))
1315 _Must_inspect_result_
1317 _Post_writable_byte_size_(Size
)
1322 _In_ HANDLE HeapHandle
,
1323 _In_opt_ ULONG Flags
,
1326 _Success_(return != 0)
1331 _In_ PVOID HeapHandle
,
1332 _In_opt_ ULONG Flags
,
1333 _In_ _Post_invalid_ PVOID BaseAddress
);
1339 _Out_ PCONTEXT ContextRecord
);
1341 _Ret_range_(<, MAXLONG
)
1346 _Inout_ PULONG Seed
);
1348 _IRQL_requires_max_(APC_LEVEL
)
1349 _Success_(return != 0)
1350 _Must_inspect_result_
1354 RtlCreateUnicodeString(
1355 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
))
1356 PUNICODE_STRING DestinationString
,
1357 _In_z_ PCWSTR SourceString
);
1359 _IRQL_requires_max_(PASSIVE_LEVEL
)
1360 _Must_inspect_result_
1365 _In_
const STRING
*String1
,
1366 _In_
const STRING
*String2
,
1367 _In_ BOOLEAN CaseInsensitive
);
1369 _IRQL_requires_max_(APC_LEVEL
)
1373 RtlAppendStringToString(
1374 _Inout_ PSTRING Destination
,
1375 _In_
const STRING
*Source
);
1377 _IRQL_requires_max_(PASSIVE_LEVEL
)
1378 _Must_inspect_result_
1382 RtlOemStringToUnicodeString(
1383 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1384 _When_(!AllocateDestinationString
, _Inout_
)
1385 PUNICODE_STRING DestinationString
,
1386 _In_ PCOEM_STRING SourceString
,
1387 _In_ BOOLEAN AllocateDestinationString
);
1389 _IRQL_requires_max_(PASSIVE_LEVEL
)
1390 _Must_inspect_result_
1394 RtlUnicodeStringToOemString(
1395 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1396 _When_(!AllocateDestinationString
, _Inout_
)
1397 POEM_STRING DestinationString
,
1398 _In_ PCUNICODE_STRING SourceString
,
1399 _In_ BOOLEAN AllocateDestinationString
);
1401 _IRQL_requires_max_(PASSIVE_LEVEL
)
1402 _Must_inspect_result_
1406 RtlUpcaseUnicodeStringToOemString(
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 RtlOemStringToCountedUnicodeString(
1419 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1420 _When_(!AllocateDestinationString
, _Inout_
)
1421 PUNICODE_STRING DestinationString
,
1422 _In_ PCOEM_STRING SourceString
,
1423 _In_ BOOLEAN AllocateDestinationString
);
1425 _IRQL_requires_max_(PASSIVE_LEVEL
)
1426 _Must_inspect_result_
1430 RtlUnicodeStringToCountedOemString(
1431 _When_(AllocateDestinationString
, _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)))
1432 _When_(!AllocateDestinationString
, _Inout_
)
1433 POEM_STRING DestinationString
,
1434 _In_ PCUNICODE_STRING SourceString
,
1435 _In_ BOOLEAN AllocateDestinationString
);
1437 _IRQL_requires_max_(PASSIVE_LEVEL
)
1438 _Must_inspect_result_
1442 RtlUpcaseUnicodeStringToCountedOemString(
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 _When_(AllocateDestinationString
, _Must_inspect_result_
)
1454 RtlDowncaseUnicodeString(
1455 _When_(AllocateDestinationString
, _Out_
_At_(UniDest
->Buffer
, __drv_allocatesMem(Mem
)))
1456 _When_(!AllocateDestinationString
, _Inout_
)
1457 PUNICODE_STRING UniDest
,
1458 _In_ PCUNICODE_STRING UniSource
,
1459 _In_ BOOLEAN AllocateDestinationString
);
1461 _IRQL_requires_max_(PASSIVE_LEVEL
)
1466 _Inout_
_At_(OemString
->Buffer
, __drv_freesMem(Mem
)) POEM_STRING OemString
);
1468 _IRQL_requires_max_(PASSIVE_LEVEL
)
1472 RtlxUnicodeStringToOemSize(
1473 _In_ PCUNICODE_STRING UnicodeString
);
1475 _IRQL_requires_max_(PASSIVE_LEVEL
)
1479 RtlxOemStringToUnicodeSize(
1480 _In_ PCOEM_STRING OemString
);
1482 _IRQL_requires_max_(PASSIVE_LEVEL
)
1486 RtlMultiByteToUnicodeN(
1487 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1488 _In_ ULONG MaxBytesInUnicodeString
,
1489 _Out_opt_ PULONG BytesInUnicodeString
,
1490 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1491 _In_ ULONG BytesInMultiByteString
);
1493 _IRQL_requires_max_(PASSIVE_LEVEL
)
1497 RtlMultiByteToUnicodeSize(
1498 _Out_ PULONG BytesInUnicodeString
,
1499 _In_reads_bytes_(BytesInMultiByteString
) const CHAR
*MultiByteString
,
1500 _In_ ULONG BytesInMultiByteString
);
1502 _IRQL_requires_max_(PASSIVE_LEVEL
)
1506 RtlUnicodeToMultiByteSize(
1507 _Out_ PULONG BytesInMultiByteString
,
1508 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1509 _In_ ULONG BytesInUnicodeString
);
1511 _IRQL_requires_max_(PASSIVE_LEVEL
)
1515 RtlUnicodeToMultiByteN(
1516 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1517 _In_ ULONG MaxBytesInMultiByteString
,
1518 _Out_opt_ PULONG BytesInMultiByteString
,
1519 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1520 _In_ ULONG BytesInUnicodeString
);
1522 _IRQL_requires_max_(PASSIVE_LEVEL
)
1526 RtlUpcaseUnicodeToMultiByteN(
1527 _Out_writes_bytes_to_(MaxBytesInMultiByteString
, *BytesInMultiByteString
) PCHAR MultiByteString
,
1528 _In_ ULONG MaxBytesInMultiByteString
,
1529 _Out_opt_ PULONG BytesInMultiByteString
,
1530 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1531 _In_ ULONG BytesInUnicodeString
);
1533 _IRQL_requires_max_(PASSIVE_LEVEL
)
1538 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWSTR UnicodeString
,
1539 _In_ ULONG MaxBytesInUnicodeString
,
1540 _Out_opt_ PULONG BytesInUnicodeString
,
1541 _In_reads_bytes_(BytesInOemString
) PCCH OemString
,
1542 _In_ ULONG BytesInOemString
);
1544 _IRQL_requires_max_(PASSIVE_LEVEL
)
1549 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1550 _In_ ULONG MaxBytesInOemString
,
1551 _Out_opt_ PULONG BytesInOemString
,
1552 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1553 _In_ ULONG BytesInUnicodeString
);
1555 _IRQL_requires_max_(PASSIVE_LEVEL
)
1559 RtlUpcaseUnicodeToOemN(
1560 _Out_writes_bytes_to_(MaxBytesInOemString
, *BytesInOemString
) PCHAR OemString
,
1561 _In_ ULONG MaxBytesInOemString
,
1562 _Out_opt_ PULONG BytesInOemString
,
1563 _In_reads_bytes_(BytesInUnicodeString
) PCWCH UnicodeString
,
1564 _In_ ULONG BytesInUnicodeString
);
1566 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1567 _IRQL_requires_max_(PASSIVE_LEVEL
)
1571 RtlGenerate8dot3Name(
1572 _In_ PCUNICODE_STRING Name
,
1573 _In_ BOOLEAN AllowExtendedCharacters
,
1574 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1575 _Inout_ PUNICODE_STRING Name8dot3
);
1577 _IRQL_requires_max_(PASSIVE_LEVEL
)
1581 RtlGenerate8dot3Name(
1582 _In_ PCUNICODE_STRING Name
,
1583 _In_ BOOLEAN AllowExtendedCharacters
,
1584 _Inout_ PGENERATE_NAME_CONTEXT Context
,
1585 _Inout_ PUNICODE_STRING Name8dot3
);
1588 _IRQL_requires_max_(PASSIVE_LEVEL
)
1589 _Must_inspect_result_
1593 RtlIsNameLegalDOS8Dot3(
1594 _In_ PCUNICODE_STRING Name
,
1595 _Inout_opt_ POEM_STRING OemName
,
1596 _Out_opt_ PBOOLEAN NameContainsSpaces
);
1598 _IRQL_requires_max_(PASSIVE_LEVEL
)
1599 _Must_inspect_result_
1603 RtlIsValidOemCharacter(
1604 _Inout_ PWCHAR Char
);
1606 _IRQL_requires_max_(PASSIVE_LEVEL
)
1611 _Out_ PPREFIX_TABLE PrefixTable
);
1613 _IRQL_requires_max_(PASSIVE_LEVEL
)
1618 _In_ PPREFIX_TABLE PrefixTable
,
1619 _In_ __drv_aliasesMem PSTRING Prefix
,
1620 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1622 _IRQL_requires_max_(PASSIVE_LEVEL
)
1627 _In_ PPREFIX_TABLE PrefixTable
,
1628 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry
);
1630 _IRQL_requires_max_(PASSIVE_LEVEL
)
1631 _Must_inspect_result_
1636 _In_ PPREFIX_TABLE PrefixTable
,
1637 _In_ PSTRING FullName
);
1639 _IRQL_requires_max_(PASSIVE_LEVEL
)
1643 RtlInitializeUnicodePrefix(
1644 _Out_ PUNICODE_PREFIX_TABLE PrefixTable
);
1646 _IRQL_requires_max_(PASSIVE_LEVEL
)
1650 RtlInsertUnicodePrefix(
1651 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1652 _In_ __drv_aliasesMem PUNICODE_STRING Prefix
,
1653 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1655 _IRQL_requires_max_(PASSIVE_LEVEL
)
1659 RtlRemoveUnicodePrefix(
1660 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1661 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry
);
1663 _IRQL_requires_max_(PASSIVE_LEVEL
)
1664 _Must_inspect_result_
1666 PUNICODE_PREFIX_TABLE_ENTRY
1668 RtlFindUnicodePrefix(
1669 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1670 _In_ PUNICODE_STRING FullName
,
1671 _In_ ULONG CaseInsensitiveIndex
);
1673 _IRQL_requires_max_(PASSIVE_LEVEL
)
1674 _Must_inspect_result_
1676 PUNICODE_PREFIX_TABLE_ENTRY
1678 RtlNextUnicodePrefix(
1679 _In_ PUNICODE_PREFIX_TABLE PrefixTable
,
1680 _In_ BOOLEAN Restart
);
1682 _Must_inspect_result_
1686 RtlCompareMemoryUlong(
1687 _In_reads_bytes_(Length
) PVOID Source
,
1689 _In_ ULONG Pattern
);
1691 _Success_(return != 0)
1695 RtlTimeToSecondsSince1980(
1696 _In_ PLARGE_INTEGER Time
,
1697 _Out_ PULONG ElapsedSeconds
);
1702 RtlSecondsSince1980ToTime(
1703 _In_ ULONG ElapsedSeconds
,
1704 _Out_ PLARGE_INTEGER Time
);
1706 _Success_(return != 0)
1707 _Must_inspect_result_
1711 RtlTimeToSecondsSince1970(
1712 _In_ PLARGE_INTEGER Time
,
1713 _Out_ PULONG ElapsedSeconds
);
1718 RtlSecondsSince1970ToTime(
1719 _In_ ULONG ElapsedSeconds
,
1720 _Out_ PLARGE_INTEGER Time
);
1722 _IRQL_requires_max_(APC_LEVEL
)
1723 _Must_inspect_result_
1730 _Must_inspect_result_
1738 _IRQL_requires_max_(APC_LEVEL
)
1739 _Must_inspect_result_
1747 _IRQL_requires_max_(APC_LEVEL
)
1751 RtlLengthRequiredSid(
1752 _In_ ULONG SubAuthorityCount
);
1758 _In_ _Post_invalid_ PSID Sid
);
1760 _Must_inspect_result_
1764 RtlAllocateAndInitializeSid(
1765 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1766 _In_ UCHAR SubAuthorityCount
,
1767 _In_ ULONG SubAuthority0
,
1768 _In_ ULONG SubAuthority1
,
1769 _In_ ULONG SubAuthority2
,
1770 _In_ ULONG SubAuthority3
,
1771 _In_ ULONG SubAuthority4
,
1772 _In_ ULONG SubAuthority5
,
1773 _In_ ULONG SubAuthority6
,
1774 _In_ ULONG SubAuthority7
,
1775 _Outptr_ PSID
*Sid
);
1777 _IRQL_requires_max_(APC_LEVEL
)
1783 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1784 _In_ UCHAR SubAuthorityCount
);
1791 _In_ ULONG SubAuthority
);
1793 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE
)
1800 _IRQL_requires_max_(APC_LEVEL
)
1805 _In_ ULONG DestinationSidLength
,
1806 _Out_writes_bytes_(DestinationSidLength
) PSID DestinationSid
,
1807 _In_ PSID SourceSid
);
1809 _IRQL_requires_max_(APC_LEVEL
)
1813 RtlConvertSidToUnicodeString(
1814 _Inout_ PUNICODE_STRING UnicodeString
,
1816 _In_ BOOLEAN AllocateDestinationString
);
1818 _IRQL_requires_max_(APC_LEVEL
)
1823 _Out_ PLUID DestinationLuid
,
1824 _In_ PLUID SourceLuid
);
1826 _IRQL_requires_max_(APC_LEVEL
)
1831 _Out_writes_bytes_(AclLength
) PACL Acl
,
1832 _In_ ULONG AclLength
,
1833 _In_ ULONG AclRevision
);
1835 _IRQL_requires_max_(APC_LEVEL
)
1841 _In_ ULONG AceRevision
,
1842 _In_ ULONG StartingAceIndex
,
1843 _In_reads_bytes_(AceListLength
) PVOID AceList
,
1844 _In_ ULONG AceListLength
);
1846 _IRQL_requires_max_(APC_LEVEL
)
1852 _In_ ULONG AceIndex
);
1859 _In_ ULONG AceIndex
,
1860 _Outptr_ PVOID
*Ace
);
1862 _IRQL_requires_max_(APC_LEVEL
)
1866 RtlAddAccessAllowedAce(
1868 _In_ ULONG AceRevision
,
1869 _In_ ACCESS_MASK AccessMask
,
1872 _IRQL_requires_max_(APC_LEVEL
)
1876 RtlAddAccessAllowedAceEx(
1878 _In_ ULONG AceRevision
,
1879 _In_ ULONG AceFlags
,
1880 _In_ ACCESS_MASK AccessMask
,
1883 _IRQL_requires_max_(APC_LEVEL
)
1887 RtlCreateSecurityDescriptorRelative(
1888 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
1889 _In_ ULONG Revision
);
1894 RtlGetDaclSecurityDescriptor(
1895 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1896 _Out_ PBOOLEAN DaclPresent
,
1898 _Out_ PBOOLEAN DaclDefaulted
);
1900 _IRQL_requires_max_(APC_LEVEL
)
1904 RtlSetOwnerSecurityDescriptor(
1905 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1906 _In_opt_ PSID Owner
,
1907 _In_opt_ BOOLEAN OwnerDefaulted
);
1909 _IRQL_requires_max_(APC_LEVEL
)
1913 RtlGetOwnerSecurityDescriptor(
1914 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
1916 _Out_ PBOOLEAN OwnerDefaulted
);
1918 _IRQL_requires_max_(APC_LEVEL
)
1919 _When_(Status
< 0, _Out_range_(>, 0))
1920 _When_(Status
>= 0, _Out_range_(==, 0))
1924 RtlNtStatusToDosError(
1925 _In_ NTSTATUS Status
);
1927 _IRQL_requires_max_(PASSIVE_LEVEL
)
1931 RtlCustomCPToUnicodeN(
1932 _In_ PCPTABLEINFO CustomCP
,
1933 _Out_writes_bytes_to_(MaxBytesInUnicodeString
, *BytesInUnicodeString
) PWCH UnicodeString
,
1934 _In_ ULONG MaxBytesInUnicodeString
,
1935 _Out_opt_ PULONG BytesInUnicodeString
,
1936 _In_reads_bytes_(BytesInCustomCPString
) PCH CustomCPString
,
1937 _In_ ULONG BytesInCustomCPString
);
1939 _IRQL_requires_max_(PASSIVE_LEVEL
)
1943 RtlUnicodeToCustomCPN(
1944 _In_ PCPTABLEINFO CustomCP
,
1945 _Out_writes_bytes_to_(MaxBytesInCustomCPString
, *BytesInCustomCPString
) PCH CustomCPString
,
1946 _In_ ULONG MaxBytesInCustomCPString
,
1947 _Out_opt_ PULONG BytesInCustomCPString
,
1948 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
1949 _In_ ULONG BytesInUnicodeString
);
1951 _IRQL_requires_max_(PASSIVE_LEVEL
)
1955 RtlUpcaseUnicodeToCustomCPN(
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 RtlInitCodePageTable(
1968 _In_ PUSHORT TableBase
,
1969 _Out_ PCPTABLEINFO CodePageTable
);
1973 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1977 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1981 RtlPrefetchMemoryNonTemporal(
1983 _In_ SIZE_T Length
);
1988 #if (NTDDI_VERSION >= NTDDI_WINXP)
1996 _In_ PRTL_BITMAP BitMapHeader
,
1997 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
1999 _IRQL_requires_max_(PASSIVE_LEVEL
)
2003 RtlDowncaseUnicodeChar(
2004 _In_ WCHAR SourceCharacter
);
2010 _In_ PRTL_BITMAP BitMapHeader
,
2011 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2013 _Must_inspect_result_
2018 _In_ PRTL_BITMAP BitMapHeader
,
2019 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitNumber
);
2021 _IRQL_requires_max_(PASSIVE_LEVEL
)
2025 RtlHashUnicodeString(
2026 _In_ CONST UNICODE_STRING
*String
,
2027 _In_ BOOLEAN CaseInSensitive
,
2028 _In_ ULONG HashAlgorithm
,
2029 _Out_ PULONG HashValue
);
2038 RtlInitializeGenericTableAvl(
2039 _Out_ PRTL_AVL_TABLE Table
,
2040 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine
,
2041 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine
,
2042 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine
,
2043 _In_opt_ PVOID TableContext
);
2048 RtlInsertElementGenericTableAvl(
2049 _In_ PRTL_AVL_TABLE Table
,
2050 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2051 _In_ CLONG BufferSize
,
2052 _Out_opt_ PBOOLEAN NewElement
);
2057 RtlInsertElementGenericTableFullAvl(
2058 _In_ PRTL_AVL_TABLE Table
,
2059 _In_reads_bytes_(BufferSize
) PVOID Buffer
,
2060 _In_ CLONG BufferSize
,
2061 _Out_opt_ PBOOLEAN NewElement
,
2062 _In_ PVOID NodeOrParent
,
2063 _In_ TABLE_SEARCH_RESULT SearchResult
);
2068 RtlDeleteElementGenericTableAvl(
2069 _In_ PRTL_AVL_TABLE Table
,
2072 _Must_inspect_result_
2076 RtlLookupElementGenericTableAvl(
2077 _In_ PRTL_AVL_TABLE Table
,
2083 RtlLookupElementGenericTableFullAvl(
2084 _In_ PRTL_AVL_TABLE Table
,
2086 _Out_ PVOID
*NodeOrParent
,
2087 _Out_ TABLE_SEARCH_RESULT
*SearchResult
);
2089 _Must_inspect_result_
2093 RtlEnumerateGenericTableAvl(
2094 _In_ PRTL_AVL_TABLE Table
,
2095 _In_ BOOLEAN Restart
);
2097 _Must_inspect_result_
2101 RtlEnumerateGenericTableWithoutSplayingAvl(
2102 _In_ PRTL_AVL_TABLE Table
,
2103 _Inout_ PVOID
*RestartKey
);
2105 _Must_inspect_result_
2109 RtlLookupFirstMatchingElementGenericTableAvl(
2110 _In_ PRTL_AVL_TABLE Table
,
2112 _Out_ PVOID
*RestartKey
);
2114 _Must_inspect_result_
2118 RtlEnumerateGenericTableLikeADirectory(
2119 _In_ PRTL_AVL_TABLE Table
,
2120 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction
,
2121 _In_opt_ PVOID MatchData
,
2122 _In_ ULONG NextFlag
,
2123 _Inout_ PVOID
*RestartKey
,
2124 _Inout_ PULONG DeleteCount
,
2127 _Must_inspect_result_
2131 RtlGetElementGenericTableAvl(
2132 _In_ PRTL_AVL_TABLE Table
,
2138 RtlNumberGenericTableElementsAvl(
2139 _In_ PRTL_AVL_TABLE Table
);
2141 _Must_inspect_result_
2145 RtlIsGenericTableEmptyAvl(
2146 _In_ PRTL_AVL_TABLE Table
);
2151 _Must_inspect_result_
2157 _In_opt_ PVOID HeapBase
,
2158 _In_opt_ SIZE_T ReserveSize
,
2159 _In_opt_ SIZE_T CommitSize
,
2160 _In_opt_ PVOID Lock
,
2161 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
);
2167 _In_ _Post_invalid_ PVOID HeapHandle
);
2172 RtlCaptureStackBackTrace(
2173 _In_ ULONG FramesToSkip
,
2174 _In_ ULONG FramesToCapture
,
2175 _Out_writes_to_(FramesToCapture
, return) PVOID
*BackTrace
,
2176 _Out_opt_ PULONG BackTraceHash
);
2178 _Ret_range_(<, MAXLONG
)
2183 _Inout_ PULONG Seed
);
2185 _IRQL_requires_max_(DISPATCH_LEVEL
)
2189 RtlInitUnicodeStringEx(
2190 _Out_ PUNICODE_STRING DestinationString
,
2191 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
);
2193 _Must_inspect_result_
2197 RtlValidateUnicodeString(
2199 _In_ PCUNICODE_STRING String
);
2201 _IRQL_requires_max_(PASSIVE_LEVEL
)
2202 _Must_inspect_result_
2206 RtlDuplicateUnicodeString(
2208 _In_ PCUNICODE_STRING SourceString
,
2209 _Out_
_At_(DestinationString
->Buffer
, __drv_allocatesMem(Mem
)) PUNICODE_STRING DestinationString
);
2214 RtlGetCompressionWorkSpaceSize(
2215 _In_ USHORT CompressionFormatAndEngine
,
2216 _Out_ PULONG CompressBufferWorkSpaceSize
,
2217 _Out_ PULONG CompressFragmentWorkSpaceSize
);
2223 _In_ USHORT CompressionFormatAndEngine
,
2224 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2225 _In_ ULONG UncompressedBufferSize
,
2226 _Out_writes_bytes_to_(CompressedBufferSize
, *FinalCompressedSize
) PUCHAR CompressedBuffer
,
2227 _In_ ULONG CompressedBufferSize
,
2228 _In_ ULONG UncompressedChunkSize
,
2229 _Out_ PULONG FinalCompressedSize
,
2230 _In_ PVOID WorkSpace
);
2232 _IRQL_requires_max_(APC_LEVEL
)
2236 RtlDecompressBuffer(
2237 _In_ USHORT CompressionFormat
,
2238 _Out_writes_bytes_to_(UncompressedBufferSize
, *FinalUncompressedSize
) PUCHAR UncompressedBuffer
,
2239 _In_ ULONG UncompressedBufferSize
,
2240 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2241 _In_ ULONG CompressedBufferSize
,
2242 _Out_ PULONG FinalUncompressedSize
);
2244 _IRQL_requires_max_(APC_LEVEL
)
2248 RtlDecompressFragment(
2249 _In_ USHORT CompressionFormat
,
2250 _Out_writes_bytes_to_(UncompressedFragmentSize
, *FinalUncompressedSize
) PUCHAR UncompressedFragment
,
2251 _In_ ULONG UncompressedFragmentSize
,
2252 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2253 _In_ ULONG CompressedBufferSize
,
2254 _In_range_(<, CompressedBufferSize
) ULONG FragmentOffset
,
2255 _Out_ PULONG FinalUncompressedSize
,
2256 _In_ PVOID WorkSpace
);
2258 _IRQL_requires_max_(APC_LEVEL
)
2263 _In_ USHORT CompressionFormat
,
2264 _Inout_ PUCHAR
*CompressedBuffer
,
2265 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2266 _Out_ PUCHAR
*ChunkBuffer
,
2267 _Out_ PULONG ChunkSize
);
2269 _IRQL_requires_max_(APC_LEVEL
)
2274 _In_ USHORT CompressionFormat
,
2275 _Inout_ PUCHAR
*CompressedBuffer
,
2276 _In_ PUCHAR EndOfCompressedBufferPlus1
,
2277 _Out_ PUCHAR
*ChunkBuffer
,
2278 _In_ ULONG ChunkSize
);
2280 _IRQL_requires_max_(APC_LEVEL
)
2284 RtlDecompressChunks(
2285 _Out_writes_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2286 _In_ ULONG UncompressedBufferSize
,
2287 _In_reads_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2288 _In_ ULONG CompressedBufferSize
,
2289 _In_reads_bytes_(CompressedTailSize
) PUCHAR CompressedTail
,
2290 _In_ ULONG CompressedTailSize
,
2291 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
);
2293 _IRQL_requires_max_(APC_LEVEL
)
2298 _In_reads_bytes_(UncompressedBufferSize
) PUCHAR UncompressedBuffer
,
2299 _In_ ULONG UncompressedBufferSize
,
2300 _Out_writes_bytes_(CompressedBufferSize
) PUCHAR CompressedBuffer
,
2301 _In_range_(>=, (UncompressedBufferSize
- (UncompressedBufferSize
/ 16))) ULONG CompressedBufferSize
,
2302 _Inout_updates_bytes_(CompressedDataInfoLength
) PCOMPRESSED_DATA_INFO CompressedDataInfo
,
2303 _In_range_(>, sizeof(COMPRESSED_DATA_INFO
)) ULONG CompressedDataInfoLength
,
2304 _In_ PVOID WorkSpace
);
2306 _IRQL_requires_max_(APC_LEVEL
)
2308 PSID_IDENTIFIER_AUTHORITY
2310 RtlIdentifierAuthoritySid(
2316 RtlSubAuthorityCountSid(
2319 _When_(Status
< 0, _Out_range_(>, 0))
2320 _When_(Status
>= 0, _Out_range_(==, 0))
2324 RtlNtStatusToDosErrorNoTeb(
2325 _In_ NTSTATUS Status
);
2327 _IRQL_requires_max_(PASSIVE_LEVEL
)
2331 RtlCreateSystemVolumeInformationFolder(
2332 _In_ PCUNICODE_STRING VolumeRootPath
);
2334 #if defined(_M_AMD64)
2339 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2343 PULONG Address
= (PULONG
)Destination
;
2344 if ((Length
/= 4) != 0) {
2345 if (((ULONG64
)Address
& 4) != 0) {
2347 if ((Length
-= 1) == 0) {
2352 __stosq((PULONG64
)(Address
), Pattern
| ((ULONG64
)Pattern
<< 32), Length
/ 2);
2353 if ((Length
& 1) != 0) Address
[Length
- 1] = Pattern
;
2358 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2359 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2367 OUT PVOID Destination
,
2374 RtlFillMemoryUlonglong(
2375 _Out_writes_bytes_all_(Length
) PVOID Destination
,
2377 _In_ ULONGLONG Pattern
);
2379 #endif /* defined(_M_AMD64) */
2382 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2385 #if (NTDDI_VERSION >= NTDDI_WS03)
2386 _IRQL_requires_max_(DISPATCH_LEVEL
)
2390 RtlInitAnsiStringEx(
2391 _Out_ PANSI_STRING DestinationString
,
2392 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
);
2395 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2397 _IRQL_requires_max_(APC_LEVEL
)
2401 RtlGetSaclSecurityDescriptor(
2402 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2403 _Out_ PBOOLEAN SaclPresent
,
2405 _Out_ PBOOLEAN SaclDefaulted
);
2407 _IRQL_requires_max_(APC_LEVEL
)
2411 RtlSetGroupSecurityDescriptor(
2412 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2413 _In_opt_ PSID Group
,
2414 _In_opt_ BOOLEAN GroupDefaulted
);
2416 _IRQL_requires_max_(APC_LEVEL
)
2420 RtlGetGroupSecurityDescriptor(
2421 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2423 _Out_ PBOOLEAN GroupDefaulted
);
2425 _IRQL_requires_max_(APC_LEVEL
)
2429 RtlAbsoluteToSelfRelativeSD(
2430 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2431 _Out_writes_bytes_to_opt_(*BufferLength
, *BufferLength
) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2432 _Inout_ PULONG BufferLength
);
2434 _IRQL_requires_max_(APC_LEVEL
)
2438 RtlSelfRelativeToAbsoluteSD(
2439 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
2440 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize
, *AbsoluteSecurityDescriptorSize
) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
2441 _Inout_ PULONG AbsoluteSecurityDescriptorSize
,
2442 _Out_writes_bytes_to_opt_(*DaclSize
, *DaclSize
) PACL Dacl
,
2443 _Inout_ PULONG DaclSize
,
2444 _Out_writes_bytes_to_opt_(*SaclSize
, *SaclSize
) PACL Sacl
,
2445 _Inout_ PULONG SaclSize
,
2446 _Out_writes_bytes_to_opt_(*OwnerSize
, *OwnerSize
) PSID Owner
,
2447 _Inout_ PULONG OwnerSize
,
2448 _Out_writes_bytes_to_opt_(*PrimaryGroupSize
, *PrimaryGroupSize
) PSID PrimaryGroup
,
2449 _Inout_ PULONG PrimaryGroupSize
);
2451 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2454 #if (NTDDI_VERSION >= NTDDI_VISTA)
2460 RtlNumberOfSetBitsUlongPtr(
2461 _In_ ULONG_PTR Target
);
2466 RtlIoDecodeMemIoResource(
2467 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2468 _Out_opt_ PULONGLONG Alignment
,
2469 _Out_opt_ PULONGLONG MinimumAddress
,
2470 _Out_opt_ PULONGLONG MaximumAddress
);
2475 RtlIoEncodeMemIoResource(
2476 _In_
struct _IO_RESOURCE_DESCRIPTOR
*Descriptor
,
2478 _In_ ULONGLONG Length
,
2479 _In_ ULONGLONG Alignment
,
2480 _In_ ULONGLONG MinimumAddress
,
2481 _In_ ULONGLONG MaximumAddress
);
2486 RtlCmDecodeMemIoResource(
2487 _In_
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
,
2488 _Out_opt_ PULONGLONG Start
);
2493 RtlFindClosestEncodableLength(
2494 _In_ ULONGLONG SourceLength
,
2495 _Out_ PULONGLONG TargetLength
);
2500 RtlCmEncodeMemIoResource(
2501 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
,
2503 _In_ ULONGLONG Length
,
2504 _In_ ULONGLONG Start
);
2509 _IRQL_requires_max_(APC_LEVEL
)
2513 RtlRunOnceInitialize(
2514 _Out_ PRTL_RUN_ONCE RunOnce
);
2516 _IRQL_requires_max_(APC_LEVEL
)
2517 _Maybe_raises_SEH_exception_
2521 RtlRunOnceExecuteOnce(
2522 _Inout_ PRTL_RUN_ONCE RunOnce
,
2523 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
,
2524 _Inout_opt_ PVOID Parameter
,
2525 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2527 _IRQL_requires_max_(APC_LEVEL
)
2528 _Must_inspect_result_
2532 RtlRunOnceBeginInitialize(
2533 _Inout_ PRTL_RUN_ONCE RunOnce
,
2535 _Outptr_opt_result_maybenull_ PVOID
*Context
);
2537 _IRQL_requires_max_(APC_LEVEL
)
2542 _Inout_ PRTL_RUN_ONCE RunOnce
,
2544 _In_opt_ PVOID Context
);
2550 _In_ ULONG OSMajorVersion
,
2551 _In_ ULONG OSMinorVersion
,
2552 _In_ ULONG SpMajorVersion
,
2553 _In_ ULONG SpMinorVersion
,
2554 _Out_ PULONG ReturnedProductType
);
2562 _In_ ULONG NormForm
,
2563 _In_ PCWSTR SourceString
,
2564 _In_ LONG SourceStringLength
,
2565 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2566 _Inout_ PLONG DestinationStringLength
);
2571 RtlIsNormalizedString(
2572 _In_ ULONG NormForm
,
2573 _In_ PCWSTR SourceString
,
2574 _In_ LONG SourceStringLength
,
2575 _Out_ PBOOLEAN Normalized
);
2582 _In_ PCWSTR SourceString
,
2583 _In_ LONG SourceStringLength
,
2584 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2585 _Inout_ PLONG DestinationStringLength
);
2592 IN PCWSTR SourceString
,
2593 IN LONG SourceStringLength
,
2594 OUT PWSTR DestinationString
,
2595 IN OUT PLONG DestinationStringLength
);
2600 RtlIdnToNameprepUnicode(
2602 _In_ PCWSTR SourceString
,
2603 _In_ LONG SourceStringLength
,
2604 _Out_writes_to_(*DestinationStringLength
, *DestinationStringLength
) PWSTR DestinationString
,
2605 _Inout_ PLONG DestinationStringLength
);
2610 RtlCreateServiceSid(
2611 _In_ PUNICODE_STRING ServiceName
,
2612 _Out_writes_bytes_opt_(*ServiceSidLength
) PSID ServiceSid
,
2613 _Inout_ PULONG ServiceSidLength
);
2618 RtlCompareAltitudes(
2619 _In_ PCUNICODE_STRING Altitude1
,
2620 _In_ PCUNICODE_STRING Altitude2
);
2624 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2626 #if (NTDDI_VERSION >= NTDDI_WIN7)
2629 _IRQL_requires_max_(PASSIVE_LEVEL
)
2630 _Must_inspect_result_
2635 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
)
2636 PCHAR UTF8StringDestination
,
2637 _In_ ULONG UTF8StringMaxByteCount
,
2638 _Out_ PULONG UTF8StringActualByteCount
,
2639 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2640 _In_ ULONG UnicodeStringByteCount
);
2642 _IRQL_requires_max_(PASSIVE_LEVEL
)
2643 _Must_inspect_result_
2648 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
)
2649 PWSTR UnicodeStringDestination
,
2650 _In_ ULONG UnicodeStringMaxByteCount
,
2651 _Out_ PULONG UnicodeStringActualByteCount
,
2652 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2653 _In_ ULONG UTF8StringByteCount
);
2658 RtlGetEnabledExtendedFeatures(
2659 IN ULONG64 FeatureMask
);
2664 _Must_inspect_result_
2669 _Inout_
_When_(NULL
== *HashTable
, __drv_allocatesMem(Mem
))
2670 PRTL_DYNAMIC_HASH_TABLE
*HashTable
,
2672 _In_ _Reserved_ ULONG Flags
);
2678 _In_
_When_((HashTable
->Flags
& RTL_HASH_ALLOCATED_HEADER
), __drv_freesMem(Mem
) _Post_invalid_
)
2679 PRTL_DYNAMIC_HASH_TABLE HashTable
);
2684 RtlInsertEntryHashTable(
2685 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2686 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2687 _In_ ULONG_PTR Signature
,
2688 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2693 RtlRemoveEntryHashTable(
2694 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2695 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry
,
2696 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2698 _Must_inspect_result_
2700 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2702 RtlLookupEntryHashTable(
2703 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2704 _In_ ULONG_PTR Signature
,
2705 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2707 _Must_inspect_result_
2709 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2711 RtlGetNextEntryHashTable(
2712 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2713 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
);
2718 RtlInitEnumerationHashTable(
2719 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2720 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2722 _Must_inspect_result_
2724 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2726 RtlEnumerateEntryHashTable(
2727 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2728 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2733 RtlEndEnumerationHashTable(
2734 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2735 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2740 RtlInitWeakEnumerationHashTable(
2741 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2742 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2744 _Must_inspect_result_
2746 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2748 RtlWeaklyEnumerateEntryHashTable(
2749 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2750 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2755 RtlEndWeakEnumerationHashTable(
2756 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
,
2757 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
);
2763 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2768 RtlContractHashTable(
2769 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
);
2773 _IRQL_requires_max_(PASSIVE_LEVEL
)
2774 _Must_inspect_result_
2779 _Out_writes_bytes_to_(UTF8StringMaxByteCount
, *UTF8StringActualByteCount
) PCHAR UTF8StringDestination
,
2780 _In_ ULONG UTF8StringMaxByteCount
,
2781 _Out_ PULONG UTF8StringActualByteCount
,
2782 _In_reads_bytes_(UnicodeStringByteCount
) PCWCH UnicodeStringSource
,
2783 _In_ ULONG UnicodeStringByteCount
);
2785 _IRQL_requires_max_(PASSIVE_LEVEL
)
2786 _Must_inspect_result_
2791 _Out_writes_bytes_to_(UnicodeStringMaxByteCount
, *UnicodeStringActualByteCount
) PWSTR UnicodeStringDestination
,
2792 _In_ ULONG UnicodeStringMaxByteCount
,
2793 _Out_ PULONG UnicodeStringActualByteCount
,
2794 _In_reads_bytes_(UTF8StringByteCount
) PCCH UTF8StringSource
,
2795 _In_ ULONG UTF8StringByteCount
);
2797 _IRQL_requires_max_(APC_LEVEL
)
2802 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor
,
2805 _Out_ ULONG
*NumChanges
);
2810 RtlCreateVirtualAccountSid(
2811 _In_ PCUNICODE_STRING Name
,
2812 _In_ ULONG BaseSubAuthority
,
2813 _Out_writes_bytes_(*SidLength
) PSID Sid
,
2814 _Inout_ PULONG SidLength
);
2817 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2821 #if !defined(MIDL_PASS)
2822 /* inline funftions */
2823 //DECLSPEC_DEPRECATED_DDK_WINXP
2827 RtlConvertLongToLargeInteger(
2828 _In_ LONG SignedInteger
)
2831 ret
.QuadPart
= SignedInteger
;
2835 //DECLSPEC_DEPRECATED_DDK_WINXP
2839 RtlConvertUlongToLargeInteger(
2840 _In_ ULONG UnsignedInteger
)
2843 ret
.QuadPart
= UnsignedInteger
;
2847 //DECLSPEC_DEPRECATED_DDK_WINXP
2851 RtlLargeIntegerShiftLeft(
2852 _In_ LARGE_INTEGER LargeInteger
,
2853 _In_ CCHAR ShiftCount
)
2855 LARGE_INTEGER Result
;
2857 Result
.QuadPart
= LargeInteger
.QuadPart
<< ShiftCount
;
2861 //DECLSPEC_DEPRECATED_DDK_WINXP
2865 RtlLargeIntegerShiftRight(
2866 _In_ LARGE_INTEGER LargeInteger
,
2867 _In_ CCHAR ShiftCount
)
2869 LARGE_INTEGER Result
;
2871 Result
.QuadPart
= (ULONG64
)LargeInteger
.QuadPart
>> ShiftCount
;
2875 //DECLSPEC_DEPRECATED_DDK
2879 RtlEnlargedUnsignedDivide(
2880 _In_ ULARGE_INTEGER Dividend
,
2882 _Out_opt_ PULONG Remainder
)
2885 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2886 return (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2889 //DECLSPEC_DEPRECATED_DDK
2893 RtlLargeIntegerNegate(
2894 _In_ LARGE_INTEGER Subtrahend
)
2896 LARGE_INTEGER Difference
;
2898 Difference
.QuadPart
= -Subtrahend
.QuadPart
;
2902 //DECLSPEC_DEPRECATED_DDK
2906 RtlLargeIntegerSubtract(
2907 _In_ LARGE_INTEGER Minuend
,
2908 _In_ LARGE_INTEGER Subtrahend
)
2910 LARGE_INTEGER Difference
;
2912 Difference
.QuadPart
= Minuend
.QuadPart
- Subtrahend
.QuadPart
;
2916 //DECLSPEC_DEPRECATED_DDK
2920 RtlEnlargedUnsignedMultiply(
2921 _In_ ULONG Multiplicand
,
2922 _In_ ULONG Multiplier
)
2925 ret
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2929 //DECLSPEC_DEPRECATED_DDK
2933 RtlEnlargedIntegerMultiply(
2934 _In_ LONG Multiplicand
,
2935 _In_ LONG Multiplier
)
2938 ret
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2942 _At_(AnsiString
->Buffer
, _Post_equal_to_(Buffer
))
2943 _At_(AnsiString
->Length
, _Post_equal_to_(0))
2944 _At_(AnsiString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2947 RtlInitEmptyAnsiString(
2948 _Out_ PANSI_STRING AnsiString
,
2949 _Pre_maybenull_
_Pre_readable_size_(BufferSize
) __drv_aliasesMem PCHAR Buffer
,
2950 _In_ USHORT BufferSize
)
2952 AnsiString
->Length
= 0;
2953 AnsiString
->MaximumLength
= BufferSize
;
2954 AnsiString
->Buffer
= Buffer
;
2957 _At_(UnicodeString
->Buffer
, _Post_equal_to_(Buffer
))
2958 _At_(UnicodeString
->Length
, _Post_equal_to_(0))
2959 _At_(UnicodeString
->MaximumLength
, _Post_equal_to_(BufferSize
))
2962 RtlInitEmptyUnicodeString(
2963 _Out_ PUNICODE_STRING UnicodeString
,
2964 _Writable_bytes_(BufferSize
)
2965 _When_(BufferSize
!= 0, _Notnull_
)
2966 __drv_aliasesMem PWSTR Buffer
,
2967 _In_ USHORT BufferSize
)
2969 UnicodeString
->Length
= 0;
2970 UnicodeString
->MaximumLength
= BufferSize
;
2971 UnicodeString
->Buffer
= Buffer
;
2975 #if defined(_AMD64_) || defined(_IA64_)
2982 RtlExtendedIntegerMultiply(
2983 _In_ LARGE_INTEGER Multiplicand
,
2984 _In_ LONG Multiplier
)
2987 ret
.QuadPart
= Multiplicand
.QuadPart
* Multiplier
;
2994 RtlExtendedLargeIntegerDivide(
2995 _In_ LARGE_INTEGER Dividend
,
2997 _Out_opt_ PULONG Remainder
)
3000 ret
.QuadPart
= (ULONG64
)Dividend
.QuadPart
/ Divisor
;
3002 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
3010 //DECLSPEC_DEPRECATED_DDK_WINXP
3014 RtlLargeIntegerDivide(
3015 _In_ LARGE_INTEGER Dividend
,
3016 _In_ LARGE_INTEGER Divisor
,
3017 _Out_opt_ PLARGE_INTEGER Remainder
)
3020 ret
.QuadPart
= Dividend
.QuadPart
/ Divisor
.QuadPart
;
3022 Remainder
->QuadPart
= Dividend
.QuadPart
% Divisor
.QuadPart
;
3028 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3032 RtlLargeIntegerDivide(
3033 _In_ LARGE_INTEGER Dividend
,
3034 _In_ LARGE_INTEGER Divisor
,
3035 _Out_opt_ PLARGE_INTEGER Remainder
);
3040 #endif /* defined(_AMD64_) || defined(_IA64_) */
3044 #if defined(_AMD64_)
3046 #define MultiplyHigh __mulh
3047 #define UnsignedMultiplyHigh __umulh
3049 //DECLSPEC_DEPRECATED_DDK
3053 RtlExtendedMagicDivide(
3054 _In_ LARGE_INTEGER Dividend
,
3055 _In_ LARGE_INTEGER MagicDivisor
,
3056 _In_ CCHAR ShiftCount
)
3061 Pos
= (Dividend
.QuadPart
>= 0);
3062 ret64
= UnsignedMultiplyHigh(Pos
? Dividend
.QuadPart
: -Dividend
.QuadPart
,
3063 MagicDivisor
.QuadPart
);
3064 ret64
>>= ShiftCount
;
3065 ret
.QuadPart
= Pos
? ret64
: -(LONG64
)ret64
;
3070 //DECLSPEC_DEPRECATED_DDK
3075 _In_ LARGE_INTEGER Addend1
,
3076 _In_ LARGE_INTEGER Addend2
)
3079 ret
.QuadPart
= Addend1
.QuadPart
+ Addend2
.QuadPart
;
3084 * RtlLargeIntegerAnd(
3085 * IN OUT LARGE_INTEGER Result,
3086 * IN LARGE_INTEGER Source,
3087 * IN LARGE_INTEGER Mask);
3089 #define RtlLargeIntegerAnd(Result, Source, Mask) \
3090 Result.QuadPart = Source.QuadPart & Mask.QuadPart
3092 //DECLSPEC_DEPRECATED_DDK
3096 RtlLargeIntegerArithmeticShift(
3097 _In_ LARGE_INTEGER LargeInteger
,
3098 _In_ CCHAR ShiftCount
)
3101 ret
.QuadPart
= LargeInteger
.QuadPart
>> ShiftCount
;
3106 * RtlLargeIntegerEqualTo(
3107 * IN LARGE_INTEGER Operand1,
3108 * IN LARGE_INTEGER Operand2);
3110 #define RtlLargeIntegerEqualTo(X,Y) \
3111 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
3115 RtlSecureZeroMemory(
3116 _Out_writes_bytes_all_(Size
) PVOID Pointer
,
3119 volatile char* vptr
= (volatile char*)Pointer
;
3120 #if defined(_M_AMD64)
3121 __stosb((PUCHAR
)vptr
, 0, Size
);
3123 char * endptr
= (char *)vptr
+ Size
;
3124 while (vptr
< endptr
) {
3131 #if defined(_M_AMD64)
3132 _Must_inspect_result_
3136 _In_ PRTL_BITMAP BitMapHeader
,
3137 _In_range_(<, BitMapHeader
->SizeOfBitMap
) ULONG BitPosition
)
3139 return BitTest64((LONG64 CONST
*)BitMapHeader
->Buffer
, (LONG64
)BitPosition
);
3142 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3143 #endif /* defined(_M_AMD64) */
3145 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3146 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3147 ((X).HighPart > (Y).HighPart) \
3150 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3151 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3152 ((X).HighPart > (Y).HighPart) \
3155 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3156 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3159 #define RtlLargeIntegerLessThan(X,Y) ( \
3160 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3161 ((X).HighPart < (Y).HighPart) \
3164 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3165 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3166 ((X).HighPart < (Y).HighPart) \
3169 #define RtlLargeIntegerGreaterThanZero(X) ( \
3170 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3171 ((X).HighPart > 0 ) \
3174 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3176 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3178 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3180 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3182 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3184 #endif /* !defined(MIDL_PASS) */
3186 /* Byte Swap Functions */
3187 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
3188 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
3189 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
3191 #if defined(_MSC_VER)
3192 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg)
3193 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg)
3195 # define __assert_annotationA(msg) \
3196 DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg)
3197 # define __assert_annotationW(msg) \
3198 DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg)
3202 # define NT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp)
3204 # define NT_ANALYSIS_ASSUME(_exp) ((void)0)
3206 # define NT_ANALYSIS_ASSUME(_exp) __noop(_exp)
3209 #define NT_ASSERT_ACTION(exp) \
3210 (NT_ANALYSIS_ASSUME(exp), \
3212 (__assert_annotationA(#exp), \
3213 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3215 #define NT_ASSERTMSG_ACTION(msg, exp) \
3216 (NT_ANALYSIS_ASSUME(exp), \
3218 (__assert_annotationA(msg), \
3219 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3221 #define NT_ASSERTMSGW_ACTION(msg, exp) \
3222 (NT_ANALYSIS_ASSUME(exp), \
3224 (__assert_annotationW(msg), \
3225 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3229 #define RTL_VERIFY(exp) \
3231 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3233 #define RTL_VERIFYMSG(msg, exp) \
3235 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3237 #define RTL_SOFT_VERIFY(exp) \
3239 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3241 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3243 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3245 /* The ASSERTs must be cast to void to avoid warnings about unused results. */
3246 #define ASSERT (void)RTL_VERIFY
3247 #define ASSERTMSG (void)RTL_VERIFYMSG
3248 #define RTL_SOFT_ASSERT (void)RTL_SOFT_VERIFY
3249 #define RTL_SOFT_ASSERTMSG (void)RTL_SOFT_VERIFYMSG
3251 #define NT_VERIFY NT_ASSERT_ACTION
3252 #define NT_VERIFYMSG NT_ASSERTMSG_ACTION
3253 #define NT_VERIFYMSGW NT_ASSERTMSGW_ACTION
3255 #define NT_ASSERT_ASSUME (void)NT_ASSERT_ACTION
3256 #define NT_ASSERTMSG_ASSUME (void)NT_ASSERTMSG_ACTION
3257 #define NT_ASSERTMSGW_ASSUME (void)NT_ASSERTMSGW_ACTION
3259 #define NT_ASSERT_NOASSUME (void)NT_ASSERT_ACTION
3260 #define NT_ASSERTMSG_NOASSUME (void)NT_ASSERTMSG_ACTION
3261 #define NT_ASSERTMSGW_NOASSUME (void)NT_ASSERTMSGW_ACTION
3265 #define ASSERT(exp) ((void)0)
3266 #define ASSERTMSG(msg, exp) ((void)0)
3268 #define RTL_SOFT_ASSERT(exp) ((void)0)
3269 #define RTL_SOFT_ASSERTMSG(msg, exp) ((void)0)
3271 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3272 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3274 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3275 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3277 #define NT_VERIFY(exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3278 #define NT_VERIFYMSG(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3279 #define NT_VERIFYMSGW(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE))
3281 #define NT_ASSERT_ASSUME(exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3282 #define NT_ASSERTMSG_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3283 #define NT_ASSERTMSGW_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0)
3285 #define NT_ASSERT_NOASSUME(exp) ((void)0)
3286 #define NT_ASSERTMSG_NOASSUME(msg, exp) ((void)0)
3287 #define NT_ASSERTMSGW_NOASSUME(msg, exp) ((void)0)
3291 #define NT_FRE_ASSERT (void)NT_ASSERT_ACTION
3292 #define NT_FRE_ASSERTMSG (void)NT_ASSERTMSG_ACTION
3293 #define NT_FRE_ASSERTMSGW (void)NT_ASSERTMSGW_ACTION
3295 #ifdef NT_ASSERT_ALWAYS_ASSUMES
3296 # define NT_ASSERT NT_ASSERT_ASSUME
3297 # define NT_ASSERTMSG NT_ASSERTMSG_ASSUME
3298 # define NT_ASSERTMSGW NT_ASSERTMSGW_ASSUME
3300 # define NT_ASSERT NT_ASSERT_NOASSUME
3301 # define NT_ASSERTMSG NT_ASSERTMSG_NOASSUME
3302 # define NT_ASSERTMSGW NT_ASSERTMSGW_NOASSUME
3303 #endif /* NT_ASSERT_ALWAYS_ASSUMES */
3305 #if defined(_MSC_VER) && (defined(__REACTOS__) || defined(ASSERT_ALWAYS_NT_ASSERT))
3307 #define ASSERT NT_ASSERT
3309 #define ASSERTMSG NT_ASSERTMSG
3311 #define ASSERTMSGW NT_ASSERTMSGW
3313 #define RTL_VERIFY NT_VERIFY
3316 #define InitializeListHead32(ListHead) (\
3317 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3319 #if !defined(_WINBASE_)
3321 #if defined(_WIN64) && !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || !defined(_NTOSP_))
3325 InitializeSListHead(
3326 _Out_ PSLIST_HEADER SListHead
);
3328 #else /* defined(_WIN64) && ... */
3331 _IRQL_requires_max_(APC_LEVEL
)
3337 _In_ NTSTATUS Status
);
3341 InitializeSListHead(
3342 _Out_ PSLIST_HEADER SListHead
)
3345 if (((ULONG_PTR
)SListHead
& 0xf) != 0) {
3346 ExRaiseStatus(STATUS_DATATYPE_MISALIGNMENT
);
3349 SListHead
->Region
= (ULONG_PTR
)SListHead
& VRN_MASK
;
3351 SListHead
->Region
= 0;
3354 SListHead
->Alignment
= 0;
3357 #endif /* defined(_WIN64) && ... */
3364 InterlockedPushEntrySList(
3365 _Inout_ PSLIST_HEADER SListHead
,
3366 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry
);
3371 InterlockedPopEntrySList(
3372 _Inout_ PSLIST_HEADER SListHead
);
3374 #define InterlockedFlushSList(SListHead) \
3375 ExInterlockedFlushSList(SListHead)
3379 #define InterlockedPushEntrySList(SListHead, SListEntry) \
3380 ExpInterlockedPushEntrySList(SListHead, SListEntry)
3382 #define InterlockedPopEntrySList(SListHead) \
3383 ExpInterlockedPopEntrySList(SListHead)
3385 #define InterlockedFlushSList(SListHead) \
3386 ExpInterlockedFlushSList(SListHead)
3390 #define QueryDepthSList(SListHead) \
3391 ExQueryDepthSList(SListHead)
3393 #endif /* !defined(_WINBASE_) */
3395 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
3396 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
3397 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
3398 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
3399 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
3400 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
3401 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
3402 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
3403 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
3404 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
3405 (PCONTEXT_EX)(Context + 1), \
3409 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable
)(
3410 _In_ ULONG Version
);
3413 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled
)(
3414 _In_ ULONG Version
);
3416 #ifndef RtlIsNtDdiVersionAvailable
3417 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3420 #ifndef RtlIsServicePackVersionInstalled
3421 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3424 #define RtlInterlockedSetBits(Flags, Flag) \
3425 InterlockedOr((PLONG)(Flags), Flag)
3427 #define RtlInterlockedAndBits(Flags, Flag) \
3428 InterlockedAnd((PLONG)(Flags), Flag)
3430 #define RtlInterlockedClearBits(Flags, Flag) \
3431 RtlInterlockedAndBits(Flags, ~(Flag))
3433 #define RtlInterlockedXorBits(Flags, Flag) \
3434 InterlockedXor(Flags, Flag)
3436 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3437 (VOID) RtlInterlockedSetBits(Flags, Flag)
3439 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3440 (VOID) RtlInterlockedAndBits(Flags, Flag)
3442 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3443 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3449 #ifdef RTL_USE_AVL_TABLES
3451 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
3452 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
3453 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
3454 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
3455 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
3456 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
3457 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
3458 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
3459 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
3460 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
3461 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
3463 #endif /* RTL_USE_AVL_TABLES */
3465 #define RtlInitializeSplayLinks(Links) { \
3466 PRTL_SPLAY_LINKS _SplayLinks; \
3467 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
3468 _SplayLinks->Parent = _SplayLinks; \
3469 _SplayLinks->LeftChild = NULL; \
3470 _SplayLinks->RightChild = NULL; \
3473 #define RtlIsLeftChild(Links) \
3474 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3476 #define RtlIsRightChild(Links) \
3477 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3479 #define RtlRightChild(Links) \
3480 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3482 #define RtlIsRoot(Links) \
3483 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3485 #define RtlLeftChild(Links) \
3486 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3488 #define RtlParent(Links) \
3489 ((PRTL_SPLAY_LINKS)(Links))->Parent
3491 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3493 PRTL_SPLAY_LINKS _SplayParent; \
3494 PRTL_SPLAY_LINKS _SplayChild; \
3495 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3496 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3497 _SplayParent->LeftChild = _SplayChild; \
3498 _SplayChild->Parent = _SplayParent; \
3501 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3503 PRTL_SPLAY_LINKS _SplayParent; \
3504 PRTL_SPLAY_LINKS _SplayChild; \
3505 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3506 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3507 _SplayParent->RightChild = _SplayChild; \
3508 _SplayChild->Parent = _SplayParent; \
3511 #if !defined(MIDL_PASS)
3516 RtlConvertLongToLuid(
3522 Temp
.QuadPart
= Val
;
3523 Luid
.LowPart
= Temp
.u
.LowPart
;
3524 Luid
.HighPart
= Temp
.u
.HighPart
;
3531 RtlConvertUlongToLuid(
3541 #endif /* !defined(MIDL_PASS) */
3543 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3544 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3545 *CallersAddress = (PVOID)_ReturnAddress(); \
3546 *CallersCaller = NULL;
3548 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3552 RtlGetCallersAddress(
3553 _Out_ PVOID
*CallersAddress
,
3554 _Out_ PVOID
*CallersCaller
);
3558 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3560 #if (NTDDI_VERSION >= NTDDI_WIN7)
3565 RtlInitHashTableContext(
3566 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3568 Context
->ChainHead
= NULL
;
3569 Context
->PrevLinkage
= NULL
;
3575 RtlInitHashTableContextFromEnumerator(
3576 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
,
3577 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator
)
3579 Context
->ChainHead
= Enumerator
->ChainHead
;
3580 Context
->PrevLinkage
= Enumerator
->HashEntry
.Linkage
.Blink
;
3586 RtlReleaseHashTableContext(
3587 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context
)
3589 UNREFERENCED_PARAMETER(Context
);
3596 RtlTotalBucketsHashTable(
3597 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3599 return HashTable
->TableSize
;
3605 RtlNonEmptyBucketsHashTable(
3606 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3608 return HashTable
->NonEmptyBuckets
;
3614 RtlEmptyBucketsHashTable(
3615 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3617 return HashTable
->TableSize
- HashTable
->NonEmptyBuckets
;
3623 RtlTotalEntriesHashTable(
3624 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3626 return HashTable
->NumEntries
;
3632 RtlActiveEnumeratorsHashTable(
3633 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable
)
3635 return HashTable
->NumEnumerators
;
3638 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3640 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3645 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3646 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3648 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3649 RtlxUnicodeStringToOemSize(STRING) : \
3650 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3653 #define RtlOemStringToUnicodeSize(STRING) ( \
3654 NLS_MB_OEM_CODE_PAGE_TAG ? \
3655 RtlxOemStringToUnicodeSize(STRING) : \
3656 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3659 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3660 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3663 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3664 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))