Sync with trunk (48237)
[reactos.git] / include / xdk / rtlfuncs.h
1 /******************************************************************************
2 * Runtime Library Functions *
3 ******************************************************************************/
4
5 $if (_WDMDDK_)
6
7 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
8
9 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
10
11 FORCEINLINE
12 VOID
13 InitializeListHead(
14 OUT PLIST_ENTRY ListHead)
15 {
16 ListHead->Flink = ListHead->Blink = ListHead;
17 }
18
19 FORCEINLINE
20 BOOLEAN
21 IsListEmpty(
22 IN CONST LIST_ENTRY * ListHead)
23 {
24 return (BOOLEAN)(ListHead->Flink == ListHead);
25 }
26
27 FORCEINLINE
28 BOOLEAN
29 RemoveEntryList(
30 IN PLIST_ENTRY Entry)
31 {
32 PLIST_ENTRY OldFlink;
33 PLIST_ENTRY OldBlink;
34
35 OldFlink = Entry->Flink;
36 OldBlink = Entry->Blink;
37 OldFlink->Blink = OldBlink;
38 OldBlink->Flink = OldFlink;
39 return (BOOLEAN)(OldFlink == OldBlink);
40 }
41
42 FORCEINLINE
43 PLIST_ENTRY
44 RemoveHeadList(
45 IN OUT PLIST_ENTRY ListHead)
46 {
47 PLIST_ENTRY Flink;
48 PLIST_ENTRY Entry;
49
50 Entry = ListHead->Flink;
51 Flink = Entry->Flink;
52 ListHead->Flink = Flink;
53 Flink->Blink = ListHead;
54 return Entry;
55 }
56
57 FORCEINLINE
58 PLIST_ENTRY
59 RemoveTailList(
60 IN OUT PLIST_ENTRY ListHead)
61 {
62 PLIST_ENTRY Blink;
63 PLIST_ENTRY Entry;
64
65 Entry = ListHead->Blink;
66 Blink = Entry->Blink;
67 ListHead->Blink = Blink;
68 Blink->Flink = ListHead;
69 return Entry;
70 }
71
72 FORCEINLINE
73 VOID
74 InsertTailList(
75 IN OUT PLIST_ENTRY ListHead,
76 IN OUT PLIST_ENTRY Entry)
77 {
78 PLIST_ENTRY OldBlink;
79 OldBlink = ListHead->Blink;
80 Entry->Flink = ListHead;
81 Entry->Blink = OldBlink;
82 OldBlink->Flink = Entry;
83 ListHead->Blink = Entry;
84 }
85
86 FORCEINLINE
87 VOID
88 InsertHeadList(
89 IN OUT PLIST_ENTRY ListHead,
90 IN OUT PLIST_ENTRY Entry)
91 {
92 PLIST_ENTRY OldFlink;
93 OldFlink = ListHead->Flink;
94 Entry->Flink = OldFlink;
95 Entry->Blink = ListHead;
96 OldFlink->Blink = Entry;
97 ListHead->Flink = Entry;
98 }
99
100 FORCEINLINE
101 VOID
102 AppendTailList(
103 IN OUT PLIST_ENTRY ListHead,
104 IN OUT PLIST_ENTRY ListToAppend)
105 {
106 PLIST_ENTRY ListEnd = ListHead->Blink;
107
108 ListHead->Blink->Flink = ListToAppend;
109 ListHead->Blink = ListToAppend->Blink;
110 ListToAppend->Blink->Flink = ListHead;
111 ListToAppend->Blink = ListEnd;
112 }
113
114 FORCEINLINE
115 PSINGLE_LIST_ENTRY
116 PopEntryList(
117 IN OUT PSINGLE_LIST_ENTRY ListHead)
118 {
119 PSINGLE_LIST_ENTRY FirstEntry;
120 FirstEntry = ListHead->Next;
121 if (FirstEntry != NULL) {
122 ListHead->Next = FirstEntry->Next;
123 }
124 return FirstEntry;
125 }
126
127 FORCEINLINE
128 VOID
129 PushEntryList(
130 IN OUT PSINGLE_LIST_ENTRY ListHead,
131 IN OUT PSINGLE_LIST_ENTRY Entry)
132 {
133 Entry->Next = ListHead->Next;
134 ListHead->Next = Entry;
135 }
136
137 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
138
139 NTSYSAPI
140 VOID
141 NTAPI
142 RtlAssert(
143 IN PVOID FailedAssertion,
144 IN PVOID FileName,
145 IN ULONG LineNumber,
146 IN PSTR Message);
147
148 /* VOID
149 * RtlCopyMemory(
150 * IN VOID UNALIGNED *Destination,
151 * IN CONST VOID UNALIGNED *Source,
152 * IN SIZE_T Length)
153 */
154 #define RtlCopyMemory(Destination, Source, Length) \
155 memcpy(Destination, Source, Length)
156
157 #define RtlCopyBytes RtlCopyMemory
158
159 #if defined(_M_AMD64)
160 NTSYSAPI
161 VOID
162 NTAPI
163 RtlCopyMemoryNonTemporal(
164 VOID UNALIGNED *Destination,
165 CONST VOID UNALIGNED *Source,
166 SIZE_T Length);
167 #else
168 #define RtlCopyMemoryNonTemporal RtlCopyMemory
169 #endif
170
171 /* BOOLEAN
172 * RtlEqualLuid(
173 * IN PLUID Luid1,
174 * IN PLUID Luid2)
175 */
176 #define RtlEqualLuid(Luid1, Luid2) \
177 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
178
179 /* ULONG
180 * RtlEqualMemory(
181 * IN VOID UNALIGNED *Destination,
182 * IN CONST VOID UNALIGNED *Source,
183 * IN SIZE_T Length)
184 */
185 #define RtlEqualMemory(Destination, Source, Length) \
186 (!memcmp(Destination, Source, Length))
187
188 /* VOID
189 * RtlFillMemory(
190 * IN VOID UNALIGNED *Destination,
191 * IN SIZE_T Length,
192 * IN UCHAR Fill)
193 */
194 #define RtlFillMemory(Destination, Length, Fill) \
195 memset(Destination, Fill, Length)
196
197 #define RtlFillBytes RtlFillMemory
198
199 NTSYSAPI
200 VOID
201 NTAPI
202 RtlFreeUnicodeString(
203 IN OUT PUNICODE_STRING UnicodeString);
204
205 NTSYSAPI
206 NTSTATUS
207 NTAPI
208 RtlGUIDFromString(
209 IN PUNICODE_STRING GuidString,
210 OUT GUID *Guid);
211
212 NTSYSAPI
213 VOID
214 NTAPI
215 RtlInitUnicodeString(
216 IN OUT PUNICODE_STRING DestinationString,
217 IN PCWSTR SourceString OPTIONAL);
218
219 /* VOID
220 * RtlMoveMemory(
221 * IN VOID UNALIGNED *Destination,
222 * IN CONST VOID UNALIGNED *Source,
223 * IN SIZE_T Length)
224 */
225 #define RtlMoveMemory(Destination, Source, Length) \
226 memmove(Destination, Source, Length)
227
228 NTSYSAPI
229 NTSTATUS
230 NTAPI
231 RtlStringFromGUID(
232 IN REFGUID Guid,
233 OUT PUNICODE_STRING GuidString);
234
235 /* VOID
236 * RtlZeroMemory(
237 * IN VOID UNALIGNED *Destination,
238 * IN SIZE_T Length)
239 */
240 #define RtlZeroMemory(Destination, Length) \
241 memset(Destination, 0, Length)
242
243 #define RtlZeroBytes RtlZeroMemory
244 $endif (_WDMDDK_)
245
246 #if (NTDDI_VERSION >= NTDDI_WIN2K)
247
248 $if (_WDMDDK_)
249 NTSYSAPI
250 BOOLEAN
251 NTAPI
252 RtlAreBitsClear(
253 IN PRTL_BITMAP BitMapHeader,
254 IN ULONG StartingIndex,
255 IN ULONG Length);
256
257 NTSYSAPI
258 BOOLEAN
259 NTAPI
260 RtlAreBitsSet(
261 IN PRTL_BITMAP BitMapHeader,
262 IN ULONG StartingIndex,
263 IN ULONG Length);
264
265 NTSYSAPI
266 NTSTATUS
267 NTAPI
268 RtlAnsiStringToUnicodeString(
269 IN OUT PUNICODE_STRING DestinationString,
270 IN PANSI_STRING SourceString,
271 IN BOOLEAN AllocateDestinationString);
272
273 NTSYSAPI
274 ULONG
275 NTAPI
276 RtlxAnsiStringToUnicodeSize(
277 IN PCANSI_STRING AnsiString);
278
279 #define RtlAnsiStringToUnicodeSize(String) ( \
280 NLS_MB_CODE_PAGE_TAG ? \
281 RtlxAnsiStringToUnicodeSize(String) : \
282 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
283 )
284
285 NTSYSAPI
286 NTSTATUS
287 NTAPI
288 RtlAppendUnicodeStringToString(
289 IN OUT PUNICODE_STRING Destination,
290 IN PCUNICODE_STRING Source);
291
292 NTSYSAPI
293 NTSTATUS
294 NTAPI
295 RtlAppendUnicodeToString(
296 IN OUT PUNICODE_STRING Destination,
297 IN PCWSTR Source);
298
299 NTSYSAPI
300 NTSTATUS
301 NTAPI
302 RtlCheckRegistryKey(
303 IN ULONG RelativeTo,
304 IN PWSTR Path);
305
306 NTSYSAPI
307 VOID
308 NTAPI
309 RtlClearAllBits(
310 IN PRTL_BITMAP BitMapHeader);
311
312 NTSYSAPI
313 VOID
314 NTAPI
315 RtlClearBits(
316 IN PRTL_BITMAP BitMapHeader,
317 IN ULONG StartingIndex,
318 IN ULONG NumberToClear);
319
320 NTSYSAPI
321 SIZE_T
322 NTAPI
323 RtlCompareMemory(
324 IN CONST VOID *Source1,
325 IN CONST VOID *Source2,
326 IN SIZE_T Length);
327
328 NTSYSAPI
329 LONG
330 NTAPI
331 RtlCompareUnicodeString(
332 IN PCUNICODE_STRING String1,
333 IN PCUNICODE_STRING String2,
334 IN BOOLEAN CaseInSensitive);
335
336 NTSYSAPI
337 LONG
338 NTAPI
339 RtlCompareUnicodeStrings(
340 IN PCWCH String1,
341 IN SIZE_T String1Length,
342 IN PCWCH String2,
343 IN SIZE_T String2Length,
344 IN BOOLEAN CaseInSensitive);
345
346 NTSYSAPI
347 VOID
348 NTAPI
349 RtlCopyUnicodeString(
350 IN OUT PUNICODE_STRING DestinationString,
351 IN PCUNICODE_STRING SourceString OPTIONAL);
352
353 NTSYSAPI
354 NTSTATUS
355 NTAPI
356 RtlCreateRegistryKey(
357 IN ULONG RelativeTo,
358 IN PWSTR Path);
359
360 NTSYSAPI
361 NTSTATUS
362 NTAPI
363 RtlCreateSecurityDescriptor(
364 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
365 IN ULONG Revision);
366
367 NTSYSAPI
368 NTSTATUS
369 NTAPI
370 RtlDeleteRegistryValue(
371 IN ULONG RelativeTo,
372 IN PCWSTR Path,
373 IN PCWSTR ValueName);
374
375 NTSYSAPI
376 BOOLEAN
377 NTAPI
378 RtlEqualUnicodeString(
379 IN CONST UNICODE_STRING *String1,
380 IN CONST UNICODE_STRING *String2,
381 IN BOOLEAN CaseInSensitive);
382
383 #if !defined(_AMD64_) && !defined(_IA64_)
384 NTSYSAPI
385 LARGE_INTEGER
386 NTAPI
387 RtlExtendedIntegerMultiply(
388 IN LARGE_INTEGER Multiplicand,
389 IN LONG Multiplier);
390
391 NTSYSAPI
392 LARGE_INTEGER
393 NTAPI
394 RtlExtendedLargeIntegerDivide(
395 IN LARGE_INTEGER Dividend,
396 IN ULONG Divisor,
397 OUT PULONG Remainder OPTIONAL);
398 #endif
399
400 #if defined(_X86_) || defined(_IA64_)
401 NTSYSAPI
402 LARGE_INTEGER
403 NTAPI
404 RtlExtendedMagicDivide(
405 IN LARGE_INTEGER Dividend,
406 IN LARGE_INTEGER MagicDivisor,
407 IN CCHAR ShiftCount);
408 #endif
409
410 NTSYSAPI
411 VOID
412 NTAPI
413 RtlFreeAnsiString(
414 IN PANSI_STRING AnsiString);
415
416 NTSYSAPI
417 ULONG
418 NTAPI
419 RtlFindClearBits(
420 IN PRTL_BITMAP BitMapHeader,
421 IN ULONG NumberToFind,
422 IN ULONG HintIndex);
423
424 NTSYSAPI
425 ULONG
426 NTAPI
427 RtlFindClearBitsAndSet(
428 IN PRTL_BITMAP BitMapHeader,
429 IN ULONG NumberToFind,
430 IN ULONG HintIndex);
431
432 NTSYSAPI
433 ULONG
434 NTAPI
435 RtlFindFirstRunClear(
436 IN PRTL_BITMAP BitMapHeader,
437 OUT PULONG StartingIndex);
438
439 NTSYSAPI
440 ULONG
441 NTAPI
442 RtlFindClearRuns(
443 IN PRTL_BITMAP BitMapHeader,
444 OUT PRTL_BITMAP_RUN RunArray,
445 IN ULONG SizeOfRunArray,
446 IN BOOLEAN LocateLongestRuns);
447
448 NTSYSAPI
449 ULONG
450 NTAPI
451 RtlFindLastBackwardRunClear(
452 IN PRTL_BITMAP BitMapHeader,
453 IN ULONG FromIndex,
454 OUT PULONG StartingRunIndex);
455
456 NTSYSAPI
457 CCHAR
458 NTAPI
459 RtlFindLeastSignificantBit(
460 IN ULONGLONG Set);
461
462 NTSYSAPI
463 ULONG
464 NTAPI
465 RtlFindLongestRunClear(
466 IN PRTL_BITMAP BitMapHeader,
467 OUT PULONG StartingIndex);
468
469 NTSYSAPI
470 CCHAR
471 NTAPI
472 RtlFindMostSignificantBit(
473 IN ULONGLONG Set);
474
475 NTSYSAPI
476 ULONG
477 NTAPI
478 RtlFindNextForwardRunClear(
479 IN PRTL_BITMAP BitMapHeader,
480 IN ULONG FromIndex,
481 OUT PULONG StartingRunIndex);
482
483 NTSYSAPI
484 ULONG
485 NTAPI
486 RtlFindSetBits(
487 IN PRTL_BITMAP BitMapHeader,
488 IN ULONG NumberToFind,
489 IN ULONG HintIndex);
490
491 NTSYSAPI
492 ULONG
493 NTAPI
494 RtlFindSetBitsAndClear(
495 IN PRTL_BITMAP BitMapHeader,
496 IN ULONG NumberToFind,
497 IN ULONG HintIndex);
498
499 NTSYSAPI
500 VOID
501 NTAPI
502 RtlInitAnsiString(
503 IN OUT PANSI_STRING DestinationString,
504 IN PCSZ SourceString);
505
506 NTSYSAPI
507 VOID
508 NTAPI
509 RtlInitializeBitMap(
510 IN PRTL_BITMAP BitMapHeader,
511 IN PULONG BitMapBuffer,
512 IN ULONG SizeOfBitMap);
513
514 NTSYSAPI
515 VOID
516 NTAPI
517 RtlInitString(
518 IN OUT PSTRING DestinationString,
519 IN PCSZ SourceString);
520
521 NTSYSAPI
522 NTSTATUS
523 NTAPI
524 RtlIntegerToUnicodeString(
525 IN ULONG Value,
526 IN ULONG Base OPTIONAL,
527 IN OUT PUNICODE_STRING String);
528
529 NTSYSAPI
530 NTSTATUS
531 NTAPI
532 RtlInt64ToUnicodeString(
533 IN ULONGLONG Value,
534 IN ULONG Base OPTIONAL,
535 IN OUT PUNICODE_STRING String);
536
537 #ifdef _WIN64
538 #define RtlIntPtrToUnicodeString(Value, Base, String) \
539 RtlInt64ToUnicodeString(Value, Base, String)
540 #else
541 #define RtlIntPtrToUnicodeString(Value, Base, String) \
542 RtlIntegerToUnicodeString(Value, Base, String)
543 #endif
544
545 /* BOOLEAN
546 * RtlIsZeroLuid(
547 * IN PLUID L1);
548 */
549 #define RtlIsZeroLuid(_L1) \
550 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
551
552 NTSYSAPI
553 ULONG
554 NTAPI
555 RtlLengthSecurityDescriptor(
556 IN PSECURITY_DESCRIPTOR SecurityDescriptor);
557
558 NTSYSAPI
559 ULONG
560 NTAPI
561 RtlNumberOfClearBits(
562 IN PRTL_BITMAP BitMapHeader);
563
564 NTSYSAPI
565 ULONG
566 NTAPI
567 RtlNumberOfSetBits(
568 IN PRTL_BITMAP BitMapHeader);
569
570 NTSYSAPI
571 NTSTATUS
572 NTAPI
573 RtlQueryRegistryValues(
574 IN ULONG RelativeTo,
575 IN PCWSTR Path,
576 IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable,
577 IN PVOID Context OPTIONAL,
578 IN PVOID Environment OPTIONAL);
579
580 #define SHORT_SIZE (sizeof(USHORT))
581 #define SHORT_MASK (SHORT_SIZE - 1)
582 #define LONG_SIZE (sizeof(LONG))
583 #define LONGLONG_SIZE (sizeof(LONGLONG))
584 #define LONG_MASK (LONG_SIZE - 1)
585 #define LONGLONG_MASK (LONGLONG_SIZE - 1)
586 #define LOWBYTE_MASK 0x00FF
587
588 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK)
589 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
590 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK)
591 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
592
593 NTSYSAPI
594 VOID
595 NTAPI
596 RtlSetAllBits(
597 IN PRTL_BITMAP BitMapHeader);
598
599 NTSYSAPI
600 VOID
601 NTAPI
602 RtlSetBits(
603 IN PRTL_BITMAP BitMapHeader,
604 IN ULONG StartingIndex,
605 IN ULONG NumberToSet);
606
607 NTSYSAPI
608 NTSTATUS
609 NTAPI
610 RtlSetDaclSecurityDescriptor(
611 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
612 IN BOOLEAN DaclPresent,
613 IN PACL Dacl OPTIONAL,
614 IN BOOLEAN DaclDefaulted OPTIONAL);
615
616 #if defined(_AMD64_)
617
618 /* VOID
619 * RtlStoreUlong(
620 * IN PULONG Address,
621 * IN ULONG Value);
622 */
623 #define RtlStoreUlong(Address,Value) \
624 *(ULONG UNALIGNED *)(Address) = (Value)
625
626 /* VOID
627 * RtlStoreUlonglong(
628 * IN OUT PULONGLONG Address,
629 * ULONGLONG Value);
630 */
631 #define RtlStoreUlonglong(Address,Value) \
632 *(ULONGLONG UNALIGNED *)(Address) = (Value)
633
634 /* VOID
635 * RtlStoreUshort(
636 * IN PUSHORT Address,
637 * IN USHORT Value);
638 */
639 #define RtlStoreUshort(Address,Value) \
640 *(USHORT UNALIGNED *)(Address) = (Value)
641
642 /* VOID
643 * RtlRetrieveUshort(
644 * PUSHORT DestinationAddress,
645 * PUSHORT SourceAddress);
646 */
647 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
648 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
649
650 /* VOID
651 * RtlRetrieveUlong(
652 * PULONG DestinationAddress,
653 * PULONG SourceAddress);
654 */
655 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
656 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
657
658 #else
659
660 #define RtlStoreUlong(Address,Value) \
661 if ((ULONG_PTR)(Address) & LONG_MASK) { \
662 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
663 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
664 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
665 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \
666 } \
667 else { \
668 *((PULONG)(Address)) = (ULONG) (Value); \
669 }
670
671 #define RtlStoreUlonglong(Address,Value) \
672 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
673 RtlStoreUlong((ULONG_PTR)(Address), \
674 (ULONGLONG)(Value) & 0xFFFFFFFF); \
675 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
676 (ULONGLONG)(Value) >> 32); \
677 } else { \
678 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
679 }
680
681 #define RtlStoreUshort(Address,Value) \
682 if ((ULONG_PTR)(Address) & SHORT_MASK) { \
683 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
684 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
685 } \
686 else { \
687 *((PUSHORT) (Address)) = (USHORT)Value; \
688 }
689
690 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
691 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
692 { \
693 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
694 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
695 } \
696 else \
697 { \
698 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
699 }
700
701 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
702 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
703 { \
704 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
705 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
706 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
707 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
708 } \
709 else \
710 { \
711 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
712 }
713
714 #endif /* defined(_AMD64_) */
715
716 #ifdef _WIN64
717 /* VOID
718 * RtlStoreUlongPtr(
719 * IN OUT PULONG_PTR Address,
720 * IN ULONG_PTR Value);
721 */
722 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
723 #else
724 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
725 #endif /* _WIN64 */
726
727 NTSYSAPI
728 BOOLEAN
729 NTAPI
730 RtlTimeFieldsToTime(
731 IN PTIME_FIELDS TimeFields,
732 IN PLARGE_INTEGER Time);
733
734 NTSYSAPI
735 VOID
736 NTAPI
737 RtlTimeToTimeFields(
738 IN PLARGE_INTEGER Time,
739 IN PTIME_FIELDS TimeFields);
740
741 NTSYSAPI
742 ULONG
743 FASTCALL
744 RtlUlongByteSwap(
745 IN ULONG Source);
746
747 NTSYSAPI
748 ULONGLONG
749 FASTCALL
750 RtlUlonglongByteSwap(
751 IN ULONGLONG Source);
752
753 NTSYSAPI
754 NTSTATUS
755 NTAPI
756 RtlUnicodeStringToAnsiString(
757 IN OUT PANSI_STRING DestinationString,
758 IN PCUNICODE_STRING SourceString,
759 IN BOOLEAN AllocateDestinationString);
760
761 NTSYSAPI
762 ULONG
763 NTAPI
764 RtlxUnicodeStringToAnsiSize(
765 IN PCUNICODE_STRING UnicodeString);
766
767 #define RtlUnicodeStringToAnsiSize(String) ( \
768 NLS_MB_CODE_PAGE_TAG ? \
769 RtlxUnicodeStringToAnsiSize(String) : \
770 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
771 )
772
773 NTSYSAPI
774 NTSTATUS
775 NTAPI
776 RtlUnicodeStringToInteger(
777 IN PCUNICODE_STRING String,
778 IN ULONG Base OPTIONAL,
779 OUT PULONG Value);
780
781 NTSYSAPI
782 WCHAR
783 NTAPI
784 RtlUpcaseUnicodeChar(
785 IN WCHAR SourceCharacter);
786
787 NTSYSAPI
788 USHORT
789 FASTCALL
790 RtlUshortByteSwap(
791 IN USHORT Source);
792
793 NTSYSAPI
794 BOOLEAN
795 NTAPI
796 RtlValidRelativeSecurityDescriptor(
797 IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
798 IN ULONG SecurityDescriptorLength,
799 IN SECURITY_INFORMATION RequiredInformation);
800
801 NTSYSAPI
802 BOOLEAN
803 NTAPI
804 RtlValidSecurityDescriptor(
805 IN PSECURITY_DESCRIPTOR SecurityDescriptor);
806
807 NTSYSAPI
808 NTSTATUS
809 NTAPI
810 RtlWriteRegistryValue(
811 IN ULONG RelativeTo,
812 IN PCWSTR Path,
813 IN PCWSTR ValueName,
814 IN ULONG ValueType,
815 IN PVOID ValueData,
816 IN ULONG ValueLength);
817
818 $endif (_WDMDDK_)
819 $if (_NTDDK_)
820
821 #ifndef RTL_USE_AVL_TABLES
822
823 NTSYSAPI
824 VOID
825 NTAPI
826 RtlInitializeGenericTable(
827 OUT PRTL_GENERIC_TABLE Table,
828 IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine,
829 IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine,
830 IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine,
831 IN PVOID TableContext OPTIONAL);
832
833 NTSYSAPI
834 PVOID
835 NTAPI
836 RtlInsertElementGenericTable(
837 IN PRTL_GENERIC_TABLE Table,
838 IN PVOID Buffer,
839 IN CLONG BufferSize,
840 OUT PBOOLEAN NewElement OPTIONAL);
841
842 NTSYSAPI
843 PVOID
844 NTAPI
845 RtlInsertElementGenericTableFull(
846 IN PRTL_GENERIC_TABLE Table,
847 IN PVOID Buffer,
848 IN CLONG BufferSize,
849 OUT PBOOLEAN NewElement OPTIONAL,
850 IN PVOID NodeOrParent,
851 IN TABLE_SEARCH_RESULT SearchResult);
852
853 NTSYSAPI
854 BOOLEAN
855 NTAPI
856 RtlDeleteElementGenericTable(
857 IN PRTL_GENERIC_TABLE Table,
858 IN PVOID Buffer);
859
860 NTSYSAPI
861 PVOID
862 NTAPI
863 RtlLookupElementGenericTable(
864 IN PRTL_GENERIC_TABLE Table,
865 IN PVOID Buffer);
866
867 NTSYSAPI
868 PVOID
869 NTAPI
870 RtlLookupElementGenericTableFull(
871 IN PRTL_GENERIC_TABLE Table,
872 IN PVOID Buffer,
873 OUT PVOID *NodeOrParent,
874 OUT TABLE_SEARCH_RESULT *SearchResult);
875
876 NTSYSAPI
877 PVOID
878 NTAPI
879 RtlEnumerateGenericTable(
880 IN PRTL_GENERIC_TABLE Table,
881 IN BOOLEAN Restart);
882
883 NTSYSAPI
884 PVOID
885 NTAPI
886 RtlEnumerateGenericTableWithoutSplaying(
887 IN PRTL_GENERIC_TABLE Table,
888 IN OUT PVOID *RestartKey);
889
890 NTSYSAPI
891 PVOID
892 NTAPI
893 RtlGetElementGenericTable(
894 IN PRTL_GENERIC_TABLE Table,
895 IN ULONG I);
896
897 NTSYSAPI
898 ULONG
899 NTAPI
900 RtlNumberGenericTableElements(
901 IN PRTL_GENERIC_TABLE Table);
902
903 NTSYSAPI
904 BOOLEAN
905 NTAPI
906 RtlIsGenericTableEmpty(
907 IN PRTL_GENERIC_TABLE Table);
908
909 #endif /* !RTL_USE_AVL_TABLES */
910
911 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
912
913 NTSYSAPI
914 PRTL_SPLAY_LINKS
915 NTAPI
916 RtlSplay(
917 IN OUT PRTL_SPLAY_LINKS Links);
918
919 NTSYSAPI
920 PRTL_SPLAY_LINKS
921 NTAPI
922 RtlDelete(
923 IN PRTL_SPLAY_LINKS Links);
924
925 NTSYSAPI
926 VOID
927 NTAPI
928 RtlDeleteNoSplay(
929 IN PRTL_SPLAY_LINKS Links,
930 IN OUT PRTL_SPLAY_LINKS *Root);
931
932 NTSYSAPI
933 PRTL_SPLAY_LINKS
934 NTAPI
935 RtlSubtreeSuccessor(
936 IN PRTL_SPLAY_LINKS Links);
937
938 NTSYSAPI
939 PRTL_SPLAY_LINKS
940 NTAPI
941 RtlSubtreePredecessor(
942 IN PRTL_SPLAY_LINKS Links);
943
944 NTSYSAPI
945 PRTL_SPLAY_LINKS
946 NTAPI
947 RtlRealSuccessor(
948 IN PRTL_SPLAY_LINKS Links);
949
950 NTSYSAPI
951 PRTL_SPLAY_LINKS
952 NTAPI
953 RtlRealPredecessor(
954 IN PRTL_SPLAY_LINKS Links);
955
956 NTSYSAPI
957 BOOLEAN
958 NTAPI
959 RtlPrefixUnicodeString(
960 IN PCUNICODE_STRING String1,
961 IN PCUNICODE_STRING String2,
962 IN BOOLEAN CaseInSensitive);
963
964 NTSYSAPI
965 VOID
966 NTAPI
967 RtlUpperString(
968 IN OUT PSTRING DestinationString,
969 IN const PSTRING SourceString);
970
971 NTSYSAPI
972 NTSTATUS
973 NTAPI
974 RtlUpcaseUnicodeString(
975 IN OUT PUNICODE_STRING DestinationString,
976 IN PCUNICODE_STRING SourceString,
977 IN BOOLEAN AllocateDestinationString);
978
979 NTSYSAPI
980 VOID
981 NTAPI
982 RtlMapGenericMask(
983 IN OUT PACCESS_MASK AccessMask,
984 IN PGENERIC_MAPPING GenericMapping);
985
986 NTSYSAPI
987 NTSTATUS
988 NTAPI
989 RtlVolumeDeviceToDosName(
990 IN PVOID VolumeDeviceObject,
991 OUT PUNICODE_STRING DosName);
992
993 NTSYSAPI
994 NTSTATUS
995 NTAPI
996 RtlGetVersion(
997 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
998
999 NTSYSAPI
1000 NTSTATUS
1001 NTAPI
1002 RtlVerifyVersionInfo(
1003 IN PRTL_OSVERSIONINFOEXW VersionInfo,
1004 IN ULONG TypeMask,
1005 IN ULONGLONG ConditionMask);
1006
1007 NTSYSAPI
1008 LONG
1009 NTAPI
1010 RtlCompareString(
1011 IN const PSTRING String1,
1012 IN const PSTRING String2,
1013 IN BOOLEAN CaseInSensitive);
1014
1015 NTSYSAPI
1016 VOID
1017 NTAPI
1018 RtlCopyString(
1019 OUT PSTRING DestinationString,
1020 IN const PSTRING SourceString OPTIONAL);
1021
1022 NTSYSAPI
1023 BOOLEAN
1024 NTAPI
1025 RtlEqualString(
1026 IN const PSTRING String1,
1027 IN const PSTRING String2,
1028 IN BOOLEAN CaseInSensitive);
1029
1030 NTSYSAPI
1031 NTSTATUS
1032 NTAPI
1033 RtlCharToInteger(
1034 IN PCSZ String,
1035 IN ULONG Base OPTIONAL,
1036 OUT PULONG Value);
1037
1038 NTSYSAPI
1039 CHAR
1040 NTAPI
1041 RtlUpperChar(
1042 IN CHAR Character);
1043
1044 NTSYSAPI
1045 ULONG
1046 NTAPI
1047 RtlWalkFrameChain(
1048 OUT PVOID *Callers,
1049 IN ULONG Count,
1050 IN ULONG Flags);
1051
1052 $endif (_NTDDK_)
1053 $if (_NTIFS_)
1054
1055 NTSYSAPI
1056 PVOID
1057 NTAPI
1058 RtlAllocateHeap(
1059 IN HANDLE HeapHandle,
1060 IN ULONG Flags OPTIONAL,
1061 IN SIZE_T Size);
1062
1063 NTSYSAPI
1064 BOOLEAN
1065 NTAPI
1066 RtlFreeHeap(
1067 IN PVOID HeapHandle,
1068 IN ULONG Flags OPTIONAL,
1069 IN PVOID BaseAddress);
1070
1071 NTSYSAPI
1072 VOID
1073 NTAPI
1074 RtlCaptureContext(
1075 OUT PCONTEXT ContextRecord);
1076
1077 NTSYSAPI
1078 ULONG
1079 NTAPI
1080 RtlRandom(
1081 IN OUT PULONG Seed);
1082
1083 NTSYSAPI
1084 BOOLEAN
1085 NTAPI
1086 RtlCreateUnicodeString(
1087 OUT PUNICODE_STRING DestinationString,
1088 IN PCWSTR SourceString);
1089
1090 NTSYSAPI
1091 NTSTATUS
1092 NTAPI
1093 RtlAppendStringToString(
1094 IN OUT PSTRING Destination,
1095 IN const STRING *Source);
1096
1097 NTSYSAPI
1098 NTSTATUS
1099 NTAPI
1100 RtlOemStringToUnicodeString(
1101 IN OUT PUNICODE_STRING DestinationString,
1102 IN PCOEM_STRING SourceString,
1103 IN BOOLEAN AllocateDestinationString);
1104
1105 NTSYSAPI
1106 NTSTATUS
1107 NTAPI
1108 RtlUnicodeStringToOemString(
1109 IN OUT POEM_STRING DestinationString,
1110 IN PCUNICODE_STRING SourceString,
1111 IN BOOLEAN AllocateDestinationString);
1112
1113 NTSYSAPI
1114 NTSTATUS
1115 NTAPI
1116 RtlUpcaseUnicodeStringToOemString(
1117 IN OUT POEM_STRING DestinationString,
1118 IN PCUNICODE_STRING SourceString,
1119 IN BOOLEAN AllocateDestinationString);
1120
1121 NTSYSAPI
1122 NTSTATUS
1123 NTAPI
1124 RtlOemStringToCountedUnicodeString(
1125 IN OUT PUNICODE_STRING DestinationString,
1126 IN PCOEM_STRING SourceString,
1127 IN BOOLEAN AllocateDestinationString);
1128
1129 NTSYSAPI
1130 NTSTATUS
1131 NTAPI
1132 RtlUnicodeStringToCountedOemString(
1133 IN OUT POEM_STRING DestinationString,
1134 IN PCUNICODE_STRING SourceString,
1135 IN BOOLEAN AllocateDestinationString);
1136
1137 NTSYSAPI
1138 NTSTATUS
1139 NTAPI
1140 RtlUpcaseUnicodeStringToCountedOemString(
1141 IN OUT POEM_STRING DestinationString,
1142 IN PCUNICODE_STRING SourceString,
1143 IN BOOLEAN AllocateDestinationString);
1144
1145 NTSYSAPI
1146 NTSTATUS
1147 NTAPI
1148 RtlDowncaseUnicodeString(
1149 IN OUT PUNICODE_STRING UniDest,
1150 IN PCUNICODE_STRING UniSource,
1151 IN BOOLEAN AllocateDestinationString);
1152
1153 NTSYSAPI
1154 VOID
1155 NTAPI
1156 RtlFreeOemString (
1157 IN OUT POEM_STRING OemString);
1158
1159 NTSYSAPI
1160 ULONG
1161 NTAPI
1162 RtlxUnicodeStringToOemSize(
1163 IN PCUNICODE_STRING UnicodeString);
1164
1165 NTSYSAPI
1166 ULONG
1167 NTAPI
1168 RtlxOemStringToUnicodeSize(
1169 IN PCOEM_STRING OemString);
1170
1171 NTSYSAPI
1172 NTSTATUS
1173 NTAPI
1174 RtlMultiByteToUnicodeN(
1175 OUT PWCH UnicodeString,
1176 IN ULONG MaxBytesInUnicodeString,
1177 OUT PULONG BytesInUnicodeString OPTIONAL,
1178 IN const CHAR *MultiByteString,
1179 IN ULONG BytesInMultiByteString);
1180
1181 NTSYSAPI
1182 NTSTATUS
1183 NTAPI
1184 RtlMultiByteToUnicodeSize(
1185 OUT PULONG BytesInUnicodeString,
1186 IN const CHAR *MultiByteString,
1187 IN ULONG BytesInMultiByteString);
1188
1189 NTSYSAPI
1190 NTSTATUS
1191 NTAPI
1192 RtlUnicodeToMultiByteSize(
1193 OUT PULONG BytesInMultiByteString,
1194 IN PCWCH UnicodeString,
1195 IN ULONG BytesInUnicodeString);
1196
1197 NTSYSAPI
1198 NTSTATUS
1199 NTAPI
1200 RtlUnicodeToMultiByteN(
1201 OUT PCHAR MultiByteString,
1202 IN ULONG MaxBytesInMultiByteString,
1203 OUT PULONG BytesInMultiByteString OPTIONAL,
1204 IN PWCH UnicodeString,
1205 IN ULONG BytesInUnicodeString);
1206
1207 NTSYSAPI
1208 NTSTATUS
1209 NTAPI
1210 RtlUpcaseUnicodeToMultiByteN(
1211 OUT PCHAR MultiByteString,
1212 IN ULONG MaxBytesInMultiByteString,
1213 OUT PULONG BytesInMultiByteString OPTIONAL,
1214 IN PCWCH UnicodeString,
1215 IN ULONG BytesInUnicodeString);
1216
1217 NTSYSAPI
1218 NTSTATUS
1219 NTAPI
1220 RtlOemToUnicodeN(
1221 OUT PWSTR UnicodeString,
1222 IN ULONG MaxBytesInUnicodeString,
1223 OUT PULONG BytesInUnicodeString OPTIONAL,
1224 IN PCCH OemString,
1225 IN ULONG BytesInOemString);
1226
1227 NTSYSAPI
1228 NTSTATUS
1229 NTAPI
1230 RtlUnicodeToOemN(
1231 OUT PCHAR OemString,
1232 IN ULONG MaxBytesInOemString,
1233 OUT PULONG BytesInOemString OPTIONAL,
1234 IN PCWCH UnicodeString,
1235 IN ULONG BytesInUnicodeString);
1236
1237 NTSYSAPI
1238 NTSTATUS
1239 NTAPI
1240 RtlUpcaseUnicodeToOemN(
1241 OUT PCHAR OemString,
1242 IN ULONG MaxBytesInOemString,
1243 OUT PULONG BytesInOemString OPTIONAL,
1244 IN PCWCH UnicodeString,
1245 IN ULONG BytesInUnicodeString);
1246
1247 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1248 NTSYSAPI
1249 NTSTATUS
1250 NTAPI
1251 RtlGenerate8dot3Name(
1252 IN PCUNICODE_STRING Name,
1253 IN BOOLEAN AllowExtendedCharacters,
1254 IN OUT PGENERATE_NAME_CONTEXT Context,
1255 IN OUT PUNICODE_STRING Name8dot3);
1256 #else
1257 NTSYSAPI
1258 VOID
1259 NTAPI
1260 RtlGenerate8dot3Name(
1261 IN PCUNICODE_STRING Name,
1262 IN BOOLEAN AllowExtendedCharacters,
1263 IN OUT PGENERATE_NAME_CONTEXT Context,
1264 IN OUT PUNICODE_STRING Name8dot3);
1265 #endif
1266
1267 NTSYSAPI
1268 BOOLEAN
1269 NTAPI
1270 RtlIsNameLegalDOS8Dot3(
1271 IN PCUNICODE_STRING Name,
1272 IN OUT POEM_STRING OemName OPTIONAL,
1273 IN OUT PBOOLEAN NameContainsSpaces OPTIONAL);
1274
1275 NTSYSAPI
1276 BOOLEAN
1277 NTAPI
1278 RtlIsValidOemCharacter(
1279 IN OUT PWCHAR Char);
1280
1281 NTSYSAPI
1282 VOID
1283 NTAPI
1284 PfxInitialize(
1285 OUT PPREFIX_TABLE PrefixTable);
1286
1287 NTSYSAPI
1288 BOOLEAN
1289 NTAPI
1290 PfxInsertPrefix(
1291 IN PPREFIX_TABLE PrefixTable,
1292 IN PSTRING Prefix,
1293 OUT PPREFIX_TABLE_ENTRY PrefixTableEntry);
1294
1295 NTSYSAPI
1296 VOID
1297 NTAPI
1298 PfxRemovePrefix(
1299 IN PPREFIX_TABLE PrefixTable,
1300 IN PPREFIX_TABLE_ENTRY PrefixTableEntry);
1301
1302 NTSYSAPI
1303 PPREFIX_TABLE_ENTRY
1304 NTAPI
1305 PfxFindPrefix(
1306 IN PPREFIX_TABLE PrefixTable,
1307 IN PSTRING FullName);
1308
1309 NTSYSAPI
1310 VOID
1311 NTAPI
1312 RtlInitializeUnicodePrefix(
1313 OUT PUNICODE_PREFIX_TABLE PrefixTable);
1314
1315 NTSYSAPI
1316 BOOLEAN
1317 NTAPI
1318 RtlInsertUnicodePrefix(
1319 IN PUNICODE_PREFIX_TABLE PrefixTable,
1320 IN PUNICODE_STRING Prefix,
1321 OUT PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry);
1322
1323 NTSYSAPI
1324 VOID
1325 NTAPI
1326 RtlRemoveUnicodePrefix(
1327 IN PUNICODE_PREFIX_TABLE PrefixTable,
1328 IN PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry);
1329
1330 NTSYSAPI
1331 PUNICODE_PREFIX_TABLE_ENTRY
1332 NTAPI
1333 RtlFindUnicodePrefix(
1334 IN PUNICODE_PREFIX_TABLE PrefixTable,
1335 IN PUNICODE_STRING FullName,
1336 IN ULONG CaseInsensitiveIndex);
1337
1338 NTSYSAPI
1339 PUNICODE_PREFIX_TABLE_ENTRY
1340 NTAPI
1341 RtlNextUnicodePrefix(
1342 IN PUNICODE_PREFIX_TABLE PrefixTable,
1343 IN BOOLEAN Restart);
1344
1345 NTSYSAPI
1346 SIZE_T
1347 NTAPI
1348 RtlCompareMemoryUlong(
1349 IN PVOID Source,
1350 IN SIZE_T Length,
1351 IN ULONG Pattern);
1352
1353 NTSYSAPI
1354 BOOLEAN
1355 NTAPI
1356 RtlTimeToSecondsSince1980(
1357 IN PLARGE_INTEGER Time,
1358 OUT PULONG ElapsedSeconds);
1359
1360 NTSYSAPI
1361 VOID
1362 NTAPI
1363 RtlSecondsSince1980ToTime(
1364 IN ULONG ElapsedSeconds,
1365 OUT PLARGE_INTEGER Time);
1366
1367 NTSYSAPI
1368 BOOLEAN
1369 NTAPI
1370 RtlTimeToSecondsSince1970(
1371 IN PLARGE_INTEGER Time,
1372 OUT PULONG ElapsedSeconds);
1373
1374 NTSYSAPI
1375 VOID
1376 NTAPI
1377 RtlSecondsSince1970ToTime(
1378 IN ULONG ElapsedSeconds,
1379 OUT PLARGE_INTEGER Time);
1380
1381 NTSYSAPI
1382 BOOLEAN
1383 NTAPI
1384 RtlValidSid(
1385 IN PSID Sid);
1386
1387 NTSYSAPI
1388 BOOLEAN
1389 NTAPI
1390 RtlEqualSid(
1391 IN PSID Sid1,
1392 IN PSID Sid2);
1393
1394 NTSYSAPI
1395 BOOLEAN
1396 NTAPI
1397 RtlEqualPrefixSid(
1398 IN PSID Sid1,
1399 IN PSID Sid2);
1400
1401 NTSYSAPI
1402 ULONG
1403 NTAPI
1404 RtlLengthRequiredSid(
1405 IN ULONG SubAuthorityCount);
1406
1407 NTSYSAPI
1408 PVOID
1409 NTAPI
1410 RtlFreeSid(
1411 IN PSID Sid);
1412
1413 NTSYSAPI
1414 NTSTATUS
1415 NTAPI
1416 RtlAllocateAndInitializeSid(
1417 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1418 IN UCHAR SubAuthorityCount,
1419 IN ULONG SubAuthority0,
1420 IN ULONG SubAuthority1,
1421 IN ULONG SubAuthority2,
1422 IN ULONG SubAuthority3,
1423 IN ULONG SubAuthority4,
1424 IN ULONG SubAuthority5,
1425 IN ULONG SubAuthority6,
1426 IN ULONG SubAuthority7,
1427 OUT PSID *Sid);
1428
1429 NTSYSAPI
1430 NTSTATUS
1431 NTAPI
1432 RtlInitializeSid(
1433 OUT PSID Sid,
1434 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1435 IN UCHAR SubAuthorityCount);
1436
1437 NTSYSAPI
1438 PULONG
1439 NTAPI
1440 RtlSubAuthoritySid(
1441 IN PSID Sid,
1442 IN ULONG SubAuthority);
1443
1444 NTSYSAPI
1445 ULONG
1446 NTAPI
1447 RtlLengthSid(
1448 IN PSID Sid);
1449
1450 NTSYSAPI
1451 NTSTATUS
1452 NTAPI
1453 RtlCopySid(
1454 IN ULONG Length,
1455 IN PSID Destination,
1456 IN PSID Source);
1457
1458 NTSYSAPI
1459 NTSTATUS
1460 NTAPI
1461 RtlConvertSidToUnicodeString(
1462 IN OUT PUNICODE_STRING UnicodeString,
1463 IN PSID Sid,
1464 IN BOOLEAN AllocateDestinationString);
1465
1466 NTSYSAPI
1467 VOID
1468 NTAPI
1469 RtlCopyLuid(
1470 OUT PLUID DestinationLuid,
1471 IN PLUID SourceLuid);
1472
1473 NTSYSAPI
1474 NTSTATUS
1475 NTAPI
1476 RtlCreateAcl(
1477 OUT PACL Acl,
1478 IN ULONG AclLength,
1479 IN ULONG AclRevision);
1480
1481 NTSYSAPI
1482 NTSTATUS
1483 NTAPI
1484 RtlAddAce(
1485 IN OUT PACL Acl,
1486 IN ULONG AceRevision,
1487 IN ULONG StartingAceIndex,
1488 IN PVOID AceList,
1489 IN ULONG AceListLength);
1490
1491 NTSYSAPI
1492 NTSTATUS
1493 NTAPI
1494 RtlDeleteAce(
1495 IN OUT PACL Acl,
1496 IN ULONG AceIndex);
1497
1498 NTSYSAPI
1499 NTSTATUS
1500 NTAPI
1501 RtlGetAce(
1502 IN PACL Acl,
1503 IN ULONG AceIndex,
1504 OUT PVOID *Ace);
1505
1506 NTSYSAPI
1507 NTSTATUS
1508 NTAPI
1509 RtlAddAccessAllowedAce(
1510 IN OUT PACL Acl,
1511 IN ULONG AceRevision,
1512 IN ACCESS_MASK AccessMask,
1513 IN PSID Sid);
1514
1515 NTSYSAPI
1516 NTSTATUS
1517 NTAPI
1518 RtlAddAccessAllowedAceEx(
1519 IN OUT PACL Acl,
1520 IN ULONG AceRevision,
1521 IN ULONG AceFlags,
1522 IN ACCESS_MASK AccessMask,
1523 IN PSID Sid);
1524
1525 NTSYSAPI
1526 NTSTATUS
1527 NTAPI
1528 RtlCreateSecurityDescriptorRelative(
1529 OUT PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
1530 IN ULONG Revision);
1531
1532 NTSYSAPI
1533 NTSTATUS
1534 NTAPI
1535 RtlGetDaclSecurityDescriptor(
1536 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
1537 OUT PBOOLEAN DaclPresent,
1538 OUT PACL *Dacl,
1539 OUT PBOOLEAN DaclDefaulted);
1540
1541 NTSYSAPI
1542 NTSTATUS
1543 NTAPI
1544 RtlSetOwnerSecurityDescriptor(
1545 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
1546 IN PSID Owner OPTIONAL,
1547 IN BOOLEAN OwnerDefaulted);
1548
1549 NTSYSAPI
1550 NTSTATUS
1551 NTAPI
1552 RtlGetOwnerSecurityDescriptor(
1553 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
1554 OUT PSID *Owner,
1555 OUT PBOOLEAN OwnerDefaulted);
1556
1557 NTSYSAPI
1558 ULONG
1559 NTAPI
1560 RtlNtStatusToDosError(
1561 IN NTSTATUS Status);
1562
1563 NTSYSAPI
1564 NTSTATUS
1565 NTAPI
1566 RtlCustomCPToUnicodeN(
1567 IN PCPTABLEINFO CustomCP,
1568 OUT PWCH UnicodeString,
1569 IN ULONG MaxBytesInUnicodeString,
1570 OUT PULONG BytesInUnicodeString OPTIONAL,
1571 IN PCH CustomCPString,
1572 IN ULONG BytesInCustomCPString);
1573
1574 NTSYSAPI
1575 NTSTATUS
1576 NTAPI
1577 RtlUnicodeToCustomCPN(
1578 IN PCPTABLEINFO CustomCP,
1579 OUT PCH CustomCPString,
1580 IN ULONG MaxBytesInCustomCPString,
1581 OUT PULONG BytesInCustomCPString OPTIONAL,
1582 IN PWCH UnicodeString,
1583 IN ULONG BytesInUnicodeString);
1584
1585 NTSYSAPI
1586 NTSTATUS
1587 NTAPI
1588 RtlUpcaseUnicodeToCustomCPN(
1589 IN PCPTABLEINFO CustomCP,
1590 OUT PCH CustomCPString,
1591 IN ULONG MaxBytesInCustomCPString,
1592 OUT PULONG BytesInCustomCPString OPTIONAL,
1593 IN PWCH UnicodeString,
1594 IN ULONG BytesInUnicodeString);
1595
1596 NTSYSAPI
1597 VOID
1598 NTAPI
1599 RtlInitCodePageTable(
1600 IN PUSHORT TableBase,
1601 IN OUT PCPTABLEINFO CodePageTable);
1602
1603 $endif
1604
1605 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1606
1607 $if (_WDMDDK_)
1608
1609 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1610 NTSYSAPI
1611 VOID
1612 FASTCALL
1613 RtlPrefetchMemoryNonTemporal(
1614 IN PVOID Source,
1615 IN SIZE_T Length);
1616 #endif
1617
1618 $endif
1619
1620 #if (NTDDI_VERSION >= NTDDI_WINXP)
1621
1622 $if (_WDMDDK_)
1623
1624 NTSYSAPI
1625 VOID
1626 NTAPI
1627 RtlClearBit(
1628 PRTL_BITMAP BitMapHeader,
1629 ULONG BitNumber);
1630
1631 NTSYSAPI
1632 WCHAR
1633 NTAPI
1634 RtlDowncaseUnicodeChar(
1635 IN WCHAR SourceCharacter);
1636
1637 NTSYSAPI
1638 VOID
1639 NTAPI
1640 RtlSetBit(
1641 PRTL_BITMAP BitMapHeader,
1642 ULONG BitNumber);
1643
1644 NTSYSAPI
1645 BOOLEAN
1646 NTAPI
1647 RtlTestBit(
1648 IN PRTL_BITMAP BitMapHeader,
1649 IN ULONG BitNumber);
1650
1651 NTSYSAPI
1652 NTSTATUS
1653 NTAPI
1654 RtlHashUnicodeString(
1655 IN CONST UNICODE_STRING *String,
1656 IN BOOLEAN CaseInSensitive,
1657 IN ULONG HashAlgorithm,
1658 OUT PULONG HashValue);
1659
1660 $endif (_WDMDDK_)
1661
1662 $if (_NTDDK_)
1663
1664 NTSYSAPI
1665 VOID
1666 NTAPI
1667 RtlInitializeGenericTableAvl(
1668 OUT PRTL_AVL_TABLE Table,
1669 IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
1670 IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
1671 IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
1672 IN PVOID TableContext OPTIONAL);
1673
1674 NTSYSAPI
1675 PVOID
1676 NTAPI
1677 RtlInsertElementGenericTableAvl(
1678 IN PRTL_AVL_TABLE Table,
1679 IN PVOID Buffer,
1680 IN CLONG BufferSize,
1681 OUT PBOOLEAN NewElement OPTIONAL);
1682
1683 NTSYSAPI
1684 PVOID
1685 NTAPI
1686 RtlInsertElementGenericTableFullAvl(
1687 IN PRTL_AVL_TABLE Table,
1688 IN PVOID Buffer,
1689 IN CLONG BufferSize,
1690 OUT PBOOLEAN NewElement OPTIONAL,
1691 IN PVOID NodeOrParent,
1692 IN TABLE_SEARCH_RESULT SearchResult);
1693
1694 NTSYSAPI
1695 BOOLEAN
1696 NTAPI
1697 RtlDeleteElementGenericTableAvl(
1698 IN PRTL_AVL_TABLE Table,
1699 IN PVOID Buffer);
1700
1701 NTSYSAPI
1702 PVOID
1703 NTAPI
1704 RtlLookupElementGenericTableAvl(
1705 IN PRTL_AVL_TABLE Table,
1706 IN PVOID Buffer);
1707
1708 NTSYSAPI
1709 PVOID
1710 NTAPI
1711 RtlLookupElementGenericTableFullAvl(
1712 IN PRTL_AVL_TABLE Table,
1713 IN PVOID Buffer,
1714 OUT PVOID *NodeOrParent,
1715 OUT TABLE_SEARCH_RESULT *SearchResult);
1716
1717 NTSYSAPI
1718 PVOID
1719 NTAPI
1720 RtlEnumerateGenericTableAvl(
1721 IN PRTL_AVL_TABLE Table,
1722 IN BOOLEAN Restart);
1723
1724 NTSYSAPI
1725 PVOID
1726 NTAPI
1727 RtlEnumerateGenericTableWithoutSplayingAvl(
1728 IN PRTL_AVL_TABLE Table,
1729 IN OUT PVOID *RestartKey);
1730
1731 NTSYSAPI
1732 PVOID
1733 NTAPI
1734 RtlLookupFirstMatchingElementGenericTableAvl(
1735 IN PRTL_AVL_TABLE Table,
1736 IN PVOID Buffer,
1737 OUT PVOID *RestartKey);
1738
1739 NTSYSAPI
1740 PVOID
1741 NTAPI
1742 RtlEnumerateGenericTableLikeADirectory(
1743 IN PRTL_AVL_TABLE Table,
1744 IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL,
1745 IN PVOID MatchData OPTIONAL,
1746 IN ULONG NextFlag,
1747 IN OUT PVOID *RestartKey,
1748 IN OUT PULONG DeleteCount,
1749 IN PVOID Buffer);
1750
1751 NTSYSAPI
1752 PVOID
1753 NTAPI
1754 RtlGetElementGenericTableAvl(
1755 IN PRTL_AVL_TABLE Table,
1756 IN ULONG I);
1757
1758 NTSYSAPI
1759 ULONG
1760 NTAPI
1761 RtlNumberGenericTableElementsAvl(
1762 IN PRTL_AVL_TABLE Table);
1763
1764 NTSYSAPI
1765 BOOLEAN
1766 NTAPI
1767 RtlIsGenericTableEmptyAvl(
1768 IN PRTL_AVL_TABLE Table);
1769
1770 $endif (_NTDDK_)
1771 $if (_NTIFS_)
1772
1773 NTSYSAPI
1774 PVOID
1775 NTAPI
1776 RtlCreateHeap(
1777 IN ULONG Flags,
1778 IN PVOID HeapBase OPTIONAL,
1779 IN SIZE_T ReserveSize OPTIONAL,
1780 IN SIZE_T CommitSize OPTIONAL,
1781 IN PVOID Lock OPTIONAL,
1782 IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL);
1783
1784 NTSYSAPI
1785 PVOID
1786 NTAPI
1787 RtlDestroyHeap(
1788 IN PVOID HeapHandle);
1789
1790 NTSYSAPI
1791 USHORT
1792 NTAPI
1793 RtlCaptureStackBackTrace(
1794 IN ULONG FramesToSkip,
1795 IN ULONG FramesToCapture,
1796 OUT PVOID *BackTrace,
1797 OUT PULONG BackTraceHash OPTIONAL);
1798
1799 NTSYSAPI
1800 ULONG
1801 NTAPI
1802 RtlRandomEx(
1803 IN OUT PULONG Seed);
1804
1805 NTSYSAPI
1806 NTSTATUS
1807 NTAPI
1808 RtlInitUnicodeStringEx(
1809 OUT PUNICODE_STRING DestinationString,
1810 IN PCWSTR SourceString OPTIONAL);
1811
1812 NTSYSAPI
1813 NTSTATUS
1814 NTAPI
1815 RtlValidateUnicodeString(
1816 IN ULONG Flags,
1817 IN PCUNICODE_STRING String);
1818
1819 NTSYSAPI
1820 NTSTATUS
1821 NTAPI
1822 RtlDuplicateUnicodeString(
1823 IN ULONG Flags,
1824 IN PCUNICODE_STRING SourceString,
1825 OUT PUNICODE_STRING DestinationString);
1826
1827 NTSYSAPI
1828 NTSTATUS
1829 NTAPI
1830 RtlGetCompressionWorkSpaceSize(
1831 IN USHORT CompressionFormatAndEngine,
1832 OUT PULONG CompressBufferWorkSpaceSize,
1833 OUT PULONG CompressFragmentWorkSpaceSize);
1834
1835 NTSYSAPI
1836 NTSTATUS
1837 NTAPI
1838 RtlCompressBuffer(
1839 IN USHORT CompressionFormatAndEngine,
1840 IN PUCHAR UncompressedBuffer,
1841 IN ULONG UncompressedBufferSize,
1842 OUT PUCHAR CompressedBuffer,
1843 IN ULONG CompressedBufferSize,
1844 IN ULONG UncompressedChunkSize,
1845 OUT PULONG FinalCompressedSize,
1846 IN PVOID WorkSpace);
1847
1848 NTSYSAPI
1849 NTSTATUS
1850 NTAPI
1851 RtlDecompressBuffer(
1852 IN USHORT CompressionFormat,
1853 OUT PUCHAR UncompressedBuffer,
1854 IN ULONG UncompressedBufferSize,
1855 IN PUCHAR CompressedBuffer,
1856 IN ULONG CompressedBufferSize,
1857 OUT PULONG FinalUncompressedSize);
1858
1859 NTSYSAPI
1860 NTSTATUS
1861 NTAPI
1862 RtlDecompressFragment(
1863 IN USHORT CompressionFormat,
1864 OUT PUCHAR UncompressedFragment,
1865 IN ULONG UncompressedFragmentSize,
1866 IN PUCHAR CompressedBuffer,
1867 IN ULONG CompressedBufferSize,
1868 IN ULONG FragmentOffset,
1869 OUT PULONG FinalUncompressedSize,
1870 IN PVOID WorkSpace);
1871
1872 NTSYSAPI
1873 NTSTATUS
1874 NTAPI
1875 RtlDescribeChunk(
1876 IN USHORT CompressionFormat,
1877 IN OUT PUCHAR *CompressedBuffer,
1878 IN PUCHAR EndOfCompressedBufferPlus1,
1879 OUT PUCHAR *ChunkBuffer,
1880 OUT PULONG ChunkSize);
1881
1882 NTSYSAPI
1883 NTSTATUS
1884 NTAPI
1885 RtlReserveChunk(
1886 IN USHORT CompressionFormat,
1887 IN OUT PUCHAR *CompressedBuffer,
1888 IN PUCHAR EndOfCompressedBufferPlus1,
1889 OUT PUCHAR *ChunkBuffer,
1890 IN ULONG ChunkSize);
1891
1892 NTSYSAPI
1893 NTSTATUS
1894 NTAPI
1895 RtlDecompressChunks(
1896 OUT PUCHAR UncompressedBuffer,
1897 IN ULONG UncompressedBufferSize,
1898 IN PUCHAR CompressedBuffer,
1899 IN ULONG CompressedBufferSize,
1900 IN PUCHAR CompressedTail,
1901 IN ULONG CompressedTailSize,
1902 IN PCOMPRESSED_DATA_INFO CompressedDataInfo);
1903
1904 NTSYSAPI
1905 NTSTATUS
1906 NTAPI
1907 RtlCompressChunks(
1908 IN PUCHAR UncompressedBuffer,
1909 IN ULONG UncompressedBufferSize,
1910 OUT PUCHAR CompressedBuffer,
1911 IN ULONG CompressedBufferSize,
1912 IN OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
1913 IN ULONG CompressedDataInfoLength,
1914 IN PVOID WorkSpace);
1915
1916 NTSYSAPI
1917 PSID_IDENTIFIER_AUTHORITY
1918 NTAPI
1919 RtlIdentifierAuthoritySid(
1920 IN PSID Sid);
1921
1922 NTSYSAPI
1923 PUCHAR
1924 NTAPI
1925 RtlSubAuthorityCountSid(
1926 IN PSID Sid);
1927
1928 NTSYSAPI
1929 ULONG
1930 NTAPI
1931 RtlNtStatusToDosErrorNoTeb(
1932 IN NTSTATUS Status);
1933
1934 NTSYSAPI
1935 NTSTATUS
1936 NTAPI
1937 RtlCreateSystemVolumeInformationFolder(
1938 IN PCUNICODE_STRING VolumeRootPath);
1939
1940 #if defined(_M_AMD64)
1941
1942 FORCEINLINE
1943 VOID
1944 RtlFillMemoryUlong (
1945 OUT PVOID Destination,
1946 IN SIZE_T Length,
1947 IN ULONG Pattern)
1948 {
1949 PULONG Address = (PULONG)Destination;
1950 if ((Length /= 4) != 0) {
1951 if (((ULONG64)Address & 4) != 0) {
1952 *Address = Pattern;
1953 if ((Length -= 1) == 0) {
1954 return;
1955 }
1956 Address += 1;
1957 }
1958 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2);
1959 if ((Length & 1) != 0) Address[Length - 1] = Pattern;
1960 }
1961 return;
1962 }
1963
1964 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
1965 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
1966
1967 #else
1968
1969 NTSYSAPI
1970 VOID
1971 NTAPI
1972 RtlFillMemoryUlong(
1973 OUT PVOID Destination,
1974 IN SIZE_T Length,
1975 IN ULONG Pattern);
1976
1977 NTSYSAPI
1978 VOID
1979 NTAPI
1980 RtlFillMemoryUlonglong(
1981 OUT PVOID Destination,
1982 IN SIZE_T Length,
1983 IN ULONGLONG Pattern);
1984
1985 #endif /* defined(_M_AMD64) */
1986 $endif (_NTIFS_)
1987
1988 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
1989
1990 $if (_NTIFS_)
1991 #if (NTDDI_VERSION >= NTDDI_WS03)
1992 NTSYSAPI
1993 NTSTATUS
1994 NTAPI
1995 RtlInitAnsiStringEx(
1996 OUT PANSI_STRING DestinationString,
1997 IN PCSZ SourceString OPTIONAL);
1998 #endif
1999
2000 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2001
2002 NTSYSAPI
2003 NTSTATUS
2004 NTAPI
2005 RtlGetSaclSecurityDescriptor(
2006 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
2007 OUT PBOOLEAN SaclPresent,
2008 OUT PACL *Sacl,
2009 OUT PBOOLEAN SaclDefaulted);
2010
2011 NTSYSAPI
2012 NTSTATUS
2013 NTAPI
2014 RtlSetGroupSecurityDescriptor(
2015 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
2016 IN PSID Group OPTIONAL,
2017 IN BOOLEAN GroupDefaulted OPTIONAL);
2018
2019 NTSYSAPI
2020 NTSTATUS
2021 NTAPI
2022 RtlGetGroupSecurityDescriptor(
2023 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
2024 OUT PSID *Group,
2025 OUT PBOOLEAN GroupDefaulted);
2026
2027 NTSYSAPI
2028 NTSTATUS
2029 NTAPI
2030 RtlAbsoluteToSelfRelativeSD(
2031 IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
2032 OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor OPTIONAL,
2033 IN OUT PULONG BufferLength);
2034
2035 NTSYSAPI
2036 NTSTATUS
2037 NTAPI
2038 RtlSelfRelativeToAbsoluteSD(
2039 IN PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
2040 OUT PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor OPTIONAL,
2041 IN OUT PULONG AbsoluteSecurityDescriptorSize,
2042 OUT PACL Dacl OPTIONAL,
2043 IN OUT PULONG DaclSize,
2044 OUT PACL Sacl OPTIONAL,
2045 IN OUT PULONG SaclSize,
2046 OUT PSID Owner OPTIONAL,
2047 IN OUT PULONG OwnerSize,
2048 OUT PSID PrimaryGroup OPTIONAL,
2049 IN OUT PULONG PrimaryGroupSize);
2050
2051 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2052 $endif (_NTIFS_)
2053
2054 #if (NTDDI_VERSION >= NTDDI_VISTA)
2055
2056 $if (_WDMDDK_)
2057 NTSYSAPI
2058 ULONG
2059 NTAPI
2060 RtlNumberOfSetBitsUlongPtr(
2061 IN ULONG_PTR Target);
2062
2063 NTSYSAPI
2064 ULONGLONG
2065 NTAPI
2066 RtlIoDecodeMemIoResource(
2067 IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
2068 OUT PULONGLONG Alignment OPTIONAL,
2069 OUT PULONGLONG MinimumAddress OPTIONAL,
2070 OUT PULONGLONG MaximumAddress OPTIONAL);
2071
2072 NTSYSAPI
2073 NTSTATUS
2074 NTAPI
2075 RtlIoEncodeMemIoResource(
2076 IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
2077 IN UCHAR Type,
2078 IN ULONGLONG Length,
2079 IN ULONGLONG Alignment,
2080 IN ULONGLONG MinimumAddress,
2081 IN ULONGLONG MaximumAddress);
2082
2083 NTSYSAPI
2084 ULONGLONG
2085 NTAPI
2086 RtlCmDecodeMemIoResource(
2087 IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
2088 OUT PULONGLONG Start OPTIONAL);
2089
2090 NTSYSAPI
2091 NTSTATUS
2092 NTAPI
2093 RtlFindClosestEncodableLength(
2094 IN ULONGLONG SourceLength,
2095 OUT PULONGLONG TargetLength);
2096
2097 NTSYSAPI
2098 NTSTATUS
2099 NTAPI
2100 RtlCmEncodeMemIoResource(
2101 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
2102 IN UCHAR Type,
2103 IN ULONGLONG Length,
2104 IN ULONGLONG Start);
2105
2106 $endif (_WDMDDK_)
2107 $if (_NTDDK_)
2108
2109 NTSYSAPI
2110 VOID
2111 NTAPI
2112 RtlRunOnceInitialize(
2113 OUT PRTL_RUN_ONCE RunOnce);
2114
2115 NTSYSAPI
2116 NTSTATUS
2117 NTAPI
2118 RtlRunOnceExecuteOnce(
2119 IN OUT PRTL_RUN_ONCE RunOnce,
2120 IN PRTL_RUN_ONCE_INIT_FN InitFn,
2121 IN OUT PVOID Parameter OPTIONAL,
2122 OUT PVOID *Context OPTIONAL);
2123
2124 NTSYSAPI
2125 NTSTATUS
2126 NTAPI
2127 RtlRunOnceBeginInitialize(
2128 IN OUT PRTL_RUN_ONCE RunOnce,
2129 IN ULONG Flags,
2130 OUT PVOID *Context OPTIONAL);
2131
2132 NTSYSAPI
2133 NTSTATUS
2134 NTAPI
2135 RtlRunOnceComplete(
2136 IN OUT PRTL_RUN_ONCE RunOnce,
2137 IN ULONG Flags,
2138 IN PVOID Context OPTIONAL);
2139
2140 NTSYSAPI
2141 BOOLEAN
2142 NTAPI
2143 RtlGetProductInfo(
2144 IN ULONG OSMajorVersion,
2145 IN ULONG OSMinorVersion,
2146 IN ULONG SpMajorVersion,
2147 IN ULONG SpMinorVersion,
2148 OUT PULONG ReturnedProductType);
2149
2150 $endif (_NTDDK_)
2151 $if (_NTIFS_)
2152 NTSYSAPI
2153 NTSTATUS
2154 NTAPI
2155 RtlNormalizeString(
2156 IN ULONG NormForm,
2157 IN PCWSTR SourceString,
2158 IN LONG SourceStringLength,
2159 OUT PWSTR DestinationString,
2160 IN OUT PLONG DestinationStringLength);
2161
2162 NTSYSAPI
2163 NTSTATUS
2164 NTAPI
2165 RtlIsNormalizedString(
2166 IN ULONG NormForm,
2167 IN PCWSTR SourceString,
2168 IN LONG SourceStringLength,
2169 OUT PBOOLEAN Normalized);
2170
2171 NTSYSAPI
2172 NTSTATUS
2173 NTAPI
2174 RtlIdnToAscii(
2175 IN ULONG Flags,
2176 IN PCWSTR SourceString,
2177 IN LONG SourceStringLength,
2178 OUT PWSTR DestinationString,
2179 IN OUT PLONG DestinationStringLength);
2180
2181 NTSYSAPI
2182 NTSTATUS
2183 NTAPI
2184 RtlIdnToUnicode(
2185 IN ULONG Flags,
2186 IN PCWSTR SourceString,
2187 IN LONG SourceStringLength,
2188 OUT PWSTR DestinationString,
2189 IN OUT PLONG DestinationStringLength);
2190
2191 NTSYSAPI
2192 NTSTATUS
2193 NTAPI
2194 RtlIdnToNameprepUnicode(
2195 IN ULONG Flags,
2196 IN PCWSTR SourceString,
2197 IN LONG SourceStringLength,
2198 OUT PWSTR DestinationString,
2199 IN OUT PLONG DestinationStringLength);
2200
2201 NTSYSAPI
2202 NTSTATUS
2203 NTAPI
2204 RtlCreateServiceSid(
2205 IN PUNICODE_STRING ServiceName,
2206 OUT PSID ServiceSid,
2207 IN OUT PULONG ServiceSidLength);
2208
2209 NTSYSAPI
2210 LONG
2211 NTAPI
2212 RtlCompareAltitudes(
2213 IN PCUNICODE_STRING Altitude1,
2214 IN PCUNICODE_STRING Altitude2);
2215
2216 $endif (_NTIFS_)
2217
2218 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2219
2220 #if (NTDDI_VERSION >= NTDDI_WIN7)
2221
2222 $if (_WDMDDK_)
2223 NTSYSAPI
2224 NTSTATUS
2225 NTAPI
2226 RtlUnicodeToUTF8N(
2227 OUT PCHAR UTF8StringDestination,
2228 IN ULONG UTF8StringMaxByteCount,
2229 OUT PULONG UTF8StringActualByteCount,
2230 IN PCWCH UnicodeStringSource,
2231 IN ULONG UnicodeStringByteCount);
2232
2233 NTSYSAPI
2234 NTSTATUS
2235 NTAPI
2236 RtlUTF8ToUnicodeN(
2237 OUT PWSTR UnicodeStringDestination,
2238 IN ULONG UnicodeStringMaxByteCount,
2239 OUT PULONG UnicodeStringActualByteCount,
2240 IN PCCH UTF8StringSource,
2241 IN ULONG UTF8StringByteCount);
2242
2243 NTSYSAPI
2244 ULONG64
2245 NTAPI
2246 RtlGetEnabledExtendedFeatures(
2247 IN ULONG64 FeatureMask);
2248
2249 $endif (_WDMDDK_)
2250 $if (_NTDDK_)
2251
2252 NTSYSAPI
2253 BOOLEAN
2254 NTAPI
2255 RtlCreateHashTable(
2256 IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL,
2257 IN ULONG Shift,
2258 IN ULONG Flags);
2259
2260 NTSYSAPI
2261 VOID
2262 NTAPI
2263 RtlDeleteHashTable(
2264 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
2265
2266 NTSYSAPI
2267 BOOLEAN
2268 NTAPI
2269 RtlInsertEntryHashTable(
2270 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2271 IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry,
2272 IN ULONG_PTR Signature,
2273 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
2274
2275 NTSYSAPI
2276 BOOLEAN
2277 NTAPI
2278 RtlRemoveEntryHashTable(
2279 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2280 IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry,
2281 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
2282
2283 NTSYSAPI
2284 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2285 NTAPI
2286 RtlLookupEntryHashTable(
2287 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2288 IN ULONG_PTR Signature,
2289 OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL);
2290
2291 NTSYSAPI
2292 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2293 NTAPI
2294 RtlGetNextEntryHashTable(
2295 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2296 IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context);
2297
2298 NTSYSAPI
2299 BOOLEAN
2300 NTAPI
2301 RtlInitEnumerationHashTable(
2302 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2303 OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2304
2305 NTSYSAPI
2306 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2307 NTAPI
2308 RtlEnumerateEntryHashTable(
2309 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2310 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2311
2312 NTSYSAPI
2313 VOID
2314 NTAPI
2315 RtlEndEnumerationHashTable(
2316 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2317 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2318
2319 NTSYSAPI
2320 BOOLEAN
2321 NTAPI
2322 RtlInitWeakEnumerationHashTable(
2323 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2324 OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2325
2326 NTSYSAPI
2327 PRTL_DYNAMIC_HASH_TABLE_ENTRY
2328 NTAPI
2329 RtlWeaklyEnumerateEntryHashTable(
2330 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2331 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2332
2333 NTSYSAPI
2334 VOID
2335 NTAPI
2336 RtlEndWeakEnumerationHashTable(
2337 IN PRTL_DYNAMIC_HASH_TABLE HashTable,
2338 IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator);
2339
2340 NTSYSAPI
2341 BOOLEAN
2342 NTAPI
2343 RtlExpandHashTable(
2344 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
2345
2346 NTSYSAPI
2347 BOOLEAN
2348 NTAPI
2349 RtlContractHashTable(
2350 IN PRTL_DYNAMIC_HASH_TABLE HashTable);
2351
2352 $endif (_NTDDK_)
2353 $if (_NTIFS_)
2354 NTSYSAPI
2355 NTSTATUS
2356 NTAPI
2357 RtlUnicodeToUTF8N(
2358 OUT PCHAR UTF8StringDestination,
2359 IN ULONG UTF8StringMaxByteCount,
2360 OUT PULONG UTF8StringActualByteCount,
2361 IN PCWCH UnicodeStringSource,
2362 IN ULONG UnicodeStringByteCount);
2363
2364 NTSYSAPI
2365 NTSTATUS
2366 NTAPI
2367 RtlUTF8ToUnicodeN(
2368 OUT PWSTR UnicodeStringDestination,
2369 IN ULONG UnicodeStringMaxByteCount,
2370 OUT PULONG UnicodeStringActualByteCount,
2371 IN PCCH UTF8StringSource,
2372 IN ULONG UTF8StringByteCount);
2373
2374 NTSYSAPI
2375 NTSTATUS
2376 NTAPI
2377 RtlReplaceSidInSd(
2378 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
2379 IN PSID OldSid,
2380 IN PSID NewSid,
2381 OUT ULONG *NumChanges);
2382
2383 NTSYSAPI
2384 NTSTATUS
2385 NTAPI
2386 RtlCreateVirtualAccountSid(
2387 IN PCUNICODE_STRING Name,
2388 IN ULONG BaseSubAuthority,
2389 OUT PSID Sid,
2390 IN OUT PULONG SidLength);
2391 $endif (_NTIFS_)
2392
2393 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2394
2395 $if (_WDMDDK_)
2396
2397 #if !defined(MIDL_PASS)
2398 /* inline funftions */
2399 //DECLSPEC_DEPRECATED_DDK_WINXP
2400 static __inline
2401 LARGE_INTEGER
2402 NTAPI_INLINE
2403 RtlConvertLongToLargeInteger(
2404 IN LONG SignedInteger)
2405 {
2406 LARGE_INTEGER ret;
2407 ret.QuadPart = SignedInteger;
2408 return ret;
2409 }
2410
2411 //DECLSPEC_DEPRECATED_DDK_WINXP
2412 static __inline
2413 LARGE_INTEGER
2414 NTAPI_INLINE
2415 RtlConvertUlongToLargeInteger(
2416 IN ULONG UnsignedInteger)
2417 {
2418 LARGE_INTEGER ret;
2419 ret.QuadPart = UnsignedInteger;
2420 return ret;
2421 }
2422
2423 //DECLSPEC_DEPRECATED_DDK_WINXP
2424 static __inline
2425 LARGE_INTEGER
2426 NTAPI_INLINE
2427 RtlLargeIntegerShiftLeft(
2428 IN LARGE_INTEGER LargeInteger,
2429 IN CCHAR ShiftCount)
2430 {
2431 LARGE_INTEGER Result;
2432
2433 Result.QuadPart = LargeInteger.QuadPart << ShiftCount;
2434 return Result;
2435 }
2436
2437 //DECLSPEC_DEPRECATED_DDK_WINXP
2438 static __inline
2439 LARGE_INTEGER
2440 NTAPI_INLINE
2441 RtlLargeIntegerShiftRight(
2442 IN LARGE_INTEGER LargeInteger,
2443 IN CCHAR ShiftCount)
2444 {
2445 LARGE_INTEGER Result;
2446
2447 Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount;
2448 return Result;
2449 }
2450
2451 //DECLSPEC_DEPRECATED_DDK
2452 static __inline
2453 ULONG
2454 NTAPI_INLINE
2455 RtlEnlargedUnsignedDivide(
2456 IN ULARGE_INTEGER Dividend,
2457 IN ULONG Divisor,
2458 IN OUT PULONG Remainder)
2459 {
2460 if (Remainder)
2461 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
2462 return (ULONG)(Dividend.QuadPart / Divisor);
2463 }
2464
2465 //DECLSPEC_DEPRECATED_DDK
2466 static __inline
2467 LARGE_INTEGER
2468 NTAPI_INLINE
2469 RtlLargeIntegerNegate(
2470 IN LARGE_INTEGER Subtrahend)
2471 {
2472 LARGE_INTEGER Difference;
2473
2474 Difference.QuadPart = -Subtrahend.QuadPart;
2475 return Difference;
2476 }
2477
2478 //DECLSPEC_DEPRECATED_DDK
2479 static __inline
2480 LARGE_INTEGER
2481 NTAPI_INLINE
2482 RtlLargeIntegerSubtract(
2483 IN LARGE_INTEGER Minuend,
2484 IN LARGE_INTEGER Subtrahend)
2485 {
2486 LARGE_INTEGER Difference;
2487
2488 Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
2489 return Difference;
2490 }
2491
2492 //DECLSPEC_DEPRECATED_DDK
2493 static __inline
2494 LARGE_INTEGER
2495 NTAPI_INLINE
2496 RtlEnlargedUnsignedMultiply(
2497 IN ULONG Multiplicand,
2498 IN ULONG Multiplier)
2499 {
2500 LARGE_INTEGER ret;
2501 ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2502 return ret;
2503 }
2504
2505 //DECLSPEC_DEPRECATED_DDK
2506 static __inline
2507 LARGE_INTEGER
2508 NTAPI_INLINE
2509 RtlEnlargedIntegerMultiply(
2510 IN LONG Multiplicand,
2511 IN LONG Multiplier)
2512 {
2513 LARGE_INTEGER ret;
2514 ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2515 return ret;
2516 }
2517
2518 FORCEINLINE
2519 VOID
2520 RtlInitEmptyAnsiString(
2521 OUT PANSI_STRING AnsiString,
2522 IN PCHAR Buffer,
2523 IN USHORT BufferSize)
2524 {
2525 AnsiString->Length = 0;
2526 AnsiString->MaximumLength = BufferSize;
2527 AnsiString->Buffer = Buffer;
2528 }
2529
2530 FORCEINLINE
2531 VOID
2532 RtlInitEmptyUnicodeString(
2533 OUT PUNICODE_STRING UnicodeString,
2534 IN PWSTR Buffer,
2535 IN USHORT BufferSize)
2536 {
2537 UnicodeString->Length = 0;
2538 UnicodeString->MaximumLength = BufferSize;
2539 UnicodeString->Buffer = Buffer;
2540 }
2541 $endif (_WDMDDK_)
2542
2543 #if defined(_AMD64_) || defined(_IA64_)
2544
2545 $if (_WDMDDK_)
2546
2547 static __inline
2548 LARGE_INTEGER
2549 NTAPI_INLINE
2550 RtlExtendedIntegerMultiply(
2551 IN LARGE_INTEGER Multiplicand,
2552 IN LONG Multiplier)
2553 {
2554 LARGE_INTEGER ret;
2555 ret.QuadPart = Multiplicand.QuadPart * Multiplier;
2556 return ret;
2557 }
2558
2559 static __inline
2560 LARGE_INTEGER
2561 NTAPI_INLINE
2562 RtlExtendedLargeIntegerDivide(
2563 IN LARGE_INTEGER Dividend,
2564 IN ULONG Divisor,
2565 OUT PULONG Remainder OPTIONAL)
2566 {
2567 LARGE_INTEGER ret;
2568 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
2569 if (Remainder)
2570 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
2571 return ret;
2572 }
2573
2574 $endif (_WDMDDK_)
2575
2576 $if (_NTDDK_)
2577
2578 //DECLSPEC_DEPRECATED_DDK_WINXP
2579 FORCEINLINE
2580 LARGE_INTEGER
2581 NTAPI_INLINE
2582 RtlLargeIntegerDivide(
2583 IN LARGE_INTEGER Dividend,
2584 IN LARGE_INTEGER Divisor,
2585 OUT PLARGE_INTEGER Remainder OPTIONAL)
2586 {
2587 LARGE_INTEGER ret;
2588 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
2589 if (Remainder)
2590 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
2591 return ret;
2592 }
2593
2594 #else
2595
2596 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2597 NTSYSAPI
2598 LARGE_INTEGER
2599 NTAPI
2600 RtlLargeIntegerDivide(
2601 IN LARGE_INTEGER Dividend,
2602 IN LARGE_INTEGER Divisor,
2603 OUT PLARGE_INTEGER Remainder OPTIONAL);
2604 #endif
2605
2606 $endif (_NTDDK_)
2607
2608 #endif /* defined(_AMD64_) || defined(_IA64_) */
2609
2610 $if (_WDMDDK_)
2611
2612 #if defined(_AMD64_)
2613
2614 #define MultiplyHigh __mulh
2615 #define UnsignedMultiplyHigh __umulh
2616
2617 //DECLSPEC_DEPRECATED_DDK
2618 static __inline
2619 LARGE_INTEGER
2620 NTAPI_INLINE
2621 RtlExtendedMagicDivide(
2622 IN LARGE_INTEGER Dividend,
2623 IN LARGE_INTEGER MagicDivisor,
2624 IN CCHAR ShiftCount)
2625 {
2626 LARGE_INTEGER ret;
2627 ULONG64 ret64;
2628 BOOLEAN Pos;
2629 Pos = (Dividend.QuadPart >= 0);
2630 ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart,
2631 MagicDivisor.QuadPart);
2632 ret64 >>= ShiftCount;
2633 ret.QuadPart = Pos ? ret64 : -ret64;
2634 return ret;
2635 }
2636 #endif
2637
2638 //DECLSPEC_DEPRECATED_DDK
2639 static __inline
2640 LARGE_INTEGER
2641 NTAPI_INLINE
2642 RtlLargeIntegerAdd(
2643 IN LARGE_INTEGER Addend1,
2644 IN LARGE_INTEGER Addend2)
2645 {
2646 LARGE_INTEGER ret;
2647 ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
2648 return ret;
2649 }
2650
2651 /* VOID
2652 * RtlLargeIntegerAnd(
2653 * IN OUT LARGE_INTEGER Result,
2654 * IN LARGE_INTEGER Source,
2655 * IN LARGE_INTEGER Mask);
2656 */
2657 #define RtlLargeIntegerAnd(Result, Source, Mask) \
2658 Result.QuadPart = Source.QuadPart & Mask.QuadPart
2659
2660 //DECLSPEC_DEPRECATED_DDK
2661 static __inline
2662 LARGE_INTEGER
2663 NTAPI_INLINE
2664 RtlLargeIntegerArithmeticShift(
2665 IN LARGE_INTEGER LargeInteger,
2666 IN CCHAR ShiftCount)
2667 {
2668 LARGE_INTEGER ret;
2669 ret.QuadPart = LargeInteger.QuadPart >> ShiftCount;
2670 return ret;
2671 }
2672
2673 /* BOOLEAN
2674 * RtlLargeIntegerEqualTo(
2675 * IN LARGE_INTEGER Operand1,
2676 * IN LARGE_INTEGER Operand2);
2677 */
2678 #define RtlLargeIntegerEqualTo(X,Y) \
2679 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
2680
2681 FORCEINLINE
2682 PVOID
2683 RtlSecureZeroMemory(
2684 OUT PVOID Pointer,
2685 IN SIZE_T Size)
2686 {
2687 volatile char* vptr = (volatile char*)Pointer;
2688 #if defined(_M_AMD64)
2689 __stosb((PUCHAR)vptr, 0, Size);
2690 #else
2691 char * endptr = (char *)vptr + Size;
2692 while (vptr < endptr) {
2693 *vptr = 0; vptr++;
2694 }
2695 #endif
2696 return Pointer;
2697 }
2698
2699 #if defined(_M_AMD64)
2700 FORCEINLINE
2701 BOOLEAN
2702 RtlCheckBit(
2703 IN PRTL_BITMAP BitMapHeader,
2704 IN ULONG BitPosition)
2705 {
2706 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
2707 }
2708 #else
2709 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
2710 #endif /* defined(_M_AMD64) */
2711
2712 #define RtlLargeIntegerGreaterThan(X,Y) ( \
2713 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
2714 ((X).HighPart > (Y).HighPart) \
2715 )
2716
2717 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
2718 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
2719 ((X).HighPart > (Y).HighPart) \
2720 )
2721
2722 #define RtlLargeIntegerNotEqualTo(X,Y) ( \
2723 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
2724 )
2725
2726 #define RtlLargeIntegerLessThan(X,Y) ( \
2727 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
2728 ((X).HighPart < (Y).HighPart) \
2729 )
2730
2731 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
2732 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
2733 ((X).HighPart < (Y).HighPart) \
2734 )
2735
2736 #define RtlLargeIntegerGreaterThanZero(X) ( \
2737 (((X).HighPart == 0) && ((X).LowPart > 0)) || \
2738 ((X).HighPart > 0 ) \
2739 )
2740
2741 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
2742
2743 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
2744
2745 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
2746
2747 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
2748
2749 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
2750
2751 #endif /* !defined(MIDL_PASS) */
2752
2753 /* Byte Swap Functions */
2754 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
2755 ((defined(_M_AMD64) || defined(_M_IA64)) \
2756 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
2757
2758 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
2759 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
2760 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
2761
2762 #endif
2763
2764 #if DBG
2765
2766 #define ASSERT(exp) \
2767 (VOID)((!(exp)) ? \
2768 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
2769
2770 #define ASSERTMSG(msg, exp) \
2771 (VOID)((!(exp)) ? \
2772 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
2773
2774 #define RTL_SOFT_ASSERT(exp) \
2775 (VOID)((!(exp)) ? \
2776 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
2777
2778 #define RTL_SOFT_ASSERTMSG(msg, exp) \
2779 (VOID)((!(exp)) ? \
2780 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
2781
2782 #define RTL_VERIFY(exp) ASSERT(exp)
2783 #define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
2784
2785 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
2786 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
2787
2788 #if defined(_MSC_VER)
2789
2790 #define NT_ASSERT(exp) \
2791 ((!(exp)) ? \
2792 (__annotation(L"Debug", L"AssertFail", L#exp), \
2793 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2794
2795 #define NT_ASSERTMSG(msg, exp) \
2796 ((!(exp)) ? \
2797 (__annotation(L"Debug", L"AssertFail", L##msg), \
2798 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2799
2800 #define NT_ASSERTMSGW(msg, exp) \
2801 ((!(exp)) ? \
2802 (__annotation(L"Debug", L"AssertFail", msg), \
2803 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2804
2805 #define NT_VERIFY NT_ASSERT
2806 #define NT_VERIFYMSG NT_ASSERTMSG
2807 #define NT_VERIFYMSGW NT_ASSERTMSGW
2808
2809 #else
2810
2811 /* GCC doesn't support __annotation (nor PDB) */
2812 #define NT_ASSERT(exp) \
2813 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
2814
2815 #define NT_ASSERTMSG NT_ASSERT
2816 #define NT_ASSERTMSGW NT_ASSERT
2817
2818 #endif
2819
2820 #else /* !DBG */
2821
2822 #define ASSERT(exp) ((VOID) 0)
2823 #define ASSERTMSG(msg, exp) ((VOID) 0)
2824
2825 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
2826 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
2827
2828 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
2829 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2830
2831 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
2832 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2833
2834 #define NT_ASSERT(exp) ((VOID)0)
2835 #define NT_ASSERTMSG(msg, exp) ((VOID)0)
2836 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
2837
2838 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
2839 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
2840 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
2841
2842 #endif /* DBG */
2843
2844 #define InitializeListHead32(ListHead) (\
2845 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
2846
2847 #if !defined(_WINBASE_)
2848
2849 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
2850
2851 NTKERNELAPI
2852 VOID
2853 InitializeSListHead(
2854 OUT PSLIST_HEADER SListHead);
2855
2856 #else
2857
2858 FORCEINLINE
2859 VOID
2860 InitializeSListHead(
2861 OUT PSLIST_HEADER SListHead)
2862 {
2863 #if defined(_IA64_)
2864 ULONG64 FeatureBits;
2865 #endif
2866
2867 #if defined(_WIN64)
2868 if (((ULONG_PTR)SListHead & 0xf) != 0) {
2869 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
2870 }
2871 #endif
2872 RtlZeroMemory(SListHead, sizeof(SLIST_HEADER));
2873 #if defined(_IA64_)
2874 FeatureBits = __getReg(CV_IA64_CPUID4);
2875 if ((FeatureBits & KF_16BYTE_INSTR) != 0) {
2876 SListHead->Header16.HeaderType = 1;
2877 SListHead->Header16.Init = 1;
2878 }
2879 #endif
2880 }
2881
2882 #endif
2883
2884 #if defined(_WIN64)
2885
2886 #define InterlockedPopEntrySList(Head) \
2887 ExpInterlockedPopEntrySList(Head)
2888
2889 #define InterlockedPushEntrySList(Head, Entry) \
2890 ExpInterlockedPushEntrySList(Head, Entry)
2891
2892 #define InterlockedFlushSList(Head) \
2893 ExpInterlockedFlushSList(Head)
2894
2895 #define QueryDepthSList(Head) \
2896 ExQueryDepthSList(Head)
2897
2898 #else /* !defined(_WIN64) */
2899
2900 NTKERNELAPI
2901 PSLIST_ENTRY
2902 FASTCALL
2903 InterlockedPopEntrySList(
2904 IN PSLIST_HEADER ListHead);
2905
2906 NTKERNELAPI
2907 PSLIST_ENTRY
2908 FASTCALL
2909 InterlockedPushEntrySList(
2910 IN PSLIST_HEADER ListHead,
2911 IN PSLIST_ENTRY ListEntry);
2912
2913 #define InterlockedFlushSList(ListHead) \
2914 ExInterlockedFlushSList(ListHead)
2915
2916 #define QueryDepthSList(Head) \
2917 ExQueryDepthSList(Head)
2918
2919 #endif /* !defined(_WIN64) */
2920
2921 #endif /* !defined(_WINBASE_) */
2922
2923 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
2924 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
2925 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \
2926 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
2927 #define RTL_CONTEXT_OFFSET(Context, Chunk) \
2928 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
2929 #define RTL_CONTEXT_LENGTH(Context, Chunk) \
2930 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
2931 #define RTL_CONTEXT_CHUNK(Context, Chunk) \
2932 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \
2933 (PCONTEXT_EX)(Context + 1), \
2934 Chunk)
2935
2936 BOOLEAN
2937 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)(
2938 IN ULONG Version);
2939
2940 BOOLEAN
2941 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)(
2942 IN ULONG Version);
2943
2944 #ifndef RtlIsNtDdiVersionAvailable
2945 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
2946 #endif
2947
2948 #ifndef RtlIsServicePackVersionInstalled
2949 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
2950 #endif
2951
2952 #define RtlInterlockedSetBits(Flags, Flag) \
2953 InterlockedOr((PLONG)(Flags), Flag)
2954
2955 #define RtlInterlockedAndBits(Flags, Flag) \
2956 InterlockedAnd((PLONG)(Flags), Flag)
2957
2958 #define RtlInterlockedClearBits(Flags, Flag) \
2959 RtlInterlockedAndBits(Flags, ~(Flag))
2960
2961 #define RtlInterlockedXorBits(Flags, Flag) \
2962 InterlockedXor(Flags, Flag)
2963
2964 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
2965 (VOID) RtlInterlockedSetBits(Flags, Flag)
2966
2967 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
2968 (VOID) RtlInterlockedAndBits(Flags, Flag)
2969
2970 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
2971 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
2972
2973 $endif (_WDMDDK_)
2974
2975 $if (_NTDDK_)
2976
2977 #ifdef RTL_USE_AVL_TABLES
2978
2979 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
2980 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
2981 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
2982 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
2983 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
2984 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
2985 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
2986 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
2987 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
2988 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
2989 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
2990
2991 #endif /* RTL_USE_AVL_TABLES */
2992
2993 #define RtlInitializeSplayLinks(Links) { \
2994 PRTL_SPLAY_LINKS _SplayLinks; \
2995 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
2996 _SplayLinks->Parent = _SplayLinks; \
2997 _SplayLinks->LeftChild = NULL; \
2998 _SplayLinks->RightChild = NULL; \
2999 }
3000
3001 #define RtlIsLeftChild(Links) \
3002 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3003
3004 #define RtlIsRightChild(Links) \
3005 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
3006
3007 #define RtlRightChild(Links) \
3008 ((PRTL_SPLAY_LINKS)(Links))->RightChild
3009
3010 #define RtlIsRoot(Links) \
3011 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
3012
3013 #define RtlLeftChild(Links) \
3014 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
3015
3016 #define RtlParent(Links) \
3017 ((PRTL_SPLAY_LINKS)(Links))->Parent
3018
3019 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
3020 { \
3021 PRTL_SPLAY_LINKS _SplayParent; \
3022 PRTL_SPLAY_LINKS _SplayChild; \
3023 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3024 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3025 _SplayParent->LeftChild = _SplayChild; \
3026 _SplayChild->Parent = _SplayParent; \
3027 }
3028
3029 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
3030 { \
3031 PRTL_SPLAY_LINKS _SplayParent; \
3032 PRTL_SPLAY_LINKS _SplayChild; \
3033 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
3034 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
3035 _SplayParent->RightChild = _SplayChild; \
3036 _SplayChild->Parent = _SplayParent; \
3037 }
3038
3039 #if !defined(MIDL_PASS)
3040
3041 FORCEINLINE
3042 LUID
3043 NTAPI_INLINE
3044 RtlConvertLongToLuid(
3045 IN LONG Val)
3046 {
3047 LUID Luid;
3048 LARGE_INTEGER Temp;
3049
3050 Temp.QuadPart = Val;
3051 Luid.LowPart = Temp.u.LowPart;
3052 Luid.HighPart = Temp.u.HighPart;
3053 return Luid;
3054 }
3055
3056 FORCEINLINE
3057 LUID
3058 NTAPI_INLINE
3059 RtlConvertUlongToLuid(
3060 IN ULONG Val)
3061 {
3062 LUID Luid;
3063
3064 Luid.LowPart = Val;
3065 Luid.HighPart = 0;
3066 return Luid;
3067 }
3068
3069 #endif /* !defined(MIDL_PASS) */
3070
3071 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3072 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3073 *CallersAddress = (PVOID)_ReturnAddress(); \
3074 *CallersCaller = NULL;
3075 #else
3076 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3077 NTSYSAPI
3078 VOID
3079 NTAPI
3080 RtlGetCallersAddress(
3081 OUT PVOID *CallersAddress,
3082 OUT PVOID *CallersCaller);
3083 #endif
3084 #endif
3085
3086 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
3087
3088 #if (NTDDI_VERSION >= NTDDI_WIN7)
3089
3090 FORCEINLINE
3091 VOID
3092 NTAPI
3093 RtlInitHashTableContext(
3094 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
3095 {
3096 Context->ChainHead = NULL;
3097 Context->PrevLinkage = NULL;
3098 }
3099
3100 FORCEINLINE
3101 VOID
3102 NTAPI
3103 RtlInitHashTableContextFromEnumerator(
3104 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context,
3105 IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator)
3106 {
3107 Context->ChainHead = Enumerator->ChainHead;
3108 Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink;
3109 }
3110
3111 FORCEINLINE
3112 VOID
3113 NTAPI
3114 RtlReleaseHashTableContext(
3115 IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context)
3116 {
3117 UNREFERENCED_PARAMETER(Context);
3118 return;
3119 }
3120
3121 FORCEINLINE
3122 ULONG
3123 NTAPI
3124 RtlTotalBucketsHashTable(
3125 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
3126 {
3127 return HashTable->TableSize;
3128 }
3129
3130 FORCEINLINE
3131 ULONG
3132 NTAPI
3133 RtlNonEmptyBucketsHashTable(
3134 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
3135 {
3136 return HashTable->NonEmptyBuckets;
3137 }
3138
3139 FORCEINLINE
3140 ULONG
3141 NTAPI
3142 RtlEmptyBucketsHashTable(
3143 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
3144 {
3145 return HashTable->TableSize - HashTable->NonEmptyBuckets;
3146 }
3147
3148 FORCEINLINE
3149 ULONG
3150 NTAPI
3151 RtlTotalEntriesHashTable(
3152 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
3153 {
3154 return HashTable->NumEntries;
3155 }
3156
3157 FORCEINLINE
3158 ULONG
3159 NTAPI
3160 RtlActiveEnumeratorsHashTable(
3161 IN PRTL_DYNAMIC_HASH_TABLE HashTable)
3162 {
3163 return HashTable->NumEnumerators;
3164 }
3165
3166 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3167
3168 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
3169
3170 $endif (_NTDDK_)
3171 $if (_NTIFS_)
3172
3173 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
3174 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
3175
3176 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \
3177 RtlxUnicodeStringToOemSize(STRING) : \
3178 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
3179 )
3180
3181 #define RtlOemStringToUnicodeSize(STRING) ( \
3182 NLS_MB_OEM_CODE_PAGE_TAG ? \
3183 RtlxOemStringToUnicodeSize(STRING) : \
3184 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
3185 )
3186
3187 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
3188 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
3189 )
3190
3191 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O))))
3192 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B))))
3193 $endif (_NTIFS_)