[XDK/DDK] Fix copy pasta
[reactos.git] / reactos / include / xdk / rtlfuncs.h
1 /******************************************************************************
2 * Runtime Library Functions *
3 ******************************************************************************/
4
5 $if (_WDMDDK_)
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
24
25 DECLSPEC_NORETURN
26 FORCEINLINE
27 VOID
28 RtlFailFast(
29 _In_ ULONG Code)
30 {
31 __fastfail(Code);
32 }
33
34 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && (defined(_M_CEE_PURE) || defined(_M_CEE_SAFE))
35 #define NO_KERNEL_LIST_ENTRY_CHECKS
36 #endif
37
38 #if !defined(EXTRA_KERNEL_LIST_ENTRY_CHECKS) && defined(__REACTOS__)
39 #define EXTRA_KERNEL_LIST_ENTRY_CHECKS
40 #endif
41
42 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
43
44 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
45
46 FORCEINLINE
47 VOID
48 InitializeListHead(
49 _Out_ PLIST_ENTRY ListHead)
50 {
51 ListHead->Flink = ListHead->Blink = ListHead;
52 }
53
54 _Must_inspect_result_
55 FORCEINLINE
56 BOOLEAN
57 IsListEmpty(
58 _In_ const LIST_ENTRY * ListHead)
59 {
60 return (BOOLEAN)(ListHead->Flink == ListHead);
61 }
62
63 FORCEINLINE
64 BOOLEAN
65 RemoveEntryListUnsafe(
66 _In_ PLIST_ENTRY Entry)
67 {
68 PLIST_ENTRY OldFlink;
69 PLIST_ENTRY OldBlink;
70
71 OldFlink = Entry->Flink;
72 OldBlink = Entry->Blink;
73 OldFlink->Blink = OldBlink;
74 OldBlink->Flink = OldFlink;
75 return (BOOLEAN)(OldFlink == OldBlink);
76 }
77
78 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
79 FORCEINLINE
80 VOID
81 FatalListEntryError(
82 _In_ PVOID P1,
83 _In_ PVOID P2,
84 _In_ PVOID P3)
85 {
86 UNREFERENCED_PARAMETER(P1);
87 UNREFERENCED_PARAMETER(P2);
88 UNREFERENCED_PARAMETER(P3);
89
90 RtlFailFast(FAST_FAIL_CORRUPT_LIST_ENTRY);
91 }
92
93 FORCEINLINE
94 VOID
95 RtlpCheckListEntry(
96 _In_ PLIST_ENTRY Entry)
97 {
98 if (Entry->Flink->Blink != Entry || Entry->Blink->Flink != Entry)
99 FatalListEntryError(Entry->Blink, Entry, Entry->Flink);
100 }
101 #endif
102
103 FORCEINLINE
104 BOOLEAN
105 RemoveEntryList(
106 _In_ PLIST_ENTRY Entry)
107 {
108 PLIST_ENTRY OldFlink;
109 PLIST_ENTRY OldBlink;
110
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);
117 #endif
118 if (OldFlink->Blink != Entry || OldBlink->Flink != Entry)
119 FatalListEntryError(OldBlink, Entry, OldFlink);
120 #endif
121 OldFlink->Blink = OldBlink;
122 OldBlink->Flink = OldFlink;
123 return (BOOLEAN)(OldFlink == OldBlink);
124 }
125
126 FORCEINLINE
127 PLIST_ENTRY
128 RemoveHeadList(
129 _Inout_ PLIST_ENTRY ListHead)
130 {
131 PLIST_ENTRY Flink;
132 PLIST_ENTRY Entry;
133
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);
139 #endif
140 #endif
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);
146 #endif
147 ListHead->Flink = Flink;
148 Flink->Blink = ListHead;
149 return Entry;
150 }
151
152 FORCEINLINE
153 PLIST_ENTRY
154 RemoveTailList(
155 _Inout_ PLIST_ENTRY ListHead)
156 {
157 PLIST_ENTRY Blink;
158 PLIST_ENTRY Entry;
159
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);
165 #endif
166 #endif
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);
172 #endif
173 ListHead->Blink = Blink;
174 Blink->Flink = ListHead;
175 return Entry;
176 }
177
178 FORCEINLINE
179 VOID
180 InsertTailList(
181 _Inout_ PLIST_ENTRY ListHead,
182 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
183 {
184 PLIST_ENTRY OldBlink;
185 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
186 RtlpCheckListEntry(ListHead);
187 #endif
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);
194 #endif
195 OldBlink->Flink = Entry;
196 ListHead->Blink = Entry;
197 }
198
199 FORCEINLINE
200 VOID
201 InsertHeadList(
202 _Inout_ PLIST_ENTRY ListHead,
203 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
204 {
205 PLIST_ENTRY OldFlink;
206 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG
207 RtlpCheckListEntry(ListHead);
208 #endif
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);
215 #endif
216 OldFlink->Blink = Entry;
217 ListHead->Flink = Entry;
218 }
219
220 FORCEINLINE
221 VOID
222 AppendTailList(
223 _Inout_ PLIST_ENTRY ListHead,
224 _Inout_ PLIST_ENTRY ListToAppend)
225 {
226 PLIST_ENTRY ListEnd = ListHead->Blink;
227
228 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS)
229 RtlpCheckListEntry(ListHead);
230 RtlpCheckListEntry(ListToAppend);
231 #endif
232 ListHead->Blink->Flink = ListToAppend;
233 ListHead->Blink = ListToAppend->Blink;
234 ListToAppend->Blink->Flink = ListHead;
235 ListToAppend->Blink = ListEnd;
236 }
237
238 FORCEINLINE
239 PSINGLE_LIST_ENTRY
240 PopEntryList(
241 _Inout_ PSINGLE_LIST_ENTRY ListHead)
242 {
243 PSINGLE_LIST_ENTRY FirstEntry;
244 FirstEntry = ListHead->Next;
245 if (FirstEntry != NULL) {
246 ListHead->Next = FirstEntry->Next;
247 }
248 return FirstEntry;
249 }
250
251 FORCEINLINE
252 VOID
253 PushEntryList(
254 _Inout_ PSINGLE_LIST_ENTRY ListHead,
255 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
256 {
257 Entry->Next = ListHead->Next;
258 ListHead->Next = Entry;
259 }
260
261 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
262
263 __analysis_noreturn
264 NTSYSAPI
265 VOID
266 NTAPI
267 RtlAssert(
268 _In_ PVOID FailedAssertion,
269 _In_ PVOID FileName,
270 _In_ ULONG LineNumber,
271 _In_opt_z_ PSTR Message);
272
273 /* VOID
274 * RtlCopyMemory(
275 * IN VOID UNALIGNED *Destination,
276 * IN CONST VOID UNALIGNED *Source,
277 * IN SIZE_T Length)
278 */
279 #define RtlCopyMemory(Destination, Source, Length) \
280 memcpy(Destination, Source, Length)
281
282 #define RtlCopyBytes RtlCopyMemory
283
284 #if defined(_M_AMD64)
285 NTSYSAPI
286 VOID
287 NTAPI
288 RtlCopyMemoryNonTemporal(
289 _Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
290 _In_reads_bytes_(Length) const VOID UNALIGNED *Source,
291 _In_ SIZE_T Length);
292 #else
293 #define RtlCopyMemoryNonTemporal RtlCopyMemory
294 #endif
295
296 /* BOOLEAN
297 * RtlEqualLuid(
298 * IN PLUID Luid1,
299 * IN PLUID Luid2)
300 */
301 #define RtlEqualLuid(Luid1, Luid2) \
302 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
303
304 /* LOGICAL
305 * RtlEqualMemory(
306 * IN VOID UNALIGNED *Destination,
307 * IN CONST VOID UNALIGNED *Source,
308 * IN SIZE_T Length)
309 */
310 #define RtlEqualMemory(Destination, Source, Length) \
311 (!memcmp(Destination, Source, Length))
312
313 /* VOID
314 * RtlFillMemory(
315 * IN VOID UNALIGNED *Destination,
316 * IN SIZE_T Length,
317 * IN UCHAR Fill)
318 */
319 #define RtlFillMemory(Destination, Length, Fill) \
320 memset(Destination, Fill, Length)
321
322 #define RtlFillBytes RtlFillMemory
323
324 _IRQL_requires_max_(PASSIVE_LEVEL)
325 NTSYSAPI
326 VOID
327 NTAPI
328 RtlFreeUnicodeString(
329 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem))
330 PUNICODE_STRING UnicodeString);
331
332 _IRQL_requires_max_(PASSIVE_LEVEL)
333 _Must_inspect_result_
334 NTSYSAPI
335 NTSTATUS
336 NTAPI
337 RtlGUIDFromString(
338 _In_ PUNICODE_STRING GuidString,
339 _Out_ GUID *Guid);
340
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)))
349 NTSYSAPI
350 VOID
351 NTAPI
352 RtlInitUnicodeString(
353 _Out_ PUNICODE_STRING DestinationString,
354 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString);
355
356 /* VOID
357 * RtlMoveMemory(
358 * IN VOID UNALIGNED *Destination,
359 * IN CONST VOID UNALIGNED *Source,
360 * IN SIZE_T Length)
361 */
362 #define RtlMoveMemory(Destination, Source, Length) \
363 memmove(Destination, Source, Length)
364
365 _IRQL_requires_max_(PASSIVE_LEVEL)
366 _Must_inspect_result_
367 NTSYSAPI
368 NTSTATUS
369 NTAPI
370 RtlStringFromGUID(
371 _In_ REFGUID Guid,
372 _Out_ _At_(GuidString->Buffer, __drv_allocatesMem(Mem))
373 PUNICODE_STRING GuidString);
374
375 /* VOID
376 * RtlZeroMemory(
377 * IN VOID UNALIGNED *Destination,
378 * IN SIZE_T Length)
379 */
380 #define RtlZeroMemory(Destination, Length) \
381 memset(Destination, 0, Length)
382
383 #define RtlZeroBytes RtlZeroMemory
384 $endif (_WDMDDK_)
385
386 #if (NTDDI_VERSION >= NTDDI_WIN2K)
387
388 $if (_WDMDDK_)
389 _Must_inspect_result_
390 NTSYSAPI
391 BOOLEAN
392 NTAPI
393 RtlAreBitsClear(
394 _In_ PRTL_BITMAP BitMapHeader,
395 _In_ ULONG StartingIndex,
396 _In_ ULONG Length);
397
398 _Must_inspect_result_
399 NTSYSAPI
400 BOOLEAN
401 NTAPI
402 RtlAreBitsSet(
403 _In_ PRTL_BITMAP BitMapHeader,
404 _In_ ULONG StartingIndex,
405 _In_ ULONG Length);
406
407 _IRQL_requires_max_(PASSIVE_LEVEL)
408 _Must_inspect_result_
409 NTSYSAPI
410 NTSTATUS
411 NTAPI
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);
418
419 _IRQL_requires_max_(PASSIVE_LEVEL)
420 NTSYSAPI
421 ULONG
422 NTAPI
423 RtlxAnsiStringToUnicodeSize(
424 _In_ PCANSI_STRING AnsiString);
425
426 #define RtlAnsiStringToUnicodeSize(String) ( \
427 NLS_MB_CODE_PAGE_TAG ? \
428 RtlxAnsiStringToUnicodeSize(String) : \
429 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
430 )
431
432 _Success_(1)
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)))
441 NTSYSAPI
442 NTSTATUS
443 NTAPI
444 RtlAppendUnicodeStringToString(
445 _Inout_ PUNICODE_STRING Destination,
446 _In_ PCUNICODE_STRING Source);
447
448 _Success_(1)
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))) */
457 NTSYSAPI
458 NTSTATUS
459 NTAPI
460 RtlAppendUnicodeToString(
461 _Inout_ PUNICODE_STRING Destination,
462 _In_opt_z_ PCWSTR Source);
463
464 _IRQL_requires_max_(PASSIVE_LEVEL)
465 _Must_inspect_result_
466 NTSYSAPI
467 NTSTATUS
468 NTAPI
469 RtlCheckRegistryKey(
470 _In_ ULONG RelativeTo,
471 _In_ PWSTR Path);
472
473 NTSYSAPI
474 VOID
475 NTAPI
476 RtlClearAllBits(
477 _In_ PRTL_BITMAP BitMapHeader);
478
479 NTSYSAPI
480 VOID
481 NTAPI
482 RtlClearBits(
483 _In_ PRTL_BITMAP BitMapHeader,
484 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
485 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear);
486
487 _Must_inspect_result_
488 NTSYSAPI
489 SIZE_T
490 NTAPI
491 RtlCompareMemory(
492 _In_ const VOID *Source1,
493 _In_ const VOID *Source2,
494 _In_ SIZE_T Length);
495
496 _IRQL_requires_max_(PASSIVE_LEVEL)
497 _Must_inspect_result_
498 NTSYSAPI
499 LONG
500 NTAPI
501 RtlCompareUnicodeString(
502 _In_ PCUNICODE_STRING String1,
503 _In_ PCUNICODE_STRING String2,
504 _In_ BOOLEAN CaseInSensitive);
505
506 _IRQL_requires_max_(PASSIVE_LEVEL)
507 _Must_inspect_result_
508 NTSYSAPI
509 LONG
510 NTAPI
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);
517
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)))
525 NTSYSAPI
526 VOID
527 NTAPI
528 RtlCopyUnicodeString(
529 _Inout_ PUNICODE_STRING DestinationString,
530 _In_opt_ PCUNICODE_STRING SourceString);
531
532 _IRQL_requires_max_(PASSIVE_LEVEL)
533 NTSYSAPI
534 NTSTATUS
535 NTAPI
536 RtlCreateRegistryKey(
537 _In_ ULONG RelativeTo,
538 _In_ PWSTR Path);
539
540 _IRQL_requires_max_(APC_LEVEL)
541 NTSYSAPI
542 NTSTATUS
543 NTAPI
544 RtlCreateSecurityDescriptor(
545 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor,
546 _In_ ULONG Revision);
547
548 _IRQL_requires_max_(PASSIVE_LEVEL)
549 NTSYSAPI
550 NTSTATUS
551 NTAPI
552 RtlDeleteRegistryValue(
553 _In_ ULONG RelativeTo,
554 _In_ PCWSTR Path,
555 _In_z_ PCWSTR ValueName);
556
557 _IRQL_requires_max_(PASSIVE_LEVEL)
558 _Must_inspect_result_
559 NTSYSAPI
560 BOOLEAN
561 NTAPI
562 RtlEqualUnicodeString(
563 _In_ CONST UNICODE_STRING *String1,
564 _In_ CONST UNICODE_STRING *String2,
565 _In_ BOOLEAN CaseInSensitive);
566
567 #if !defined(_AMD64_) && !defined(_IA64_)
568 NTSYSAPI
569 LARGE_INTEGER
570 NTAPI
571 RtlExtendedIntegerMultiply(
572 _In_ LARGE_INTEGER Multiplicand,
573 _In_ LONG Multiplier);
574
575 NTSYSAPI
576 LARGE_INTEGER
577 NTAPI
578 RtlExtendedLargeIntegerDivide(
579 _In_ LARGE_INTEGER Dividend,
580 _In_ ULONG Divisor,
581 _Out_opt_ PULONG Remainder);
582 #endif
583
584 #if defined(_X86_) || defined(_IA64_)
585 NTSYSAPI
586 LARGE_INTEGER
587 NTAPI
588 RtlExtendedMagicDivide(
589 _In_ LARGE_INTEGER Dividend,
590 _In_ LARGE_INTEGER MagicDivisor,
591 _In_ CCHAR ShiftCount);
592 #endif
593
594 _IRQL_requires_max_(PASSIVE_LEVEL)
595 NTSYSAPI
596 VOID
597 NTAPI
598 RtlFreeAnsiString(
599 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
600 PANSI_STRING AnsiString);
601
602 _Success_(return != -1)
603 _Must_inspect_result_
604 NTSYSAPI
605 ULONG
606 NTAPI
607 RtlFindClearBits(
608 _In_ PRTL_BITMAP BitMapHeader,
609 _In_ ULONG NumberToFind,
610 _In_ ULONG HintIndex);
611
612 _Success_(return != -1)
613 NTSYSAPI
614 ULONG
615 NTAPI
616 RtlFindClearBitsAndSet(
617 _In_ PRTL_BITMAP BitMapHeader,
618 _In_ ULONG NumberToFind,
619 _In_ ULONG HintIndex);
620
621 NTSYSAPI
622 ULONG
623 NTAPI
624 RtlFindFirstRunClear(
625 _In_ PRTL_BITMAP BitMapHeader,
626 _Out_ PULONG StartingIndex);
627
628 NTSYSAPI
629 ULONG
630 NTAPI
631 RtlFindClearRuns(
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);
636
637 NTSYSAPI
638 ULONG
639 NTAPI
640 RtlFindLastBackwardRunClear(
641 _In_ PRTL_BITMAP BitMapHeader,
642 _In_ ULONG FromIndex,
643 _Out_ PULONG StartingRunIndex);
644
645 _Success_(return != -1)
646 _Must_inspect_result_
647 NTSYSAPI
648 CCHAR
649 NTAPI
650 RtlFindLeastSignificantBit(
651 _In_ ULONGLONG Set);
652
653 NTSYSAPI
654 ULONG
655 NTAPI
656 RtlFindLongestRunClear(
657 _In_ PRTL_BITMAP BitMapHeader,
658 _Out_ PULONG StartingIndex);
659
660 _Success_(return != -1)
661 _Must_inspect_result_
662 NTSYSAPI
663 CCHAR
664 NTAPI
665 RtlFindMostSignificantBit(
666 _In_ ULONGLONG Set);
667
668 NTSYSAPI
669 ULONG
670 NTAPI
671 RtlFindNextForwardRunClear(
672 _In_ PRTL_BITMAP BitMapHeader,
673 _In_ ULONG FromIndex,
674 _Out_ PULONG StartingRunIndex);
675
676 _Success_(return != -1)
677 _Must_inspect_result_
678 NTSYSAPI
679 ULONG
680 NTAPI
681 RtlFindSetBits(
682 _In_ PRTL_BITMAP BitMapHeader,
683 _In_ ULONG NumberToFind,
684 _In_ ULONG HintIndex);
685
686 _Success_(return != -1)
687 NTSYSAPI
688 ULONG
689 NTAPI
690 RtlFindSetBitsAndClear(
691 _In_ PRTL_BITMAP BitMapHeader,
692 _In_ ULONG NumberToFind,
693 _In_ ULONG HintIndex);
694
695 _IRQL_requires_max_(DISPATCH_LEVEL)
696 NTSYSAPI
697 VOID
698 NTAPI
699 RtlInitAnsiString(
700 _Out_ PANSI_STRING DestinationString,
701 _In_opt_z_ __drv_aliasesMem PCSZ SourceString);
702
703 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
704 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
705 NTSYSAPI
706 VOID
707 NTAPI
708 RtlInitializeBitMap(
709 _Out_ PRTL_BITMAP BitMapHeader,
710 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
711 _In_opt_ ULONG SizeOfBitMap);
712
713 _IRQL_requires_max_(DISPATCH_LEVEL)
714 NTSYSAPI
715 VOID
716 NTAPI
717 RtlInitString(
718 _Out_ PSTRING DestinationString,
719 _In_opt_z_ __drv_aliasesMem PCSZ SourceString);
720
721 _IRQL_requires_max_(PASSIVE_LEVEL)
722 _At_(String->MaximumLength, _Const_)
723 NTSYSAPI
724 NTSTATUS
725 NTAPI
726 RtlIntegerToUnicodeString(
727 _In_ ULONG Value,
728 _In_opt_ ULONG Base,
729 _Inout_ PUNICODE_STRING String);
730
731 _IRQL_requires_max_(PASSIVE_LEVEL)
732 _At_(String->MaximumLength, _Const_)
733 NTSYSAPI
734 NTSTATUS
735 NTAPI
736 RtlInt64ToUnicodeString(
737 _In_ ULONGLONG Value,
738 _In_opt_ ULONG Base,
739 _Inout_ PUNICODE_STRING String);
740
741 #ifdef _WIN64
742 #define RtlIntPtrToUnicodeString(Value, Base, String) \
743 RtlInt64ToUnicodeString(Value, Base, String)
744 #else
745 #define RtlIntPtrToUnicodeString(Value, Base, String) \
746 RtlIntegerToUnicodeString(Value, Base, String)
747 #endif
748
749 /* BOOLEAN
750 * RtlIsZeroLuid(
751 * IN PLUID L1);
752 */
753 #define RtlIsZeroLuid(_L1) \
754 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
755
756 _IRQL_requires_max_(APC_LEVEL)
757 NTSYSAPI
758 ULONG
759 NTAPI
760 RtlLengthSecurityDescriptor(
761 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
762
763 NTSYSAPI
764 ULONG
765 NTAPI
766 RtlNumberOfClearBits(
767 _In_ PRTL_BITMAP BitMapHeader);
768
769 NTSYSAPI
770 ULONG
771 NTAPI
772 RtlNumberOfSetBits(
773 _In_ PRTL_BITMAP BitMapHeader);
774
775 _IRQL_requires_max_(PASSIVE_LEVEL)
776 NTSYSAPI
777 NTSTATUS
778 NTAPI
779 RtlQueryRegistryValues(
780 _In_ ULONG RelativeTo,
781 _In_ PCWSTR Path,
782 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
783 PRTL_QUERY_REGISTRY_TABLE QueryTable,
784 _In_opt_ PVOID Context,
785 _In_opt_ PVOID Environment);
786
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
794
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)
799
800 NTSYSAPI
801 VOID
802 NTAPI
803 RtlSetAllBits(
804 _In_ PRTL_BITMAP BitMapHeader);
805
806 NTSYSAPI
807 VOID
808 NTAPI
809 RtlSetBits(
810 _In_ PRTL_BITMAP BitMapHeader,
811 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
812 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet);
813
814 _IRQL_requires_max_(APC_LEVEL)
815 NTSYSAPI
816 NTSTATUS
817 NTAPI
818 RtlSetDaclSecurityDescriptor(
819 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
820 _In_ BOOLEAN DaclPresent,
821 _In_opt_ PACL Dacl,
822 _In_opt_ BOOLEAN DaclDefaulted);
823
824 #if defined(_AMD64_)
825
826 /* VOID
827 * RtlStoreUlong(
828 * IN PULONG Address,
829 * IN ULONG Value);
830 */
831 #define RtlStoreUlong(Address,Value) \
832 *(ULONG UNALIGNED *)(Address) = (Value)
833
834 /* VOID
835 * RtlStoreUlonglong(
836 * IN OUT PULONGLONG Address,
837 * ULONGLONG Value);
838 */
839 #define RtlStoreUlonglong(Address,Value) \
840 *(ULONGLONG UNALIGNED *)(Address) = (Value)
841
842 /* VOID
843 * RtlStoreUshort(
844 * IN PUSHORT Address,
845 * IN USHORT Value);
846 */
847 #define RtlStoreUshort(Address,Value) \
848 *(USHORT UNALIGNED *)(Address) = (Value)
849
850 /* VOID
851 * RtlRetrieveUshort(
852 * PUSHORT DestinationAddress,
853 * PUSHORT SourceAddress);
854 */
855 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
856 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
857
858 /* VOID
859 * RtlRetrieveUlong(
860 * PULONG DestinationAddress,
861 * PULONG SourceAddress);
862 */
863 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
864 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
865
866 #else
867
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)); \
874 } \
875 else { \
876 *((PULONG)(Address)) = (ULONG) (Value); \
877 }
878
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); \
885 } else { \
886 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
887 }
888
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)); \
893 } \
894 else { \
895 *((PUSHORT) (Address)) = (USHORT)Value; \
896 }
897
898 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
899 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
900 { \
901 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
902 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
903 } \
904 else \
905 { \
906 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
907 }
908
909 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
910 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
911 { \
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]; \
916 } \
917 else \
918 { \
919 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
920 }
921
922 #endif /* defined(_AMD64_) */
923
924 #ifdef _WIN64
925 /* VOID
926 * RtlStoreUlongPtr(
927 * IN OUT PULONG_PTR Address,
928 * IN ULONG_PTR Value);
929 */
930 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
931 #else
932 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
933 #endif /* _WIN64 */
934
935 _Success_(return!=FALSE)
936 _Must_inspect_result_
937 NTSYSAPI
938 BOOLEAN
939 NTAPI
940 RtlTimeFieldsToTime(
941 _In_ PTIME_FIELDS TimeFields,
942 _Out_ PLARGE_INTEGER Time);
943
944 NTSYSAPI
945 VOID
946 NTAPI
947 RtlTimeToTimeFields(
948 _In_ PLARGE_INTEGER Time,
949 _Out_ PTIME_FIELDS TimeFields);
950
951 NTSYSAPI
952 ULONG
953 FASTCALL
954 RtlUlongByteSwap(
955 _In_ ULONG Source);
956
957 NTSYSAPI
958 ULONGLONG
959 FASTCALL
960 RtlUlonglongByteSwap(
961 _In_ ULONGLONG Source);
962
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_)
971 NTSYSAPI
972 NTSTATUS
973 NTAPI
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);
980
981 _IRQL_requires_max_(PASSIVE_LEVEL)
982 NTSYSAPI
983 ULONG
984 NTAPI
985 RtlxUnicodeStringToAnsiSize(
986 _In_ PCUNICODE_STRING UnicodeString);
987
988 #define RtlUnicodeStringToAnsiSize(String) ( \
989 NLS_MB_CODE_PAGE_TAG ? \
990 RtlxUnicodeStringToAnsiSize(String) : \
991 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
992 )
993
994 _IRQL_requires_max_(PASSIVE_LEVEL)
995 NTSYSAPI
996 NTSTATUS
997 NTAPI
998 RtlUnicodeStringToInteger(
999 _In_ PCUNICODE_STRING String,
1000 _In_opt_ ULONG Base,
1001 _Out_ PULONG Value);
1002
1003 _IRQL_requires_max_(PASSIVE_LEVEL)
1004 NTSYSAPI
1005 WCHAR
1006 NTAPI
1007 RtlUpcaseUnicodeChar(
1008 _In_ WCHAR SourceCharacter);
1009
1010 NTSYSAPI
1011 USHORT
1012 FASTCALL
1013 RtlUshortByteSwap(
1014 _In_ USHORT Source);
1015
1016 _IRQL_requires_max_(APC_LEVEL)
1017 _Must_inspect_result_
1018 NTSYSAPI
1019 BOOLEAN
1020 NTAPI
1021 RtlValidRelativeSecurityDescriptor(
1022 _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput,
1023 _In_ ULONG SecurityDescriptorLength,
1024 _In_ SECURITY_INFORMATION RequiredInformation);
1025
1026 _IRQL_requires_max_(APC_LEVEL)
1027 _Must_inspect_result_
1028 NTSYSAPI
1029 BOOLEAN
1030 NTAPI
1031 RtlValidSecurityDescriptor(
1032 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
1033
1034 _IRQL_requires_max_(PASSIVE_LEVEL)
1035 NTSYSAPI
1036 NTSTATUS
1037 NTAPI
1038 RtlGetVersion(
1039 _Out_
1040 _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_)
1041 _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW),
1042 _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_))
1043 PRTL_OSVERSIONINFOW lpVersionInformation);
1044
1045 _IRQL_requires_max_(PASSIVE_LEVEL)
1046 _Must_inspect_result_
1047 NTSYSAPI
1048 NTSTATUS
1049 NTAPI
1050 RtlVerifyVersionInfo(
1051 _In_ PRTL_OSVERSIONINFOEXW VersionInfo,
1052 _In_ ULONG TypeMask,
1053 _In_ ULONGLONG ConditionMask);
1054
1055 _IRQL_requires_max_(PASSIVE_LEVEL)
1056 NTSYSAPI
1057 NTSTATUS
1058 NTAPI
1059 RtlWriteRegistryValue(
1060 _In_ ULONG RelativeTo,
1061 _In_ PCWSTR Path,
1062 _In_z_ PCWSTR ValueName,
1063 _In_ ULONG ValueType,
1064 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
1065 _In_ ULONG ValueLength);
1066
1067 $endif (_WDMDDK_)
1068 $if (_NTDDK_)
1069
1070 #ifndef RTL_USE_AVL_TABLES
1071
1072 NTSYSAPI
1073 VOID
1074 NTAPI
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);
1081
1082 NTSYSAPI
1083 PVOID
1084 NTAPI
1085 RtlInsertElementGenericTable(
1086 _In_ PRTL_GENERIC_TABLE Table,
1087 _In_reads_bytes_(BufferSize) PVOID Buffer,
1088 _In_ CLONG BufferSize,
1089 _Out_opt_ PBOOLEAN NewElement);
1090
1091 NTSYSAPI
1092 PVOID
1093 NTAPI
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);
1101
1102 NTSYSAPI
1103 BOOLEAN
1104 NTAPI
1105 RtlDeleteElementGenericTable(
1106 _In_ PRTL_GENERIC_TABLE Table,
1107 _In_ PVOID Buffer);
1108
1109 _Must_inspect_result_
1110 NTSYSAPI
1111 PVOID
1112 NTAPI
1113 RtlLookupElementGenericTable(
1114 _In_ PRTL_GENERIC_TABLE Table,
1115 _In_ PVOID Buffer);
1116
1117 NTSYSAPI
1118 PVOID
1119 NTAPI
1120 RtlLookupElementGenericTableFull(
1121 _In_ PRTL_GENERIC_TABLE Table,
1122 _In_ PVOID Buffer,
1123 _Out_ PVOID *NodeOrParent,
1124 _Out_ TABLE_SEARCH_RESULT *SearchResult);
1125
1126 _Must_inspect_result_
1127 NTSYSAPI
1128 PVOID
1129 NTAPI
1130 RtlEnumerateGenericTable(
1131 _In_ PRTL_GENERIC_TABLE Table,
1132 _In_ BOOLEAN Restart);
1133
1134 _Must_inspect_result_
1135 NTSYSAPI
1136 PVOID
1137 NTAPI
1138 RtlEnumerateGenericTableWithoutSplaying(
1139 _In_ PRTL_GENERIC_TABLE Table,
1140 _Inout_ PVOID *RestartKey);
1141
1142 _Must_inspect_result_
1143 NTSYSAPI
1144 PVOID
1145 NTAPI
1146 RtlGetElementGenericTable(
1147 _In_ PRTL_GENERIC_TABLE Table,
1148 _In_ ULONG I);
1149
1150 NTSYSAPI
1151 ULONG
1152 NTAPI
1153 RtlNumberGenericTableElements(
1154 _In_ PRTL_GENERIC_TABLE Table);
1155
1156 _Must_inspect_result_
1157 NTSYSAPI
1158 BOOLEAN
1159 NTAPI
1160 RtlIsGenericTableEmpty(
1161 _In_ PRTL_GENERIC_TABLE Table);
1162
1163 #endif /* !RTL_USE_AVL_TABLES */
1164
1165 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
1166
1167 NTSYSAPI
1168 PRTL_SPLAY_LINKS
1169 NTAPI
1170 RtlSplay(
1171 _Inout_ PRTL_SPLAY_LINKS Links);
1172
1173 NTSYSAPI
1174 PRTL_SPLAY_LINKS
1175 NTAPI
1176 RtlDelete(
1177 _In_ PRTL_SPLAY_LINKS Links);
1178
1179 NTSYSAPI
1180 VOID
1181 NTAPI
1182 RtlDeleteNoSplay(
1183 _In_ PRTL_SPLAY_LINKS Links,
1184 _Inout_ PRTL_SPLAY_LINKS *Root);
1185
1186 _Must_inspect_result_
1187 NTSYSAPI
1188 PRTL_SPLAY_LINKS
1189 NTAPI
1190 RtlSubtreeSuccessor(
1191 _In_ PRTL_SPLAY_LINKS Links);
1192
1193 _Must_inspect_result_
1194 NTSYSAPI
1195 PRTL_SPLAY_LINKS
1196 NTAPI
1197 RtlSubtreePredecessor(
1198 _In_ PRTL_SPLAY_LINKS Links);
1199
1200 _Must_inspect_result_
1201 NTSYSAPI
1202 PRTL_SPLAY_LINKS
1203 NTAPI
1204 RtlRealSuccessor(
1205 _In_ PRTL_SPLAY_LINKS Links);
1206
1207 _Must_inspect_result_
1208 NTSYSAPI
1209 PRTL_SPLAY_LINKS
1210 NTAPI
1211 RtlRealPredecessor(
1212 _In_ PRTL_SPLAY_LINKS Links);
1213
1214 _IRQL_requires_max_(PASSIVE_LEVEL)
1215 _Must_inspect_result_
1216 NTSYSAPI
1217 BOOLEAN
1218 NTAPI
1219 RtlPrefixUnicodeString(
1220 _In_ PCUNICODE_STRING String1,
1221 _In_ PCUNICODE_STRING String2,
1222 _In_ BOOLEAN CaseInSensitive);
1223
1224 _IRQL_requires_max_(PASSIVE_LEVEL)
1225 NTSYSAPI
1226 VOID
1227 NTAPI
1228 RtlUpperString(
1229 _Inout_ PSTRING DestinationString,
1230 _In_ const STRING *SourceString);
1231
1232 _IRQL_requires_max_(PASSIVE_LEVEL)
1233 _When_(AllocateDestinationString, _Must_inspect_result_)
1234 NTSYSAPI
1235 NTSTATUS
1236 NTAPI
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);
1243
1244 _IRQL_requires_max_(APC_LEVEL)
1245 NTSYSAPI
1246 VOID
1247 NTAPI
1248 RtlMapGenericMask(
1249 _Inout_ PACCESS_MASK AccessMask,
1250 _In_ PGENERIC_MAPPING GenericMapping);
1251
1252 _IRQL_requires_max_(PASSIVE_LEVEL)
1253 NTSYSAPI
1254 NTSTATUS
1255 NTAPI
1256 RtlVolumeDeviceToDosName(
1257 _In_ PVOID VolumeDeviceObject,
1258 _Out_ PUNICODE_STRING DosName);
1259
1260 _IRQL_requires_max_(PASSIVE_LEVEL)
1261 _Must_inspect_result_
1262 NTSYSAPI
1263 LONG
1264 NTAPI
1265 RtlCompareString(
1266 _In_ const STRING *String1,
1267 _In_ const STRING *String2,
1268 _In_ BOOLEAN CaseInSensitive);
1269
1270 NTSYSAPI
1271 VOID
1272 NTAPI
1273 RtlCopyString(
1274 _Out_ PSTRING DestinationString,
1275 _In_opt_ const STRING *SourceString);
1276
1277 _IRQL_requires_max_(PASSIVE_LEVEL)
1278 _Must_inspect_result_
1279 NTSYSAPI
1280 BOOLEAN
1281 NTAPI
1282 RtlEqualString(
1283 _In_ const STRING *String1,
1284 _In_ const STRING *String2,
1285 _In_ BOOLEAN CaseInSensitive);
1286
1287 _IRQL_requires_max_(PASSIVE_LEVEL)
1288 NTSYSAPI
1289 NTSTATUS
1290 NTAPI
1291 RtlCharToInteger(
1292 _In_z_ PCSZ String,
1293 _In_opt_ ULONG Base,
1294 _Out_ PULONG Value);
1295
1296 _IRQL_requires_max_(PASSIVE_LEVEL)
1297 NTSYSAPI
1298 CHAR
1299 NTAPI
1300 RtlUpperChar(
1301 _In_ CHAR Character);
1302
1303 NTSYSAPI
1304 ULONG
1305 NTAPI
1306 RtlWalkFrameChain(
1307 _Out_writes_(Count - (Flags >> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT))
1308 PVOID *Callers,
1309 _In_ ULONG Count,
1310 _In_ ULONG Flags);
1311
1312 $endif (_NTDDK_)
1313 $if (_NTIFS_)
1314
1315 _Must_inspect_result_
1316 _Ret_maybenull_
1317 _Post_writable_byte_size_(Size)
1318 NTSYSAPI
1319 PVOID
1320 NTAPI
1321 RtlAllocateHeap(
1322 _In_ HANDLE HeapHandle,
1323 _In_opt_ ULONG Flags,
1324 _In_ SIZE_T Size);
1325
1326 _Success_(return != 0)
1327 NTSYSAPI
1328 BOOLEAN
1329 NTAPI
1330 RtlFreeHeap(
1331 _In_ PVOID HeapHandle,
1332 _In_opt_ ULONG Flags,
1333 _In_ _Post_invalid_ PVOID BaseAddress);
1334
1335 NTSYSAPI
1336 VOID
1337 NTAPI
1338 RtlCaptureContext(
1339 _Out_ PCONTEXT ContextRecord);
1340
1341 _Ret_range_(<, MAXLONG)
1342 NTSYSAPI
1343 ULONG
1344 NTAPI
1345 RtlRandom(
1346 _Inout_ PULONG Seed);
1347
1348 _IRQL_requires_max_(APC_LEVEL)
1349 _Success_(return != 0)
1350 _Must_inspect_result_
1351 NTSYSAPI
1352 BOOLEAN
1353 NTAPI
1354 RtlCreateUnicodeString(
1355 _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))
1356 PUNICODE_STRING DestinationString,
1357 _In_z_ PCWSTR SourceString);
1358
1359 _IRQL_requires_max_(PASSIVE_LEVEL)
1360 _Must_inspect_result_
1361 NTSYSAPI
1362 BOOLEAN
1363 NTAPI
1364 RtlPrefixString(
1365 _In_ const STRING *String1,
1366 _In_ const STRING *String2,
1367 _In_ BOOLEAN CaseInsensitive);
1368
1369 _IRQL_requires_max_(APC_LEVEL)
1370 NTSYSAPI
1371 NTSTATUS
1372 NTAPI
1373 RtlAppendStringToString(
1374 _Inout_ PSTRING Destination,
1375 _In_ const STRING *Source);
1376
1377 _IRQL_requires_max_(PASSIVE_LEVEL)
1378 _Must_inspect_result_
1379 NTSYSAPI
1380 NTSTATUS
1381 NTAPI
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);
1388
1389 _IRQL_requires_max_(PASSIVE_LEVEL)
1390 _Must_inspect_result_
1391 NTSYSAPI
1392 NTSTATUS
1393 NTAPI
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);
1400
1401 _IRQL_requires_max_(PASSIVE_LEVEL)
1402 _Must_inspect_result_
1403 NTSYSAPI
1404 NTSTATUS
1405 NTAPI
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);
1412
1413 _IRQL_requires_max_(PASSIVE_LEVEL)
1414 _Must_inspect_result_
1415 NTSYSAPI
1416 NTSTATUS
1417 NTAPI
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);
1424
1425 _IRQL_requires_max_(PASSIVE_LEVEL)
1426 _Must_inspect_result_
1427 NTSYSAPI
1428 NTSTATUS
1429 NTAPI
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);
1436
1437 _IRQL_requires_max_(PASSIVE_LEVEL)
1438 _Must_inspect_result_
1439 NTSYSAPI
1440 NTSTATUS
1441 NTAPI
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);
1448
1449 _IRQL_requires_max_(PASSIVE_LEVEL)
1450 _When_(AllocateDestinationString, _Must_inspect_result_)
1451 NTSYSAPI
1452 NTSTATUS
1453 NTAPI
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);
1460
1461 _IRQL_requires_max_(PASSIVE_LEVEL)
1462 NTSYSAPI
1463 VOID
1464 NTAPI
1465 RtlFreeOemString(
1466 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem)) POEM_STRING OemString);
1467
1468 _IRQL_requires_max_(PASSIVE_LEVEL)
1469 NTSYSAPI
1470 ULONG
1471 NTAPI
1472 RtlxUnicodeStringToOemSize(
1473 _In_ PCUNICODE_STRING UnicodeString);
1474
1475 _IRQL_requires_max_(PASSIVE_LEVEL)
1476 NTSYSAPI
1477 ULONG
1478 NTAPI
1479 RtlxOemStringToUnicodeSize(
1480 _In_ PCOEM_STRING OemString);
1481
1482 _IRQL_requires_max_(PASSIVE_LEVEL)
1483 NTSYSAPI
1484 NTSTATUS
1485 NTAPI
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);
1492
1493 _IRQL_requires_max_(PASSIVE_LEVEL)
1494 NTSYSAPI
1495 NTSTATUS
1496 NTAPI
1497 RtlMultiByteToUnicodeSize(
1498 _Out_ PULONG BytesInUnicodeString,
1499 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
1500 _In_ ULONG BytesInMultiByteString);
1501
1502 _IRQL_requires_max_(PASSIVE_LEVEL)
1503 NTSYSAPI
1504 NTSTATUS
1505 NTAPI
1506 RtlUnicodeToMultiByteSize(
1507 _Out_ PULONG BytesInMultiByteString,
1508 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString,
1509 _In_ ULONG BytesInUnicodeString);
1510
1511 _IRQL_requires_max_(PASSIVE_LEVEL)
1512 NTSYSAPI
1513 NTSTATUS
1514 NTAPI
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);
1521
1522 _IRQL_requires_max_(PASSIVE_LEVEL)
1523 NTSYSAPI
1524 NTSTATUS
1525 NTAPI
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);
1532
1533 _IRQL_requires_max_(PASSIVE_LEVEL)
1534 NTSYSAPI
1535 NTSTATUS
1536 NTAPI
1537 RtlOemToUnicodeN(
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);
1543
1544 _IRQL_requires_max_(PASSIVE_LEVEL)
1545 NTSYSAPI
1546 NTSTATUS
1547 NTAPI
1548 RtlUnicodeToOemN(
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);
1554
1555 _IRQL_requires_max_(PASSIVE_LEVEL)
1556 NTSYSAPI
1557 NTSTATUS
1558 NTAPI
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);
1565
1566 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1567 _IRQL_requires_max_(PASSIVE_LEVEL)
1568 NTSYSAPI
1569 NTSTATUS
1570 NTAPI
1571 RtlGenerate8dot3Name(
1572 _In_ PCUNICODE_STRING Name,
1573 _In_ BOOLEAN AllowExtendedCharacters,
1574 _Inout_ PGENERATE_NAME_CONTEXT Context,
1575 _Inout_ PUNICODE_STRING Name8dot3);
1576 #else
1577 _IRQL_requires_max_(PASSIVE_LEVEL)
1578 NTSYSAPI
1579 VOID
1580 NTAPI
1581 RtlGenerate8dot3Name(
1582 _In_ PCUNICODE_STRING Name,
1583 _In_ BOOLEAN AllowExtendedCharacters,
1584 _Inout_ PGENERATE_NAME_CONTEXT Context,
1585 _Inout_ PUNICODE_STRING Name8dot3);
1586 #endif
1587
1588 _IRQL_requires_max_(PASSIVE_LEVEL)
1589 _Must_inspect_result_
1590 NTSYSAPI
1591 BOOLEAN
1592 NTAPI
1593 RtlIsNameLegalDOS8Dot3(
1594 _In_ PCUNICODE_STRING Name,
1595 _Inout_opt_ POEM_STRING OemName,
1596 _Out_opt_ PBOOLEAN NameContainsSpaces);
1597
1598 _IRQL_requires_max_(PASSIVE_LEVEL)
1599 _Must_inspect_result_
1600 NTSYSAPI
1601 BOOLEAN
1602 NTAPI
1603 RtlIsValidOemCharacter(
1604 _Inout_ PWCHAR Char);
1605
1606 _IRQL_requires_max_(PASSIVE_LEVEL)
1607 NTSYSAPI
1608 VOID
1609 NTAPI
1610 PfxInitialize(
1611 _Out_ PPREFIX_TABLE PrefixTable);
1612
1613 _IRQL_requires_max_(PASSIVE_LEVEL)
1614 NTSYSAPI
1615 BOOLEAN
1616 NTAPI
1617 PfxInsertPrefix(
1618 _In_ PPREFIX_TABLE PrefixTable,
1619 _In_ __drv_aliasesMem PSTRING Prefix,
1620 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry);
1621
1622 _IRQL_requires_max_(PASSIVE_LEVEL)
1623 NTSYSAPI
1624 VOID
1625 NTAPI
1626 PfxRemovePrefix(
1627 _In_ PPREFIX_TABLE PrefixTable,
1628 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry);
1629
1630 _IRQL_requires_max_(PASSIVE_LEVEL)
1631 _Must_inspect_result_
1632 NTSYSAPI
1633 PPREFIX_TABLE_ENTRY
1634 NTAPI
1635 PfxFindPrefix(
1636 _In_ PPREFIX_TABLE PrefixTable,
1637 _In_ PSTRING FullName);
1638
1639 _IRQL_requires_max_(PASSIVE_LEVEL)
1640 NTSYSAPI
1641 VOID
1642 NTAPI
1643 RtlInitializeUnicodePrefix(
1644 _Out_ PUNICODE_PREFIX_TABLE PrefixTable);
1645
1646 _IRQL_requires_max_(PASSIVE_LEVEL)
1647 NTSYSAPI
1648 BOOLEAN
1649 NTAPI
1650 RtlInsertUnicodePrefix(
1651 _In_ PUNICODE_PREFIX_TABLE PrefixTable,
1652 _In_ __drv_aliasesMem PUNICODE_STRING Prefix,
1653 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry);
1654
1655 _IRQL_requires_max_(PASSIVE_LEVEL)
1656 NTSYSAPI
1657 VOID
1658 NTAPI
1659 RtlRemoveUnicodePrefix(
1660 _In_ PUNICODE_PREFIX_TABLE PrefixTable,
1661 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry);
1662
1663 _IRQL_requires_max_(PASSIVE_LEVEL)
1664 _Must_inspect_result_
1665 NTSYSAPI
1666 PUNICODE_PREFIX_TABLE_ENTRY
1667 NTAPI
1668 RtlFindUnicodePrefix(
1669 _In_ PUNICODE_PREFIX_TABLE PrefixTable,
1670 _In_ PUNICODE_STRING FullName,
1671 _In_ ULONG CaseInsensitiveIndex);
1672
1673 _IRQL_requires_max_(PASSIVE_LEVEL)
1674 _Must_inspect_result_
1675 NTSYSAPI
1676 PUNICODE_PREFIX_TABLE_ENTRY
1677 NTAPI
1678 RtlNextUnicodePrefix(
1679 _In_ PUNICODE_PREFIX_TABLE PrefixTable,
1680 _In_ BOOLEAN Restart);
1681
1682 _Must_inspect_result_
1683 NTSYSAPI
1684 SIZE_T
1685 NTAPI
1686 RtlCompareMemoryUlong(
1687 _In_reads_bytes_(Length) PVOID Source,
1688 _In_ SIZE_T Length,
1689 _In_ ULONG Pattern);
1690
1691 _Success_(return != 0)
1692 NTSYSAPI
1693 BOOLEAN
1694 NTAPI
1695 RtlTimeToSecondsSince1980(
1696 _In_ PLARGE_INTEGER Time,
1697 _Out_ PULONG ElapsedSeconds);
1698
1699 NTSYSAPI
1700 VOID
1701 NTAPI
1702 RtlSecondsSince1980ToTime(
1703 _In_ ULONG ElapsedSeconds,
1704 _Out_ PLARGE_INTEGER Time);
1705
1706 _Success_(return != 0)
1707 _Must_inspect_result_
1708 NTSYSAPI
1709 BOOLEAN
1710 NTAPI
1711 RtlTimeToSecondsSince1970(
1712 _In_ PLARGE_INTEGER Time,
1713 _Out_ PULONG ElapsedSeconds);
1714
1715 NTSYSAPI
1716 VOID
1717 NTAPI
1718 RtlSecondsSince1970ToTime(
1719 _In_ ULONG ElapsedSeconds,
1720 _Out_ PLARGE_INTEGER Time);
1721
1722 _IRQL_requires_max_(APC_LEVEL)
1723 _Must_inspect_result_
1724 NTSYSAPI
1725 BOOLEAN
1726 NTAPI
1727 RtlValidSid(
1728 _In_ PSID Sid);
1729
1730 _Must_inspect_result_
1731 NTSYSAPI
1732 BOOLEAN
1733 NTAPI
1734 RtlEqualSid(
1735 _In_ PSID Sid1,
1736 _In_ PSID Sid2);
1737
1738 _IRQL_requires_max_(APC_LEVEL)
1739 _Must_inspect_result_
1740 NTSYSAPI
1741 BOOLEAN
1742 NTAPI
1743 RtlEqualPrefixSid(
1744 _In_ PSID Sid1,
1745 _In_ PSID Sid2);
1746
1747 _IRQL_requires_max_(APC_LEVEL)
1748 NTSYSAPI
1749 ULONG
1750 NTAPI
1751 RtlLengthRequiredSid(
1752 _In_ ULONG SubAuthorityCount);
1753
1754 NTSYSAPI
1755 PVOID
1756 NTAPI
1757 RtlFreeSid(
1758 _In_ _Post_invalid_ PSID Sid);
1759
1760 _Must_inspect_result_
1761 NTSYSAPI
1762 NTSTATUS
1763 NTAPI
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);
1776
1777 _IRQL_requires_max_(APC_LEVEL)
1778 NTSYSAPI
1779 NTSTATUS
1780 NTAPI
1781 RtlInitializeSid(
1782 _Out_ PSID Sid,
1783 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1784 _In_ UCHAR SubAuthorityCount);
1785
1786 NTSYSAPI
1787 PULONG
1788 NTAPI
1789 RtlSubAuthoritySid(
1790 _In_ PSID Sid,
1791 _In_ ULONG SubAuthority);
1792
1793 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE)
1794 NTSYSAPI
1795 ULONG
1796 NTAPI
1797 RtlLengthSid(
1798 _In_ PSID Sid);
1799
1800 _IRQL_requires_max_(APC_LEVEL)
1801 NTSYSAPI
1802 NTSTATUS
1803 NTAPI
1804 RtlCopySid(
1805 _In_ ULONG DestinationSidLength,
1806 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1807 _In_ PSID SourceSid);
1808
1809 _IRQL_requires_max_(APC_LEVEL)
1810 NTSYSAPI
1811 NTSTATUS
1812 NTAPI
1813 RtlConvertSidToUnicodeString(
1814 _Inout_ PUNICODE_STRING UnicodeString,
1815 _In_ PSID Sid,
1816 _In_ BOOLEAN AllocateDestinationString);
1817
1818 _IRQL_requires_max_(APC_LEVEL)
1819 NTSYSAPI
1820 VOID
1821 NTAPI
1822 RtlCopyLuid(
1823 _Out_ PLUID DestinationLuid,
1824 _In_ PLUID SourceLuid);
1825
1826 _IRQL_requires_max_(APC_LEVEL)
1827 NTSYSAPI
1828 NTSTATUS
1829 NTAPI
1830 RtlCreateAcl(
1831 _Out_writes_bytes_(AclLength) PACL Acl,
1832 _In_ ULONG AclLength,
1833 _In_ ULONG AclRevision);
1834
1835 _IRQL_requires_max_(APC_LEVEL)
1836 NTSYSAPI
1837 NTSTATUS
1838 NTAPI
1839 RtlAddAce(
1840 _Inout_ PACL Acl,
1841 _In_ ULONG AceRevision,
1842 _In_ ULONG StartingAceIndex,
1843 _In_reads_bytes_(AceListLength) PVOID AceList,
1844 _In_ ULONG AceListLength);
1845
1846 _IRQL_requires_max_(APC_LEVEL)
1847 NTSYSAPI
1848 NTSTATUS
1849 NTAPI
1850 RtlDeleteAce(
1851 _Inout_ PACL Acl,
1852 _In_ ULONG AceIndex);
1853
1854 NTSYSAPI
1855 NTSTATUS
1856 NTAPI
1857 RtlGetAce(
1858 _In_ PACL Acl,
1859 _In_ ULONG AceIndex,
1860 _Outptr_ PVOID *Ace);
1861
1862 _IRQL_requires_max_(APC_LEVEL)
1863 NTSYSAPI
1864 NTSTATUS
1865 NTAPI
1866 RtlAddAccessAllowedAce(
1867 _Inout_ PACL Acl,
1868 _In_ ULONG AceRevision,
1869 _In_ ACCESS_MASK AccessMask,
1870 _In_ PSID Sid);
1871
1872 _IRQL_requires_max_(APC_LEVEL)
1873 NTSYSAPI
1874 NTSTATUS
1875 NTAPI
1876 RtlAddAccessAllowedAceEx(
1877 _Inout_ PACL Acl,
1878 _In_ ULONG AceRevision,
1879 _In_ ULONG AceFlags,
1880 _In_ ACCESS_MASK AccessMask,
1881 _In_ PSID Sid);
1882
1883 _IRQL_requires_max_(APC_LEVEL)
1884 NTSYSAPI
1885 NTSTATUS
1886 NTAPI
1887 RtlCreateSecurityDescriptorRelative(
1888 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
1889 _In_ ULONG Revision);
1890
1891 NTSYSAPI
1892 NTSTATUS
1893 NTAPI
1894 RtlGetDaclSecurityDescriptor(
1895 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1896 _Out_ PBOOLEAN DaclPresent,
1897 _Out_ PACL *Dacl,
1898 _Out_ PBOOLEAN DaclDefaulted);
1899
1900 _IRQL_requires_max_(APC_LEVEL)
1901 NTSYSAPI
1902 NTSTATUS
1903 NTAPI
1904 RtlSetOwnerSecurityDescriptor(
1905 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1906 _In_opt_ PSID Owner,
1907 _In_opt_ BOOLEAN OwnerDefaulted);
1908
1909 _IRQL_requires_max_(APC_LEVEL)
1910 NTSYSAPI
1911 NTSTATUS
1912 NTAPI
1913 RtlGetOwnerSecurityDescriptor(
1914 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1915 _Out_ PSID *Owner,
1916 _Out_ PBOOLEAN OwnerDefaulted);
1917
1918 _IRQL_requires_max_(APC_LEVEL)
1919 _When_(Status < 0, _Out_range_(>, 0))
1920 _When_(Status >= 0, _Out_range_(==, 0))
1921 NTSYSAPI
1922 ULONG
1923 NTAPI
1924 RtlNtStatusToDosError(
1925 _In_ NTSTATUS Status);
1926
1927 _IRQL_requires_max_(PASSIVE_LEVEL)
1928 NTSYSAPI
1929 NTSTATUS
1930 NTAPI
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);
1938
1939 _IRQL_requires_max_(PASSIVE_LEVEL)
1940 NTSYSAPI
1941 NTSTATUS
1942 NTAPI
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);
1950
1951 _IRQL_requires_max_(PASSIVE_LEVEL)
1952 NTSYSAPI
1953 NTSTATUS
1954 NTAPI
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);
1962
1963 _IRQL_requires_max_(PASSIVE_LEVEL)
1964 NTSYSAPI
1965 VOID
1966 NTAPI
1967 RtlInitCodePageTable(
1968 _In_ PUSHORT TableBase,
1969 _Out_ PCPTABLEINFO CodePageTable);
1970
1971 $endif (_NTIFS_)
1972
1973 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1974
1975 $if (_WDMDDK_)
1976
1977 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1978 NTSYSAPI
1979 VOID
1980 FASTCALL
1981 RtlPrefetchMemoryNonTemporal(
1982 _In_ PVOID Source,
1983 _In_ SIZE_T Length);
1984 #endif
1985
1986 $endif (_WDMDDK_)
1987
1988 #if (NTDDI_VERSION >= NTDDI_WINXP)
1989
1990 $if (_WDMDDK_)
1991
1992 NTSYSAPI
1993 VOID
1994 NTAPI
1995 RtlClearBit(
1996 _In_ PRTL_BITMAP BitMapHeader,
1997 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber);
1998
1999 _IRQL_requires_max_(PASSIVE_LEVEL)
2000 NTSYSAPI
2001 WCHAR
2002 NTAPI
2003 RtlDowncaseUnicodeChar(
2004 _In_ WCHAR SourceCharacter);
2005
2006 NTSYSAPI
2007 VOID
2008 NTAPI
2009 RtlSetBit(
2010 _In_ PRTL_BITMAP BitMapHeader,
2011 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber);
2012
2013 _Must_inspect_result_
2014 NTSYSAPI
2015 BOOLEAN
2016 NTAPI
2017 RtlTestBit(
2018 _In_ PRTL_BITMAP BitMapHeader,
2019 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber);
2020
2021 _IRQL_requires_max_(PASSIVE_LEVEL)
2022 NTSYSAPI
2023 NTSTATUS
2024 NTAPI
2025 RtlHashUnicodeString(
2026 _In_ CONST UNICODE_STRING *String,
2027 _In_ BOOLEAN CaseInSensitive,
2028 _In_ ULONG HashAlgorithm,
2029 _Out_ PULONG HashValue);
2030
2031 $endif (_WDMDDK_)
2032
2033 $if (_NTDDK_)
2034
2035 NTSYSAPI
2036 VOID
2037 NTAPI
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);
2044
2045 NTSYSAPI
2046 PVOID
2047 NTAPI
2048 RtlInsertElementGenericTableAvl(
2049 _In_ PRTL_AVL_TABLE Table,
2050 _In_reads_bytes_(BufferSize) PVOID Buffer,
2051 _In_ CLONG BufferSize,
2052 _Out_opt_ PBOOLEAN NewElement);
2053
2054 NTSYSAPI
2055 PVOID
2056 NTAPI
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);
2064
2065 NTSYSAPI
2066 BOOLEAN
2067 NTAPI
2068 RtlDeleteElementGenericTableAvl(
2069 _In_ PRTL_AVL_TABLE Table,
2070 _In_ PVOID Buffer);
2071
2072 _Must_inspect_result_
2073 NTSYSAPI
2074 PVOID
2075 NTAPI
2076 RtlLookupElementGenericTableAvl(
2077 _In_ PRTL_AVL_TABLE Table,
2078 _In_ PVOID Buffer);
2079
2080 NTSYSAPI
2081 PVOID
2082 NTAPI
2083 RtlLookupElementGenericTableFullAvl(
2084 _In_ PRTL_AVL_TABLE Table,
2085 _In_ PVOID Buffer,
2086 _Out_ PVOID *NodeOrParent,
2087 _Out_ TABLE_SEARCH_RESULT *SearchResult);
2088
2089 _Must_inspect_result_
2090 NTSYSAPI
2091 PVOID
2092 NTAPI
2093 RtlEnumerateGenericTableAvl(
2094 _In_ PRTL_AVL_TABLE Table,
2095 _In_ BOOLEAN Restart);
2096
2097 _Must_inspect_result_
2098 NTSYSAPI
2099 PVOID
2100 NTAPI
2101 RtlEnumerateGenericTableWithoutSplayingAvl(
2102 _In_ PRTL_AVL_TABLE Table,
2103 _Inout_ PVOID *RestartKey);
2104
2105 _Must_inspect_result_
2106 NTSYSAPI
2107 PVOID
2108 NTAPI
2109 RtlLookupFirstMatchingElementGenericTableAvl(
2110 _In_ PRTL_AVL_TABLE Table,
2111 _In_ PVOID Buffer,
2112 _Out_ PVOID *RestartKey);
2113
2114 _Must_inspect_result_
2115 NTSYSAPI
2116 PVOID
2117 NTAPI
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,
2125 _In_ PVOID Buffer);
2126
2127 _Must_inspect_result_
2128 NTSYSAPI
2129 PVOID
2130 NTAPI
2131 RtlGetElementGenericTableAvl(
2132 _In_ PRTL_AVL_TABLE Table,
2133 _In_ ULONG I);
2134
2135 NTSYSAPI
2136 ULONG
2137 NTAPI
2138 RtlNumberGenericTableElementsAvl(
2139 _In_ PRTL_AVL_TABLE Table);
2140
2141 _Must_inspect_result_
2142 NTSYSAPI
2143 BOOLEAN
2144 NTAPI
2145 RtlIsGenericTableEmptyAvl(
2146 _In_ PRTL_AVL_TABLE Table);
2147
2148 $endif (_NTDDK_)
2149 $if (_NTIFS_)
2150
2151 _Must_inspect_result_
2152 NTSYSAPI
2153 PVOID
2154 NTAPI
2155 RtlCreateHeap(
2156 _In_ ULONG Flags,
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);
2162
2163 NTSYSAPI
2164 PVOID
2165 NTAPI
2166 RtlDestroyHeap(
2167 _In_ _Post_invalid_ PVOID HeapHandle);
2168
2169 NTSYSAPI
2170 USHORT
2171 NTAPI
2172 RtlCaptureStackBackTrace(
2173 _In_ ULONG FramesToSkip,
2174 _In_ ULONG FramesToCapture,
2175 _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace,
2176 _Out_opt_ PULONG BackTraceHash);
2177
2178 _Ret_range_(<, MAXLONG)
2179 NTSYSAPI
2180 ULONG
2181 NTAPI
2182 RtlRandomEx(
2183 _Inout_ PULONG Seed);
2184
2185 _IRQL_requires_max_(DISPATCH_LEVEL)
2186 NTSYSAPI
2187 NTSTATUS
2188 NTAPI
2189 RtlInitUnicodeStringEx(
2190 _Out_ PUNICODE_STRING DestinationString,
2191 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString);
2192
2193 _Must_inspect_result_
2194 NTSYSAPI
2195 NTSTATUS
2196 NTAPI
2197 RtlValidateUnicodeString(
2198 _In_ ULONG Flags,
2199 _In_ PCUNICODE_STRING String);
2200
2201 _IRQL_requires_max_(PASSIVE_LEVEL)
2202 _Must_inspect_result_
2203 NTSYSAPI
2204 NTSTATUS
2205 NTAPI
2206 RtlDuplicateUnicodeString(
2207 _In_ ULONG Flags,
2208 _In_ PCUNICODE_STRING SourceString,
2209 _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)) PUNICODE_STRING DestinationString);
2210
2211 NTSYSAPI
2212 NTSTATUS
2213 NTAPI
2214 RtlGetCompressionWorkSpaceSize(
2215 _In_ USHORT CompressionFormatAndEngine,
2216 _Out_ PULONG CompressBufferWorkSpaceSize,
2217 _Out_ PULONG CompressFragmentWorkSpaceSize);
2218
2219 NTSYSAPI
2220 NTSTATUS
2221 NTAPI
2222 RtlCompressBuffer(
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);
2231
2232 _IRQL_requires_max_(APC_LEVEL)
2233 NTSYSAPI
2234 NTSTATUS
2235 NTAPI
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);
2243
2244 _IRQL_requires_max_(APC_LEVEL)
2245 NTSYSAPI
2246 NTSTATUS
2247 NTAPI
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);
2257
2258 _IRQL_requires_max_(APC_LEVEL)
2259 NTSYSAPI
2260 NTSTATUS
2261 NTAPI
2262 RtlDescribeChunk(
2263 _In_ USHORT CompressionFormat,
2264 _Inout_ PUCHAR *CompressedBuffer,
2265 _In_ PUCHAR EndOfCompressedBufferPlus1,
2266 _Out_ PUCHAR *ChunkBuffer,
2267 _Out_ PULONG ChunkSize);
2268
2269 _IRQL_requires_max_(APC_LEVEL)
2270 NTSYSAPI
2271 NTSTATUS
2272 NTAPI
2273 RtlReserveChunk(
2274 _In_ USHORT CompressionFormat,
2275 _Inout_ PUCHAR *CompressedBuffer,
2276 _In_ PUCHAR EndOfCompressedBufferPlus1,
2277 _Out_ PUCHAR *ChunkBuffer,
2278 _In_ ULONG ChunkSize);
2279
2280 _IRQL_requires_max_(APC_LEVEL)
2281 NTSYSAPI
2282 NTSTATUS
2283 NTAPI
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);
2292
2293 _IRQL_requires_max_(APC_LEVEL)
2294 NTSYSAPI
2295 NTSTATUS
2296 NTAPI
2297 RtlCompressChunks(
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);
2305
2306 _IRQL_requires_max_(APC_LEVEL)
2307 NTSYSAPI
2308 PSID_IDENTIFIER_AUTHORITY
2309 NTAPI
2310 RtlIdentifierAuthoritySid(
2311 _In_ PSID Sid);
2312
2313 NTSYSAPI
2314 PUCHAR
2315 NTAPI
2316 RtlSubAuthorityCountSid(
2317 _In_ PSID Sid);
2318
2319 _When_(Status < 0, _Out_range_(>, 0))
2320 _When_(Status >= 0, _Out_range_(==, 0))
2321 NTSYSAPI
2322 ULONG
2323 NTAPI
2324 RtlNtStatusToDosErrorNoTeb(
2325 _In_ NTSTATUS Status);
2326
2327 _IRQL_requires_max_(PASSIVE_LEVEL)
2328 NTSYSAPI
2329 NTSTATUS
2330 NTAPI
2331 RtlCreateSystemVolumeInformationFolder(
2332 _In_ PCUNICODE_STRING VolumeRootPath);
2333
2334 #if defined(_M_AMD64)
2335
2336 FORCEINLINE
2337 VOID
2338 RtlFillMemoryUlong(
2339 _Out_writes_bytes_all_(Length) PVOID Destination,
2340 _In_ SIZE_T Length,
2341 _In_ ULONG Pattern)
2342 {
2343 PULONG Address = (PULONG)Destination;
2344 if ((Length /= 4) != 0) {
2345 if (((ULONG64)Address & 4) != 0) {
2346 *Address = Pattern;
2347 if ((Length -= 1) == 0) {
2348 return;
2349 }
2350 Address += 1;
2351 }
2352 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2);
2353 if ((Length & 1) != 0) Address[Length - 1] = Pattern;
2354 }
2355 return;
2356 }
2357
2358 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2359 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2360
2361 #else
2362
2363 NTSYSAPI
2364 VOID
2365 NTAPI
2366 RtlFillMemoryUlong(
2367 OUT PVOID Destination,
2368 IN SIZE_T Length,
2369 IN ULONG Pattern);
2370
2371 NTSYSAPI
2372 VOID
2373 NTAPI
2374 RtlFillMemoryUlonglong(
2375 _Out_writes_bytes_all_(Length) PVOID Destination,
2376 _In_ SIZE_T Length,
2377 _In_ ULONGLONG Pattern);
2378
2379 #endif /* defined(_M_AMD64) */
2380 $endif (_NTIFS_)
2381
2382 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2383
2384 $if (_NTIFS_)
2385 #if (NTDDI_VERSION >= NTDDI_WS03)
2386 _IRQL_requires_max_(DISPATCH_LEVEL)
2387 NTSYSAPI
2388 NTSTATUS
2389 NTAPI
2390 RtlInitAnsiStringEx(
2391 _Out_ PANSI_STRING DestinationString,
2392 _In_opt_z_ __drv_aliasesMem PCSZ SourceString);
2393 #endif
2394
2395 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2396
2397 _IRQL_requires_max_(APC_LEVEL)
2398 NTSYSAPI
2399 NTSTATUS
2400 NTAPI
2401 RtlGetSaclSecurityDescriptor(
2402 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2403 _Out_ PBOOLEAN SaclPresent,
2404 _Out_ PACL *Sacl,
2405 _Out_ PBOOLEAN SaclDefaulted);
2406
2407 _IRQL_requires_max_(APC_LEVEL)
2408 NTSYSAPI
2409 NTSTATUS
2410 NTAPI
2411 RtlSetGroupSecurityDescriptor(
2412 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2413 _In_opt_ PSID Group,
2414 _In_opt_ BOOLEAN GroupDefaulted);
2415
2416 _IRQL_requires_max_(APC_LEVEL)
2417 NTSYSAPI
2418 NTSTATUS
2419 NTAPI
2420 RtlGetGroupSecurityDescriptor(
2421 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2422 _Out_ PSID *Group,
2423 _Out_ PBOOLEAN GroupDefaulted);
2424
2425 _IRQL_requires_max_(APC_LEVEL)
2426 NTSYSAPI
2427 NTSTATUS
2428 NTAPI
2429 RtlAbsoluteToSelfRelativeSD(
2430 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
2431 _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
2432 _Inout_ PULONG BufferLength);
2433
2434 _IRQL_requires_max_(APC_LEVEL)
2435 NTSYSAPI
2436 NTSTATUS
2437 NTAPI
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);
2450
2451 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2452 $endif (_NTIFS_)
2453
2454 #if (NTDDI_VERSION >= NTDDI_VISTA)
2455
2456 $if (_WDMDDK_)
2457 NTSYSAPI
2458 ULONG
2459 NTAPI
2460 RtlNumberOfSetBitsUlongPtr(
2461 _In_ ULONG_PTR Target);
2462
2463 NTSYSAPI
2464 ULONGLONG
2465 NTAPI
2466 RtlIoDecodeMemIoResource(
2467 _In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
2468 _Out_opt_ PULONGLONG Alignment,
2469 _Out_opt_ PULONGLONG MinimumAddress,
2470 _Out_opt_ PULONGLONG MaximumAddress);
2471
2472 NTSYSAPI
2473 NTSTATUS
2474 NTAPI
2475 RtlIoEncodeMemIoResource(
2476 _In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
2477 _In_ UCHAR Type,
2478 _In_ ULONGLONG Length,
2479 _In_ ULONGLONG Alignment,
2480 _In_ ULONGLONG MinimumAddress,
2481 _In_ ULONGLONG MaximumAddress);
2482
2483 NTSYSAPI
2484 ULONGLONG
2485 NTAPI
2486 RtlCmDecodeMemIoResource(
2487 _In_ struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
2488 _Out_opt_ PULONGLONG Start);
2489
2490 NTSYSAPI
2491 NTSTATUS
2492 NTAPI
2493 RtlFindClosestEncodableLength(
2494 _In_ ULONGLONG SourceLength,
2495 _Out_ PULONGLONG TargetLength);
2496
2497 NTSYSAPI
2498 NTSTATUS
2499 NTAPI
2500 RtlCmEncodeMemIoResource(
2501 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
2502 _In_ UCHAR Type,
2503 _In_ ULONGLONG Length,
2504 _In_ ULONGLONG Start);
2505
2506 $endif (_WDMDDK_)
2507 $if (_NTDDK_)
2508
2509 _IRQL_requires_max_(APC_LEVEL)
2510 NTSYSAPI
2511 VOID
2512 NTAPI
2513 RtlRunOnceInitialize(
2514 _Out_ PRTL_RUN_ONCE RunOnce);
2515
2516 _IRQL_requires_max_(APC_LEVEL)
2517 _Maybe_raises_SEH_exception_
2518 NTSYSAPI
2519 NTSTATUS
2520 NTAPI
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);
2526
2527 _IRQL_requires_max_(APC_LEVEL)
2528 _Must_inspect_result_
2529 NTSYSAPI
2530 NTSTATUS
2531 NTAPI
2532 RtlRunOnceBeginInitialize(
2533 _Inout_ PRTL_RUN_ONCE RunOnce,
2534 _In_ ULONG Flags,
2535 _Outptr_opt_result_maybenull_ PVOID *Context);
2536
2537 _IRQL_requires_max_(APC_LEVEL)
2538 NTSYSAPI
2539 NTSTATUS
2540 NTAPI
2541 RtlRunOnceComplete(
2542 _Inout_ PRTL_RUN_ONCE RunOnce,
2543 _In_ ULONG Flags,
2544 _In_opt_ PVOID Context);
2545
2546 NTSYSAPI
2547 BOOLEAN
2548 NTAPI
2549 RtlGetProductInfo(
2550 _In_ ULONG OSMajorVersion,
2551 _In_ ULONG OSMinorVersion,
2552 _In_ ULONG SpMajorVersion,
2553 _In_ ULONG SpMinorVersion,
2554 _Out_ PULONG ReturnedProductType);
2555
2556 $endif (_NTDDK_)
2557 $if (_NTIFS_)
2558 NTSYSAPI
2559 NTSTATUS
2560 NTAPI
2561 RtlNormalizeString(
2562 _In_ ULONG NormForm,
2563 _In_ PCWSTR SourceString,
2564 _In_ LONG SourceStringLength,
2565 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString,
2566 _Inout_ PLONG DestinationStringLength);
2567
2568 NTSYSAPI
2569 NTSTATUS
2570 NTAPI
2571 RtlIsNormalizedString(
2572 _In_ ULONG NormForm,
2573 _In_ PCWSTR SourceString,
2574 _In_ LONG SourceStringLength,
2575 _Out_ PBOOLEAN Normalized);
2576
2577 NTSYSAPI
2578 NTSTATUS
2579 NTAPI
2580 RtlIdnToAscii(
2581 _In_ ULONG Flags,
2582 _In_ PCWSTR SourceString,
2583 _In_ LONG SourceStringLength,
2584 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString,
2585 _Inout_ PLONG DestinationStringLength);
2586
2587 NTSYSAPI
2588 NTSTATUS
2589 NTAPI
2590 RtlIdnToUnicode(
2591 IN ULONG Flags,
2592 IN PCWSTR SourceString,
2593 IN LONG SourceStringLength,
2594 OUT PWSTR DestinationString,
2595 IN OUT PLONG DestinationStringLength);
2596
2597 NTSYSAPI
2598 NTSTATUS
2599 NTAPI
2600 RtlIdnToNameprepUnicode(
2601 _In_ ULONG Flags,
2602 _In_ PCWSTR SourceString,
2603 _In_ LONG SourceStringLength,
2604 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString,
2605 _Inout_ PLONG DestinationStringLength);
2606
2607 NTSYSAPI
2608 NTSTATUS
2609 NTAPI
2610 RtlCreateServiceSid(
2611 _In_ PUNICODE_STRING ServiceName,
2612 _Out_writes_bytes_opt_(*ServiceSidLength) PSID ServiceSid,
2613 _Inout_ PULONG ServiceSidLength);
2614
2615 NTSYSAPI
2616 LONG
2617 NTAPI
2618 RtlCompareAltitudes(
2619 _In_ PCUNICODE_STRING Altitude1,
2620 _In_ PCUNICODE_STRING Altitude2);
2621
2622 $endif (_NTIFS_)
2623
2624 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2625
2626 #if (NTDDI_VERSION >= NTDDI_WIN7)
2627
2628 $if (_WDMDDK_)
2629 _IRQL_requires_max_(PASSIVE_LEVEL)
2630 _Must_inspect_result_
2631 NTSYSAPI
2632 NTSTATUS
2633 NTAPI
2634 RtlUnicodeToUTF8N(
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);
2641
2642 _IRQL_requires_max_(PASSIVE_LEVEL)
2643 _Must_inspect_result_
2644 NTSYSAPI
2645 NTSTATUS
2646 NTAPI
2647 RtlUTF8ToUnicodeN(
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);
2654
2655 NTSYSAPI
2656 ULONG64
2657 NTAPI
2658 RtlGetEnabledExtendedFeatures(
2659 IN ULONG64 FeatureMask);
2660
2661 $endif (_WDMDDK_)
2662 $if (_NTDDK_)
2663
2664 _Must_inspect_result_
2665 NTSYSAPI
2666 BOOLEAN
2667 NTAPI
2668 RtlCreateHashTable(
2669 _Inout_ _When_(NULL == *HashTable, __drv_allocatesMem(Mem))
2670 PRTL_DYNAMIC_HASH_TABLE *HashTable,
2671 _In_ ULONG Shift,
2672 _In_ _Reserved_ ULONG Flags);
2673
2674 NTSYSAPI
2675 VOID
2676 NTAPI
2677 RtlDeleteHashTable(
2678 _In_ _When_((HashTable->Flags & RTL_HASH_ALLOCATED_HEADER), __drv_freesMem(Mem) _Post_invalid_)
2679 PRTL_DYNAMIC_HASH_TABLE HashTable);
2680
2681 NTSYSAPI
2682 BOOLEAN
2683 NTAPI
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);
2689
2690 NTSYSAPI
2691 BOOLEAN
2692 NTAPI
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);
2697
2698 _Must_inspect_result_
2699 NTSYSAPI
2700 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2701 NTAPI
2702 RtlLookupEntryHashTable(
2703 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2704 _In_ ULONG_PTR Signature,
2705 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context);
2706
2707 _Must_inspect_result_
2708 NTSYSAPI
2709 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2710 NTAPI
2711 RtlGetNextEntryHashTable(
2712 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2713 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context);
2714
2715 NTSYSAPI
2716 BOOLEAN
2717 NTAPI
2718 RtlInitEnumerationHashTable(
2719 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2720 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2721
2722 _Must_inspect_result_
2723 NTSYSAPI
2724 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2725 NTAPI
2726 RtlEnumerateEntryHashTable(
2727 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2728 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2729
2730 NTSYSAPI
2731 VOID
2732 NTAPI
2733 RtlEndEnumerationHashTable(
2734 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2735 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2736
2737 NTSYSAPI
2738 BOOLEAN
2739 NTAPI
2740 RtlInitWeakEnumerationHashTable(
2741 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2742 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2743
2744 _Must_inspect_result_
2745 NTSYSAPI
2746 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2747 NTAPI
2748 RtlWeaklyEnumerateEntryHashTable(
2749 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2750 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2751
2752 NTSYSAPI
2753 VOID
2754 NTAPI
2755 RtlEndWeakEnumerationHashTable(
2756 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable,
2757 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2758
2759 NTSYSAPI
2760 BOOLEAN
2761 NTAPI
2762 RtlExpandHashTable(
2763 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable);
2764
2765 NTSYSAPI
2766 BOOLEAN
2767 NTAPI
2768 RtlContractHashTable(
2769 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable);
2770
2771 $endif (_NTDDK_)
2772 $if (_NTIFS_)
2773 _IRQL_requires_max_(PASSIVE_LEVEL)
2774 _Must_inspect_result_
2775 NTSYSAPI
2776 NTSTATUS
2777 NTAPI
2778 RtlUnicodeToUTF8N(
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);
2784
2785 _IRQL_requires_max_(PASSIVE_LEVEL)
2786 _Must_inspect_result_
2787 NTSYSAPI
2788 NTSTATUS
2789 NTAPI
2790 RtlUTF8ToUnicodeN(
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);
2796
2797 _IRQL_requires_max_(APC_LEVEL)
2798 NTSYSAPI
2799 NTSTATUS
2800 NTAPI
2801 RtlReplaceSidInSd(
2802 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2803 _In_ PSID OldSid,
2804 _In_ PSID NewSid,
2805 _Out_ ULONG *NumChanges);
2806
2807 NTSYSAPI
2808 NTSTATUS
2809 NTAPI
2810 RtlCreateVirtualAccountSid(
2811 _In_ PCUNICODE_STRING Name,
2812 _In_ ULONG BaseSubAuthority,
2813 _Out_writes_bytes_(*SidLength) PSID Sid,
2814 _Inout_ PULONG SidLength);
2815 $endif (_NTIFS_)
2816
2817 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2818
2819 $if (_WDMDDK_)
2820
2821 #if !defined(MIDL_PASS)
2822 /* inline funftions */
2823 //DECLSPEC_DEPRECATED_DDK_WINXP
2824 static __inline
2825 LARGE_INTEGER
2826 NTAPI_INLINE
2827 RtlConvertLongToLargeInteger(
2828 _In_ LONG SignedInteger)
2829 {
2830 LARGE_INTEGER ret;
2831 ret.QuadPart = SignedInteger;
2832 return ret;
2833 }
2834
2835 //DECLSPEC_DEPRECATED_DDK_WINXP
2836 static __inline
2837 LARGE_INTEGER
2838 NTAPI_INLINE
2839 RtlConvertUlongToLargeInteger(
2840 _In_ ULONG UnsignedInteger)
2841 {
2842 LARGE_INTEGER ret;
2843 ret.QuadPart = UnsignedInteger;
2844 return ret;
2845 }
2846
2847 //DECLSPEC_DEPRECATED_DDK_WINXP
2848 static __inline
2849 LARGE_INTEGER
2850 NTAPI_INLINE
2851 RtlLargeIntegerShiftLeft(
2852 _In_ LARGE_INTEGER LargeInteger,
2853 _In_ CCHAR ShiftCount)
2854 {
2855 LARGE_INTEGER Result;
2856
2857 Result.QuadPart = LargeInteger.QuadPart << ShiftCount;
2858 return Result;
2859 }
2860
2861 //DECLSPEC_DEPRECATED_DDK_WINXP
2862 static __inline
2863 LARGE_INTEGER
2864 NTAPI_INLINE
2865 RtlLargeIntegerShiftRight(
2866 _In_ LARGE_INTEGER LargeInteger,
2867 _In_ CCHAR ShiftCount)
2868 {
2869 LARGE_INTEGER Result;
2870
2871 Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount;
2872 return Result;
2873 }
2874
2875 //DECLSPEC_DEPRECATED_DDK
2876 static __inline
2877 ULONG
2878 NTAPI_INLINE
2879 RtlEnlargedUnsignedDivide(
2880 _In_ ULARGE_INTEGER Dividend,
2881 _In_ ULONG Divisor,
2882 _Out_opt_ PULONG Remainder)
2883 {
2884 if (Remainder)
2885 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
2886 return (ULONG)(Dividend.QuadPart / Divisor);
2887 }
2888
2889 //DECLSPEC_DEPRECATED_DDK
2890 static __inline
2891 LARGE_INTEGER
2892 NTAPI_INLINE
2893 RtlLargeIntegerNegate(
2894 _In_ LARGE_INTEGER Subtrahend)
2895 {
2896 LARGE_INTEGER Difference;
2897
2898 Difference.QuadPart = -Subtrahend.QuadPart;
2899 return Difference;
2900 }
2901
2902 //DECLSPEC_DEPRECATED_DDK
2903 static __inline
2904 LARGE_INTEGER
2905 NTAPI_INLINE
2906 RtlLargeIntegerSubtract(
2907 _In_ LARGE_INTEGER Minuend,
2908 _In_ LARGE_INTEGER Subtrahend)
2909 {
2910 LARGE_INTEGER Difference;
2911
2912 Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
2913 return Difference;
2914 }
2915
2916 //DECLSPEC_DEPRECATED_DDK
2917 static __inline
2918 LARGE_INTEGER
2919 NTAPI_INLINE
2920 RtlEnlargedUnsignedMultiply(
2921 _In_ ULONG Multiplicand,
2922 _In_ ULONG Multiplier)
2923 {
2924 LARGE_INTEGER ret;
2925 ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2926 return ret;
2927 }
2928
2929 //DECLSPEC_DEPRECATED_DDK
2930 static __inline
2931 LARGE_INTEGER
2932 NTAPI_INLINE
2933 RtlEnlargedIntegerMultiply(
2934 _In_ LONG Multiplicand,
2935 _In_ LONG Multiplier)
2936 {
2937 LARGE_INTEGER ret;
2938 ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2939 return ret;
2940 }
2941
2942 _At_(AnsiString->Buffer, _Post_equal_to_(Buffer))
2943 _At_(AnsiString->Length, _Post_equal_to_(0))
2944 _At_(AnsiString->MaximumLength, _Post_equal_to_(BufferSize))
2945 FORCEINLINE
2946 VOID
2947 RtlInitEmptyAnsiString(
2948 _Out_ PANSI_STRING AnsiString,
2949 _Pre_maybenull_ _Pre_readable_size_(BufferSize) __drv_aliasesMem PCHAR Buffer,
2950 _In_ USHORT BufferSize)
2951 {
2952 AnsiString->Length = 0;
2953 AnsiString->MaximumLength = BufferSize;
2954 AnsiString->Buffer = Buffer;
2955 }
2956
2957 _At_(UnicodeString->Buffer, _Post_equal_to_(Buffer))
2958 _At_(UnicodeString->Length, _Post_equal_to_(0))
2959 _At_(UnicodeString->MaximumLength, _Post_equal_to_(BufferSize))
2960 FORCEINLINE
2961 VOID
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)
2968 {
2969 UnicodeString->Length = 0;
2970 UnicodeString->MaximumLength = BufferSize;
2971 UnicodeString->Buffer = Buffer;
2972 }
2973 $endif (_WDMDDK_)
2974
2975 #if defined(_AMD64_) || defined(_IA64_)
2976
2977 $if (_WDMDDK_)
2978
2979 static __inline
2980 LARGE_INTEGER
2981 NTAPI_INLINE
2982 RtlExtendedIntegerMultiply(
2983 _In_ LARGE_INTEGER Multiplicand,
2984 _In_ LONG Multiplier)
2985 {
2986 LARGE_INTEGER ret;
2987 ret.QuadPart = Multiplicand.QuadPart * Multiplier;
2988 return ret;
2989 }
2990
2991 static __inline
2992 LARGE_INTEGER
2993 NTAPI_INLINE
2994 RtlExtendedLargeIntegerDivide(
2995 _In_ LARGE_INTEGER Dividend,
2996 _In_ ULONG Divisor,
2997 _Out_opt_ PULONG Remainder)
2998 {
2999 LARGE_INTEGER ret;
3000 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
3001 if (Remainder)
3002 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
3003 return ret;
3004 }
3005
3006 $endif (_WDMDDK_)
3007
3008 $if (_NTDDK_)
3009
3010 //DECLSPEC_DEPRECATED_DDK_WINXP
3011 FORCEINLINE
3012 LARGE_INTEGER
3013 NTAPI_INLINE
3014 RtlLargeIntegerDivide(
3015 _In_ LARGE_INTEGER Dividend,
3016 _In_ LARGE_INTEGER Divisor,
3017 _Out_opt_ PLARGE_INTEGER Remainder)
3018 {
3019 LARGE_INTEGER ret;
3020 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3021 if (Remainder)
3022 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3023 return ret;
3024 }
3025
3026 #else
3027
3028 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3029 NTSYSAPI
3030 LARGE_INTEGER
3031 NTAPI
3032 RtlLargeIntegerDivide(
3033 _In_ LARGE_INTEGER Dividend,
3034 _In_ LARGE_INTEGER Divisor,
3035 _Out_opt_ PLARGE_INTEGER Remainder);
3036 #endif
3037
3038 $endif (_NTDDK_)
3039
3040 #endif /* defined(_AMD64_) || defined(_IA64_) */
3041
3042 $if (_WDMDDK_)
3043
3044 #if defined(_AMD64_)
3045
3046 #define MultiplyHigh __mulh
3047 #define UnsignedMultiplyHigh __umulh
3048
3049 //DECLSPEC_DEPRECATED_DDK
3050 static __inline
3051 LARGE_INTEGER
3052 NTAPI_INLINE
3053 RtlExtendedMagicDivide(
3054 _In_ LARGE_INTEGER Dividend,
3055 _In_ LARGE_INTEGER MagicDivisor,
3056 _In_ CCHAR ShiftCount)
3057 {
3058 LARGE_INTEGER ret;
3059 ULONG64 ret64;
3060 BOOLEAN Pos;
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;
3066 return ret;
3067 }
3068 #endif
3069
3070 //DECLSPEC_DEPRECATED_DDK
3071 static __inline
3072 LARGE_INTEGER
3073 NTAPI_INLINE
3074 RtlLargeIntegerAdd(
3075 _In_ LARGE_INTEGER Addend1,
3076 _In_ LARGE_INTEGER Addend2)
3077 {
3078 LARGE_INTEGER ret;
3079 ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
3080 return ret;
3081 }
3082
3083 /* VOID
3084 * RtlLargeIntegerAnd(
3085 * IN OUT LARGE_INTEGER Result,
3086 * IN LARGE_INTEGER Source,
3087 * IN LARGE_INTEGER Mask);
3088 */
3089 #define RtlLargeIntegerAnd(Result, Source, Mask) \
3090 Result.QuadPart = Source.QuadPart & Mask.QuadPart
3091
3092 //DECLSPEC_DEPRECATED_DDK
3093 static __inline
3094 LARGE_INTEGER
3095 NTAPI_INLINE
3096 RtlLargeIntegerArithmeticShift(
3097 _In_ LARGE_INTEGER LargeInteger,
3098 _In_ CCHAR ShiftCount)
3099 {
3100 LARGE_INTEGER ret;
3101 ret.QuadPart = LargeInteger.QuadPart >> ShiftCount;
3102 return ret;
3103 }
3104
3105 /* BOOLEAN
3106 * RtlLargeIntegerEqualTo(
3107 * IN LARGE_INTEGER Operand1,
3108 * IN LARGE_INTEGER Operand2);
3109 */
3110 #define RtlLargeIntegerEqualTo(X,Y) \
3111 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
3112
3113 FORCEINLINE
3114 PVOID
3115 RtlSecureZeroMemory(
3116 _Out_writes_bytes_all_(Size) PVOID Pointer,
3117 _In_ SIZE_T Size)
3118 {
3119 volatile char* vptr = (volatile char*)Pointer;
3120 #if defined(_M_AMD64)
3121 __stosb((PUCHAR)vptr, 0, Size);
3122 #else
3123 char * endptr = (char *)vptr + Size;
3124 while (vptr < endptr) {
3125 *vptr = 0; vptr++;
3126 }
3127 #endif
3128 return Pointer;
3129 }
3130
3131 #if defined(_M_AMD64)
3132 _Must_inspect_result_
3133 FORCEINLINE
3134 BOOLEAN
3135 RtlCheckBit(
3136 _In_ PRTL_BITMAP BitMapHeader,
3137 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition)
3138 {
3139 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
3140 }
3141 #else
3142 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3143 #endif /* defined(_M_AMD64) */
3144
3145 #define RtlLargeIntegerGreaterThan(X,Y) ( \
3146 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
3147 ((X).HighPart > (Y).HighPart) \
3148 )
3149
3150 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
3151 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
3152 ((X).HighPart > (Y).HighPart) \
3153 )
3154
3155 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
3156 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
3157 )
3158
3159 #define RtlLargeIntegerLessThan(X,Y) ( \
3160 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
3161 ((X).HighPart < (Y).HighPart) \
3162 )
3163
3164 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
3165 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
3166 ((X).HighPart < (Y).HighPart) \
3167 )
3168
3169 #define RtlLargeIntegerGreaterThanZero(X) ( \
3170 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
3171 ((X).HighPart > 0 ) \
3172 )
3173
3174 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
3175
3176 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
3177
3178 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
3179
3180 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
3181
3182 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
3183
3184 #endif /* !defined(MIDL_PASS) */
3185
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))
3190
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)
3194 #else
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)
3199 #endif
3200
3201 #ifdef _PREFAST_
3202 # define NT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp)
3203 #elif DBG
3204 # define NT_ANALYSIS_ASSUME(_exp) ((void)0)
3205 #else
3206 # define NT_ANALYSIS_ASSUME(_exp) __noop(_exp)
3207 #endif
3208
3209 #define NT_ASSERT_ACTION(exp) \
3210 (NT_ANALYSIS_ASSUME(exp), \
3211 ((!(exp)) ? \
3212 (__assert_annotationA(#exp), \
3213 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3214
3215 #define NT_ASSERTMSG_ACTION(msg, exp) \
3216 (NT_ANALYSIS_ASSUME(exp), \
3217 ((!(exp)) ? \
3218 (__assert_annotationA(msg), \
3219 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3220
3221 #define NT_ASSERTMSGW_ACTION(msg, exp) \
3222 (NT_ANALYSIS_ASSUME(exp), \
3223 ((!(exp)) ? \
3224 (__assert_annotationW(msg), \
3225 DbgRaiseAssertionFailure(), FALSE) : TRUE))
3226
3227 #if DBG
3228
3229 #define RTL_VERIFY(exp) \
3230 ((!(exp)) ? \
3231 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
3232
3233 #define RTL_VERIFYMSG(msg, exp) \
3234 ((!(exp)) ? \
3235 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
3236
3237 #define RTL_SOFT_VERIFY(exp) \
3238 ((!(exp)) ? \
3239 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
3240
3241 #define RTL_SOFT_VERIFYMSG(msg, exp) \
3242 ((!(exp)) ? \
3243 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
3244
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
3250
3251 #define NT_VERIFY NT_ASSERT_ACTION
3252 #define NT_VERIFYMSG NT_ASSERTMSG_ACTION
3253 #define NT_VERIFYMSGW NT_ASSERTMSGW_ACTION
3254
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
3258
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
3262
3263 #else /* !DBG */
3264
3265 #define ASSERT(exp) ((void)0)
3266 #define ASSERTMSG(msg, exp) ((void)0)
3267
3268 #define RTL_SOFT_ASSERT(exp) ((void)0)
3269 #define RTL_SOFT_ASSERTMSG(msg, exp) ((void)0)
3270
3271 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3272 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3273
3274 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3275 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3276
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))
3280
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)
3284
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)
3288
3289 #endif /* DBG */
3290
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
3294
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
3299 #else
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 */
3304
3305 #if defined(_MSC_VER) && (defined(__REACTOS__) || defined(ASSERT_ALWAYS_NT_ASSERT))
3306 #undef ASSERT
3307 #define ASSERT NT_ASSERT
3308 #undef ASSERTMSG
3309 #define ASSERTMSG NT_ASSERTMSG
3310 #undef ASSERTMSGW
3311 #define ASSERTMSGW NT_ASSERTMSGW
3312 #undef RTL_VERIFY
3313 #define RTL_VERIFY NT_VERIFY
3314 #endif
3315
3316 #define InitializeListHead32(ListHead) (\
3317 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
3318
3319 #if !defined(_WINBASE_)
3320
3321 #if defined(_WIN64) && !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || !defined(_NTOSP_))
3322
3323 NTKERNELAPI
3324 VOID
3325 InitializeSListHead(
3326 _Out_ PSLIST_HEADER SListHead);
3327
3328 #else /* defined(_WIN64) && ... */
3329
3330 /* HACK */
3331 _IRQL_requires_max_(APC_LEVEL)
3332 NTKERNELAPI
3333 DECLSPEC_NORETURN
3334 VOID
3335 NTAPI
3336 ExRaiseStatus(
3337 _In_ NTSTATUS Status);
3338
3339 FORCEINLINE
3340 VOID
3341 InitializeSListHead(
3342 _Out_ PSLIST_HEADER SListHead)
3343 {
3344 #if defined(_WIN64)
3345 if (((ULONG_PTR)SListHead & 0xf) != 0) {
3346 ExRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
3347 }
3348 #if defined(_IA64_)
3349 SListHead->Region = (ULONG_PTR)SListHead & VRN_MASK;
3350 #else
3351 SListHead->Region = 0;
3352 #endif /* _IA64_ */
3353 #endif /* _WIN64 */
3354 SListHead->Alignment = 0;
3355 }
3356
3357 #endif /* defined(_WIN64) && ... */
3358
3359 #ifdef _X86_
3360
3361 NTKERNELAPI
3362 PSLIST_ENTRY
3363 FASTCALL
3364 InterlockedPushEntrySList(
3365 _Inout_ PSLIST_HEADER SListHead,
3366 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry);
3367
3368 NTKERNELAPI
3369 PSLIST_ENTRY
3370 FASTCALL
3371 InterlockedPopEntrySList(
3372 _Inout_ PSLIST_HEADER SListHead);
3373
3374 #define InterlockedFlushSList(SListHead) \
3375 ExInterlockedFlushSList(SListHead)
3376
3377 #else /* !_X86_ */
3378
3379 #define InterlockedPushEntrySList(SListHead, SListEntry) \
3380 ExpInterlockedPushEntrySList(SListHead, SListEntry)
3381
3382 #define InterlockedPopEntrySList(SListHead) \
3383 ExpInterlockedPopEntrySList(SListHead)
3384
3385 #define InterlockedFlushSList(SListHead) \
3386 ExpInterlockedFlushSList(SListHead)
3387
3388 #endif /* _X86_ */
3389
3390 #define QueryDepthSList(SListHead) \
3391 ExQueryDepthSList(SListHead)
3392
3393 #endif /* !defined(_WINBASE_) */
3394
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), \
3406 Chunk)
3407
3408 BOOLEAN
3409 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)(
3410 _In_ ULONG Version);
3411
3412 BOOLEAN
3413 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)(
3414 _In_ ULONG Version);
3415
3416 #ifndef RtlIsNtDdiVersionAvailable
3417 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
3418 #endif
3419
3420 #ifndef RtlIsServicePackVersionInstalled
3421 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
3422 #endif
3423
3424 #define RtlInterlockedSetBits(Flags, Flag) \
3425 InterlockedOr((PLONG)(Flags), Flag)
3426
3427 #define RtlInterlockedAndBits(Flags, Flag) \
3428 InterlockedAnd((PLONG)(Flags), Flag)
3429
3430 #define RtlInterlockedClearBits(Flags, Flag) \
3431 RtlInterlockedAndBits(Flags, ~(Flag))
3432
3433 #define RtlInterlockedXorBits(Flags, Flag) \
3434 InterlockedXor(Flags, Flag)
3435
3436 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
3437 (VOID) RtlInterlockedSetBits(Flags, Flag)
3438
3439 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
3440 (VOID) RtlInterlockedAndBits(Flags, Flag)
3441
3442 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
3443 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
3444
3445 $endif (_WDMDDK_)
3446
3447 $if (_NTDDK_)
3448
3449 #ifdef RTL_USE_AVL_TABLES
3450
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
3462
3463 #endif /* RTL_USE_AVL_TABLES */
3464
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; \
3471 }
3472
3473 #define RtlIsLeftChild(Links) \
3474 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3475
3476 #define RtlIsRightChild(Links) \
3477 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3478
3479 #define RtlRightChild(Links) \
3480 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3481
3482 #define RtlIsRoot(Links) \
3483 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3484
3485 #define RtlLeftChild(Links) \
3486 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3487
3488 #define RtlParent(Links) \
3489 ((PRTL_SPLAY_LINKS)(Links))->Parent
3490
3491 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3492 { \
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; \
3499 }
3500
3501 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3502 { \
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; \
3509 }
3510
3511 #if !defined(MIDL_PASS)
3512
3513 FORCEINLINE
3514 LUID
3515 NTAPI_INLINE
3516 RtlConvertLongToLuid(
3517 _In_ LONG Val)
3518 {
3519 LUID Luid;
3520 LARGE_INTEGER Temp;
3521
3522 Temp.QuadPart = Val;
3523 Luid.LowPart = Temp.u.LowPart;
3524 Luid.HighPart = Temp.u.HighPart;
3525 return Luid;
3526 }
3527
3528 FORCEINLINE
3529 LUID
3530 NTAPI_INLINE
3531 RtlConvertUlongToLuid(
3532 _In_ ULONG Val)
3533 {
3534 LUID Luid;
3535
3536 Luid.LowPart = Val;
3537 Luid.HighPart = 0;
3538 return Luid;
3539 }
3540
3541 #endif /* !defined(MIDL_PASS) */
3542
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;
3547 #else
3548 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3549 NTSYSAPI
3550 VOID
3551 NTAPI
3552 RtlGetCallersAddress(
3553 _Out_ PVOID *CallersAddress,
3554 _Out_ PVOID *CallersCaller);
3555 #endif
3556 #endif
3557
3558 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3559
3560 #if (NTDDI_VERSION >= NTDDI_WIN7)
3561
3562 FORCEINLINE
3563 VOID
3564 NTAPI
3565 RtlInitHashTableContext(
3566 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
3567 {
3568 Context->ChainHead = NULL;
3569 Context->PrevLinkage = NULL;
3570 }
3571
3572 FORCEINLINE
3573 VOID
3574 NTAPI
3575 RtlInitHashTableContextFromEnumerator(
3576 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context,
3577 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator)
3578 {
3579 Context->ChainHead = Enumerator->ChainHead;
3580 Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink;
3581 }
3582
3583 FORCEINLINE
3584 VOID
3585 NTAPI
3586 RtlReleaseHashTableContext(
3587 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
3588 {
3589 UNREFERENCED_PARAMETER(Context);
3590 return;
3591 }
3592
3593 FORCEINLINE
3594 ULONG
3595 NTAPI
3596 RtlTotalBucketsHashTable(
3597 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable)
3598 {
3599 return HashTable->TableSize;
3600 }
3601
3602 FORCEINLINE
3603 ULONG
3604 NTAPI
3605 RtlNonEmptyBucketsHashTable(
3606 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable)
3607 {
3608 return HashTable->NonEmptyBuckets;
3609 }
3610
3611 FORCEINLINE
3612 ULONG
3613 NTAPI
3614 RtlEmptyBucketsHashTable(
3615 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable)
3616 {
3617 return HashTable->TableSize - HashTable->NonEmptyBuckets;
3618 }
3619
3620 FORCEINLINE
3621 ULONG
3622 NTAPI
3623 RtlTotalEntriesHashTable(
3624 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable)
3625 {
3626 return HashTable->NumEntries;
3627 }
3628
3629 FORCEINLINE
3630 ULONG
3631 NTAPI
3632 RtlActiveEnumeratorsHashTable(
3633 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable)
3634 {
3635 return HashTable->NumEnumerators;
3636 }
3637
3638 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3639
3640 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3641
3642 $endif (_NTDDK_)
3643 $if (_NTIFS_)
3644
3645 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3646 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3647
3648 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3649 RtlxUnicodeStringToOemSize(STRING) : \
3650 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3651 )
3652
3653 #define RtlOemStringToUnicodeSize(STRING) ( \
3654 NLS_MB_OEM_CODE_PAGE_TAG ? \
3655 RtlxOemStringToUnicodeSize(STRING) : \
3656 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3657 )
3658
3659 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3660 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3661 )
3662
3663 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3664 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))
3665 $endif (_NTIFS_)