cd188184899dbdd1353a0b0c06440d0bb7edf729
[reactos.git] / reactos / sdk / include / ndk / rtlfuncs.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 rtlfuncs.h
8
9 Abstract:
10
11 Function definitions for the Run-Time Library
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _RTLFUNCS_H
20 #define _RTLFUNCS_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <ntnls.h>
27 #include <rtltypes.h>
28 #include <pstypes.h>
29 #include <extypes.h>
30 #include "in6addr.h"
31 #include "inaddr.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifdef NTOS_MODE_USER
38
39 //
40 // List Functions
41 //
42 FORCEINLINE
43 VOID
44 InitializeListHead(
45 _Out_ PLIST_ENTRY ListHead
46 )
47 {
48 ListHead->Flink = ListHead->Blink = ListHead;
49 }
50
51 FORCEINLINE
52 VOID
53 InsertHeadList(
54 _Inout_ PLIST_ENTRY ListHead,
55 _Inout_ PLIST_ENTRY Entry
56 )
57 {
58 PLIST_ENTRY OldFlink;
59 OldFlink = ListHead->Flink;
60 Entry->Flink = OldFlink;
61 Entry->Blink = ListHead;
62 OldFlink->Blink = Entry;
63 ListHead->Flink = Entry;
64 }
65
66 FORCEINLINE
67 VOID
68 InsertTailList(
69 _Inout_ PLIST_ENTRY ListHead,
70 _Inout_ PLIST_ENTRY Entry
71 )
72 {
73 PLIST_ENTRY OldBlink;
74 OldBlink = ListHead->Blink;
75 Entry->Flink = ListHead;
76 Entry->Blink = OldBlink;
77 OldBlink->Flink = Entry;
78 ListHead->Blink = Entry;
79 }
80
81 _Must_inspect_result_
82 FORCEINLINE
83 BOOLEAN
84 IsListEmpty(
85 _In_ const LIST_ENTRY * ListHead
86 )
87 {
88 return (BOOLEAN)(ListHead->Flink == ListHead);
89 }
90
91 FORCEINLINE
92 PSINGLE_LIST_ENTRY
93 PopEntryList(
94 _Inout_ PSINGLE_LIST_ENTRY ListHead
95 )
96 {
97 PSINGLE_LIST_ENTRY FirstEntry;
98 FirstEntry = ListHead->Next;
99 if (FirstEntry != NULL) {
100 ListHead->Next = FirstEntry->Next;
101 }
102
103 return FirstEntry;
104 }
105
106 FORCEINLINE
107 VOID
108 PushEntryList(
109 _Inout_ PSINGLE_LIST_ENTRY ListHead,
110 _Inout_ PSINGLE_LIST_ENTRY Entry
111 )
112 {
113 Entry->Next = ListHead->Next;
114 ListHead->Next = Entry;
115 }
116
117 FORCEINLINE
118 BOOLEAN
119 RemoveEntryList(
120 _In_ PLIST_ENTRY Entry)
121 {
122 PLIST_ENTRY OldFlink;
123 PLIST_ENTRY OldBlink;
124
125 OldFlink = Entry->Flink;
126 OldBlink = Entry->Blink;
127 OldFlink->Blink = OldBlink;
128 OldBlink->Flink = OldFlink;
129 return (BOOLEAN)(OldFlink == OldBlink);
130 }
131
132 FORCEINLINE
133 PLIST_ENTRY
134 RemoveHeadList(
135 _Inout_ PLIST_ENTRY ListHead)
136 {
137 PLIST_ENTRY Flink;
138 PLIST_ENTRY Entry;
139
140 Entry = ListHead->Flink;
141 Flink = Entry->Flink;
142 ListHead->Flink = Flink;
143 Flink->Blink = ListHead;
144 return Entry;
145 }
146
147 FORCEINLINE
148 PLIST_ENTRY
149 RemoveTailList(
150 _Inout_ PLIST_ENTRY ListHead)
151 {
152 PLIST_ENTRY Blink;
153 PLIST_ENTRY Entry;
154
155 Entry = ListHead->Blink;
156 Blink = Entry->Blink;
157 ListHead->Blink = Blink;
158 Blink->Flink = ListHead;
159 return Entry;
160 }
161
162 //
163 // Unicode string macros
164 //
165 _At_(UnicodeString->Buffer, _Post_equal_to_(Buffer))
166 _At_(UnicodeString->Length, _Post_equal_to_(0))
167 _At_(UnicodeString->MaximumLength, _Post_equal_to_(BufferSize))
168 FORCEINLINE
169 VOID
170 RtlInitEmptyUnicodeString(
171 _Out_ PUNICODE_STRING UnicodeString,
172 _When_(BufferSize != 0, _Notnull_) _Writable_bytes_(BufferSize) __drv_aliasesMem PWCHAR Buffer,
173 _In_ USHORT BufferSize)
174 {
175 UnicodeString->Length = 0;
176 UnicodeString->MaximumLength = BufferSize;
177 UnicodeString->Buffer = Buffer;
178 }
179
180 _At_(AnsiString->Buffer, _Post_equal_to_(Buffer))
181 _At_(AnsiString->Length, _Post_equal_to_(0))
182 _At_(AnsiString->MaximumLength, _Post_equal_to_(BufferSize))
183 FORCEINLINE
184 VOID
185 RtlInitEmptyAnsiString(
186 _Out_ PANSI_STRING AnsiString,
187 _When_(BufferSize != 0, _Notnull_) _Writable_bytes_(BufferSize) __drv_aliasesMem PCHAR Buffer,
188 _In_ USHORT BufferSize)
189 {
190 AnsiString->Length = 0;
191 AnsiString->MaximumLength = BufferSize;
192 AnsiString->Buffer = Buffer;
193 }
194
195 //
196 // LUID Macros
197 //
198 #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
199 ((L1)->LowPart == (L2)->LowPart))
200 FORCEINLINE
201 LUID
202 NTAPI_INLINE
203 RtlConvertUlongToLuid(
204 _In_ ULONG Ulong)
205 {
206 LUID TempLuid;
207
208 TempLuid.LowPart = Ulong;
209 TempLuid.HighPart = 0;
210 return TempLuid;
211 }
212
213 //
214 // ASSERT Macros
215 //
216 #ifndef ASSERT
217 #if DBG
218
219 #define ASSERT( exp ) \
220 ((void)((!(exp)) ? \
221 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \
222 TRUE))
223
224 #define ASSERTMSG( msg, exp ) \
225 ((void)((!(exp)) ? \
226 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \
227 TRUE))
228
229 #else
230
231 #define ASSERT( exp ) ((void) 0)
232 #define ASSERTMSG( msg, exp ) ((void) 0)
233
234 #endif
235 #endif
236
237 #ifdef NTOS_KERNEL_RUNTIME
238
239 //
240 // Executing RTL functions at DISPATCH_LEVEL or higher will result in a
241 // bugcheck.
242 //
243 #define RTL_PAGED_CODE PAGED_CODE
244
245 #else
246
247 //
248 // This macro does nothing in user mode
249 //
250 #define RTL_PAGED_CODE NOP_FUNCTION
251
252 #endif
253
254 //
255 // RTL Splay Tree Functions
256 //
257 #ifndef RTL_USE_AVL_TABLES
258
259 NTSYSAPI
260 VOID
261 NTAPI
262 RtlInitializeGenericTable(
263 _Out_ PRTL_GENERIC_TABLE Table,
264 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine,
265 _In_opt_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine,
266 _In_opt_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine,
267 _In_opt_ PVOID TableContext
268 );
269
270 NTSYSAPI
271 PVOID
272 NTAPI
273 RtlInsertElementGenericTable(
274 _In_ PRTL_GENERIC_TABLE Table,
275 _In_reads_bytes_(BufferSize) PVOID Buffer,
276 _In_ CLONG BufferSize,
277 _Out_opt_ PBOOLEAN NewElement
278 );
279
280 NTSYSAPI
281 PVOID
282 NTAPI
283 RtlInsertElementGenericTableFull(
284 _In_ PRTL_GENERIC_TABLE Table,
285 _In_reads_bytes_(BufferSize) PVOID Buffer,
286 _In_ CLONG BufferSize,
287 _Out_opt_ PBOOLEAN NewElement,
288 _In_ PVOID NodeOrParent,
289 _In_ TABLE_SEARCH_RESULT SearchResult
290 );
291
292 NTSYSAPI
293 BOOLEAN
294 NTAPI
295 RtlDeleteElementGenericTable(
296 _In_ PRTL_GENERIC_TABLE Table,
297 _In_ PVOID Buffer
298 );
299
300 _Must_inspect_result_
301 NTSYSAPI
302 PVOID
303 NTAPI
304 RtlLookupElementGenericTable(
305 _In_ PRTL_GENERIC_TABLE Table,
306 _In_ PVOID Buffer
307 );
308
309 NTSYSAPI
310 PVOID
311 NTAPI
312 RtlLookupElementGenericTableFull(
313 _In_ PRTL_GENERIC_TABLE Table,
314 _In_ PVOID Buffer,
315 _Out_ PVOID *NodeOrParent,
316 _Out_ TABLE_SEARCH_RESULT *SearchResult
317 );
318
319 _Must_inspect_result_
320 NTSYSAPI
321 PVOID
322 NTAPI
323 RtlEnumerateGenericTable(
324 _In_ PRTL_GENERIC_TABLE Table,
325 _In_ BOOLEAN Restart
326 );
327
328 _Must_inspect_result_
329 NTSYSAPI
330 PVOID
331 NTAPI
332 RtlEnumerateGenericTableWithoutSplaying(
333 _In_ PRTL_GENERIC_TABLE Table,
334 _Inout_ PVOID *RestartKey
335 );
336
337 _Must_inspect_result_
338 NTSYSAPI
339 PVOID
340 NTAPI
341 RtlGetElementGenericTable(
342 _In_ PRTL_GENERIC_TABLE Table,
343 _In_ ULONG I
344 );
345
346 NTSYSAPI
347 ULONG
348 NTAPI
349 RtlNumberGenericTableElements(
350 _In_ PRTL_GENERIC_TABLE Table
351 );
352
353 _Must_inspect_result_
354 NTSYSAPI
355 BOOLEAN
356 NTAPI
357 RtlIsGenericTableEmpty(
358 _In_ PRTL_GENERIC_TABLE Table
359 );
360
361 #endif /* !RTL_USE_AVL_TABLES */
362
363 NTSYSAPI
364 PRTL_SPLAY_LINKS
365 NTAPI
366 RtlSplay(
367 _Inout_ PRTL_SPLAY_LINKS Links
368 );
369
370 NTSYSAPI
371 PRTL_SPLAY_LINKS
372 NTAPI
373 RtlDelete(
374 _In_ PRTL_SPLAY_LINKS Links
375 );
376
377 NTSYSAPI
378 VOID
379 NTAPI
380 RtlDeleteNoSplay(
381 _In_ PRTL_SPLAY_LINKS Links,
382 _Inout_ PRTL_SPLAY_LINKS *Root
383 );
384
385 _Must_inspect_result_
386 NTSYSAPI
387 PRTL_SPLAY_LINKS
388 NTAPI
389 RtlSubtreeSuccessor(
390 _In_ PRTL_SPLAY_LINKS Links
391 );
392
393 _Must_inspect_result_
394 NTSYSAPI
395 PRTL_SPLAY_LINKS
396 NTAPI
397 RtlSubtreePredecessor(
398 _In_ PRTL_SPLAY_LINKS Links
399 );
400
401 _Must_inspect_result_
402 NTSYSAPI
403 PRTL_SPLAY_LINKS
404 NTAPI
405 RtlRealSuccessor(
406 _In_ PRTL_SPLAY_LINKS Links
407 );
408
409 _Must_inspect_result_
410 NTSYSAPI
411 PRTL_SPLAY_LINKS
412 NTAPI
413 RtlRealPredecessor(
414 _In_ PRTL_SPLAY_LINKS Links
415 );
416
417 #define RtlIsLeftChild(Links) \
418 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
419
420 #define RtlIsRightChild(Links) \
421 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
422
423 #define RtlRightChild(Links) \
424 ((PRTL_SPLAY_LINKS)(Links))->RightChild
425
426 #define RtlIsRoot(Links) \
427 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
428
429 #define RtlLeftChild(Links) \
430 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
431
432 #define RtlParent(Links) \
433 ((PRTL_SPLAY_LINKS)(Links))->Parent
434
435 // FIXME: use inline function
436
437 #define RtlInitializeSplayLinks(Links) \
438 { \
439 PRTL_SPLAY_LINKS _SplayLinks; \
440 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
441 _SplayLinks->Parent = _SplayLinks; \
442 _SplayLinks->LeftChild = NULL; \
443 _SplayLinks->RightChild = NULL; \
444 }
445
446 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
447 { \
448 PRTL_SPLAY_LINKS _SplayParent; \
449 PRTL_SPLAY_LINKS _SplayChild; \
450 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
451 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
452 _SplayParent->LeftChild = _SplayChild; \
453 _SplayChild->Parent = _SplayParent; \
454 }
455
456 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
457 { \
458 PRTL_SPLAY_LINKS _SplayParent; \
459 PRTL_SPLAY_LINKS _SplayChild; \
460 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
461 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
462 _SplayParent->RightChild = _SplayChild; \
463 _SplayChild->Parent = _SplayParent; \
464 }
465
466 //
467 // RTL AVL Tree Functions
468 //
469 NTSYSAPI
470 VOID
471 NTAPI
472 RtlInitializeGenericTableAvl(
473 _Out_ PRTL_AVL_TABLE Table,
474 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
475 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
476 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine,
477 _In_opt_ PVOID TableContext
478 );
479
480 NTSYSAPI
481 PVOID
482 NTAPI
483 RtlInsertElementGenericTableAvl(
484 _In_ PRTL_AVL_TABLE Table,
485 _In_reads_bytes_(BufferSize) PVOID Buffer,
486 _In_ CLONG BufferSize,
487 _Out_opt_ PBOOLEAN NewElement
488 );
489
490 NTSYSAPI
491 PVOID
492 NTAPI
493 RtlInsertElementGenericTableFullAvl(
494 _In_ PRTL_AVL_TABLE Table,
495 _In_reads_bytes_(BufferSize) PVOID Buffer,
496 _In_ CLONG BufferSize,
497 _Out_opt_ PBOOLEAN NewElement,
498 _In_ PVOID NodeOrParent,
499 _In_ TABLE_SEARCH_RESULT SearchResult
500 );
501
502 NTSYSAPI
503 BOOLEAN
504 NTAPI
505 RtlDeleteElementGenericTableAvl(
506 _In_ PRTL_AVL_TABLE Table,
507 _In_ PVOID Buffer
508 );
509
510 _Must_inspect_result_
511 NTSYSAPI
512 PVOID
513 NTAPI
514 RtlLookupElementGenericTableAvl(
515 _In_ PRTL_AVL_TABLE Table,
516 _In_ PVOID Buffer
517 );
518
519 NTSYSAPI
520 PVOID
521 NTAPI
522 RtlLookupElementGenericTableFullAvl(
523 _In_ PRTL_AVL_TABLE Table,
524 _In_ PVOID Buffer,
525 _Out_ PVOID *NodeOrParent,
526 _Out_ TABLE_SEARCH_RESULT *SearchResult
527 );
528
529 _Must_inspect_result_
530 NTSYSAPI
531 PVOID
532 NTAPI
533 RtlEnumerateGenericTableAvl(
534 _In_ PRTL_AVL_TABLE Table,
535 _In_ BOOLEAN Restart
536 );
537
538 _Must_inspect_result_
539 NTSYSAPI
540 PVOID
541 NTAPI
542 RtlEnumerateGenericTableWithoutSplayingAvl(
543 _In_ PRTL_AVL_TABLE Table,
544 _Inout_ PVOID *RestartKey
545 );
546
547 _Must_inspect_result_
548 NTSYSAPI
549 PVOID
550 NTAPI
551 RtlLookupFirstMatchingElementGenericTableAvl(
552 _In_ PRTL_AVL_TABLE Table,
553 _In_ PVOID Buffer,
554 _Out_ PVOID *RestartKey
555 );
556
557 _Must_inspect_result_
558 NTSYSAPI
559 PVOID
560 NTAPI
561 RtlEnumerateGenericTableLikeADirectory(
562 _In_ PRTL_AVL_TABLE Table,
563 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction,
564 _In_opt_ PVOID MatchData,
565 _In_ ULONG NextFlag,
566 _Inout_ PVOID *RestartKey,
567 _Inout_ PULONG DeleteCount,
568 _In_ PVOID Buffer
569 );
570
571 _Must_inspect_result_
572 NTSYSAPI
573 PVOID
574 NTAPI
575 RtlGetElementGenericTableAvl(
576 _In_ PRTL_AVL_TABLE Table,
577 _In_ ULONG I
578 );
579
580 NTSYSAPI
581 ULONG
582 NTAPI
583 RtlNumberGenericTableElementsAvl(
584 _In_ PRTL_AVL_TABLE Table
585 );
586
587 _Must_inspect_result_
588 NTSYSAPI
589 BOOLEAN
590 NTAPI
591 RtlIsGenericTableEmptyAvl(
592 _In_ PRTL_AVL_TABLE Table
593 );
594
595 #ifdef RTL_USE_AVL_TABLES
596
597 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl
598 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
599 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
600 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
601 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
602 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
603 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
604 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
605 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl
606 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
607 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
608
609 #endif /* RTL_USE_AVL_TABLES */
610
611 //
612 // Exception and Error Functions
613 //
614 NTSYSAPI
615 PVOID
616 NTAPI
617 RtlAddVectoredExceptionHandler(
618 _In_ ULONG FirstHandler,
619 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
620 );
621
622 __analysis_noreturn
623 NTSYSAPI
624 VOID
625 NTAPI
626 RtlAssert(
627 _In_ PVOID FailedAssertion,
628 _In_ PVOID FileName,
629 _In_ ULONG LineNumber,
630 _In_opt_z_ PCHAR Message
631 );
632
633 NTSYSAPI
634 VOID
635 NTAPI
636 RtlSetUnhandledExceptionFilter(
637 _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter
638 );
639
640 NTSYSAPI
641 LONG
642 NTAPI
643 RtlUnhandledExceptionFilter(
644 _In_ struct _EXCEPTION_POINTERS* ExceptionInfo
645 );
646
647 NTSYSAPI
648 PVOID
649 NTAPI
650 RtlEncodePointer(
651 _In_ PVOID Pointer
652 );
653
654 NTSYSAPI
655 PVOID
656 NTAPI
657 RtlDecodePointer(
658 _In_ PVOID Pointer
659 );
660
661 NTSYSAPI
662 PVOID
663 NTAPI
664 RtlEncodeSystemPointer(
665 _In_ PVOID Pointer
666 );
667
668 NTSYSAPI
669 PVOID
670 NTAPI
671 RtlDecodeSystemPointer(
672 _In_ PVOID Pointer
673 );
674
675 NTSYSAPI
676 NTSTATUS
677 NTAPI
678 RtlGetLastNtStatus(
679 VOID
680 );
681
682 NTSYSAPI
683 ULONG
684 NTAPI
685 RtlGetLastWin32Error(
686 VOID
687 );
688
689 NTSYSAPI
690 VOID
691 NTAPI
692 RtlSetLastWin32Error(
693 _In_ ULONG LastError
694 );
695
696 NTSYSAPI
697 VOID
698 NTAPI
699 RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
700 _In_ NTSTATUS Status
701 );
702
703 NTSYSAPI
704 NTSTATUS
705 NTAPI
706 RtlSetThreadErrorMode(
707 _In_ ULONG NewMode,
708 _Out_opt_ PULONG OldMode
709 );
710
711 NTSYSAPI
712 ULONG
713 NTAPI
714 RtlGetThreadErrorMode(
715 VOID
716 );
717
718 #endif /* NTOS_MODE_USER */
719
720 NTSYSAPI
721 VOID
722 NTAPI
723 RtlCaptureContext(
724 _Out_ PCONTEXT ContextRecord
725 );
726
727 NTSYSAPI
728 BOOLEAN
729 NTAPI
730 RtlDispatchException(
731 _In_ PEXCEPTION_RECORD ExceptionRecord,
732 _In_ PCONTEXT Context
733 );
734
735 _IRQL_requires_max_(APC_LEVEL)
736 _When_(Status < 0, _Out_range_(>, 0))
737 _When_(Status >= 0, _Out_range_(==, 0))
738 NTSYSAPI
739 ULONG
740 NTAPI
741 RtlNtStatusToDosError(
742 _In_ NTSTATUS Status
743 );
744
745 _When_(Status < 0, _Out_range_(>, 0))
746 _When_(Status >= 0, _Out_range_(==, 0))
747 NTSYSAPI
748 ULONG
749 NTAPI
750 RtlNtStatusToDosErrorNoTeb(
751 _In_ NTSTATUS Status
752 );
753
754 NTSYSAPI
755 NTSTATUS
756 NTAPI
757 RtlMapSecurityErrorToNtStatus(
758 _In_ ULONG SecurityError
759 );
760
761 NTSYSAPI
762 VOID
763 NTAPI
764 RtlRaiseException(
765 _In_ PEXCEPTION_RECORD ExceptionRecord
766 );
767
768 DECLSPEC_NORETURN
769 NTSYSAPI
770 VOID
771 NTAPI
772 RtlRaiseStatus(
773 _In_ NTSTATUS Status
774 );
775
776 NTSYSAPI
777 VOID
778 NTAPI
779 RtlUnwind(
780 _In_opt_ PVOID TargetFrame,
781 _In_opt_ PVOID TargetIp,
782 _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
783 _In_ PVOID ReturnValue
784 );
785
786 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
787
788 //
789 // Tracing Functions
790 //
791 NTSYSAPI
792 ULONG
793 NTAPI
794 RtlWalkFrameChain(
795 _Out_writes_(Count - (Flags >> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT)) PVOID *Callers,
796 _In_ ULONG Count,
797 _In_ ULONG Flags
798 );
799
800 NTSYSAPI
801 USHORT
802 NTAPI
803 RtlLogStackBackTrace(
804 VOID
805 );
806
807 #ifdef NTOS_MODE_USER
808 //
809 // Heap Functions
810 //
811 _Must_inspect_result_
812 _Ret_maybenull_
813 _Post_writable_byte_size_(Size)
814 NTSYSAPI
815 PVOID
816 NTAPI
817 RtlAllocateHeap(
818 _In_ PVOID HeapHandle,
819 _In_opt_ ULONG Flags,
820 _In_ SIZE_T Size
821 );
822
823 _Must_inspect_result_
824 NTSYSAPI
825 PVOID
826 NTAPI
827 RtlCreateHeap(
828 _In_ ULONG Flags,
829 _In_opt_ PVOID BaseAddress,
830 _In_opt_ SIZE_T SizeToReserve,
831 _In_opt_ SIZE_T SizeToCommit,
832 _In_opt_ PVOID Lock,
833 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
834 );
835
836 NTSYSAPI
837 ULONG
838 NTAPI
839 RtlCreateTagHeap(
840 _In_ HANDLE HeapHandle,
841 _In_ ULONG Flags,
842 _In_ PWSTR TagName,
843 _In_ PWSTR TagSubName
844 );
845
846 ULONG
847 NTAPI
848 RtlCompactHeap(
849 _In_ HANDLE Heap,
850 _In_ ULONG Flags
851 );
852
853 _Must_inspect_result_
854 NTSYSAPI
855 PVOID
856 NTAPI
857 RtlDebugCreateHeap(
858 _In_ ULONG Flags,
859 _In_opt_ PVOID BaseAddress,
860 _In_opt_ SIZE_T SizeToReserve,
861 _In_opt_ SIZE_T SizeToCommit,
862 _In_opt_ PVOID Lock,
863 _In_opt_ PRTL_HEAP_PARAMETERS Parameters
864 );
865
866 NTSYSAPI
867 HANDLE
868 NTAPI
869 RtlDestroyHeap(
870 _In_ _Post_invalid_ HANDLE Heap
871 );
872
873 NTSYSAPI
874 ULONG
875 NTAPI
876 RtlExtendHeap(
877 _In_ HANDLE Heap,
878 _In_ ULONG Flags,
879 _In_ PVOID P,
880 _In_ SIZE_T Size
881 );
882
883 _Success_(return != 0)
884 NTSYSAPI
885 BOOLEAN
886 NTAPI
887 RtlFreeHeap(
888 _In_ HANDLE HeapHandle,
889 _In_opt_ ULONG Flags,
890 _In_ _Post_invalid_ PVOID P
891 );
892
893 ULONG
894 NTAPI
895 RtlGetProcessHeaps(
896 _In_ ULONG HeapCount,
897 _Out_cap_(HeapCount) HANDLE *HeapArray
898 );
899
900 _Success_(return != 0)
901 BOOLEAN
902 NTAPI
903 RtlGetUserInfoHeap(
904 _In_ PVOID HeapHandle,
905 _In_ ULONG Flags,
906 _In_ PVOID BaseAddress,
907 _Inout_opt_ PVOID *UserValue,
908 _Out_opt_ PULONG UserFlags
909 );
910
911 NTSYSAPI
912 PVOID
913 NTAPI
914 RtlProtectHeap(
915 _In_ PVOID HeapHandle,
916 _In_ BOOLEAN Protect
917 );
918
919 NTSYSAPI
920 NTSTATUS
921 NTAPI
922 RtlQueryHeapInformation(
923 _In_ PVOID HeapHandle,
924 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
925 _Out_ PVOID HeapInformation,
926 _In_ SIZE_T HeapInformationLength,
927 _When_(HeapInformationClass==HeapCompatibilityInformation, _On_failure_(_Out_opt_))
928 _Out_opt_ PSIZE_T ReturnLength
929 );
930
931 _Ret_opt_z_
932 NTSYSAPI
933 PWSTR
934 NTAPI
935 RtlQueryTagHeap(
936 _In_ PVOID HeapHandle,
937 _In_ ULONG Flags,
938 _In_ USHORT TagIndex,
939 _In_ BOOLEAN ResetCounters,
940 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
941 );
942
943 _Must_inspect_result_
944 _Ret_maybenull_
945 _Post_writable_byte_size_(Size)
946 NTSYSAPI
947 PVOID
948 NTAPI
949 RtlReAllocateHeap(
950 _In_ HANDLE Heap,
951 _In_opt_ ULONG Flags,
952 _In_ _Post_invalid_ PVOID Ptr,
953 _In_ SIZE_T Size
954 );
955
956 NTSYSAPI
957 NTSTATUS
958 NTAPI
959 RtlSetHeapInformation(
960 _In_ PVOID HeapHandle,
961 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
962 _When_(HeapInformationClass==HeapCompatibilityInformation,_In_) PVOID HeapInformation,
963 _In_ SIZE_T HeapInformationLength
964 );
965
966 NTSYSAPI
967 BOOLEAN
968 NTAPI
969 RtlLockHeap(
970 _In_ HANDLE Heap
971 );
972
973 _Must_inspect_result_
974 NTSYSAPI
975 NTSTATUS
976 NTAPI
977 RtlMultipleAllocateHeap (
978 _In_ HANDLE HeapHandle,
979 _In_ ULONG Flags,
980 _In_ SIZE_T Size,
981 _In_ ULONG Count,
982 _Out_cap_(Count) _Deref_post_bytecap_(Size) PVOID * Array
983 );
984
985 NTSYSAPI
986 NTSTATUS
987 NTAPI
988 RtlMultipleFreeHeap (
989 _In_ HANDLE HeapHandle,
990 _In_ ULONG Flags,
991 _In_ ULONG Count,
992 _In_count_(Count) /* _Deref_ _Post_invalid_ */ PVOID * Array
993 );
994
995 NTSYSAPI
996 NTSTATUS
997 NTAPI
998 RtlUsageHeap(
999 _In_ HANDLE Heap,
1000 _In_ ULONG Flags,
1001 _Out_ PRTL_HEAP_USAGE Usage
1002 );
1003
1004 NTSYSAPI
1005 BOOLEAN
1006 NTAPI
1007 RtlUnlockHeap(
1008 _In_ HANDLE Heap
1009 );
1010
1011 BOOLEAN
1012 NTAPI
1013 RtlSetUserValueHeap(
1014 _In_ PVOID HeapHandle,
1015 _In_ ULONG Flags,
1016 _In_ PVOID BaseAddress,
1017 _In_ PVOID UserValue
1018 );
1019
1020 BOOLEAN
1021 NTAPI
1022 RtlSetUserFlagsHeap(
1023 _In_ PVOID HeapHandle,
1024 _In_ ULONG Flags,
1025 _In_ PVOID BaseAddress,
1026 _In_ ULONG UserFlagsReset,
1027 _In_ ULONG UserFlagsSet
1028 );
1029
1030 NTSYSAPI
1031 BOOLEAN
1032 NTAPI
1033 RtlValidateHeap(
1034 _In_ HANDLE Heap,
1035 _In_ ULONG Flags,
1036 _In_opt_ PVOID P
1037 );
1038
1039 NTSYSAPI
1040 NTSTATUS
1041 NTAPI
1042 RtlWalkHeap(
1043 _In_ HANDLE HeapHandle,
1044 _In_ PVOID HeapEntry
1045 );
1046
1047 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1048
1049 #endif // NTOS_MODE_USER
1050
1051 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1052
1053 NTSYSAPI
1054 SIZE_T
1055 NTAPI
1056 RtlSizeHeap(
1057 _In_ PVOID HeapHandle,
1058 _In_ ULONG Flags,
1059 _In_ PVOID MemoryPointer
1060 );
1061
1062
1063 //
1064 // Security Functions
1065 //
1066 _IRQL_requires_max_(APC_LEVEL)
1067 NTSYSAPI
1068 NTSTATUS
1069 NTAPI
1070 RtlAbsoluteToSelfRelativeSD(
1071 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1072 _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1073 _Inout_ PULONG BufferLength
1074 );
1075
1076 _IRQL_requires_max_(APC_LEVEL)
1077 NTSYSAPI
1078 NTSTATUS
1079 NTAPI
1080 RtlAddAccessAllowedAce(
1081 _Inout_ PACL Acl,
1082 _In_ ULONG Revision,
1083 _In_ ACCESS_MASK AccessMask,
1084 _In_ PSID Sid
1085 );
1086
1087 _IRQL_requires_max_(APC_LEVEL)
1088 NTSYSAPI
1089 NTSTATUS
1090 NTAPI
1091 RtlAddAccessAllowedAceEx(
1092 _Inout_ PACL pAcl,
1093 _In_ ULONG dwAceRevision,
1094 _In_ ULONG AceFlags,
1095 _In_ ACCESS_MASK AccessMask,
1096 _In_ PSID pSid
1097 );
1098
1099 NTSYSAPI
1100 NTSTATUS
1101 NTAPI
1102 RtlAddAccessAllowedObjectAce(
1103 _Inout_ PACL pAcl,
1104 _In_ ULONG dwAceRevision,
1105 _In_ ULONG AceFlags,
1106 _In_ ACCESS_MASK AccessMask,
1107 _In_opt_ GUID *ObjectTypeGuid,
1108 _In_opt_ GUID *InheritedObjectTypeGuid,
1109 _In_ PSID pSid
1110 );
1111
1112 NTSYSAPI
1113 NTSTATUS
1114 NTAPI
1115 RtlAddAccessDeniedAce(
1116 _Inout_ PACL Acl,
1117 _In_ ULONG Revision,
1118 _In_ ACCESS_MASK AccessMask,
1119 _In_ PSID Sid
1120 );
1121
1122 NTSYSAPI
1123 NTSTATUS
1124 NTAPI
1125 RtlAddAccessDeniedAceEx(
1126 _Inout_ PACL Acl,
1127 _In_ ULONG Revision,
1128 _In_ ULONG Flags,
1129 _In_ ACCESS_MASK AccessMask,
1130 _In_ PSID Sid
1131 );
1132
1133 NTSYSAPI
1134 NTSTATUS
1135 NTAPI
1136 RtlAddAccessDeniedObjectAce(
1137 _Inout_ PACL pAcl,
1138 _In_ ULONG dwAceRevision,
1139 _In_ ULONG AceFlags,
1140 _In_ ACCESS_MASK AccessMask,
1141 _In_opt_ GUID *ObjectTypeGuid,
1142 _In_opt_ GUID *InheritedObjectTypeGuid,
1143 _In_ PSID pSid
1144 );
1145
1146 NTSYSAPI
1147 NTSTATUS
1148 NTAPI
1149 RtlAddAce(
1150 _Inout_ PACL Acl,
1151 _In_ ULONG AceRevision,
1152 _In_ ULONG StartingAceIndex,
1153 _In_reads_bytes_(AceListLength) PVOID AceList,
1154 _In_ ULONG AceListLength
1155 );
1156
1157 NTSYSAPI
1158 NTSTATUS
1159 NTAPI
1160 RtlAddAuditAccessAce(
1161 _Inout_ PACL Acl,
1162 _In_ ULONG Revision,
1163 _In_ ACCESS_MASK AccessMask,
1164 _In_ PSID Sid,
1165 _In_ BOOLEAN Success,
1166 _In_ BOOLEAN Failure
1167 );
1168
1169 NTSYSAPI
1170 NTSTATUS
1171 NTAPI
1172 RtlAcquirePrivilege(
1173 _In_ PULONG Privilege,
1174 _In_ ULONG NumPriv,
1175 _In_ ULONG Flags,
1176 _Out_ PVOID *ReturnedState
1177 );
1178
1179 NTSYSAPI
1180 NTSTATUS
1181 NTAPI
1182 RtlAddAuditAccessAceEx(
1183 _Inout_ PACL Acl,
1184 _In_ ULONG Revision,
1185 _In_ ULONG Flags,
1186 _In_ ACCESS_MASK AccessMask,
1187 _In_ PSID Sid,
1188 _In_ BOOLEAN Success,
1189 _In_ BOOLEAN Failure
1190 );
1191
1192 NTSYSAPI
1193 NTSTATUS
1194 NTAPI
1195 RtlAddAuditAccessObjectAce(
1196 _Inout_ PACL Acl,
1197 _In_ ULONG Revision,
1198 _In_ ULONG Flags,
1199 _In_ ACCESS_MASK AccessMask,
1200 _In_opt_ GUID *ObjectTypeGuid,
1201 _In_opt_ GUID *InheritedObjectTypeGuid,
1202 _In_ PSID Sid,
1203 _In_ BOOLEAN Success,
1204 _In_ BOOLEAN Failure
1205 );
1206
1207 NTSYSAPI
1208 NTSTATUS
1209 NTAPI
1210 RtlAddMandatoryAce(
1211 _Inout_ PACL Acl,
1212 _In_ ULONG Revision,
1213 _In_ ULONG Flags,
1214 _In_ ULONG MandatoryFlags,
1215 _In_ UCHAR AceType,
1216 _In_ PSID LabelSid);
1217
1218 NTSYSAPI
1219 NTSTATUS
1220 NTAPI
1221 RtlAdjustPrivilege(
1222 _In_ ULONG Privilege,
1223 _In_ BOOLEAN NewValue,
1224 _In_ BOOLEAN ForThread,
1225 _Out_ PBOOLEAN OldValue
1226 );
1227
1228 _Must_inspect_result_
1229 NTSYSAPI
1230 NTSTATUS
1231 NTAPI
1232 RtlAllocateAndInitializeSid(
1233 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1234 _In_ UCHAR SubAuthorityCount,
1235 _In_ ULONG SubAuthority0,
1236 _In_ ULONG SubAuthority1,
1237 _In_ ULONG SubAuthority2,
1238 _In_ ULONG SubAuthority3,
1239 _In_ ULONG SubAuthority4,
1240 _In_ ULONG SubAuthority5,
1241 _In_ ULONG SubAuthority6,
1242 _In_ ULONG SubAuthority7,
1243 _Outptr_ PSID *Sid
1244 );
1245
1246 NTSYSAPI
1247 BOOLEAN
1248 NTAPI
1249 RtlAreAllAccessesGranted(
1250 ACCESS_MASK GrantedAccess,
1251 ACCESS_MASK DesiredAccess
1252 );
1253
1254 NTSYSAPI
1255 BOOLEAN
1256 NTAPI
1257 RtlAreAnyAccessesGranted(
1258 ACCESS_MASK GrantedAccess,
1259 ACCESS_MASK DesiredAccess
1260 );
1261
1262 _IRQL_requires_max_(APC_LEVEL)
1263 NTSYSAPI
1264 VOID
1265 NTAPI
1266 RtlCopyLuid (
1267 _Out_ PLUID DestinationLuid,
1268 _In_ PLUID SourceLuid
1269 );
1270
1271 NTSYSAPI
1272 VOID
1273 NTAPI
1274 RtlCopyLuidAndAttributesArray(
1275 ULONG Count,
1276 PLUID_AND_ATTRIBUTES Src,
1277 PLUID_AND_ATTRIBUTES Dest
1278 );
1279
1280 NTSYSAPI
1281 NTSTATUS
1282 NTAPI
1283 RtlCopySidAndAttributesArray(
1284 _In_ ULONG Count,
1285 _In_ PSID_AND_ATTRIBUTES Src,
1286 _In_ ULONG SidAreaSize,
1287 _In_ PSID_AND_ATTRIBUTES Dest,
1288 _In_ PSID SidArea,
1289 _Out_ PSID* RemainingSidArea,
1290 _Out_ PULONG RemainingSidAreaSize
1291 );
1292
1293 _IRQL_requires_max_(APC_LEVEL)
1294 NTSYSAPI
1295 NTSTATUS
1296 NTAPI
1297 RtlConvertSidToUnicodeString(
1298 _Inout_ PUNICODE_STRING UnicodeString,
1299 _In_ PSID Sid,
1300 _In_ BOOLEAN AllocateDestinationString
1301 );
1302
1303 _IRQL_requires_max_(APC_LEVEL)
1304 NTSYSAPI
1305 NTSTATUS
1306 NTAPI
1307 RtlCopySid(
1308 _In_ ULONG DestinationSidLength,
1309 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1310 _In_ PSID SourceSid
1311 );
1312
1313 NTSYSAPI
1314 NTSTATUS
1315 NTAPI
1316 RtlCreateAcl(
1317 PACL Acl,
1318 ULONG AclSize,
1319 ULONG AclRevision
1320 );
1321
1322 NTSYSAPI
1323 NTSTATUS
1324 NTAPI
1325 RtlCreateSecurityDescriptor(
1326 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1327 _In_ ULONG Revision
1328 );
1329
1330 NTSYSAPI
1331 NTSTATUS
1332 NTAPI
1333 RtlCreateSecurityDescriptorRelative(
1334 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
1335 _In_ ULONG Revision
1336 );
1337
1338 NTSYSAPI
1339 NTSTATUS
1340 NTAPI
1341 RtlCopySecurityDescriptor(
1342 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
1343 _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor
1344 );
1345
1346 NTSYSAPI
1347 NTSTATUS
1348 NTAPI
1349 RtlDeleteAce(
1350 PACL Acl,
1351 ULONG AceIndex
1352 );
1353
1354 NTSYSAPI
1355 BOOLEAN
1356 NTAPI
1357 RtlEqualPrefixSid(
1358 PSID Sid1,
1359 PSID Sid2
1360 );
1361
1362 NTSYSAPI
1363 BOOLEAN
1364 NTAPI
1365 RtlEqualSid (
1366 _In_ PSID Sid1,
1367 _In_ PSID Sid2
1368 );
1369
1370 NTSYSAPI
1371 BOOLEAN
1372 NTAPI
1373 RtlFirstFreeAce(
1374 PACL Acl,
1375 PACE* Ace
1376 );
1377
1378 NTSYSAPI
1379 PVOID
1380 NTAPI
1381 RtlFreeSid(
1382 _In_ _Post_invalid_ PSID Sid
1383 );
1384
1385 NTSYSAPI
1386 NTSTATUS
1387 NTAPI
1388 RtlGetAce(
1389 PACL Acl,
1390 ULONG AceIndex,
1391 PVOID *Ace
1392 );
1393
1394 NTSYSAPI
1395 NTSTATUS
1396 NTAPI
1397 RtlGetControlSecurityDescriptor(
1398 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1399 _Out_ PSECURITY_DESCRIPTOR_CONTROL Control,
1400 _Out_ PULONG Revision
1401 );
1402
1403 NTSYSAPI
1404 NTSTATUS
1405 NTAPI
1406 RtlGetDaclSecurityDescriptor(
1407 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1408 _Out_ PBOOLEAN DaclPresent,
1409 _Out_ PACL *Dacl,
1410 _Out_ PBOOLEAN DaclDefaulted
1411 );
1412
1413 NTSYSAPI
1414 NTSTATUS
1415 NTAPI
1416 RtlGetSaclSecurityDescriptor(
1417 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1418 _Out_ PBOOLEAN SaclPresent,
1419 _Out_ PACL* Sacl,
1420 _Out_ PBOOLEAN SaclDefaulted
1421 );
1422
1423 NTSYSAPI
1424 NTSTATUS
1425 NTAPI
1426 RtlGetGroupSecurityDescriptor(
1427 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1428 _Out_ PSID *Group,
1429 _Out_ PBOOLEAN GroupDefaulted
1430 );
1431
1432 NTSYSAPI
1433 NTSTATUS
1434 NTAPI
1435 RtlGetOwnerSecurityDescriptor(
1436 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1437 _Out_ PSID *Owner,
1438 _Out_ PBOOLEAN OwnerDefaulted
1439 );
1440
1441 NTSYSAPI
1442 BOOLEAN
1443 NTAPI
1444 RtlGetSecurityDescriptorRMControl(
1445 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1446 _Out_ PUCHAR RMControl
1447 );
1448
1449 NTSYSAPI
1450 PSID_IDENTIFIER_AUTHORITY
1451 NTAPI
1452 RtlIdentifierAuthoritySid(PSID Sid);
1453
1454 NTSYSAPI
1455 NTSTATUS
1456 NTAPI
1457 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
1458
1459 _IRQL_requires_max_(APC_LEVEL)
1460 NTSYSAPI
1461 NTSTATUS
1462 NTAPI
1463 RtlInitializeSid(
1464 _Out_ PSID Sid,
1465 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1466 _In_ UCHAR SubAuthorityCount
1467 );
1468
1469 NTSYSAPI
1470 ULONG
1471 NTAPI
1472 RtlLengthRequiredSid(IN ULONG SubAuthorityCount);
1473
1474 _IRQL_requires_max_(APC_LEVEL)
1475 NTSYSAPI
1476 ULONG
1477 NTAPI
1478 RtlLengthSecurityDescriptor(
1479 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
1480
1481 NTSYSAPI
1482 ULONG
1483 NTAPI
1484 RtlLengthSid(IN PSID Sid);
1485
1486 NTSYSAPI
1487 NTSTATUS
1488 NTAPI
1489 RtlMakeSelfRelativeSD(
1490 _In_ PSECURITY_DESCRIPTOR AbsoluteSD,
1491 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1492 _Inout_ PULONG BufferLength);
1493
1494 NTSYSAPI
1495 VOID
1496 NTAPI
1497 RtlMapGenericMask(
1498 PACCESS_MASK AccessMask,
1499 PGENERIC_MAPPING GenericMapping
1500 );
1501
1502 #ifdef NTOS_MODE_USER
1503
1504 NTSYSAPI
1505 NTSTATUS
1506 NTAPI
1507 RtlQueryInformationAcl(
1508 PACL Acl,
1509 PVOID Information,
1510 ULONG InformationLength,
1511 ACL_INFORMATION_CLASS InformationClass
1512 );
1513
1514 #endif
1515
1516 NTSYSAPI
1517 VOID
1518 NTAPI
1519 RtlReleasePrivilege(
1520 _In_ PVOID ReturnedState
1521 );
1522
1523 _IRQL_requires_max_(APC_LEVEL)
1524 NTSYSAPI
1525 NTSTATUS
1526 NTAPI
1527 RtlSelfRelativeToAbsoluteSD(
1528 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1529 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1530 _Inout_ PULONG AbsoluteSecurityDescriptorSize,
1531 _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl,
1532 _Inout_ PULONG DaclSize,
1533 _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl,
1534 _Inout_ PULONG SaclSize,
1535 _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner,
1536 _Inout_ PULONG OwnerSize,
1537 _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup,
1538 _Inout_ PULONG PrimaryGroupSize
1539 );
1540
1541 NTSYSAPI
1542 NTSTATUS
1543 NTAPI
1544 RtlSelfRelativeToAbsoluteSD2(
1545 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1546 _Out_ PULONG BufferSize
1547 );
1548
1549 NTSYSAPI
1550 NTSTATUS
1551 NTAPI
1552 RtlSetAttributesSecurityDescriptor(
1553 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1554 _In_ SECURITY_DESCRIPTOR_CONTROL Control,
1555 _Out_ PULONG Revision
1556 );
1557
1558 NTSYSAPI
1559 NTSTATUS
1560 NTAPI
1561 RtlSetControlSecurityDescriptor(
1562 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1563 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
1564 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1565 );
1566
1567 _IRQL_requires_max_(APC_LEVEL)
1568 NTSYSAPI
1569 NTSTATUS
1570 NTAPI
1571 RtlSetDaclSecurityDescriptor(
1572 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1573 _In_ BOOLEAN DaclPresent,
1574 _In_opt_ PACL Dacl,
1575 _In_opt_ BOOLEAN DaclDefaulted
1576 );
1577
1578 _IRQL_requires_max_(APC_LEVEL)
1579 NTSYSAPI
1580 NTSTATUS
1581 NTAPI
1582 RtlSetGroupSecurityDescriptor(
1583 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1584 _In_opt_ PSID Group,
1585 _In_opt_ BOOLEAN GroupDefaulted
1586 );
1587
1588 #ifdef NTOS_MODE_USER
1589
1590 NTSYSAPI
1591 NTSTATUS
1592 NTAPI
1593 RtlSetInformationAcl(
1594 PACL Acl,
1595 PVOID Information,
1596 ULONG InformationLength,
1597 ACL_INFORMATION_CLASS InformationClass
1598 );
1599
1600 #endif
1601
1602 _IRQL_requires_max_(APC_LEVEL)
1603 NTSYSAPI
1604 NTSTATUS
1605 NTAPI
1606 RtlSetOwnerSecurityDescriptor(
1607 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1608 _In_opt_ PSID Owner,
1609 _In_opt_ BOOLEAN OwnerDefaulted
1610 );
1611
1612 NTSYSAPI
1613 NTSTATUS
1614 NTAPI
1615 RtlSetSaclSecurityDescriptor(
1616 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1617 _In_ BOOLEAN SaclPresent,
1618 _In_ PACL Sacl,
1619 _In_ BOOLEAN SaclDefaulted
1620 );
1621
1622 NTSYSAPI
1623 VOID
1624 NTAPI
1625 RtlSetSecurityDescriptorRMControl(
1626 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1627 _In_ PUCHAR RMControl
1628 );
1629
1630 NTSYSAPI
1631 PUCHAR
1632 NTAPI
1633 RtlSubAuthorityCountSid(
1634 _In_ PSID Sid
1635 );
1636
1637 NTSYSAPI
1638 PULONG
1639 NTAPI
1640 RtlSubAuthoritySid(
1641 _In_ PSID Sid,
1642 _In_ ULONG SubAuthority
1643 );
1644
1645 _IRQL_requires_max_(APC_LEVEL)
1646 _Must_inspect_result_
1647 NTSYSAPI
1648 BOOLEAN
1649 NTAPI
1650 RtlValidRelativeSecurityDescriptor(
1651 _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput,
1652 _In_ ULONG SecurityDescriptorLength,
1653 _In_ SECURITY_INFORMATION RequiredInformation
1654 );
1655
1656 NTSYSAPI
1657 BOOLEAN
1658 NTAPI
1659 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
1660
1661 NTSYSAPI
1662 BOOLEAN
1663 NTAPI
1664 RtlValidSid(IN PSID Sid);
1665
1666 NTSYSAPI
1667 BOOLEAN
1668 NTAPI
1669 RtlValidAcl(PACL Acl);
1670
1671 NTSYSAPI
1672 NTSTATUS
1673 NTAPI
1674 RtlDeleteSecurityObject(
1675 _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor
1676 );
1677
1678 NTSYSAPI
1679 NTSTATUS
1680 NTAPI
1681 RtlNewSecurityObject(
1682 _In_ PSECURITY_DESCRIPTOR ParentDescriptor,
1683 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor,
1684 _Out_ PSECURITY_DESCRIPTOR *NewDescriptor,
1685 _In_ BOOLEAN IsDirectoryObject,
1686 _In_ HANDLE Token,
1687 _In_ PGENERIC_MAPPING GenericMapping
1688 );
1689
1690 NTSYSAPI
1691 NTSTATUS
1692 NTAPI
1693 RtlQuerySecurityObject(
1694 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor,
1695 _In_ SECURITY_INFORMATION SecurityInformation,
1696 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor,
1697 _In_ ULONG DescriptorLength,
1698 _Out_ PULONG ReturnLength
1699 );
1700
1701 NTSYSAPI
1702 NTSTATUS
1703 NTAPI
1704 RtlSetSecurityObject(
1705 _In_ SECURITY_INFORMATION SecurityInformation,
1706 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor,
1707 _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
1708 _In_ PGENERIC_MAPPING GenericMapping,
1709 _In_ HANDLE Token
1710 );
1711
1712 //
1713 // Single-Character Functions
1714 //
1715 NTSYSAPI
1716 NTSTATUS
1717 NTAPI
1718 RtlLargeIntegerToChar(
1719 _In_ PLARGE_INTEGER Value,
1720 _In_ ULONG Base,
1721 _In_ ULONG Length,
1722 _Out_ PCHAR String
1723 );
1724
1725 NTSYSAPI
1726 CHAR
1727 NTAPI
1728 RtlUpperChar(CHAR Source);
1729
1730 NTSYSAPI
1731 WCHAR
1732 NTAPI
1733 RtlUpcaseUnicodeChar(WCHAR Source);
1734
1735 NTSYSAPI
1736 WCHAR
1737 NTAPI
1738 RtlDowncaseUnicodeChar(IN WCHAR Source);
1739
1740 NTSYSAPI
1741 NTSTATUS
1742 NTAPI
1743 RtlIntegerToChar(
1744 _In_ ULONG Value,
1745 _In_ ULONG Base,
1746 _In_ ULONG Length,
1747 _Out_ PCHAR String
1748 );
1749
1750 NTSYSAPI
1751 NTSTATUS
1752 NTAPI
1753 RtlIntegerToUnicode(
1754 _In_ ULONG Value,
1755 _In_opt_ ULONG Base,
1756 _In_opt_ ULONG Length,
1757 _Inout_ LPWSTR String
1758 );
1759
1760 _IRQL_requires_max_(PASSIVE_LEVEL)
1761 _At_(String->MaximumLength, _Const_)
1762 NTSYSAPI
1763 NTSTATUS
1764 NTAPI
1765 RtlIntegerToUnicodeString(
1766 _In_ ULONG Value,
1767 _In_opt_ ULONG Base,
1768 _Inout_ PUNICODE_STRING String
1769 );
1770
1771 NTSYSAPI
1772 NTSTATUS
1773 NTAPI
1774 RtlCharToInteger(
1775 PCSZ String,
1776 ULONG Base,
1777 PULONG Value
1778 );
1779
1780 //
1781 // Byte Swap Functions
1782 //
1783 #ifdef NTOS_MODE_USER
1784
1785 unsigned short __cdecl _byteswap_ushort(unsigned short);
1786 unsigned long __cdecl _byteswap_ulong (unsigned long);
1787 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1788 #ifdef _MSC_VER
1789 #pragma intrinsic(_byteswap_ushort)
1790 #pragma intrinsic(_byteswap_ulong)
1791 #pragma intrinsic(_byteswap_uint64)
1792 #endif // _MSC_VER
1793 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1794 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1795 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1796
1797 #endif // NTOS_MODE_USER
1798
1799 //
1800 // Unicode->Ansi String Functions
1801 //
1802 NTSYSAPI
1803 ULONG
1804 NTAPI
1805 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
1806
1807 #ifdef NTOS_MODE_USER
1808
1809 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1810 NLS_MB_CODE_PAGE_TAG ? \
1811 RtlxUnicodeStringToAnsiSize(STRING) : \
1812 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1813 )
1814
1815 #endif
1816
1817 NTSYSAPI
1818 NTSTATUS
1819 NTAPI
1820 RtlUnicodeStringToAnsiString(
1821 PANSI_STRING DestinationString,
1822 PCUNICODE_STRING SourceString,
1823 BOOLEAN AllocateDestinationString
1824 );
1825
1826 //
1827 // Unicode->OEM String Functions
1828 //
1829 NTSYSAPI
1830 NTSTATUS
1831 NTAPI
1832 RtlUpcaseUnicodeStringToOemString(
1833 POEM_STRING DestinationString,
1834 PCUNICODE_STRING SourceString,
1835 BOOLEAN AllocateDestinationString
1836 );
1837
1838 _IRQL_requires_max_(PASSIVE_LEVEL)
1839 _Must_inspect_result_
1840 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1841 NTSYSAPI
1842 NTSTATUS
1843 NTAPI
1844 RtlUpcaseUnicodeStringToCountedOemString(
1845 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
1846 _When_(!AllocateDestinationString, _Inout_)
1847 POEM_STRING DestinationString,
1848 _In_ PCUNICODE_STRING SourceString,
1849 _In_ BOOLEAN AllocateDestinationString
1850 );
1851
1852 NTSYSAPI
1853 NTSTATUS
1854 NTAPI
1855 RtlUnicodeStringToOemString(
1856 POEM_STRING DestinationString,
1857 PCUNICODE_STRING SourceString,
1858 BOOLEAN AllocateDestinationString
1859 );
1860
1861 NTSYSAPI
1862 NTSTATUS
1863 NTAPI
1864 RtlUpcaseUnicodeToOemN(
1865 PCHAR OemString,
1866 ULONG OemSize,
1867 PULONG ResultSize,
1868 PCWCH UnicodeString,
1869 ULONG UnicodeSize
1870 );
1871
1872 NTSYSAPI
1873 ULONG
1874 NTAPI
1875 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
1876
1877 #ifdef NTOS_MODE_USER
1878
1879 #define RtlUnicodeStringToOemSize(STRING) ( \
1880 NLS_MB_OEM_CODE_PAGE_TAG ? \
1881 RtlxUnicodeStringToOemSize(STRING) : \
1882 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1883 )
1884
1885 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1886 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1887 )
1888
1889 #endif
1890
1891 NTSYSAPI
1892 NTSTATUS
1893 NTAPI
1894 RtlUnicodeToOemN(
1895 PCHAR OemString,
1896 ULONG OemSize,
1897 PULONG ResultSize,
1898 PCWCH UnicodeString,
1899 ULONG UnicodeSize
1900 );
1901
1902 //
1903 // Unicode->MultiByte String Functions
1904 //
1905 NTSYSAPI
1906 NTSTATUS
1907 NTAPI
1908 RtlUnicodeToMultiByteN(
1909 PCHAR MbString,
1910 ULONG MbSize,
1911 PULONG ResultSize,
1912 PCWCH UnicodeString,
1913 ULONG UnicodeSize
1914 );
1915
1916 NTSYSAPI
1917 NTSTATUS
1918 NTAPI
1919 RtlUpcaseUnicodeToMultiByteN(
1920 PCHAR MbString,
1921 ULONG MbSize,
1922 PULONG ResultSize,
1923 PCWCH UnicodeString,
1924 ULONG UnicodeSize
1925 );
1926
1927 NTSYSAPI
1928 NTSTATUS
1929 NTAPI
1930 RtlUnicodeToMultiByteSize(
1931 PULONG MbSize,
1932 PCWCH UnicodeString,
1933 ULONG UnicodeSize
1934 );
1935
1936 NTSYSAPI
1937 ULONG
1938 NTAPI
1939 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
1940
1941 //
1942 // OEM to Unicode Functions
1943 //
1944 NTSYSAPI
1945 NTSTATUS
1946 NTAPI
1947 RtlOemStringToUnicodeString(
1948 PUNICODE_STRING DestinationString,
1949 PCOEM_STRING SourceString,
1950 BOOLEAN AllocateDestinationString
1951 );
1952
1953 _IRQL_requires_max_(PASSIVE_LEVEL)
1954 NTSYSAPI
1955 NTSTATUS
1956 NTAPI
1957 RtlOemToUnicodeN(
1958 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
1959 _In_ ULONG MaxBytesInUnicodeString,
1960 _Out_opt_ PULONG BytesInUnicodeString,
1961 _In_reads_bytes_(BytesInOemString) PCCH OemString,
1962 _In_ ULONG BytesInOemString
1963 );
1964
1965 #ifdef NTOS_MODE_USER
1966
1967 #define RtlOemStringToUnicodeSize(STRING) ( \
1968 NLS_MB_OEM_CODE_PAGE_TAG ? \
1969 RtlxOemStringToUnicodeSize(STRING) : \
1970 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1971 )
1972
1973 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1974 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1975 )
1976
1977 #endif
1978
1979 //
1980 // Ansi->Unicode String Functions
1981 //
1982 _IRQL_requires_max_(APC_LEVEL)
1983 NTSYSAPI
1984 WCHAR
1985 NTAPI
1986 RtlAnsiCharToUnicodeChar(
1987 _Inout_ PUCHAR *SourceCharacter);
1988
1989 NTSYSAPI
1990 NTSTATUS
1991 NTAPI
1992 RtlAnsiStringToUnicodeString(
1993 PUNICODE_STRING DestinationString,
1994 PCANSI_STRING SourceString,
1995 BOOLEAN AllocateDestinationString
1996 );
1997
1998 NTSYSAPI
1999 ULONG
2000 NTAPI
2001 RtlxAnsiStringToUnicodeSize(
2002 PCANSI_STRING AnsiString
2003 );
2004
2005 #ifdef NTOS_MODE_USER
2006
2007 #define RtlAnsiStringToUnicodeSize(STRING) ( \
2008 NLS_MB_CODE_PAGE_TAG ? \
2009 RtlxAnsiStringToUnicodeSize(STRING) : \
2010 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2011 )
2012
2013 #endif
2014
2015 NTSYSAPI
2016 BOOLEAN
2017 NTAPI
2018 RtlCreateUnicodeStringFromAsciiz(
2019 _Out_ PUNICODE_STRING Destination,
2020 _In_ PCSZ Source
2021 );
2022
2023 //
2024 // Unicode String Functions
2025 //
2026 NTSYSAPI
2027 NTSTATUS
2028 NTAPI
2029 RtlAppendUnicodeToString(
2030 PUNICODE_STRING Destination,
2031 PCWSTR Source
2032 );
2033
2034 NTSYSAPI
2035 NTSTATUS
2036 NTAPI
2037 RtlAppendUnicodeStringToString(
2038 PUNICODE_STRING Destination,
2039 PCUNICODE_STRING Source
2040 );
2041
2042 NTSYSAPI
2043 LONG
2044 NTAPI
2045 RtlCompareUnicodeString(
2046 PCUNICODE_STRING String1,
2047 PCUNICODE_STRING String2,
2048 BOOLEAN CaseInsensitive
2049 );
2050
2051 NTSYSAPI
2052 VOID
2053 NTAPI
2054 RtlCopyUnicodeString(
2055 PUNICODE_STRING DestinationString,
2056 PCUNICODE_STRING SourceString
2057 );
2058
2059 NTSYSAPI
2060 BOOLEAN
2061 NTAPI
2062 RtlCreateUnicodeString(
2063 PUNICODE_STRING DestinationString,
2064 PCWSTR SourceString
2065 );
2066
2067 #ifdef NTOS_MODE_USER
2068
2069 NTSYSAPI
2070 NTSTATUS
2071 NTAPI
2072 RtlDowncaseUnicodeString(
2073 _Inout_ PUNICODE_STRING UniDest,
2074 _In_ PCUNICODE_STRING UniSource,
2075 _In_ BOOLEAN AllocateDestinationString
2076 );
2077
2078 NTSYSAPI
2079 NTSTATUS
2080 NTAPI
2081 RtlDuplicateUnicodeString(
2082 _In_ ULONG Flags,
2083 _In_ PCUNICODE_STRING SourceString,
2084 _Out_ PUNICODE_STRING DestinationString
2085 );
2086
2087 //
2088 // Memory Functions
2089 //
2090 NTSYSAPI
2091 VOID
2092 NTAPI
2093 RtlFillMemoryUlong(
2094 _In_ PVOID Destination,
2095 _In_ SIZE_T Length,
2096 _In_ ULONG Fill
2097 );
2098
2099 NTSYSAPI
2100 VOID
2101 NTAPI
2102 RtlFillMemoryUlonglong(
2103 _Out_ PVOID Destination,
2104 _In_ SIZE_T Length,
2105 _In_ ULONGLONG Pattern
2106 );
2107
2108 NTSYSAPI
2109 NTSTATUS
2110 NTAPI
2111 RtlCopyMappedMemory(
2112 _Out_writes_bytes_all_(Size) PVOID Destination,
2113 _In_reads_bytes_(Size) const VOID *Source,
2114 _In_ SIZE_T Size
2115 );
2116
2117 NTSYSAPI
2118 SIZE_T
2119 NTAPI
2120 RtlCompareMemoryUlong(
2121 _In_ PVOID Source,
2122 _In_ SIZE_T Length,
2123 _In_ ULONG Pattern
2124 );
2125
2126 #ifndef RtlEqualMemory
2127 #define RtlEqualMemory(Destination, Source, Length) \
2128 (!memcmp(Destination, Source, Length))
2129 #endif
2130
2131 #define RtlCopyBytes RtlCopyMemory
2132 #define RtlFillBytes RtlFillMemory
2133 #define RtlZeroBytes RtlZeroMemory
2134
2135 #endif
2136
2137 NTSYSAPI
2138 BOOLEAN
2139 NTAPI
2140 RtlEqualUnicodeString(
2141 PCUNICODE_STRING String1,
2142 PCUNICODE_STRING String2,
2143 BOOLEAN CaseInsensitive
2144 );
2145
2146 NTSYSAPI
2147 NTSTATUS
2148 NTAPI
2149 RtlFindCharInUnicodeString(
2150 _In_ ULONG Flags,
2151 _In_ PCUNICODE_STRING SearchString,
2152 _In_ PCUNICODE_STRING MatchString,
2153 _Out_ PUSHORT Position
2154 );
2155
2156 _IRQL_requires_max_(PASSIVE_LEVEL)
2157 NTSYSAPI
2158 VOID
2159 NTAPI
2160 RtlFreeUnicodeString(
2161 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem))
2162 PUNICODE_STRING UnicodeString
2163 );
2164
2165 NTSYSAPI
2166 VOID
2167 NTAPI
2168 RtlEraseUnicodeString(
2169 _Inout_ PUNICODE_STRING String
2170 );
2171
2172 NTSYSAPI
2173 NTSTATUS
2174 NTAPI
2175 RtlHashUnicodeString(
2176 _In_ CONST UNICODE_STRING *String,
2177 _In_ BOOLEAN CaseInSensitive,
2178 _In_ ULONG HashAlgorithm,
2179 _Out_ PULONG HashValue
2180 );
2181
2182 _IRQL_requires_max_(DISPATCH_LEVEL)
2183 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2184 _When_(SourceString != NULL,
2185 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
2186 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR))))
2187 _When_(SourceString == NULL,
2188 _At_(DestinationString->Length, _Post_equal_to_(0))
2189 _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2190 NTSYSAPI
2191 VOID
2192 NTAPI
2193 RtlInitUnicodeString(
2194 _Out_ PUNICODE_STRING DestinationString,
2195 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2196 );
2197
2198 _IRQL_requires_max_(DISPATCH_LEVEL)
2199 NTSYSAPI
2200 NTSTATUS
2201 NTAPI
2202 RtlInitUnicodeStringEx(
2203 _Out_ PUNICODE_STRING DestinationString,
2204 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2205 );
2206
2207 NTSYSAPI
2208 BOOLEAN
2209 NTAPI
2210 RtlIsTextUnicode(
2211 _In_ CONST VOID* Buffer,
2212 _In_ INT Size,
2213 _Inout_opt_ INT* Flags
2214 );
2215
2216 _IRQL_requires_max_(PASSIVE_LEVEL)
2217 _Must_inspect_result_
2218 NTSYSAPI
2219 BOOLEAN
2220 NTAPI
2221 RtlPrefixString(
2222 _In_ const STRING *String1,
2223 _In_ const STRING *String2,
2224 _In_ BOOLEAN CaseInsensitive
2225 );
2226
2227 _IRQL_requires_max_(PASSIVE_LEVEL)
2228 _Must_inspect_result_
2229 NTSYSAPI
2230 BOOLEAN
2231 NTAPI
2232 RtlPrefixUnicodeString(
2233 _In_ PCUNICODE_STRING String1,
2234 _In_ PCUNICODE_STRING String2,
2235 _In_ BOOLEAN CaseInsensitive
2236 );
2237
2238 _IRQL_requires_max_(PASSIVE_LEVEL)
2239 NTSYSAPI
2240 VOID
2241 NTAPI
2242 RtlUpperString(
2243 _Inout_ PSTRING DestinationString,
2244 _In_ const STRING *SourceString
2245 );
2246
2247 _IRQL_requires_max_(PASSIVE_LEVEL)
2248 _Must_inspect_result_
2249 NTSYSAPI
2250 LONG
2251 NTAPI
2252 RtlCompareString(
2253 _In_ const STRING *String1,
2254 _In_ const STRING *String2,
2255 _In_ BOOLEAN CaseInSensitive
2256 );
2257
2258 NTSYSAPI
2259 VOID
2260 NTAPI
2261 RtlCopyString(
2262 _Out_ PSTRING DestinationString,
2263 _In_opt_ const STRING *SourceString
2264 );
2265
2266 _IRQL_requires_max_(PASSIVE_LEVEL)
2267 _Must_inspect_result_
2268 NTSYSAPI
2269 BOOLEAN
2270 NTAPI
2271 RtlEqualString(
2272 _In_ const STRING *String1,
2273 _In_ const STRING *String2,
2274 _In_ BOOLEAN CaseInSensitive
2275 );
2276
2277 _IRQL_requires_max_(APC_LEVEL)
2278 NTSYSAPI
2279 NTSTATUS
2280 NTAPI
2281 RtlAppendStringToString(
2282 _Inout_ PSTRING Destination,
2283 _In_ const STRING *Source
2284 );
2285
2286 _IRQL_requires_max_(PASSIVE_LEVEL)
2287 _When_(AllocateDestinationString, _Must_inspect_result_)
2288 NTSYSAPI
2289 NTSTATUS
2290 NTAPI
2291 RtlUpcaseUnicodeString(
2292 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
2293 _When_(!AllocateDestinationString, _Inout_)
2294 PUNICODE_STRING DestinationString,
2295 _In_ PCUNICODE_STRING SourceString,
2296 _In_ BOOLEAN AllocateDestinationString
2297 );
2298
2299 _IRQL_requires_max_(PASSIVE_LEVEL)
2300 NTSYSAPI
2301 NTSTATUS
2302 NTAPI
2303 RtlUnicodeStringToInteger(
2304 _In_ PCUNICODE_STRING String,
2305 _In_opt_ ULONG Base,
2306 _Out_ PULONG Value
2307 );
2308
2309 NTSYSAPI
2310 NTSTATUS
2311 NTAPI
2312 RtlValidateUnicodeString(
2313 _In_ ULONG Flags,
2314 _In_ PCUNICODE_STRING String
2315 );
2316
2317 #define RTL_SKIP_BUFFER_COPY 0x00000001
2318
2319 NTSYSAPI
2320 NTSTATUS
2321 NTAPI
2322 RtlpEnsureBufferSize(
2323 _In_ ULONG Flags,
2324 _Inout_ PRTL_BUFFER Buffer,
2325 _In_ SIZE_T RequiredSize
2326 );
2327
2328 #ifdef NTOS_MODE_USER
2329
2330 FORCEINLINE
2331 VOID
2332 RtlInitBuffer(
2333 _Inout_ PRTL_BUFFER Buffer,
2334 _In_ PUCHAR Data,
2335 _In_ ULONG DataSize
2336 )
2337 {
2338 Buffer->Buffer = Buffer->StaticBuffer = Data;
2339 Buffer->Size = Buffer->StaticSize = DataSize;
2340 Buffer->ReservedForAllocatedSize = 0;
2341 Buffer->ReservedForIMalloc = NULL;
2342 }
2343
2344 FORCEINLINE
2345 NTSTATUS
2346 RtlEnsureBufferSize(
2347 _In_ ULONG Flags,
2348 _Inout_ PRTL_BUFFER Buffer,
2349 _In_ ULONG RequiredSize
2350 )
2351 {
2352 if (Buffer && RequiredSize <= Buffer->Size)
2353 return STATUS_SUCCESS;
2354 return RtlpEnsureBufferSize(Flags, Buffer, RequiredSize);
2355 }
2356
2357 FORCEINLINE
2358 VOID
2359 RtlFreeBuffer(
2360 _Inout_ PRTL_BUFFER Buffer
2361 )
2362 {
2363 if (Buffer->Buffer != Buffer->StaticBuffer && Buffer->Buffer)
2364 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer->Buffer);
2365 Buffer->Buffer = Buffer->StaticBuffer;
2366 Buffer->Size = Buffer->StaticSize;
2367 }
2368
2369 #endif /* NTOS_MODE_USER */
2370
2371 //
2372 // Ansi String Functions
2373 //
2374 _IRQL_requires_max_(PASSIVE_LEVEL)
2375 NTSYSAPI
2376 VOID
2377 NTAPI
2378 RtlFreeAnsiString(
2379 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2380 PANSI_STRING AnsiString
2381 );
2382
2383 _IRQL_requires_max_(DISPATCH_LEVEL)
2384 NTSYSAPI
2385 VOID
2386 NTAPI
2387 RtlInitAnsiString(
2388 _Out_ PANSI_STRING DestinationString,
2389 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2390 );
2391
2392 _IRQL_requires_max_(DISPATCH_LEVEL)
2393 NTSYSAPI
2394 NTSTATUS
2395 NTAPI
2396 RtlInitAnsiStringEx(
2397 _Out_ PANSI_STRING DestinationString,
2398 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2399 );
2400
2401 //
2402 // OEM String Functions
2403 //
2404 _IRQL_requires_max_(PASSIVE_LEVEL)
2405 NTSYSAPI
2406 VOID
2407 NTAPI
2408 RtlFreeOemString(
2409 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2410 POEM_STRING OemString
2411 );
2412
2413 //
2414 // MultiByte->Unicode String Functions
2415 //
2416 _IRQL_requires_max_(PASSIVE_LEVEL)
2417 NTSYSAPI
2418 NTSTATUS
2419 NTAPI
2420 RtlMultiByteToUnicodeN(
2421 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2422 _In_ ULONG MaxBytesInUnicodeString,
2423 _Out_opt_ PULONG BytesInUnicodeString,
2424 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2425 _In_ ULONG BytesInMultiByteString
2426 );
2427
2428 _IRQL_requires_max_(PASSIVE_LEVEL)
2429 NTSYSAPI
2430 NTSTATUS
2431 NTAPI
2432 RtlMultiByteToUnicodeSize(
2433 _Out_ PULONG BytesInUnicodeString,
2434 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2435 _In_ ULONG BytesInMultiByteString
2436 );
2437
2438 //
2439 // Atom Functions
2440 //
2441 NTSYSAPI
2442 NTSTATUS
2443 NTAPI
2444 RtlAddAtomToAtomTable(
2445 _In_ PRTL_ATOM_TABLE AtomTable,
2446 _In_ PWSTR AtomName,
2447 _Out_ PRTL_ATOM Atom
2448 );
2449
2450 NTSYSAPI
2451 NTSTATUS
2452 NTAPI
2453 RtlCreateAtomTable(
2454 _In_ ULONG TableSize,
2455 _Inout_ PRTL_ATOM_TABLE *AtomTable
2456 );
2457
2458 NTSYSAPI
2459 NTSTATUS
2460 NTAPI
2461 RtlDeleteAtomFromAtomTable(
2462 _In_ PRTL_ATOM_TABLE AtomTable,
2463 _In_ RTL_ATOM Atom
2464 );
2465
2466 NTSYSAPI
2467 NTSTATUS
2468 NTAPI
2469 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
2470
2471 NTSYSAPI
2472 NTSTATUS
2473 NTAPI
2474 RtlQueryAtomInAtomTable(
2475 _In_ PRTL_ATOM_TABLE AtomTable,
2476 _In_ RTL_ATOM Atom,
2477 _Out_opt_ PULONG RefCount,
2478 _Out_opt_ PULONG PinCount,
2479 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2480 _Inout_opt_ PULONG NameLength
2481 );
2482
2483 NTSYSAPI
2484 NTSTATUS
2485 NTAPI
2486 RtlPinAtomInAtomTable(
2487 _In_ PRTL_ATOM_TABLE AtomTable,
2488 _In_ RTL_ATOM Atom
2489 );
2490
2491 NTSYSAPI
2492 NTSTATUS
2493 NTAPI
2494 RtlLookupAtomInAtomTable(
2495 _In_ PRTL_ATOM_TABLE AtomTable,
2496 _In_ PWSTR AtomName,
2497 _Out_ PRTL_ATOM Atom
2498 );
2499
2500 //
2501 // Process Management Functions
2502 //
2503 NTSYSAPI
2504 PPEB
2505 NTAPI
2506 RtlGetCurrentPeb(
2507 VOID
2508 );
2509
2510 NTSYSAPI
2511 VOID
2512 NTAPI
2513 RtlAcquirePebLock(VOID);
2514
2515 NTSYSAPI
2516 NTSTATUS
2517 NTAPI
2518 RtlCreateProcessParameters (
2519 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2520 _In_ PUNICODE_STRING ImagePathName,
2521 _In_opt_ PUNICODE_STRING DllPath,
2522 _In_opt_ PUNICODE_STRING CurrentDirectory,
2523 _In_opt_ PUNICODE_STRING CommandLine,
2524 _In_opt_ PWSTR Environment,
2525 _In_opt_ PUNICODE_STRING WindowTitle,
2526 _In_opt_ PUNICODE_STRING DesktopInfo,
2527 _In_opt_ PUNICODE_STRING ShellInfo,
2528 _In_opt_ PUNICODE_STRING RuntimeInfo
2529 );
2530
2531 NTSYSAPI
2532 NTSTATUS
2533 NTAPI
2534 RtlCreateUserProcess(
2535 _In_ PUNICODE_STRING ImageFileName,
2536 _In_ ULONG Attributes,
2537 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2538 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2539 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2540 _In_opt_ HANDLE ParentProcess,
2541 _In_ BOOLEAN CurrentDirectory,
2542 _In_opt_ HANDLE DebugPort,
2543 _In_opt_ HANDLE ExceptionPort,
2544 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2545 );
2546
2547 #if (NTDDI_VERSION >= NTDDI_WIN7)
2548 NTSYSAPI
2549 NTSTATUS
2550 NTAPI
2551 RtlCreateUserThread(
2552 _In_ PVOID ThreadContext,
2553 _Out_ HANDLE *OutThreadHandle,
2554 _Reserved_ PVOID Reserved1,
2555 _Reserved_ PVOID Reserved2,
2556 _Reserved_ PVOID Reserved3,
2557 _Reserved_ PVOID Reserved4,
2558 _Reserved_ PVOID Reserved5,
2559 _Reserved_ PVOID Reserved6,
2560 _Reserved_ PVOID Reserved7,
2561 _Reserved_ PVOID Reserved8
2562 );
2563 #else
2564 NTSYSAPI
2565 NTSTATUS
2566 NTAPI
2567 RtlCreateUserThread(
2568 _In_ HANDLE ProcessHandle,
2569 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2570 _In_ BOOLEAN CreateSuspended,
2571 _In_ ULONG StackZeroBits,
2572 _In_ SIZE_T StackReserve,
2573 _In_ SIZE_T StackCommit,
2574 _In_ PTHREAD_START_ROUTINE StartAddress,
2575 _In_ PVOID Parameter,
2576 _Out_opt_ PHANDLE ThreadHandle,
2577 _Out_opt_ PCLIENT_ID ClientId
2578 );
2579 #endif
2580
2581 NTSYSAPI
2582 PRTL_USER_PROCESS_PARAMETERS
2583 NTAPI
2584 RtlDeNormalizeProcessParams(
2585 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2586
2587 NTSYSAPI
2588 NTSTATUS
2589 NTAPI
2590 RtlDestroyProcessParameters(
2591 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2592
2593 NTSYSAPI
2594 VOID
2595 NTAPI
2596 RtlExitUserThread(
2597 _In_ NTSTATUS Status);
2598
2599 NTSYSAPI
2600 VOID
2601 NTAPI
2602 RtlInitializeContext(
2603 _In_ HANDLE ProcessHandle,
2604 _Out_ PCONTEXT ThreadContext,
2605 _In_opt_ PVOID ThreadStartParam,
2606 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2607 _In_ PINITIAL_TEB InitialTeb
2608 );
2609
2610 #ifdef _M_AMD64
2611 typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2612
2613 NTSYSAPI
2614 NTSTATUS
2615 NTAPI
2616 RtlWow64GetThreadContext(
2617 _In_ HANDLE ThreadHandle,
2618 _Inout_ PWOW64_CONTEXT ThreadContext
2619 );
2620
2621
2622 NTSYSAPI
2623 NTSTATUS
2624 NTAPI
2625 RtlWow64SetThreadContext(
2626 _In_ HANDLE ThreadHandle,
2627 _In_ PWOW64_CONTEXT ThreadContext
2628 );
2629 #endif
2630
2631 NTSYSAPI
2632 BOOLEAN
2633 NTAPI
2634 RtlIsThreadWithinLoaderCallout(VOID);
2635
2636 NTSYSAPI
2637 PRTL_USER_PROCESS_PARAMETERS
2638 NTAPI
2639 RtlNormalizeProcessParams(
2640 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2641
2642 NTSYSAPI
2643 VOID
2644 NTAPI
2645 RtlReleasePebLock(VOID);
2646
2647 NTSYSAPI
2648 NTSTATUS
2649 NTAPI
2650 RtlRemoteCall(
2651 _In_ HANDLE Process,
2652 _In_ HANDLE Thread,
2653 _In_ PVOID CallSite,
2654 _In_ ULONG ArgumentCount,
2655 _In_ PULONG Arguments,
2656 _In_ BOOLEAN PassContext,
2657 _In_ BOOLEAN AlreadySuspended
2658 );
2659
2660 NTSYSAPI
2661 NTSTATUS
2662 __cdecl
2663 RtlSetProcessIsCritical(
2664 _In_ BOOLEAN NewValue,
2665 _Out_opt_ PBOOLEAN OldValue,
2666 _In_ BOOLEAN NeedBreaks
2667 );
2668
2669 NTSYSAPI
2670 NTSTATUS
2671 __cdecl
2672 RtlSetThreadIsCritical(
2673 _In_ BOOLEAN NewValue,
2674 _Out_opt_ PBOOLEAN OldValue,
2675 _In_ BOOLEAN NeedBreaks
2676 );
2677
2678 NTSYSAPI
2679 ULONG
2680 NTAPI
2681 RtlGetCurrentProcessorNumber(
2682 VOID
2683 );
2684
2685
2686 //
2687 // Thread Pool Functions
2688 //
2689 //
2690 NTSTATUS
2691 NTAPI
2692 RtlSetThreadPoolStartFunc(
2693 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2694 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2695 );
2696
2697 NTSYSAPI
2698 NTSTATUS
2699 NTAPI
2700 RtlDeregisterWaitEx(
2701 _In_ HANDLE hWaitHandle,
2702 _In_opt_ HANDLE hCompletionEvent
2703 );
2704
2705 NTSYSAPI
2706 NTSTATUS
2707 NTAPI
2708 RtlDeregisterWait(
2709 _In_ HANDLE hWaitHandle
2710 );
2711
2712 NTSYSAPI
2713 NTSTATUS
2714 NTAPI
2715 RtlQueueWorkItem(
2716 _In_ WORKERCALLBACKFUNC Function,
2717 _In_opt_ PVOID Context,
2718 _In_ ULONG Flags
2719 );
2720
2721 NTSYSAPI
2722 NTSTATUS
2723 NTAPI
2724 RtlSetIoCompletionCallback(
2725 _In_ HANDLE FileHandle,
2726 _In_ PIO_APC_ROUTINE Callback,
2727 _In_ ULONG Flags
2728 );
2729
2730 NTSYSAPI
2731 NTSTATUS
2732 NTAPI
2733 RtlRegisterWait(
2734 _In_ PHANDLE phNewWaitObject,
2735 _In_ HANDLE hObject,
2736 _In_ WAITORTIMERCALLBACKFUNC Callback,
2737 _In_ PVOID pvContext,
2738 _In_ ULONG ulMilliseconds,
2739 _In_ ULONG ulFlags
2740 );
2741
2742 //
2743 // Environment/Path Functions
2744 //
2745 NTSYSAPI
2746 NTSTATUS
2747 NTAPI
2748 RtlCreateEnvironment(
2749 _In_ BOOLEAN Inherit,
2750 _Out_ PWSTR *Environment
2751 );
2752
2753 NTSYSAPI
2754 NTSTATUS
2755 NTAPI
2756 RtlComputePrivatizedDllName_U(
2757 _In_ PUNICODE_STRING DllName,
2758 _Out_ PUNICODE_STRING RealName,
2759 _Out_ PUNICODE_STRING LocalName
2760 );
2761
2762 NTSYSAPI
2763 VOID
2764 NTAPI
2765 RtlDestroyEnvironment(
2766 _In_ PWSTR Environment
2767 );
2768
2769 NTSYSAPI
2770 BOOLEAN
2771 NTAPI
2772 RtlDoesFileExists_U(
2773 _In_ PCWSTR FileName
2774 );
2775
2776 NTSYSAPI
2777 RTL_PATH_TYPE
2778 NTAPI
2779 RtlDetermineDosPathNameType_U(
2780 _In_ PCWSTR Path
2781 );
2782
2783 NTSYSAPI
2784 ULONG
2785 NTAPI
2786 RtlDosSearchPath_U(
2787 _In_ PCWSTR Path,
2788 _In_ PCWSTR FileName,
2789 _In_ PCWSTR Extension,
2790 _In_ ULONG BufferSize,
2791 _Out_ PWSTR Buffer,
2792 _Out_ PWSTR *PartName
2793 );
2794
2795 NTSYSAPI
2796 NTSTATUS
2797 NTAPI
2798 RtlDosSearchPath_Ustr(
2799 _In_ ULONG Flags,
2800 _In_ PUNICODE_STRING PathString,
2801 _In_ PUNICODE_STRING FileNameString,
2802 _In_ PUNICODE_STRING ExtensionString,
2803 _In_ PUNICODE_STRING CallerBuffer,
2804 _Inout_opt_ PUNICODE_STRING DynamicString,
2805 _Out_opt_ PUNICODE_STRING* FullNameOut,
2806 _Out_opt_ PSIZE_T FilePartSize,
2807 _Out_opt_ PSIZE_T LengthNeeded
2808 );
2809
2810 NTSYSAPI
2811 BOOLEAN
2812 NTAPI
2813 RtlDosPathNameToNtPathName_U(
2814 _In_opt_z_ PCWSTR DosPathName,
2815 _Out_ PUNICODE_STRING NtPathName,
2816 _Out_opt_ PCWSTR *NtFileNamePart,
2817 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2818 );
2819
2820 NTSYSAPI
2821 BOOLEAN
2822 NTAPI
2823 RtlDosPathNameToRelativeNtPathName_U(
2824 _In_ PCWSTR DosName,
2825 _Out_ PUNICODE_STRING NtName,
2826 _Out_ PCWSTR *PartName,
2827 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2828 );
2829
2830 _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength))
2831 NTSYSAPI
2832 NTSTATUS
2833 NTAPI
2834 RtlExpandEnvironmentStrings_U(
2835 _In_z_ PWSTR Environment,
2836 _In_ PUNICODE_STRING Source,
2837 _Inout_ PUNICODE_STRING Destination,
2838 _Out_ PULONG Length
2839 );
2840
2841 NTSYSAPI
2842 ULONG
2843 NTAPI
2844 RtlGetCurrentDirectory_U(
2845 _In_ ULONG MaximumLength,
2846 _Out_bytecap_(MaximumLength) PWSTR Buffer
2847 );
2848
2849 NTSYSAPI
2850 ULONG
2851 NTAPI
2852 RtlGetFullPathName_U(
2853 _In_ PCWSTR FileName,
2854 _In_ ULONG Size,
2855 _Out_z_bytecap_(Size) PWSTR Buffer,
2856 _Out_opt_ PWSTR *ShortName
2857 );
2858
2859 #if (NTDDI_VERSION >= NTDDI_WIN7)
2860 NTSYSAPI
2861 NTSTATUS
2862 NTAPI
2863 RtlGetFullPathName_UEx(
2864 _In_ PWSTR FileName,
2865 _In_ ULONG BufferLength,
2866 _Out_ PWSTR Buffer,
2867 _Out_opt_ PWSTR *FilePart,
2868 _Out_opt_ RTL_PATH_TYPE *InputPathType
2869 );
2870 #endif
2871
2872 NTSTATUS
2873 NTAPI
2874 RtlGetFullPathName_UstrEx(
2875 _In_ PUNICODE_STRING FileName,
2876 _In_opt_ PUNICODE_STRING StaticString,
2877 _In_opt_ PUNICODE_STRING DynamicString,
2878 _Out_opt_ PUNICODE_STRING *StringUsed,
2879 _Out_opt_ PSIZE_T FilePartSize,
2880 _Out_opt_ PBOOLEAN NameInvalid,
2881 _Out_ RTL_PATH_TYPE* PathType,
2882 _Out_opt_ PSIZE_T LengthNeeded
2883 );
2884
2885 NTSYSAPI
2886 NTSTATUS
2887 NTAPI
2888 RtlGetLengthWithoutTrailingPathSeperators(
2889 _Reserved_ ULONG Flags,
2890 _In_ PCUNICODE_STRING PathString,
2891 _Out_ PULONG Length
2892 );
2893
2894 NTSYSAPI
2895 ULONG
2896 NTAPI
2897 RtlGetLongestNtPathLength(
2898 VOID
2899 );
2900
2901 NTSYSAPI
2902 ULONG
2903 NTAPI
2904 RtlIsDosDeviceName_U(
2905 _In_ PCWSTR Name
2906 );
2907
2908 NTSYSAPI
2909 ULONG
2910 NTAPI
2911 RtlIsDosDeviceName_Ustr(
2912 _In_ PCUNICODE_STRING Name
2913 );
2914
2915 _IRQL_requires_max_(PASSIVE_LEVEL)
2916 _Must_inspect_result_
2917 NTSYSAPI
2918 BOOLEAN
2919 NTAPI
2920 RtlIsNameLegalDOS8Dot3(
2921 _In_ PCUNICODE_STRING Name,
2922 _Inout_opt_ POEM_STRING OemName,
2923 _Out_opt_ PBOOLEAN NameContainsSpaces
2924 );
2925
2926 NTSYSAPI
2927 NTSTATUS
2928 NTAPI
2929 RtlQueryEnvironmentVariable_U(
2930 _In_opt_ PWSTR Environment,
2931 _In_ PUNICODE_STRING Name,
2932 _Out_ PUNICODE_STRING Value
2933 );
2934
2935 VOID
2936 NTAPI
2937 RtlReleaseRelativeName(
2938 _In_ PRTL_RELATIVE_NAME_U RelativeName
2939 );
2940
2941 NTSYSAPI
2942 NTSTATUS
2943 NTAPI
2944 RtlSetCurrentDirectory_U(
2945 _In_ PUNICODE_STRING name
2946 );
2947
2948 NTSYSAPI
2949 NTSTATUS
2950 NTAPI
2951 RtlSetEnvironmentVariable(
2952 _In_z_ PWSTR *Environment,
2953 _In_ PUNICODE_STRING Name,
2954 _In_ PUNICODE_STRING Value
2955 );
2956
2957 //
2958 // Critical Section/Resource Functions
2959 //
2960 NTSYSAPI
2961 NTSTATUS
2962 NTAPI
2963 RtlDeleteCriticalSection (
2964 _In_ PRTL_CRITICAL_SECTION CriticalSection
2965 );
2966
2967 NTSYSAPI
2968 NTSTATUS
2969 NTAPI
2970 RtlEnterCriticalSection(
2971 _In_ PRTL_CRITICAL_SECTION CriticalSection
2972 );
2973
2974 NTSYSAPI
2975 NTSTATUS
2976 NTAPI
2977 RtlInitializeCriticalSection(
2978 _In_ PRTL_CRITICAL_SECTION CriticalSection
2979 );
2980
2981 NTSYSAPI
2982 NTSTATUS
2983 NTAPI
2984 RtlInitializeCriticalSectionAndSpinCount(
2985 _In_ PRTL_CRITICAL_SECTION CriticalSection,
2986 _In_ ULONG SpinCount
2987 );
2988
2989 NTSYSAPI
2990 NTSTATUS
2991 NTAPI
2992 RtlLeaveCriticalSection(
2993 _In_ PRTL_CRITICAL_SECTION CriticalSection
2994 );
2995
2996 NTSYSAPI
2997 BOOLEAN
2998 NTAPI
2999 RtlTryEnterCriticalSection(
3000 _In_ PRTL_CRITICAL_SECTION CriticalSection
3001 );
3002
3003 NTSYSAPI
3004 VOID
3005 NTAPI
3006 RtlpUnWaitCriticalSection(
3007 _In_ PRTL_CRITICAL_SECTION CriticalSection
3008 );
3009
3010 NTSYSAPI
3011 NTSTATUS
3012 NTAPI
3013 RtlpWaitForCriticalSection(
3014 _In_ PRTL_CRITICAL_SECTION CriticalSection
3015 );
3016
3017 NTSYSAPI
3018 BOOLEAN
3019 NTAPI
3020 RtlAcquireResourceExclusive(
3021 _In_ PRTL_RESOURCE Resource,
3022 _In_ BOOLEAN Wait
3023 );
3024
3025 NTSYSAPI
3026 BOOLEAN
3027 NTAPI
3028 RtlAcquireResourceShared(
3029 _In_ PRTL_RESOURCE Resource,
3030 _In_ BOOLEAN Wait
3031 );
3032
3033 NTSYSAPI
3034 VOID
3035 NTAPI
3036 RtlConvertExclusiveToShared(
3037 _In_ PRTL_RESOURCE Resource
3038 );
3039
3040 NTSYSAPI
3041 VOID
3042 NTAPI
3043 RtlConvertSharedToExclusive(
3044 _In_ PRTL_RESOURCE Resource
3045 );
3046
3047 NTSYSAPI
3048 VOID
3049 NTAPI
3050 RtlDeleteResource(
3051 _In_ PRTL_RESOURCE Resource
3052 );
3053
3054 NTSYSAPI
3055 VOID
3056 NTAPI
3057 RtlDumpResource(
3058 _In_ PRTL_RESOURCE Resource
3059 );
3060
3061 NTSYSAPI
3062 VOID
3063 NTAPI
3064 RtlInitializeResource(
3065 _In_ PRTL_RESOURCE Resource
3066 );
3067
3068 NTSYSAPI
3069 VOID
3070 NTAPI
3071 RtlReleaseResource(
3072 _In_ PRTL_RESOURCE Resource
3073 );
3074
3075 //
3076 // Compression Functions
3077 //
3078 NTSYSAPI //NT_RTL_COMPRESS_API
3079 NTSTATUS
3080 NTAPI
3081 RtlCompressBuffer(
3082 _In_ USHORT CompressionFormatAndEngine,
3083 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer,
3084 _In_ ULONG UncompressedBufferSize,
3085 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer,
3086 _In_ ULONG CompressedBufferSize,
3087 _In_ ULONG UncompressedChunkSize,
3088 _Out_ PULONG FinalCompressedSize,
3089 _In_ PVOID WorkSpace
3090 );
3091
3092 _IRQL_requires_max_(APC_LEVEL)
3093 NTSYSAPI //NT_RTL_COMPRESS_API
3094 NTSTATUS
3095 NTAPI
3096 RtlDecompressBuffer(
3097 _In_ USHORT CompressionFormat,
3098 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
3099 _In_ ULONG UncompressedBufferSize,
3100 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
3101 _In_ ULONG CompressedBufferSize,
3102 _Out_ PULONG FinalUncompressedSize
3103 );
3104
3105 NTSYSAPI
3106 NTSTATUS
3107 NTAPI
3108 RtlGetCompressionWorkSpaceSize(
3109 _In_ USHORT CompressionFormatAndEngine,
3110 _Out_ PULONG CompressBufferWorkSpaceSize,
3111 _Out_ PULONG CompressFragmentWorkSpaceSize
3112 );
3113
3114 //
3115 // Frame Functions
3116 //
3117 NTSYSAPI
3118 VOID
3119 NTAPI
3120 RtlPopFrame(
3121 _In_ PTEB_ACTIVE_FRAME Frame
3122 );
3123
3124 NTSYSAPI
3125 VOID
3126 NTAPI
3127 RtlPushFrame(
3128 _In_ PTEB_ACTIVE_FRAME Frame
3129 );
3130
3131 NTSYSAPI
3132 PTEB_ACTIVE_FRAME
3133 NTAPI
3134 RtlGetFrame(
3135 VOID
3136 );
3137
3138 //
3139 // Debug Info Functions
3140 //
3141 NTSYSAPI
3142 PRTL_DEBUG_INFORMATION
3143 NTAPI
3144 RtlCreateQueryDebugBuffer(
3145 _In_ ULONG Size,
3146 _In_ BOOLEAN EventPair
3147 );
3148
3149 NTSYSAPI
3150 NTSTATUS
3151 NTAPI
3152 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
3153
3154 NTSYSAPI
3155 NTSTATUS
3156 NTAPI
3157 RtlQueryProcessDebugInformation(
3158 _In_ ULONG ProcessId,
3159 _In_ ULONG DebugInfoClassMask,
3160 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3161 );
3162
3163 //
3164 // Bitmap Functions
3165 //
3166 NTSYSAPI
3167 BOOLEAN
3168 NTAPI
3169 RtlAreBitsClear(
3170 _In_ PRTL_BITMAP BitMapHeader,
3171 _In_ ULONG StartingIndex,
3172 _In_ ULONG Length
3173 );
3174
3175 NTSYSAPI
3176 BOOLEAN
3177 NTAPI
3178 RtlAreBitsSet(
3179 _In_ PRTL_BITMAP BitMapHeader,
3180 _In_ ULONG StartingIndex,
3181 _In_ ULONG Length
3182 );
3183
3184 NTSYSAPI
3185 VOID
3186 NTAPI
3187 RtlClearAllBits(
3188 _In_ PRTL_BITMAP BitMapHeader
3189 );
3190
3191 NTSYSAPI
3192 VOID
3193 NTAPI
3194 RtlClearBits(
3195 _In_ PRTL_BITMAP BitMapHeader,
3196 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3197 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3198 );
3199
3200 NTSYSAPI
3201 ULONG
3202 NTAPI
3203 RtlFindClearBits(
3204 _In_ PRTL_BITMAP BitMapHeader,
3205 _In_ ULONG NumberToFind,
3206 _In_ ULONG HintIndex
3207 );
3208
3209 NTSYSAPI
3210 ULONG
3211 NTAPI
3212 RtlFindClearBitsAndSet(
3213 _In_ PRTL_BITMAP BitMapHeader,
3214 _In_ ULONG NumberToFind,
3215 _In_ ULONG HintIndex
3216 );
3217
3218 NTSYSAPI
3219 ULONG
3220 NTAPI
3221 RtlFindFirstRunClear(
3222 _In_ PRTL_BITMAP BitMapHeader,
3223 _Out_ PULONG StartingIndex
3224 );
3225
3226 NTSYSAPI
3227 ULONG
3228 NTAPI
3229 RtlFindClearRuns(
3230 _In_ PRTL_BITMAP BitMapHeader,
3231 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray,
3232 _In_range_(>, 0) ULONG SizeOfRunArray,
3233 _In_ BOOLEAN LocateLongestRuns
3234 );
3235
3236 NTSYSAPI
3237 ULONG
3238 NTAPI
3239 RtlFindLastBackwardRunClear(
3240 _In_ PRTL_BITMAP BitMapHeader,
3241 _In_ ULONG FromIndex,
3242 _Out_ PULONG StartingRunIndex
3243 );
3244
3245 NTSYSAPI
3246 CCHAR
3247 NTAPI
3248 RtlFindLeastSignificantBit(
3249 _In_ ULONGLONG Value
3250 );
3251
3252 NTSYSAPI
3253 CCHAR
3254 NTAPI
3255 RtlFindMostSignificantBit(
3256 _In_ ULONGLONG Value
3257 );
3258
3259 NTSYSAPI
3260 ULONG
3261 NTAPI
3262 RtlFindNextForwardRunClear(
3263 _In_ PRTL_BITMAP BitMapHeader,
3264 _In_ ULONG FromIndex,
3265 _Out_ PULONG StartingRunIndex
3266 );
3267
3268 NTSYSAPI
3269 ULONG
3270 NTAPI
3271 RtlFindNextForwardRunSet(
3272 _In_ PRTL_BITMAP BitMapHeader,
3273 _In_ ULONG FromIndex,
3274 _Out_ PULONG StartingRunIndex
3275 );
3276
3277 NTSYSAPI
3278 ULONG
3279 NTAPI
3280 RtlFindSetBits(
3281 _In_ PRTL_BITMAP BitMapHeader,
3282 _In_ ULONG NumberToFind,
3283 _In_ ULONG HintIndex
3284 );
3285
3286 NTSYSAPI
3287 ULONG
3288 NTAPI
3289 RtlFindSetBitsAndClear(
3290 _In_ PRTL_BITMAP BitMapHeader,
3291 _In_ ULONG NumberToFind,
3292 _In_ ULONG HintIndex
3293 );
3294
3295 #ifdef _REACTOS_ // ReactOS improvement
3296 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3297 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3298 #endif
3299 NTSYSAPI
3300 VOID
3301 NTAPI
3302 RtlInitializeBitMap(
3303 _Out_ PRTL_BITMAP BitMapHeader,
3304 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3305 _In_opt_ ULONG SizeOfBitMap
3306 );
3307
3308 NTSYSAPI
3309 ULONG
3310 NTAPI
3311 RtlNumberOfClearBits(
3312 _In_ PRTL_BITMAP BitMapHeader
3313 );
3314
3315 NTSYSAPI
3316 ULONG
3317 NTAPI
3318 RtlNumberOfSetBits(
3319 _In_ PRTL_BITMAP BitMapHeader
3320 );
3321
3322 NTSYSAPI
3323 VOID
3324 NTAPI
3325 RtlSetBit(
3326 _In_ PRTL_BITMAP BitMapHeader,
3327 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3328 );
3329
3330 NTSYSAPI
3331 VOID
3332 NTAPI
3333 RtlSetBits(
3334 _In_ PRTL_BITMAP BitMapHeader,
3335 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3336 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3337 );
3338
3339 NTSYSAPI
3340 VOID
3341 NTAPI
3342 RtlSetAllBits(
3343 _In_ PRTL_BITMAP BitMapHeader
3344 );
3345
3346 _Must_inspect_result_
3347 NTSYSAPI
3348 BOOLEAN
3349 NTAPI
3350 RtlTestBit(
3351 _In_ PRTL_BITMAP BitMapHeader,
3352 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3353 );
3354
3355 //
3356 // Timer Functions
3357 //
3358 NTSYSAPI
3359 NTSTATUS
3360 NTAPI
3361 RtlCreateTimer(
3362 _In_ HANDLE TimerQueue,
3363 _In_ PHANDLE phNewTimer,
3364 _In_ WAITORTIMERCALLBACKFUNC Callback,
3365 _In_ PVOID Parameter,
3366 _In_ ULONG DueTime,
3367 _In_ ULONG Period,
3368 _In_ ULONG Flags
3369 );
3370
3371 NTSYSAPI
3372 NTSTATUS
3373 NTAPI
3374 RtlCreateTimerQueue(PHANDLE TimerQueue);
3375
3376 NTSYSAPI
3377 NTSTATUS
3378 NTAPI
3379 RtlDeleteTimer(
3380 _In_ HANDLE TimerQueue,
3381 _In_ HANDLE Timer,
3382 _In_ HANDLE CompletionEvent
3383 );
3384
3385 NTSYSAPI
3386 NTSTATUS
3387 NTAPI
3388 RtlUpdateTimer(
3389 _In_ HANDLE TimerQueue,
3390 _In_ HANDLE Timer,
3391 _In_ ULONG DueTime,
3392 _In_ ULONG Period
3393 );
3394
3395 NTSYSAPI
3396 NTSTATUS
3397 NTAPI
3398 RtlDeleteTimerQueueEx(
3399 _In_ HANDLE TimerQueue,
3400 _In_opt_ HANDLE CompletionEvent
3401 );
3402
3403 NTSYSAPI
3404 NTSTATUS
3405 NTAPI
3406 RtlDeleteTimerQueue(HANDLE TimerQueue);
3407
3408 //
3409 // SList functions
3410 //
3411 PSLIST_ENTRY
3412 FASTCALL
3413 InterlockedPushListSList(
3414 _Inout_ PSLIST_HEADER ListHead,
3415 _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
3416 _Inout_ PSLIST_ENTRY ListEnd,
3417 _In_ ULONG Count
3418 );
3419
3420 //
3421 // Range List functions
3422 //
3423 NTSYSAPI
3424 VOID
3425 NTAPI
3426 RtlInitializeRangeList(
3427 _Inout_ PRTL_RANGE_LIST RangeList
3428 );
3429
3430 NTSYSAPI
3431 VOID
3432 NTAPI
3433 RtlFreeRangeList(
3434 _In_ PRTL_RANGE_LIST RangeList
3435 );
3436
3437 NTSYSAPI
3438 NTSTATUS
3439 NTAPI
3440 RtlAddRange(
3441 _Inout_ PRTL_RANGE_LIST RangeList,
3442 _In_ ULONGLONG Start,
3443 _In_ ULONGLONG End,
3444 _In_ UCHAR Attributes,
3445 _In_ ULONG Flags,
3446 _In_opt_ PVOID UserData,
3447 _In_opt_ PVOID Owner
3448 );
3449
3450 //
3451 // Debug Functions
3452 //
3453 ULONG
3454 __cdecl
3455 DbgPrint(
3456 _In_z_ _Printf_format_string_ PCSTR Format,
3457 ...
3458 );
3459
3460 NTSYSAPI
3461 ULONG
3462 __cdecl
3463 DbgPrintEx(
3464 _In_ ULONG ComponentId,
3465 _In_ ULONG Level,
3466 _In_z_ _Printf_format_string_ PCSTR Format,
3467 ...
3468 );
3469
3470 NTSYSAPI
3471 ULONG
3472 NTAPI
3473 DbgPrompt(
3474 _In_z_ PCCH Prompt,
3475 _Out_writes_bytes_(MaximumResponseLength) PCH Response,
3476 _In_ ULONG MaximumResponseLength
3477 );
3478
3479 #undef DbgBreakPoint
3480 VOID
3481 NTAPI
3482 DbgBreakPoint(
3483 VOID
3484 );
3485
3486 VOID
3487 NTAPI
3488 DbgLoadImageSymbols(
3489 _In_ PSTRING Name,
3490 _In_ PVOID Base,
3491 _In_ ULONG_PTR ProcessId
3492 );
3493
3494 VOID
3495 NTAPI
3496 DbgUnLoadImageSymbols(
3497 _In_ PSTRING Name,
3498 _In_ PVOID Base,
3499 _In_ ULONG_PTR ProcessId
3500 );
3501
3502 VOID
3503 NTAPI
3504 DbgCommandString(
3505 _In_ PCCH Name,
3506 _In_ PCCH Command
3507 );
3508
3509 //
3510 // Generic Table Functions
3511 //
3512 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3513 NTSYSAPI
3514 PVOID
3515 NTAPI
3516 RtlInsertElementGenericTable(
3517 _In_ PRTL_GENERIC_TABLE Table,
3518 _In_reads_bytes_(BufferSize) PVOID Buffer,
3519 _In_ CLONG BufferSize,
3520 _Out_opt_ PBOOLEAN NewElement
3521 );
3522
3523 NTSYSAPI
3524 PVOID
3525 NTAPI
3526 RtlInsertElementGenericTableFull(
3527 _In_ PRTL_GENERIC_TABLE Table,
3528 _In_reads_bytes_(BufferSize) PVOID Buffer,
3529 _In_ CLONG BufferSize,
3530 _Out_opt_ PBOOLEAN NewElement,
3531 _In_ PVOID NodeOrParent,
3532 _In_ TABLE_SEARCH_RESULT SearchResult
3533 );
3534
3535 NTSYSAPI
3536 BOOLEAN
3537 NTAPI
3538 RtlIsGenericTableEmpty(
3539 _In_ PRTL_GENERIC_TABLE Table
3540 );
3541
3542 NTSYSAPI
3543 PVOID
3544 NTAPI
3545 RtlLookupElementGenericTableFull(
3546 _In_ PRTL_GENERIC_TABLE Table,
3547 _In_ PVOID Buffer,
3548 _Out_ PVOID *NodeOrParent,
3549 _Out_ TABLE_SEARCH_RESULT *SearchResult
3550 );
3551 #endif
3552
3553 //
3554 // Handle Table Functions
3555 //
3556 NTSYSAPI
3557 PRTL_HANDLE_TABLE_ENTRY
3558 NTAPI
3559 RtlAllocateHandle(
3560 _In_ PRTL_HANDLE_TABLE HandleTable,
3561 _Inout_ PULONG Index
3562 );
3563
3564 NTSYSAPI
3565 VOID
3566 NTAPI
3567 RtlDestroyHandleTable(
3568 _Inout_ PRTL_HANDLE_TABLE HandleTable);
3569
3570 NTSYSAPI
3571 BOOLEAN
3572 NTAPI
3573 RtlFreeHandle(
3574 _In_ PRTL_HANDLE_TABLE HandleTable,
3575 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3576 );
3577
3578 NTSYSAPI
3579 VOID
3580 NTAPI
3581 RtlInitializeHandleTable(
3582 _In_ ULONG TableSize,
3583 _In_ ULONG HandleSize,
3584 _In_ PRTL_HANDLE_TABLE HandleTable
3585 );
3586
3587 NTSYSAPI
3588 BOOLEAN
3589 NTAPI
3590 RtlIsValidHandle(
3591 _In_ PRTL_HANDLE_TABLE HandleTable,
3592 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3593 );
3594
3595 _Success_(return!=FALSE)
3596 NTSYSAPI
3597 BOOLEAN
3598 NTAPI
3599 RtlIsValidIndexHandle(
3600 _In_ PRTL_HANDLE_TABLE HandleTable,
3601 _In_ ULONG Index,
3602 _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle
3603 );
3604
3605 //
3606 // PE Functions
3607 //
3608 NTSYSAPI
3609 NTSTATUS
3610 NTAPI
3611 RtlFindMessage(
3612 _In_ PVOID BaseAddress,
3613 _In_ ULONG Type,
3614 _In_ ULONG Language,
3615 _In_ ULONG MessageId,
3616 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3617 );
3618
3619 NTSYSAPI
3620 ULONG
3621 NTAPI
3622 RtlGetNtGlobalFlags(VOID);
3623
3624 _Success_(return!=NULL)
3625 NTSYSAPI
3626 PVOID
3627 NTAPI
3628 RtlImageDirectoryEntryToData(
3629 _In_ PVOID BaseAddress,
3630 _In_ BOOLEAN MappedAsImage,
3631 _In_ USHORT Directory,
3632 _Out_ PULONG Size
3633 );
3634
3635 NTSYSAPI
3636 PVOID
3637 NTAPI
3638 RtlImageRvaToVa(
3639 _In_ PIMAGE_NT_HEADERS NtHeader,
3640 _In_ PVOID BaseAddress,
3641 _In_ ULONG Rva,
3642 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3643 );
3644
3645 NTSYSAPI
3646 PIMAGE_NT_HEADERS
3647 NTAPI
3648 RtlImageNtHeader(
3649 _In_ PVOID BaseAddress);
3650
3651 NTSYSAPI
3652 NTSTATUS
3653 NTAPI
3654 RtlImageNtHeaderEx(
3655 _In_ ULONG Flags,
3656 _In_ PVOID BaseAddress,
3657 _In_ ULONGLONG Size,
3658 _Out_ PIMAGE_NT_HEADERS *NtHeader
3659 );
3660
3661 NTSYSAPI
3662 PIMAGE_SECTION_HEADER
3663 NTAPI
3664 RtlImageRvaToSection(
3665 _In_ PIMAGE_NT_HEADERS NtHeader,
3666 _In_ PVOID BaseAddress,
3667 _In_ ULONG Rva
3668 );
3669
3670 NTSYSAPI
3671 ULONG
3672 NTAPI
3673 LdrRelocateImageWithBias(
3674 _In_ PVOID NewAddress,
3675 _In_ LONGLONG AdditionalBias,
3676 _In_ PCCH LoaderName,
3677 _In_ ULONG Success,
3678 _In_ ULONG Conflict,
3679 _In_ ULONG Invalid
3680 );
3681
3682 //
3683 // Activation Context Functions
3684 //
3685 #ifdef NTOS_MODE_USER
3686 NTSYSAPI
3687 NTSTATUS
3688 NTAPI
3689 RtlActivateActivationContextEx(
3690 _In_ ULONG Flags,
3691 _In_ PTEB Teb,
3692 _In_ PVOID Context,
3693 _Out_ PULONG_PTR Cookie
3694 );
3695
3696 NTSYSAPI
3697 NTSTATUS
3698 NTAPI
3699 RtlActivateActivationContext(
3700 _In_ ULONG Flags,
3701 _In_ HANDLE Handle,
3702 _Out_ PULONG_PTR Cookie
3703 );
3704
3705 NTSYSAPI
3706 VOID
3707 NTAPI
3708 RtlAddRefActivationContext(
3709 _In_ PVOID Context
3710 );
3711
3712 NTSYSAPI
3713 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3714 FASTCALL
3715 RtlActivateActivationContextUnsafeFast(
3716 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
3717 _In_ PVOID Context
3718 );
3719
3720 NTSYSAPI
3721 NTSTATUS
3722 NTAPI
3723 RtlAllocateActivationContextStack(
3724 _In_ PACTIVATION_CONTEXT_STACK *Stack
3725 );
3726
3727 NTSYSAPI
3728 NTSTATUS
3729 NTAPI
3730 RtlCreateActivationContext(
3731 _In_ ULONG Flags,
3732 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
3733 _In_ ULONG ExtraBytes,
3734 _In_ PVOID NotificationRoutine,
3735 _In_ PVOID NotificationContext,
3736 _Out_ PACTIVATION_CONTEXT *ActCtx
3737 );
3738
3739 NTSYSAPI
3740 NTSTATUS
3741 NTAPI
3742 RtlGetActiveActivationContext(
3743 _In_ PVOID *Context
3744 );
3745
3746 NTSYSAPI
3747 VOID
3748 NTAPI
3749 RtlReleaseActivationContext(
3750 _In_ HANDLE handle
3751 );
3752
3753 NTSYSAPI
3754 NTSTATUS
3755 NTAPI
3756 RtlDeactivateActivationContext(
3757 _In_ ULONG dwFlags,
3758 _In_ ULONG_PTR ulCookie
3759 );
3760
3761 NTSYSAPI
3762 VOID
3763 NTAPI
3764 RtlFreeActivationContextStack(
3765 _In_ PACTIVATION_CONTEXT_STACK Stack
3766 );
3767
3768 NTSYSAPI
3769 VOID
3770 NTAPI
3771 RtlFreeThreadActivationContextStack(VOID);
3772
3773 NTSYSAPI
3774 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3775 FASTCALL
3776 RtlDeactivateActivationContextUnsafeFast(
3777 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3778 );
3779
3780 NTSYSAPI
3781 NTSTATUS
3782 NTAPI
3783 RtlDosApplyFileIsolationRedirection_Ustr(
3784 _In_ ULONG Flags,
3785 _In_ PUNICODE_STRING OriginalName,
3786 _In_ PUNICODE_STRING Extension,
3787 _Inout_ PUNICODE_STRING StaticString,
3788 _Inout_ PUNICODE_STRING DynamicString,
3789 _Inout_ PUNICODE_STRING *NewName,
3790 _In_ PULONG NewFlags,
3791 _In_ PSIZE_T FileNameSize,
3792 _In_ PSIZE_T RequiredLength
3793 );
3794
3795 NTSYSAPI
3796 NTSTATUS
3797 NTAPI
3798 RtlFindActivationContextSectionString(
3799 _In_ ULONG dwFlags,
3800 _In_ const GUID *ExtensionGuid,
3801 _In_ ULONG SectionType,
3802 _In_ const UNICODE_STRING *SectionName,
3803 _Inout_ PVOID ReturnedData
3804 );
3805
3806 NTSYSAPI
3807 NTSTATUS
3808 NTAPI
3809 RtlQueryInformationActivationContext(
3810 _In_ DWORD dwFlags,
3811 _In_opt_ PVOID Context,
3812 _In_opt_ PVOID pvSubInstance,
3813 _In_ ULONG ulInfoClass,
3814 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3815 _In_opt_ SIZE_T cbBuffer,
3816 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3817 );
3818
3819 NTSYSAPI
3820 NTSTATUS
3821 NTAPI
3822 RtlQueryInformationActiveActivationContext(
3823 _In_ ULONG ulInfoClass,
3824 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3825 _In_opt_ SIZE_T cbBuffer,
3826 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3827 );
3828
3829 NTSYSAPI
3830 NTSTATUS
3831 NTAPI
3832 RtlZombifyActivationContext(
3833 PVOID Context
3834 );
3835
3836 //
3837 // WOW64 Functions
3838 //
3839 NTSYSAPI
3840 NTSTATUS
3841 NTAPI
3842 RtlWow64EnableFsRedirection(
3843 _In_ BOOLEAN Wow64FsEnableRedirection
3844 );
3845
3846 NTSYSAPI
3847 NTSTATUS
3848 NTAPI
3849 RtlWow64EnableFsRedirectionEx(
3850 _In_ PVOID Wow64FsEnableRedirection,
3851 _Out_ PVOID *OldFsRedirectionLevel
3852 );
3853
3854 #endif
3855
3856 //
3857 // Registry Functions
3858 //
3859 _IRQL_requires_max_(PASSIVE_LEVEL)
3860 _Must_inspect_result_
3861 NTSYSAPI
3862 NTSTATUS
3863 NTAPI
3864 RtlCheckRegistryKey(
3865 _In_ ULONG RelativeTo,
3866 _In_ PWSTR Path
3867 );
3868
3869 NTSYSAPI
3870 NTSTATUS
3871 NTAPI
3872 RtlCreateRegistryKey(
3873 _In_ ULONG RelativeTo,
3874 _In_ PWSTR Path
3875 );
3876
3877 NTSYSAPI
3878 NTSTATUS
3879 NTAPI
3880 RtlFormatCurrentUserKeyPath(
3881 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
3882 PUNICODE_STRING KeyPath
3883 );
3884
3885 NTSYSAPI
3886 NTSTATUS
3887 NTAPI
3888 RtlOpenCurrentUser(
3889 _In_ ACCESS_MASK DesiredAccess,
3890 _Out_ PHANDLE KeyHandle
3891 );
3892
3893 _IRQL_requires_max_(PASSIVE_LEVEL)
3894 NTSYSAPI
3895 NTSTATUS
3896 NTAPI
3897 RtlQueryRegistryValues(
3898 _In_ ULONG RelativeTo,
3899 _In_ PCWSTR Path,
3900 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
3901 PRTL_QUERY_REGISTRY_TABLE QueryTable,
3902 _In_opt_ PVOID Context,
3903 _In_opt_ PVOID Environment
3904 );
3905
3906 _IRQL_requires_max_(PASSIVE_LEVEL)
3907 NTSYSAPI
3908 NTSTATUS
3909 NTAPI
3910 RtlWriteRegistryValue(
3911 _In_ ULONG RelativeTo,
3912 _In_ PCWSTR Path,
3913 _In_z_ PCWSTR ValueName,
3914 _In_ ULONG ValueType,
3915 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
3916 _In_ ULONG ValueLength
3917 );
3918
3919 #ifdef NTOS_MODE_USER
3920 NTSYSAPI
3921 NTSTATUS
3922 NTAPI
3923 RtlpNtCreateKey(
3924 _Out_ HANDLE KeyHandle,
3925 _In_ ACCESS_MASK DesiredAccess,
3926 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3927 _In_ ULONG TitleIndex,
3928 _In_ PUNICODE_STRING Class,
3929 _Out_ PULONG Disposition
3930 );
3931
3932 NTSYSAPI
3933 NTSTATUS
3934 NTAPI
3935 RtlpNtEnumerateSubKey(
3936 _In_ HANDLE KeyHandle,
3937 _Inout_ PUNICODE_STRING SubKeyName,
3938 _In_ ULONG Index,
3939 _In_ ULONG Unused
3940 );
3941
3942 NTSYSAPI
3943 NTSTATUS
3944 NTAPI
3945 RtlpNtMakeTemporaryKey(
3946 _In_ HANDLE KeyHandle
3947 );
3948
3949 NTSYSAPI
3950 NTSTATUS
3951 NTAPI
3952 RtlpNtOpenKey(
3953 _Out_ HANDLE KeyHandle,
3954 _In_ ACCESS_MASK DesiredAccess,
3955 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3956 _In_ ULONG Unused
3957 );
3958
3959 NTSYSAPI
3960 NTSTATUS
3961 NTAPI
3962 RtlpNtQueryValueKey(
3963 _In_ HANDLE KeyHandle,
3964 _Out_opt_ PULONG Type,
3965 _Out_opt_ PVOID Data,
3966 _Inout_opt_ PULONG DataLength,
3967 _In_ ULONG Unused
3968 );
3969
3970 NTSYSAPI
3971 NTSTATUS
3972 NTAPI
3973 RtlpNtSetValueKey(
3974 _In_ HANDLE KeyHandle,
3975 _In_ ULONG Type,
3976 _In_ PVOID Data,
3977 _In_ ULONG DataLength
3978 );
3979 #endif
3980
3981 //
3982 // NLS Functions
3983 //
3984 NTSYSAPI
3985 VOID
3986 NTAPI
3987 RtlGetDefaultCodePage(
3988 _Out_ PUSHORT AnsiCodePage,
3989 _Out_ PUSHORT OemCodePage
3990 );
3991
3992 NTSYSAPI
3993 VOID
3994 NTAPI
3995 RtlInitNlsTables(
3996 _In_ PUSHORT AnsiTableBase,
3997 _In_ PUSHORT OemTableBase,
3998 _In_ PUSHORT CaseTableBase,
3999 _Out_ PNLSTABLEINFO NlsTable
4000 );
4001
4002 _IRQL_requires_max_(PASSIVE_LEVEL)
4003 NTSYSAPI
4004 VOID
4005 NTAPI
4006 RtlInitCodePageTable(
4007 _In_ PUSHORT TableBase,
4008 _Out_ PCPTABLEINFO CodePageTable