[NTDLL]
[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 NTSYSAPI
1052 SIZE_T
1053 NTAPI
1054 RtlSizeHeap(
1055 _In_ PVOID HeapHandle,
1056 _In_ ULONG Flags,
1057 _In_ PVOID MemoryPointer
1058 );
1059
1060
1061 //
1062 // Security Functions
1063 //
1064 _IRQL_requires_max_(APC_LEVEL)
1065 NTSYSAPI
1066 NTSTATUS
1067 NTAPI
1068 RtlAbsoluteToSelfRelativeSD(
1069 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1070 _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1071 _Inout_ PULONG BufferLength
1072 );
1073
1074 _IRQL_requires_max_(APC_LEVEL)
1075 NTSYSAPI
1076 NTSTATUS
1077 NTAPI
1078 RtlAddAccessAllowedAce(
1079 _Inout_ PACL Acl,
1080 _In_ ULONG Revision,
1081 _In_ ACCESS_MASK AccessMask,
1082 _In_ PSID Sid
1083 );
1084
1085 _IRQL_requires_max_(APC_LEVEL)
1086 NTSYSAPI
1087 NTSTATUS
1088 NTAPI
1089 RtlAddAccessAllowedAceEx(
1090 _Inout_ PACL pAcl,
1091 _In_ ULONG dwAceRevision,
1092 _In_ ULONG AceFlags,
1093 _In_ ACCESS_MASK AccessMask,
1094 _In_ PSID pSid
1095 );
1096
1097 NTSYSAPI
1098 NTSTATUS
1099 NTAPI
1100 RtlAddAccessAllowedObjectAce(
1101 _Inout_ PACL pAcl,
1102 _In_ ULONG dwAceRevision,
1103 _In_ ULONG AceFlags,
1104 _In_ ACCESS_MASK AccessMask,
1105 _In_opt_ GUID *ObjectTypeGuid,
1106 _In_opt_ GUID *InheritedObjectTypeGuid,
1107 _In_ PSID pSid
1108 );
1109
1110 NTSYSAPI
1111 NTSTATUS
1112 NTAPI
1113 RtlAddAccessDeniedAce(
1114 _Inout_ PACL Acl,
1115 _In_ ULONG Revision,
1116 _In_ ACCESS_MASK AccessMask,
1117 _In_ PSID Sid
1118 );
1119
1120 NTSYSAPI
1121 NTSTATUS
1122 NTAPI
1123 RtlAddAccessDeniedAceEx(
1124 _Inout_ PACL Acl,
1125 _In_ ULONG Revision,
1126 _In_ ULONG Flags,
1127 _In_ ACCESS_MASK AccessMask,
1128 _In_ PSID Sid
1129 );
1130
1131 NTSYSAPI
1132 NTSTATUS
1133 NTAPI
1134 RtlAddAccessDeniedObjectAce(
1135 _Inout_ PACL pAcl,
1136 _In_ ULONG dwAceRevision,
1137 _In_ ULONG AceFlags,
1138 _In_ ACCESS_MASK AccessMask,
1139 _In_opt_ GUID *ObjectTypeGuid,
1140 _In_opt_ GUID *InheritedObjectTypeGuid,
1141 _In_ PSID pSid
1142 );
1143
1144 NTSYSAPI
1145 NTSTATUS
1146 NTAPI
1147 RtlAddAce(
1148 _Inout_ PACL Acl,
1149 _In_ ULONG AceRevision,
1150 _In_ ULONG StartingAceIndex,
1151 _In_reads_bytes_(AceListLength) PVOID AceList,
1152 _In_ ULONG AceListLength
1153 );
1154
1155 NTSYSAPI
1156 NTSTATUS
1157 NTAPI
1158 RtlAddAuditAccessAce(
1159 _Inout_ PACL Acl,
1160 _In_ ULONG Revision,
1161 _In_ ACCESS_MASK AccessMask,
1162 _In_ PSID Sid,
1163 _In_ BOOLEAN Success,
1164 _In_ BOOLEAN Failure
1165 );
1166
1167 NTSYSAPI
1168 NTSTATUS
1169 NTAPI
1170 RtlAcquirePrivilege(
1171 _In_ PULONG Privilege,
1172 _In_ ULONG NumPriv,
1173 _In_ ULONG Flags,
1174 _Out_ PVOID *ReturnedState
1175 );
1176
1177 NTSYSAPI
1178 NTSTATUS
1179 NTAPI
1180 RtlAddAuditAccessAceEx(
1181 _Inout_ PACL Acl,
1182 _In_ ULONG Revision,
1183 _In_ ULONG Flags,
1184 _In_ ACCESS_MASK AccessMask,
1185 _In_ PSID Sid,
1186 _In_ BOOLEAN Success,
1187 _In_ BOOLEAN Failure
1188 );
1189
1190 NTSYSAPI
1191 NTSTATUS
1192 NTAPI
1193 RtlAddAuditAccessObjectAce(
1194 _Inout_ PACL Acl,
1195 _In_ ULONG Revision,
1196 _In_ ULONG Flags,
1197 _In_ ACCESS_MASK AccessMask,
1198 _In_opt_ GUID *ObjectTypeGuid,
1199 _In_opt_ GUID *InheritedObjectTypeGuid,
1200 _In_ PSID Sid,
1201 _In_ BOOLEAN Success,
1202 _In_ BOOLEAN Failure
1203 );
1204
1205 NTSYSAPI
1206 NTSTATUS
1207 NTAPI
1208 RtlAddMandatoryAce(
1209 _Inout_ PACL Acl,
1210 _In_ ULONG Revision,
1211 _In_ ULONG Flags,
1212 _In_ ULONG MandatoryFlags,
1213 _In_ UCHAR AceType,
1214 _In_ PSID LabelSid);
1215
1216 NTSYSAPI
1217 NTSTATUS
1218 NTAPI
1219 RtlAdjustPrivilege(
1220 _In_ ULONG Privilege,
1221 _In_ BOOLEAN NewValue,
1222 _In_ BOOLEAN ForThread,
1223 _Out_ PBOOLEAN OldValue
1224 );
1225
1226 _Must_inspect_result_
1227 NTSYSAPI
1228 NTSTATUS
1229 NTAPI
1230 RtlAllocateAndInitializeSid(
1231 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1232 _In_ UCHAR SubAuthorityCount,
1233 _In_ ULONG SubAuthority0,
1234 _In_ ULONG SubAuthority1,
1235 _In_ ULONG SubAuthority2,
1236 _In_ ULONG SubAuthority3,
1237 _In_ ULONG SubAuthority4,
1238 _In_ ULONG SubAuthority5,
1239 _In_ ULONG SubAuthority6,
1240 _In_ ULONG SubAuthority7,
1241 _Outptr_ PSID *Sid
1242 );
1243
1244 NTSYSAPI
1245 BOOLEAN
1246 NTAPI
1247 RtlAreAllAccessesGranted(
1248 ACCESS_MASK GrantedAccess,
1249 ACCESS_MASK DesiredAccess
1250 );
1251
1252 NTSYSAPI
1253 BOOLEAN
1254 NTAPI
1255 RtlAreAnyAccessesGranted(
1256 ACCESS_MASK GrantedAccess,
1257 ACCESS_MASK DesiredAccess
1258 );
1259
1260 _IRQL_requires_max_(APC_LEVEL)
1261 NTSYSAPI
1262 VOID
1263 NTAPI
1264 RtlCopyLuid (
1265 _Out_ PLUID DestinationLuid,
1266 _In_ PLUID SourceLuid
1267 );
1268
1269 NTSYSAPI
1270 VOID
1271 NTAPI
1272 RtlCopyLuidAndAttributesArray(
1273 ULONG Count,
1274 PLUID_AND_ATTRIBUTES Src,
1275 PLUID_AND_ATTRIBUTES Dest
1276 );
1277
1278 NTSYSAPI
1279 NTSTATUS
1280 NTAPI
1281 RtlCopySidAndAttributesArray(
1282 ULONG Count,
1283 PSID_AND_ATTRIBUTES Src,
1284 ULONG SidAreaSize,
1285 PSID_AND_ATTRIBUTES Dest,
1286 PVOID SidArea,
1287 PVOID* RemainingSidArea,
1288 PULONG RemainingSidAreaSize
1289 );
1290
1291 _IRQL_requires_max_(APC_LEVEL)
1292 NTSYSAPI
1293 NTSTATUS
1294 NTAPI
1295 RtlConvertSidToUnicodeString(
1296 _Inout_ PUNICODE_STRING UnicodeString,
1297 _In_ PSID Sid,
1298 _In_ BOOLEAN AllocateDestinationString
1299 );
1300
1301 _IRQL_requires_max_(APC_LEVEL)
1302 NTSYSAPI
1303 NTSTATUS
1304 NTAPI
1305 RtlCopySid(
1306 _In_ ULONG DestinationSidLength,
1307 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1308 _In_ PSID SourceSid
1309 );
1310
1311 NTSYSAPI
1312 NTSTATUS
1313 NTAPI
1314 RtlCreateAcl(
1315 PACL Acl,
1316 ULONG AclSize,
1317 ULONG AclRevision
1318 );
1319
1320 NTSYSAPI
1321 NTSTATUS
1322 NTAPI
1323 RtlCreateSecurityDescriptor(
1324 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1325 _In_ ULONG Revision
1326 );
1327
1328 NTSYSAPI
1329 NTSTATUS
1330 NTAPI
1331 RtlCreateSecurityDescriptorRelative(
1332 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
1333 _In_ ULONG Revision
1334 );
1335
1336 NTSYSAPI
1337 NTSTATUS
1338 NTAPI
1339 RtlCopySecurityDescriptor(
1340 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
1341 _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor
1342 );
1343
1344 NTSYSAPI
1345 NTSTATUS
1346 NTAPI
1347 RtlDeleteAce(
1348 PACL Acl,
1349 ULONG AceIndex
1350 );
1351
1352 NTSYSAPI
1353 BOOLEAN
1354 NTAPI
1355 RtlEqualPrefixSid(
1356 PSID Sid1,
1357 PSID Sid2
1358 );
1359
1360 NTSYSAPI
1361 BOOLEAN
1362 NTAPI
1363 RtlEqualSid (
1364 _In_ PSID Sid1,
1365 _In_ PSID Sid2
1366 );
1367
1368 NTSYSAPI
1369 BOOLEAN
1370 NTAPI
1371 RtlFirstFreeAce(
1372 PACL Acl,
1373 PACE* Ace
1374 );
1375
1376 NTSYSAPI
1377 PVOID
1378 NTAPI
1379 RtlFreeSid(
1380 _In_ _Post_invalid_ PSID Sid
1381 );
1382
1383 NTSYSAPI
1384 NTSTATUS
1385 NTAPI
1386 RtlGetAce(
1387 PACL Acl,
1388 ULONG AceIndex,
1389 PVOID *Ace
1390 );
1391
1392 NTSYSAPI
1393 NTSTATUS
1394 NTAPI
1395 RtlGetControlSecurityDescriptor(
1396 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1397 _Out_ PSECURITY_DESCRIPTOR_CONTROL Control,
1398 _Out_ PULONG Revision
1399 );
1400
1401 NTSYSAPI
1402 NTSTATUS
1403 NTAPI
1404 RtlGetDaclSecurityDescriptor(
1405 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1406 _Out_ PBOOLEAN DaclPresent,
1407 _Out_ PACL *Dacl,
1408 _Out_ PBOOLEAN DaclDefaulted
1409 );
1410
1411 NTSYSAPI
1412 NTSTATUS
1413 NTAPI
1414 RtlGetSaclSecurityDescriptor(
1415 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1416 _Out_ PBOOLEAN SaclPresent,
1417 _Out_ PACL* Sacl,
1418 _Out_ PBOOLEAN SaclDefaulted
1419 );
1420
1421 NTSYSAPI
1422 NTSTATUS
1423 NTAPI
1424 RtlGetGroupSecurityDescriptor(
1425 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1426 _Out_ PSID *Group,
1427 _Out_ PBOOLEAN GroupDefaulted
1428 );
1429
1430 NTSYSAPI
1431 NTSTATUS
1432 NTAPI
1433 RtlGetOwnerSecurityDescriptor(
1434 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1435 _Out_ PSID *Owner,
1436 _Out_ PBOOLEAN OwnerDefaulted
1437 );
1438
1439 NTSYSAPI
1440 BOOLEAN
1441 NTAPI
1442 RtlGetSecurityDescriptorRMControl(
1443 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1444 _Out_ PUCHAR RMControl
1445 );
1446
1447 NTSYSAPI
1448 PSID_IDENTIFIER_AUTHORITY
1449 NTAPI
1450 RtlIdentifierAuthoritySid(PSID Sid);
1451
1452 NTSYSAPI
1453 NTSTATUS
1454 NTAPI
1455 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
1456
1457 _IRQL_requires_max_(APC_LEVEL)
1458 NTSYSAPI
1459 NTSTATUS
1460 NTAPI
1461 RtlInitializeSid(
1462 _Out_ PSID Sid,
1463 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1464 _In_ UCHAR SubAuthorityCount
1465 );
1466
1467 NTSYSAPI
1468 ULONG
1469 NTAPI
1470 RtlLengthRequiredSid(IN ULONG SubAuthorityCount);
1471
1472 NTSYSAPI
1473 ULONG
1474 NTAPI
1475 RtlLengthSid(IN PSID Sid);
1476
1477 NTSYSAPI
1478 NTSTATUS
1479 NTAPI
1480 RtlMakeSelfRelativeSD(
1481 _In_ PSECURITY_DESCRIPTOR AbsoluteSD,
1482 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1483 _Inout_ PULONG BufferLength);
1484
1485 NTSYSAPI
1486 VOID
1487 NTAPI
1488 RtlMapGenericMask(
1489 PACCESS_MASK AccessMask,
1490 PGENERIC_MAPPING GenericMapping
1491 );
1492
1493 #ifdef NTOS_MODE_USER
1494
1495 NTSYSAPI
1496 NTSTATUS
1497 NTAPI
1498 RtlQueryInformationAcl(
1499 PACL Acl,
1500 PVOID Information,
1501 ULONG InformationLength,
1502 ACL_INFORMATION_CLASS InformationClass
1503 );
1504
1505 #endif
1506
1507 NTSYSAPI
1508 VOID
1509 NTAPI
1510 RtlReleasePrivilege(
1511 _In_ PVOID ReturnedState
1512 );
1513
1514 _IRQL_requires_max_(APC_LEVEL)
1515 NTSYSAPI
1516 NTSTATUS
1517 NTAPI
1518 RtlSelfRelativeToAbsoluteSD(
1519 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1520 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1521 _Inout_ PULONG AbsoluteSecurityDescriptorSize,
1522 _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl,
1523 _Inout_ PULONG DaclSize,
1524 _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl,
1525 _Inout_ PULONG SaclSize,
1526 _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner,
1527 _Inout_ PULONG OwnerSize,
1528 _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup,
1529 _Inout_ PULONG PrimaryGroupSize
1530 );
1531
1532 NTSYSAPI
1533 NTSTATUS
1534 NTAPI
1535 RtlSelfRelativeToAbsoluteSD2(
1536 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1537 _Out_ PULONG BufferSize
1538 );
1539
1540 NTSYSAPI
1541 NTSTATUS
1542 NTAPI
1543 RtlSetAttributesSecurityDescriptor(
1544 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1545 _In_ SECURITY_DESCRIPTOR_CONTROL Control,
1546 _Out_ PULONG Revision
1547 );
1548
1549 NTSYSAPI
1550 NTSTATUS
1551 NTAPI
1552 RtlSetControlSecurityDescriptor(
1553 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1554 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
1555 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1556 );
1557
1558 _IRQL_requires_max_(APC_LEVEL)
1559 NTSYSAPI
1560 NTSTATUS
1561 NTAPI
1562 RtlSetDaclSecurityDescriptor(
1563 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1564 _In_ BOOLEAN DaclPresent,
1565 _In_opt_ PACL Dacl,
1566 _In_opt_ BOOLEAN DaclDefaulted
1567 );
1568
1569 _IRQL_requires_max_(APC_LEVEL)
1570 NTSYSAPI
1571 NTSTATUS
1572 NTAPI
1573 RtlSetGroupSecurityDescriptor(
1574 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1575 _In_opt_ PSID Group,
1576 _In_opt_ BOOLEAN GroupDefaulted
1577 );
1578
1579 #ifdef NTOS_MODE_USER
1580
1581 NTSYSAPI
1582 NTSTATUS
1583 NTAPI
1584 RtlSetInformationAcl(
1585 PACL Acl,
1586 PVOID Information,
1587 ULONG InformationLength,
1588 ACL_INFORMATION_CLASS InformationClass
1589 );
1590
1591 #endif
1592
1593 _IRQL_requires_max_(APC_LEVEL)
1594 NTSYSAPI
1595 NTSTATUS
1596 NTAPI
1597 RtlSetOwnerSecurityDescriptor(
1598 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1599 _In_opt_ PSID Owner,
1600 _In_opt_ BOOLEAN OwnerDefaulted
1601 );
1602
1603 NTSYSAPI
1604 NTSTATUS
1605 NTAPI
1606 RtlSetSaclSecurityDescriptor(
1607 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1608 _In_ BOOLEAN SaclPresent,
1609 _In_ PACL Sacl,
1610 _In_ BOOLEAN SaclDefaulted
1611 );
1612
1613 NTSYSAPI
1614 VOID
1615 NTAPI
1616 RtlSetSecurityDescriptorRMControl(
1617 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1618 _In_ PUCHAR RMControl
1619 );
1620
1621 NTSYSAPI
1622 PUCHAR
1623 NTAPI
1624 RtlSubAuthorityCountSid(
1625 _In_ PSID Sid
1626 );
1627
1628 NTSYSAPI
1629 PULONG
1630 NTAPI
1631 RtlSubAuthoritySid(
1632 _In_ PSID Sid,
1633 _In_ ULONG SubAuthority
1634 );
1635
1636 _IRQL_requires_max_(APC_LEVEL)
1637 _Must_inspect_result_
1638 NTSYSAPI
1639 BOOLEAN
1640 NTAPI
1641 RtlValidRelativeSecurityDescriptor(
1642 _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput,
1643 _In_ ULONG SecurityDescriptorLength,
1644 _In_ SECURITY_INFORMATION RequiredInformation
1645 );
1646
1647 NTSYSAPI
1648 BOOLEAN
1649 NTAPI
1650 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
1651
1652 NTSYSAPI
1653 BOOLEAN
1654 NTAPI
1655 RtlValidSid(IN PSID Sid);
1656
1657 NTSYSAPI
1658 BOOLEAN
1659 NTAPI
1660 RtlValidAcl(PACL Acl);
1661
1662 NTSYSAPI
1663 NTSTATUS
1664 NTAPI
1665 RtlDeleteSecurityObject(
1666 _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor
1667 );
1668
1669 NTSYSAPI
1670 NTSTATUS
1671 NTAPI
1672 RtlNewSecurityObject(
1673 _In_ PSECURITY_DESCRIPTOR ParentDescriptor,
1674 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor,
1675 _Out_ PSECURITY_DESCRIPTOR *NewDescriptor,
1676 _In_ BOOLEAN IsDirectoryObject,
1677 _In_ HANDLE Token,
1678 _In_ PGENERIC_MAPPING GenericMapping
1679 );
1680
1681 NTSYSAPI
1682 NTSTATUS
1683 NTAPI
1684 RtlQuerySecurityObject(
1685 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor,
1686 _In_ SECURITY_INFORMATION SecurityInformation,
1687 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor,
1688 _In_ ULONG DescriptorLength,
1689 _Out_ PULONG ReturnLength
1690 );
1691
1692 NTSYSAPI
1693 NTSTATUS
1694 NTAPI
1695 RtlSetSecurityObject(
1696 _In_ SECURITY_INFORMATION SecurityInformation,
1697 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor,
1698 _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
1699 _In_ PGENERIC_MAPPING GenericMapping,
1700 _In_ HANDLE Token
1701 );
1702
1703 //
1704 // Single-Character Functions
1705 //
1706 NTSYSAPI
1707 NTSTATUS
1708 NTAPI
1709 RtlLargeIntegerToChar(
1710 _In_ PLARGE_INTEGER Value,
1711 _In_ ULONG Base,
1712 _In_ ULONG Length,
1713 _Out_ PCHAR String
1714 );
1715
1716 NTSYSAPI
1717 CHAR
1718 NTAPI
1719 RtlUpperChar(CHAR Source);
1720
1721 NTSYSAPI
1722 WCHAR
1723 NTAPI
1724 RtlUpcaseUnicodeChar(WCHAR Source);
1725
1726 NTSYSAPI
1727 WCHAR
1728 NTAPI
1729 RtlDowncaseUnicodeChar(IN WCHAR Source);
1730
1731 NTSYSAPI
1732 NTSTATUS
1733 NTAPI
1734 RtlIntegerToChar(
1735 _In_ ULONG Value,
1736 _In_ ULONG Base,
1737 _In_ ULONG Length,
1738 _Out_ PCHAR String
1739 );
1740
1741 NTSYSAPI
1742 NTSTATUS
1743 NTAPI
1744 RtlIntegerToUnicode(
1745 _In_ ULONG Value,
1746 _In_opt_ ULONG Base,
1747 _In_opt_ ULONG Length,
1748 _Inout_ LPWSTR String
1749 );
1750
1751 _IRQL_requires_max_(PASSIVE_LEVEL)
1752 _At_(String->MaximumLength, _Const_)
1753 NTSYSAPI
1754 NTSTATUS
1755 NTAPI
1756 RtlIntegerToUnicodeString(
1757 _In_ ULONG Value,
1758 _In_opt_ ULONG Base,
1759 _Inout_ PUNICODE_STRING String
1760 );
1761
1762 NTSYSAPI
1763 NTSTATUS
1764 NTAPI
1765 RtlCharToInteger(
1766 PCSZ String,
1767 ULONG Base,
1768 PULONG Value
1769 );
1770
1771 //
1772 // Byte Swap Functions
1773 //
1774 #ifdef NTOS_MODE_USER
1775
1776 unsigned short __cdecl _byteswap_ushort(unsigned short);
1777 unsigned long __cdecl _byteswap_ulong (unsigned long);
1778 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1779 #ifdef _MSC_VER
1780 #pragma intrinsic(_byteswap_ushort)
1781 #pragma intrinsic(_byteswap_ulong)
1782 #pragma intrinsic(_byteswap_uint64)
1783 #endif // _MSC_VER
1784 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1785 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1786 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1787
1788 #endif // NTOS_MODE_USER
1789
1790 //
1791 // Unicode->Ansi String Functions
1792 //
1793 NTSYSAPI
1794 ULONG
1795 NTAPI
1796 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
1797
1798 #ifdef NTOS_MODE_USER
1799
1800 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1801 NLS_MB_CODE_PAGE_TAG ? \
1802 RtlxUnicodeStringToAnsiSize(STRING) : \
1803 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1804 )
1805
1806 #endif
1807
1808 NTSYSAPI
1809 NTSTATUS
1810 NTAPI
1811 RtlUnicodeStringToAnsiString(
1812 PANSI_STRING DestinationString,
1813 PCUNICODE_STRING SourceString,
1814 BOOLEAN AllocateDestinationString
1815 );
1816
1817 //
1818 // Unicode->OEM String Functions
1819 //
1820 NTSYSAPI
1821 NTSTATUS
1822 NTAPI
1823 RtlUpcaseUnicodeStringToOemString(
1824 POEM_STRING DestinationString,
1825 PCUNICODE_STRING SourceString,
1826 BOOLEAN AllocateDestinationString
1827 );
1828
1829 _IRQL_requires_max_(PASSIVE_LEVEL)
1830 _Must_inspect_result_
1831 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1832 NTSYSAPI
1833 NTSTATUS
1834 NTAPI
1835 RtlUpcaseUnicodeStringToCountedOemString(
1836 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
1837 _When_(!AllocateDestinationString, _Inout_)
1838 POEM_STRING DestinationString,
1839 _In_ PCUNICODE_STRING SourceString,
1840 _In_ BOOLEAN AllocateDestinationString
1841 );
1842
1843 NTSYSAPI
1844 NTSTATUS
1845 NTAPI
1846 RtlUnicodeStringToOemString(
1847 POEM_STRING DestinationString,
1848 PCUNICODE_STRING SourceString,
1849 BOOLEAN AllocateDestinationString
1850 );
1851
1852 NTSYSAPI
1853 NTSTATUS
1854 NTAPI
1855 RtlUpcaseUnicodeToOemN(
1856 PCHAR OemString,
1857 ULONG OemSize,
1858 PULONG ResultSize,
1859 PCWCH UnicodeString,
1860 ULONG UnicodeSize
1861 );
1862
1863 NTSYSAPI
1864 ULONG
1865 NTAPI
1866 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
1867
1868 #ifdef NTOS_MODE_USER
1869
1870 #define RtlUnicodeStringToOemSize(STRING) ( \
1871 NLS_MB_OEM_CODE_PAGE_TAG ? \
1872 RtlxUnicodeStringToOemSize(STRING) : \
1873 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1874 )
1875
1876 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1877 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1878 )
1879
1880 #endif
1881
1882 NTSYSAPI
1883 NTSTATUS
1884 NTAPI
1885 RtlUnicodeToOemN(
1886 PCHAR OemString,
1887 ULONG OemSize,
1888 PULONG ResultSize,
1889 PCWCH UnicodeString,
1890 ULONG UnicodeSize
1891 );
1892
1893 //
1894 // Unicode->MultiByte String Functions
1895 //
1896 NTSYSAPI
1897 NTSTATUS
1898 NTAPI
1899 RtlUnicodeToMultiByteN(
1900 PCHAR MbString,
1901 ULONG MbSize,
1902 PULONG ResultSize,
1903 PCWCH UnicodeString,
1904 ULONG UnicodeSize
1905 );
1906
1907 NTSYSAPI
1908 NTSTATUS
1909 NTAPI
1910 RtlUpcaseUnicodeToMultiByteN(
1911 PCHAR MbString,
1912 ULONG MbSize,
1913 PULONG ResultSize,
1914 PCWCH UnicodeString,
1915 ULONG UnicodeSize
1916 );
1917
1918 NTSYSAPI
1919 NTSTATUS
1920 NTAPI
1921 RtlUnicodeToMultiByteSize(
1922 PULONG MbSize,
1923 PCWCH UnicodeString,
1924 ULONG UnicodeSize
1925 );
1926
1927 NTSYSAPI
1928 ULONG
1929 NTAPI
1930 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
1931
1932 //
1933 // OEM to Unicode Functions
1934 //
1935 NTSYSAPI
1936 NTSTATUS
1937 NTAPI
1938 RtlOemStringToUnicodeString(
1939 PUNICODE_STRING DestinationString,
1940 PCOEM_STRING SourceString,
1941 BOOLEAN AllocateDestinationString
1942 );
1943
1944 _IRQL_requires_max_(PASSIVE_LEVEL)
1945 NTSYSAPI
1946 NTSTATUS
1947 NTAPI
1948 RtlOemToUnicodeN(
1949 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
1950 _In_ ULONG MaxBytesInUnicodeString,
1951 _Out_opt_ PULONG BytesInUnicodeString,
1952 _In_reads_bytes_(BytesInOemString) PCCH OemString,
1953 _In_ ULONG BytesInOemString
1954 );
1955
1956 #ifdef NTOS_MODE_USER
1957
1958 #define RtlOemStringToUnicodeSize(STRING) ( \
1959 NLS_MB_OEM_CODE_PAGE_TAG ? \
1960 RtlxOemStringToUnicodeSize(STRING) : \
1961 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1962 )
1963
1964 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1965 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1966 )
1967
1968 #endif
1969
1970 //
1971 // Ansi->Unicode String Functions
1972 //
1973 _IRQL_requires_max_(APC_LEVEL)
1974 NTSYSAPI
1975 WCHAR
1976 NTAPI
1977 RtlAnsiCharToUnicodeChar(
1978 _Inout_ PUCHAR *SourceCharacter);
1979
1980 NTSYSAPI
1981 NTSTATUS
1982 NTAPI
1983 RtlAnsiStringToUnicodeString(
1984 PUNICODE_STRING DestinationString,
1985 PCANSI_STRING SourceString,
1986 BOOLEAN AllocateDestinationString
1987 );
1988
1989 NTSYSAPI
1990 ULONG
1991 NTAPI
1992 RtlxAnsiStringToUnicodeSize(
1993 PCANSI_STRING AnsiString
1994 );
1995
1996 #ifdef NTOS_MODE_USER
1997
1998 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1999 NLS_MB_CODE_PAGE_TAG ? \
2000 RtlxAnsiStringToUnicodeSize(STRING) : \
2001 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2002 )
2003
2004 #endif
2005
2006 NTSYSAPI
2007 BOOLEAN
2008 NTAPI
2009 RtlCreateUnicodeStringFromAsciiz(
2010 _Out_ PUNICODE_STRING Destination,
2011 _In_ PCSZ Source
2012 );
2013
2014 //
2015 // Unicode String Functions
2016 //
2017 NTSYSAPI
2018 NTSTATUS
2019 NTAPI
2020 RtlAppendUnicodeToString(
2021 PUNICODE_STRING Destination,
2022 PCWSTR Source
2023 );
2024
2025 NTSYSAPI
2026 NTSTATUS
2027 NTAPI
2028 RtlAppendUnicodeStringToString(
2029 PUNICODE_STRING Destination,
2030 PCUNICODE_STRING Source
2031 );
2032
2033 NTSYSAPI
2034 LONG
2035 NTAPI
2036 RtlCompareUnicodeString(
2037 PCUNICODE_STRING String1,
2038 PCUNICODE_STRING String2,
2039 BOOLEAN CaseInsensitive
2040 );
2041
2042 NTSYSAPI
2043 VOID
2044 NTAPI
2045 RtlCopyUnicodeString(
2046 PUNICODE_STRING DestinationString,
2047 PCUNICODE_STRING SourceString
2048 );
2049
2050 NTSYSAPI
2051 BOOLEAN
2052 NTAPI
2053 RtlCreateUnicodeString(
2054 PUNICODE_STRING DestinationString,
2055 PCWSTR SourceString
2056 );
2057
2058 #ifdef NTOS_MODE_USER
2059
2060 NTSYSAPI
2061 NTSTATUS
2062 NTAPI
2063 RtlDowncaseUnicodeString(
2064 _Inout_ PUNICODE_STRING UniDest,
2065 _In_ PCUNICODE_STRING UniSource,
2066 _In_ BOOLEAN AllocateDestinationString
2067 );
2068
2069 NTSYSAPI
2070 NTSTATUS
2071 NTAPI
2072 RtlDuplicateUnicodeString(
2073 _In_ ULONG Flags,
2074 _In_ PCUNICODE_STRING SourceString,
2075 _Out_ PUNICODE_STRING DestinationString
2076 );
2077
2078 //
2079 // Memory Functions
2080 //
2081 NTSYSAPI
2082 VOID
2083 NTAPI
2084 RtlFillMemoryUlong(
2085 _In_ PVOID Destination,
2086 _In_ SIZE_T Length,
2087 _In_ ULONG Fill
2088 );
2089
2090 NTSYSAPI
2091 VOID
2092 NTAPI
2093 RtlFillMemoryUlonglong(
2094 _Out_ PVOID Destination,
2095 _In_ SIZE_T Length,
2096 _In_ ULONGLONG Pattern
2097 );
2098
2099 NTSYSAPI
2100 NTSTATUS
2101 NTAPI
2102 RtlCopyMappedMemory(
2103 _Out_writes_bytes_all_(Size) PVOID Destination,
2104 _In_reads_bytes_(Size) const VOID *Source,
2105 _In_ SIZE_T Size
2106 );
2107
2108 NTSYSAPI
2109 SIZE_T
2110 NTAPI
2111 RtlCompareMemoryUlong(
2112 _In_ PVOID Source,
2113 _In_ SIZE_T Length,
2114 _In_ ULONG Pattern
2115 );
2116
2117 #ifndef RtlEqualMemory
2118 #define RtlEqualMemory(Destination, Source, Length) \
2119 (!memcmp(Destination, Source, Length))
2120 #endif
2121
2122 #define RtlCopyBytes RtlCopyMemory
2123 #define RtlFillBytes RtlFillMemory
2124 #define RtlZeroBytes RtlZeroMemory
2125
2126 #endif
2127
2128 NTSYSAPI
2129 BOOLEAN
2130 NTAPI
2131 RtlEqualUnicodeString(
2132 PCUNICODE_STRING String1,
2133 PCUNICODE_STRING String2,
2134 BOOLEAN CaseInsensitive
2135 );
2136
2137 NTSYSAPI
2138 NTSTATUS
2139 NTAPI
2140 RtlFindCharInUnicodeString(
2141 _In_ ULONG Flags,
2142 _In_ PCUNICODE_STRING SearchString,
2143 _In_ PCUNICODE_STRING MatchString,
2144 _Out_ PUSHORT Position
2145 );
2146
2147 _IRQL_requires_max_(PASSIVE_LEVEL)
2148 NTSYSAPI
2149 VOID
2150 NTAPI
2151 RtlFreeUnicodeString(
2152 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem))
2153 PUNICODE_STRING UnicodeString
2154 );
2155
2156 NTSYSAPI
2157 VOID
2158 NTAPI
2159 RtlEraseUnicodeString(
2160 _Inout_ PUNICODE_STRING String
2161 );
2162
2163 NTSYSAPI
2164 NTSTATUS
2165 NTAPI
2166 RtlHashUnicodeString(
2167 _In_ CONST UNICODE_STRING *String,
2168 _In_ BOOLEAN CaseInSensitive,
2169 _In_ ULONG HashAlgorithm,
2170 _Out_ PULONG HashValue
2171 );
2172
2173 _IRQL_requires_max_(DISPATCH_LEVEL)
2174 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2175 _When_(SourceString != NULL,
2176 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
2177 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR))))
2178 _When_(SourceString == NULL,
2179 _At_(DestinationString->Length, _Post_equal_to_(0))
2180 _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2181 NTSYSAPI
2182 VOID
2183 NTAPI
2184 RtlInitUnicodeString(
2185 _Out_ PUNICODE_STRING DestinationString,
2186 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2187 );
2188
2189 _IRQL_requires_max_(DISPATCH_LEVEL)
2190 NTSYSAPI
2191 NTSTATUS
2192 NTAPI
2193 RtlInitUnicodeStringEx(
2194 _Out_ PUNICODE_STRING DestinationString,
2195 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2196 );
2197
2198 NTSYSAPI
2199 BOOLEAN
2200 NTAPI
2201 RtlIsTextUnicode(
2202 PVOID Buffer,
2203 INT Length,
2204 INT *Flags
2205 );
2206
2207 _IRQL_requires_max_(PASSIVE_LEVEL)
2208 _Must_inspect_result_
2209 NTSYSAPI
2210 BOOLEAN
2211 NTAPI
2212 RtlPrefixString(
2213 _In_ const STRING *String1,
2214 _In_ const STRING *String2,
2215 _In_ BOOLEAN CaseInsensitive
2216 );
2217
2218 _IRQL_requires_max_(PASSIVE_LEVEL)
2219 _Must_inspect_result_
2220 NTSYSAPI
2221 BOOLEAN
2222 NTAPI
2223 RtlPrefixUnicodeString(
2224 _In_ PCUNICODE_STRING String1,
2225 _In_ PCUNICODE_STRING String2,
2226 _In_ BOOLEAN CaseInsensitive
2227 );
2228
2229 _IRQL_requires_max_(PASSIVE_LEVEL)
2230 NTSYSAPI
2231 VOID
2232 NTAPI
2233 RtlUpperString(
2234 _Inout_ PSTRING DestinationString,
2235 _In_ const STRING *SourceString
2236 );
2237
2238 _IRQL_requires_max_(PASSIVE_LEVEL)
2239 _Must_inspect_result_
2240 NTSYSAPI
2241 LONG
2242 NTAPI
2243 RtlCompareString(
2244 _In_ const STRING *String1,
2245 _In_ const STRING *String2,
2246 _In_ BOOLEAN CaseInSensitive
2247 );
2248
2249 NTSYSAPI
2250 VOID
2251 NTAPI
2252 RtlCopyString(
2253 _Out_ PSTRING DestinationString,
2254 _In_opt_ const STRING *SourceString
2255 );
2256
2257 _IRQL_requires_max_(PASSIVE_LEVEL)
2258 _Must_inspect_result_
2259 NTSYSAPI
2260 BOOLEAN
2261 NTAPI
2262 RtlEqualString(
2263 _In_ const STRING *String1,
2264 _In_ const STRING *String2,
2265 _In_ BOOLEAN CaseInSensitive
2266 );
2267
2268 _IRQL_requires_max_(APC_LEVEL)
2269 NTSYSAPI
2270 NTSTATUS
2271 NTAPI
2272 RtlAppendStringToString(
2273 _Inout_ PSTRING Destination,
2274 _In_ const STRING *Source
2275 );
2276
2277 _IRQL_requires_max_(PASSIVE_LEVEL)
2278 _When_(AllocateDestinationString, _Must_inspect_result_)
2279 NTSYSAPI
2280 NTSTATUS
2281 NTAPI
2282 RtlUpcaseUnicodeString(
2283 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
2284 _When_(!AllocateDestinationString, _Inout_)
2285 PUNICODE_STRING DestinationString,
2286 _In_ PCUNICODE_STRING SourceString,
2287 _In_ BOOLEAN AllocateDestinationString
2288 );
2289
2290 _IRQL_requires_max_(PASSIVE_LEVEL)
2291 NTSYSAPI
2292 NTSTATUS
2293 NTAPI
2294 RtlUnicodeStringToInteger(
2295 _In_ PCUNICODE_STRING String,
2296 _In_opt_ ULONG Base,
2297 _Out_ PULONG Value
2298 );
2299
2300 NTSYSAPI
2301 NTSTATUS
2302 NTAPI
2303 RtlValidateUnicodeString(
2304 _In_ ULONG Flags,
2305 _In_ PCUNICODE_STRING String
2306 );
2307
2308 //
2309 // Ansi String Functions
2310 //
2311 _IRQL_requires_max_(PASSIVE_LEVEL)
2312 NTSYSAPI
2313 VOID
2314 NTAPI
2315 RtlFreeAnsiString(
2316 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2317 PANSI_STRING AnsiString
2318 );
2319
2320 _IRQL_requires_max_(DISPATCH_LEVEL)
2321 NTSYSAPI
2322 VOID
2323 NTAPI
2324 RtlInitAnsiString(
2325 _Out_ PANSI_STRING DestinationString,
2326 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2327 );
2328
2329 _IRQL_requires_max_(DISPATCH_LEVEL)
2330 NTSYSAPI
2331 NTSTATUS
2332 NTAPI
2333 RtlInitAnsiStringEx(
2334 _Out_ PANSI_STRING DestinationString,
2335 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2336 );
2337
2338 //
2339 // OEM String Functions
2340 //
2341 _IRQL_requires_max_(PASSIVE_LEVEL)
2342 NTSYSAPI
2343 VOID
2344 NTAPI
2345 RtlFreeOemString(
2346 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2347 POEM_STRING OemString
2348 );
2349
2350 //
2351 // MultiByte->Unicode String Functions
2352 //
2353 _IRQL_requires_max_(PASSIVE_LEVEL)
2354 NTSYSAPI
2355 NTSTATUS
2356 NTAPI
2357 RtlMultiByteToUnicodeN(
2358 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2359 _In_ ULONG MaxBytesInUnicodeString,
2360 _Out_opt_ PULONG BytesInUnicodeString,
2361 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2362 _In_ ULONG BytesInMultiByteString
2363 );
2364
2365 _IRQL_requires_max_(PASSIVE_LEVEL)
2366 NTSYSAPI
2367 NTSTATUS
2368 NTAPI
2369 RtlMultiByteToUnicodeSize(
2370 _Out_ PULONG BytesInUnicodeString,
2371 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2372 _In_ ULONG BytesInMultiByteString
2373 );
2374
2375 //
2376 // Atom Functions
2377 //
2378 NTSYSAPI
2379 NTSTATUS
2380 NTAPI
2381 RtlAddAtomToAtomTable(
2382 _In_ PRTL_ATOM_TABLE AtomTable,
2383 _In_ PWSTR AtomName,
2384 _Out_ PRTL_ATOM Atom
2385 );
2386
2387 NTSYSAPI
2388 NTSTATUS
2389 NTAPI
2390 RtlCreateAtomTable(
2391 _In_ ULONG TableSize,
2392 _Inout_ PRTL_ATOM_TABLE *AtomTable
2393 );
2394
2395 NTSYSAPI
2396 NTSTATUS
2397 NTAPI
2398 RtlDeleteAtomFromAtomTable(
2399 _In_ PRTL_ATOM_TABLE AtomTable,
2400 _In_ RTL_ATOM Atom
2401 );
2402
2403 NTSYSAPI
2404 NTSTATUS
2405 NTAPI
2406 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
2407
2408 NTSYSAPI
2409 NTSTATUS
2410 NTAPI
2411 RtlQueryAtomInAtomTable(
2412 _In_ PRTL_ATOM_TABLE AtomTable,
2413 _In_ RTL_ATOM Atom,
2414 _Out_opt_ PULONG RefCount,
2415 _Out_opt_ PULONG PinCount,
2416 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2417 _Inout_opt_ PULONG NameLength
2418 );
2419
2420 NTSYSAPI
2421 NTSTATUS
2422 NTAPI
2423 RtlPinAtomInAtomTable(
2424 _In_ PRTL_ATOM_TABLE AtomTable,
2425 _In_ RTL_ATOM Atom
2426 );
2427
2428 NTSYSAPI
2429 NTSTATUS
2430 NTAPI
2431 RtlLookupAtomInAtomTable(
2432 _In_ PRTL_ATOM_TABLE AtomTable,
2433 _In_ PWSTR AtomName,
2434 _Out_ PRTL_ATOM Atom
2435 );
2436
2437 //
2438 // Process Management Functions
2439 //
2440 NTSYSAPI
2441 PPEB
2442 NTAPI
2443 RtlGetCurrentPeb(
2444 VOID
2445 );
2446
2447 NTSYSAPI
2448 VOID
2449 NTAPI
2450 RtlAcquirePebLock(VOID);
2451
2452 NTSYSAPI
2453 NTSTATUS
2454 NTAPI
2455 RtlCreateProcessParameters (
2456 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2457 _In_ PUNICODE_STRING ImagePathName,
2458 _In_opt_ PUNICODE_STRING DllPath,
2459 _In_opt_ PUNICODE_STRING CurrentDirectory,
2460 _In_opt_ PUNICODE_STRING CommandLine,
2461 _In_opt_ PWSTR Environment,
2462 _In_opt_ PUNICODE_STRING WindowTitle,
2463 _In_opt_ PUNICODE_STRING DesktopInfo,
2464 _In_opt_ PUNICODE_STRING ShellInfo,
2465 _In_opt_ PUNICODE_STRING RuntimeInfo
2466 );
2467
2468 NTSYSAPI
2469 NTSTATUS
2470 NTAPI
2471 RtlCreateUserProcess(
2472 _In_ PUNICODE_STRING ImageFileName,
2473 _In_ ULONG Attributes,
2474 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2475 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2476 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2477 _In_opt_ HANDLE ParentProcess,
2478 _In_ BOOLEAN CurrentDirectory,
2479 _In_opt_ HANDLE DebugPort,
2480 _In_opt_ HANDLE ExceptionPort,
2481 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2482 );
2483
2484 #if (NTDDI_VERSION >= NTDDI_WIN7)
2485 NTSYSAPI
2486 NTSTATUS
2487 NTAPI
2488 RtlCreateUserThread(
2489 _In_ PVOID ThreadContext,
2490 _Out_ HANDLE *OutThreadHandle,
2491 _Reserved_ PVOID Reserved1,
2492 _Reserved_ PVOID Reserved2,
2493 _Reserved_ PVOID Reserved3,
2494 _Reserved_ PVOID Reserved4,
2495 _Reserved_ PVOID Reserved5,
2496 _Reserved_ PVOID Reserved6,
2497 _Reserved_ PVOID Reserved7,
2498 _Reserved_ PVOID Reserved8
2499 );
2500 #else
2501 NTSYSAPI
2502 NTSTATUS
2503 NTAPI
2504 RtlCreateUserThread(
2505 _In_ HANDLE ProcessHandle,
2506 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2507 _In_ BOOLEAN CreateSuspended,
2508 _In_ ULONG StackZeroBits,
2509 _In_ SIZE_T StackReserve,
2510 _In_ SIZE_T StackCommit,
2511 _In_ PTHREAD_START_ROUTINE StartAddress,
2512 _In_ PVOID Parameter,
2513 _Out_opt_ PHANDLE ThreadHandle,
2514 _Out_opt_ PCLIENT_ID ClientId
2515 );
2516 #endif
2517
2518 NTSYSAPI
2519 PRTL_USER_PROCESS_PARAMETERS
2520 NTAPI
2521 RtlDeNormalizeProcessParams(
2522 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2523
2524 NTSYSAPI
2525 NTSTATUS
2526 NTAPI
2527 RtlDestroyProcessParameters(
2528 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2529
2530 NTSYSAPI
2531 VOID
2532 NTAPI
2533 RtlExitUserThread(
2534 _In_ NTSTATUS Status);
2535
2536 NTSYSAPI
2537 VOID
2538 NTAPI
2539 RtlInitializeContext(
2540 _In_ HANDLE ProcessHandle,
2541 _Out_ PCONTEXT ThreadContext,
2542 _In_opt_ PVOID ThreadStartParam,
2543 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2544 _In_ PINITIAL_TEB InitialTeb
2545 );
2546
2547 #ifdef _M_AMD64
2548 typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2549
2550 NTSYSAPI
2551 NTSTATUS
2552 NTAPI
2553 RtlWow64GetThreadContext(
2554 _In_ HANDLE ThreadHandle,
2555 _Inout_ PWOW64_CONTEXT ThreadContext
2556 );
2557
2558
2559 NTSYSAPI
2560 NTSTATUS
2561 NTAPI
2562 RtlWow64SetThreadContext(
2563 _In_ HANDLE ThreadHandle,
2564 _In_ PWOW64_CONTEXT ThreadContext
2565 );
2566 #endif
2567
2568 NTSYSAPI
2569 BOOLEAN
2570 NTAPI
2571 RtlIsThreadWithinLoaderCallout(VOID);
2572
2573 NTSYSAPI
2574 PRTL_USER_PROCESS_PARAMETERS
2575 NTAPI
2576 RtlNormalizeProcessParams(
2577 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2578
2579 NTSYSAPI
2580 VOID
2581 NTAPI
2582 RtlReleasePebLock(VOID);
2583
2584 NTSYSAPI
2585 NTSTATUS
2586 NTAPI
2587 RtlRemoteCall(
2588 _In_ HANDLE Process,
2589 _In_ HANDLE Thread,
2590 _In_ PVOID CallSite,
2591 _In_ ULONG ArgumentCount,
2592 _In_ PULONG Arguments,
2593 _In_ BOOLEAN PassContext,
2594 _In_ BOOLEAN AlreadySuspended
2595 );
2596
2597 NTSYSAPI
2598 NTSTATUS
2599 __cdecl
2600 RtlSetProcessIsCritical(
2601 _In_ BOOLEAN NewValue,
2602 _Out_opt_ PBOOLEAN OldValue,
2603 _In_ BOOLEAN NeedBreaks
2604 );
2605
2606 NTSYSAPI
2607 NTSTATUS
2608 __cdecl
2609 RtlSetThreadIsCritical(
2610 _In_ BOOLEAN NewValue,
2611 _Out_opt_ PBOOLEAN OldValue,
2612 _In_ BOOLEAN NeedBreaks
2613 );
2614
2615 NTSYSAPI
2616 ULONG
2617 NTAPI
2618 RtlGetCurrentProcessorNumber(
2619 VOID
2620 );
2621
2622 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2623
2624 //
2625 // Thread Pool Functions
2626 //
2627 //
2628 NTSTATUS
2629 NTAPI
2630 RtlSetThreadPoolStartFunc(
2631 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2632 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2633 );
2634
2635 NTSYSAPI
2636 NTSTATUS
2637 NTAPI
2638 RtlDeregisterWaitEx(
2639 _In_ HANDLE hWaitHandle,
2640 _In_opt_ HANDLE hCompletionEvent
2641 );
2642
2643 NTSYSAPI
2644 NTSTATUS
2645 NTAPI
2646 RtlDeregisterWait(
2647 _In_ HANDLE hWaitHandle
2648 );
2649
2650 NTSYSAPI
2651 NTSTATUS
2652 NTAPI
2653 RtlQueueWorkItem(
2654 _In_ WORKERCALLBACKFUNC Function,
2655 _In_opt_ PVOID Context,
2656 _In_ ULONG Flags
2657 );
2658
2659 NTSYSAPI
2660 NTSTATUS
2661 NTAPI
2662 RtlSetIoCompletionCallback(
2663 _In_ HANDLE FileHandle,
2664 _In_ PIO_APC_ROUTINE Callback,
2665 _In_ ULONG Flags
2666 );
2667
2668 NTSYSAPI
2669 NTSTATUS
2670 NTAPI
2671 RtlRegisterWait(
2672 _In_ PHANDLE phNewWaitObject,
2673 _In_ HANDLE hObject,
2674 _In_ WAITORTIMERCALLBACKFUNC Callback,
2675 _In_ PVOID pvContext,
2676 _In_ ULONG ulMilliseconds,
2677 _In_ ULONG ulFlags
2678 );
2679
2680 //
2681 // Environment/Path Functions
2682 //
2683 NTSYSAPI
2684 NTSTATUS
2685 NTAPI
2686 RtlCreateEnvironment(
2687 _In_ BOOLEAN Inherit,
2688 _Out_ PWSTR *Environment
2689 );
2690
2691 NTSYSAPI
2692 NTSTATUS
2693 NTAPI
2694 RtlComputePrivatizedDllName_U(
2695 _In_ PUNICODE_STRING DllName,
2696 _Out_ PUNICODE_STRING RealName,
2697 _Out_ PUNICODE_STRING LocalName
2698 );
2699
2700 NTSYSAPI
2701 VOID
2702 NTAPI
2703 RtlDestroyEnvironment(
2704 _In_ PWSTR Environment
2705 );
2706
2707 NTSYSAPI
2708 BOOLEAN
2709 NTAPI
2710 RtlDoesFileExists_U(
2711 _In_ PCWSTR FileName
2712 );
2713
2714 NTSYSAPI
2715 RTL_PATH_TYPE
2716 NTAPI
2717 RtlDetermineDosPathNameType_U(
2718 _In_ PCWSTR Path
2719 );
2720
2721 NTSYSAPI
2722 ULONG
2723 NTAPI
2724 RtlDosSearchPath_U(
2725 _In_ PCWSTR Path,
2726 _In_ PCWSTR FileName,
2727 _In_ PCWSTR Extension,
2728 _In_ ULONG BufferSize,
2729 _Out_ PWSTR Buffer,
2730 _Out_ PWSTR *PartName
2731 );
2732
2733 NTSYSAPI
2734 NTSTATUS
2735 NTAPI
2736 RtlDosSearchPath_Ustr(
2737 _In_ ULONG Flags,
2738 _In_ PUNICODE_STRING PathString,
2739 _In_ PUNICODE_STRING FileNameString,
2740 _In_ PUNICODE_STRING ExtensionString,
2741 _In_ PUNICODE_STRING CallerBuffer,
2742 _Inout_opt_ PUNICODE_STRING DynamicString,
2743 _Out_opt_ PUNICODE_STRING* FullNameOut,
2744 _Out_opt_ PSIZE_T FilePartSize,
2745 _Out_opt_ PSIZE_T LengthNeeded
2746 );
2747
2748 NTSYSAPI
2749 BOOLEAN
2750 NTAPI
2751 RtlDosPathNameToNtPathName_U(
2752 _In_opt_z_ PCWSTR DosPathName,
2753 _Out_ PUNICODE_STRING NtPathName,
2754 _Out_opt_ PCWSTR *NtFileNamePart,
2755 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2756 );
2757
2758 NTSYSAPI
2759 BOOLEAN
2760 NTAPI
2761 RtlDosPathNameToRelativeNtPathName_U(
2762 _In_ PCWSTR DosName,
2763 _Out_ PUNICODE_STRING NtName,
2764 _Out_ PCWSTR *PartName,
2765 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2766 );
2767
2768 _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength))
2769 NTSYSAPI
2770 NTSTATUS
2771 NTAPI
2772 RtlExpandEnvironmentStrings_U(
2773 _In_z_ PWSTR Environment,
2774 _In_ PUNICODE_STRING Source,
2775 _Inout_ PUNICODE_STRING Destination,
2776 _Out_ PULONG Length
2777 );
2778
2779 NTSYSAPI
2780 ULONG
2781 NTAPI
2782 RtlGetCurrentDirectory_U(
2783 _In_ ULONG MaximumLength,
2784 _Out_bytecap_(MaximumLength) PWSTR Buffer
2785 );
2786
2787 NTSYSAPI
2788 ULONG
2789 NTAPI
2790 RtlGetFullPathName_U(
2791 _In_ PCWSTR FileName,
2792 _In_ ULONG Size,
2793 _Out_z_bytecap_(Size) PWSTR Buffer,
2794 _Out_opt_ PWSTR *ShortName
2795 );
2796
2797 #if (NTDDI_VERSION >= NTDDI_WIN7)
2798 NTSYSAPI
2799 NTSTATUS
2800 NTAPI
2801 RtlGetFullPathName_UEx(
2802 _In_ PWSTR FileName,
2803 _In_ ULONG BufferLength,
2804 _Out_ PWSTR Buffer,
2805 _Out_opt_ PWSTR *FilePart,
2806 _Out_opt_ RTL_PATH_TYPE *InputPathType
2807 );
2808 #endif
2809
2810 NTSTATUS
2811 NTAPI
2812 RtlGetFullPathName_UstrEx(
2813 _In_ PUNICODE_STRING FileName,
2814 _In_opt_ PUNICODE_STRING StaticString,
2815 _In_opt_ PUNICODE_STRING DynamicString,
2816 _Out_opt_ PUNICODE_STRING *StringUsed,
2817 _Out_opt_ PSIZE_T FilePartSize,
2818 _Out_opt_ PBOOLEAN NameInvalid,
2819 _Out_ RTL_PATH_TYPE* PathType,
2820 _Out_opt_ PSIZE_T LengthNeeded
2821 );
2822
2823 NTSYSAPI
2824 NTSTATUS
2825 NTAPI
2826 RtlGetLengthWithoutTrailingPathSeperators(
2827 _Reserved_ ULONG Flags,
2828 _In_ PCUNICODE_STRING PathString,
2829 _Out_ PULONG Length
2830 );
2831
2832 NTSYSAPI
2833 ULONG
2834 NTAPI
2835 RtlGetLongestNtPathLength(
2836 VOID
2837 );
2838
2839 NTSYSAPI
2840 ULONG
2841 NTAPI
2842 RtlIsDosDeviceName_U(
2843 _In_ PCWSTR Name
2844 );
2845
2846 NTSYSAPI
2847 ULONG
2848 NTAPI
2849 RtlIsDosDeviceName_Ustr(
2850 _In_ PCUNICODE_STRING Name
2851 );
2852
2853 _IRQL_requires_max_(PASSIVE_LEVEL)
2854 _Must_inspect_result_
2855 NTSYSAPI
2856 BOOLEAN
2857 NTAPI
2858 RtlIsNameLegalDOS8Dot3(
2859 _In_ PCUNICODE_STRING Name,
2860 _Inout_opt_ POEM_STRING OemName,
2861 _Out_opt_ PBOOLEAN NameContainsSpaces
2862 );
2863
2864 NTSYSAPI
2865 NTSTATUS
2866 NTAPI
2867 RtlQueryEnvironmentVariable_U(
2868 _In_opt_ PWSTR Environment,
2869 _In_ PUNICODE_STRING Name,
2870 _Out_ PUNICODE_STRING Value
2871 );
2872
2873 VOID
2874 NTAPI
2875 RtlReleaseRelativeName(
2876 _In_ PRTL_RELATIVE_NAME_U RelativeName
2877 );
2878
2879 NTSYSAPI
2880 NTSTATUS
2881 NTAPI
2882 RtlSetCurrentDirectory_U(
2883 _In_ PUNICODE_STRING name
2884 );
2885
2886 NTSYSAPI
2887 NTSTATUS
2888 NTAPI
2889 RtlSetEnvironmentVariable(
2890 _In_z_ PWSTR *Environment,
2891 _In_ PUNICODE_STRING Name,
2892 _In_ PUNICODE_STRING Value
2893 );
2894
2895 //
2896 // Critical Section/Resource Functions
2897 //
2898 NTSYSAPI
2899 NTSTATUS
2900 NTAPI
2901 RtlDeleteCriticalSection (
2902 _In_ PRTL_CRITICAL_SECTION CriticalSection
2903 );
2904
2905 NTSYSAPI
2906 NTSTATUS
2907 NTAPI
2908 RtlEnterCriticalSection(
2909 _In_ PRTL_CRITICAL_SECTION CriticalSection
2910 );
2911
2912 NTSYSAPI
2913 NTSTATUS
2914 NTAPI
2915 RtlInitializeCriticalSection(
2916 _In_ PRTL_CRITICAL_SECTION CriticalSection
2917 );
2918
2919 NTSYSAPI
2920 NTSTATUS
2921 NTAPI
2922 RtlInitializeCriticalSectionAndSpinCount(
2923 _In_ PRTL_CRITICAL_SECTION CriticalSection,
2924 _In_ ULONG SpinCount
2925 );
2926
2927 NTSYSAPI
2928 NTSTATUS
2929 NTAPI
2930 RtlLeaveCriticalSection(
2931 _In_ PRTL_CRITICAL_SECTION CriticalSection
2932 );
2933
2934 NTSYSAPI
2935 BOOLEAN
2936 NTAPI
2937 RtlTryEnterCriticalSection(
2938 _In_ PRTL_CRITICAL_SECTION CriticalSection
2939 );
2940
2941 NTSYSAPI
2942 VOID
2943 NTAPI
2944 RtlpUnWaitCriticalSection(
2945 _In_ PRTL_CRITICAL_SECTION CriticalSection
2946 );
2947
2948 NTSYSAPI
2949 NTSTATUS
2950 NTAPI
2951 RtlpWaitForCriticalSection(
2952 _In_ PRTL_CRITICAL_SECTION CriticalSection
2953 );
2954
2955 NTSYSAPI
2956 BOOLEAN
2957 NTAPI
2958 RtlAcquireResourceExclusive(
2959 _In_ PRTL_RESOURCE Resource,
2960 _In_ BOOLEAN Wait
2961 );
2962
2963 NTSYSAPI
2964 BOOLEAN
2965 NTAPI
2966 RtlAcquireResourceShared(
2967 _In_ PRTL_RESOURCE Resource,
2968 _In_ BOOLEAN Wait
2969 );
2970
2971 NTSYSAPI
2972 VOID
2973 NTAPI
2974 RtlConvertExclusiveToShared(
2975 _In_ PRTL_RESOURCE Resource
2976 );
2977
2978 NTSYSAPI
2979 VOID
2980 NTAPI
2981 RtlConvertSharedToExclusive(
2982 _In_ PRTL_RESOURCE Resource
2983 );
2984
2985 NTSYSAPI
2986 VOID
2987 NTAPI
2988 RtlDeleteResource(
2989 _In_ PRTL_RESOURCE Resource
2990 );
2991
2992 NTSYSAPI
2993 VOID
2994 NTAPI
2995 RtlDumpResource(
2996 _In_ PRTL_RESOURCE Resource
2997 );
2998
2999 NTSYSAPI
3000 VOID
3001 NTAPI
3002 RtlInitializeResource(
3003 _In_ PRTL_RESOURCE Resource
3004 );
3005
3006 NTSYSAPI
3007 VOID
3008 NTAPI
3009 RtlReleaseResource(
3010 _In_ PRTL_RESOURCE Resource
3011 );
3012
3013 //
3014 // Compression Functions
3015 //
3016 NTSYSAPI //NT_RTL_COMPRESS_API
3017 NTSTATUS
3018 NTAPI
3019 RtlCompressBuffer(
3020 _In_ USHORT CompressionFormatAndEngine,
3021 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer,
3022 _In_ ULONG UncompressedBufferSize,
3023 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer,
3024 _In_ ULONG CompressedBufferSize,
3025 _In_ ULONG UncompressedChunkSize,
3026 _Out_ PULONG FinalCompressedSize,
3027 _In_ PVOID WorkSpace
3028 );
3029
3030 _IRQL_requires_max_(APC_LEVEL)
3031 NTSYSAPI //NT_RTL_COMPRESS_API
3032 NTSTATUS
3033 NTAPI
3034 RtlDecompressBuffer(
3035 _In_ USHORT CompressionFormat,
3036 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
3037 _In_ ULONG UncompressedBufferSize,
3038 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
3039 _In_ ULONG CompressedBufferSize,
3040 _Out_ PULONG FinalUncompressedSize
3041 );
3042
3043 NTSYSAPI
3044 NTSTATUS
3045 NTAPI
3046 RtlGetCompressionWorkSpaceSize(
3047 _In_ USHORT CompressionFormatAndEngine,
3048 _Out_ PULONG CompressBufferWorkSpaceSize,
3049 _Out_ PULONG CompressFragmentWorkSpaceSize
3050 );
3051
3052 //
3053 // Frame Functions
3054 //
3055 NTSYSAPI
3056 VOID
3057 NTAPI
3058 RtlPopFrame(
3059 _In_ PTEB_ACTIVE_FRAME Frame
3060 );
3061
3062 NTSYSAPI
3063 VOID
3064 NTAPI
3065 RtlPushFrame(
3066 _In_ PTEB_ACTIVE_FRAME Frame
3067 );
3068
3069 NTSYSAPI
3070 PTEB_ACTIVE_FRAME
3071 NTAPI
3072 RtlGetFrame(
3073 VOID
3074 );
3075
3076 //
3077 // Debug Info Functions
3078 //
3079 NTSYSAPI
3080 PRTL_DEBUG_INFORMATION
3081 NTAPI
3082 RtlCreateQueryDebugBuffer(
3083 _In_ ULONG Size,
3084 _In_ BOOLEAN EventPair
3085 );
3086
3087 NTSYSAPI
3088 NTSTATUS
3089 NTAPI
3090 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
3091
3092 NTSYSAPI
3093 NTSTATUS
3094 NTAPI
3095 RtlQueryProcessDebugInformation(
3096 _In_ ULONG ProcessId,
3097 _In_ ULONG DebugInfoClassMask,
3098 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3099 );
3100
3101 //
3102 // Bitmap Functions
3103 //
3104 NTSYSAPI
3105 BOOLEAN
3106 NTAPI
3107 RtlAreBitsClear(
3108 _In_ PRTL_BITMAP BitMapHeader,
3109 _In_ ULONG StartingIndex,
3110 _In_ ULONG Length
3111 );
3112
3113 NTSYSAPI
3114 BOOLEAN
3115 NTAPI
3116 RtlAreBitsSet(
3117 _In_ PRTL_BITMAP BitMapHeader,
3118 _In_ ULONG StartingIndex,
3119 _In_ ULONG Length
3120 );
3121
3122 NTSYSAPI
3123 VOID
3124 NTAPI
3125 RtlClearAllBits(
3126 _In_ PRTL_BITMAP BitMapHeader
3127 );
3128
3129 NTSYSAPI
3130 VOID
3131 NTAPI
3132 RtlClearBits(
3133 _In_ PRTL_BITMAP BitMapHeader,
3134 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3135 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3136 );
3137
3138 NTSYSAPI
3139 ULONG
3140 NTAPI
3141 RtlFindClearBits(
3142 _In_ PRTL_BITMAP BitMapHeader,
3143 _In_ ULONG NumberToFind,
3144 _In_ ULONG HintIndex
3145 );
3146
3147 NTSYSAPI
3148 ULONG
3149 NTAPI
3150 RtlFindClearBitsAndSet(
3151 _In_ PRTL_BITMAP BitMapHeader,
3152 _In_ ULONG NumberToFind,
3153 _In_ ULONG HintIndex
3154 );
3155
3156 NTSYSAPI
3157 ULONG
3158 NTAPI
3159 RtlFindFirstRunClear(
3160 _In_ PRTL_BITMAP BitMapHeader,
3161 _Out_ PULONG StartingIndex
3162 );
3163
3164 NTSYSAPI
3165 ULONG
3166 NTAPI
3167 RtlFindClearRuns(
3168 _In_ PRTL_BITMAP BitMapHeader,
3169 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray,
3170 _In_range_(>, 0) ULONG SizeOfRunArray,
3171 _In_ BOOLEAN LocateLongestRuns
3172 );
3173
3174 NTSYSAPI
3175 ULONG
3176 NTAPI
3177 RtlFindLastBackwardRunClear(
3178 _In_ PRTL_BITMAP BitMapHeader,
3179 _In_ ULONG FromIndex,
3180 _Out_ PULONG StartingRunIndex
3181 );
3182
3183 NTSYSAPI
3184 CCHAR
3185 NTAPI
3186 RtlFindLeastSignificantBit(
3187 _In_ ULONGLONG Value
3188 );
3189
3190 NTSYSAPI
3191 CCHAR
3192 NTAPI
3193 RtlFindMostSignificantBit(
3194 _In_ ULONGLONG Value
3195 );
3196
3197 NTSYSAPI
3198 ULONG
3199 NTAPI
3200 RtlFindNextForwardRunClear(
3201 _In_ PRTL_BITMAP BitMapHeader,
3202 _In_ ULONG FromIndex,
3203 _Out_ PULONG StartingRunIndex
3204 );
3205
3206 NTSYSAPI
3207 ULONG
3208 NTAPI
3209 RtlFindNextForwardRunSet(
3210 _In_ PRTL_BITMAP BitMapHeader,
3211 _In_ ULONG FromIndex,
3212 _Out_ PULONG StartingRunIndex
3213 );
3214
3215 NTSYSAPI
3216 ULONG
3217 NTAPI
3218 RtlFindSetBits(
3219 _In_ PRTL_BITMAP BitMapHeader,
3220 _In_ ULONG NumberToFind,
3221 _In_ ULONG HintIndex
3222 );
3223
3224 NTSYSAPI
3225 ULONG
3226 NTAPI
3227 RtlFindSetBitsAndClear(
3228 _In_ PRTL_BITMAP BitMapHeader,
3229 _In_ ULONG NumberToFind,
3230 _In_ ULONG HintIndex
3231 );
3232
3233 #ifdef _REACTOS_ // ReactOS improvement
3234 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3235 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3236 #endif
3237 NTSYSAPI
3238 VOID
3239 NTAPI
3240 RtlInitializeBitMap(
3241 _Out_ PRTL_BITMAP BitMapHeader,
3242 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3243 _In_opt_ ULONG SizeOfBitMap
3244 );
3245
3246 NTSYSAPI
3247 ULONG
3248 NTAPI
3249 RtlNumberOfClearBits(
3250 _In_ PRTL_BITMAP BitMapHeader
3251 );
3252
3253 NTSYSAPI
3254 ULONG
3255 NTAPI
3256 RtlNumberOfSetBits(
3257 _In_ PRTL_BITMAP BitMapHeader
3258 );
3259
3260 NTSYSAPI
3261 VOID
3262 NTAPI
3263 RtlSetBit(
3264 _In_ PRTL_BITMAP BitMapHeader,
3265 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3266 );
3267
3268 NTSYSAPI
3269 VOID
3270 NTAPI
3271 RtlSetBits(
3272 _In_ PRTL_BITMAP BitMapHeader,
3273 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3274 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3275 );
3276
3277 NTSYSAPI
3278 VOID
3279 NTAPI
3280 RtlSetAllBits(
3281 _In_ PRTL_BITMAP BitMapHeader
3282 );
3283
3284 _Must_inspect_result_
3285 NTSYSAPI
3286 BOOLEAN
3287 NTAPI
3288 RtlTestBit(
3289 _In_ PRTL_BITMAP BitMapHeader,
3290 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3291 );
3292
3293 //
3294 // Timer Functions
3295 //
3296 NTSYSAPI
3297 NTSTATUS
3298 NTAPI
3299 RtlCreateTimer(
3300 _In_ HANDLE TimerQueue,
3301 _In_ PHANDLE phNewTimer,
3302 _In_ WAITORTIMERCALLBACKFUNC Callback,
3303 _In_ PVOID Parameter,
3304 _In_ ULONG DueTime,
3305 _In_ ULONG Period,
3306 _In_ ULONG Flags
3307 );
3308
3309 NTSYSAPI
3310 NTSTATUS
3311 NTAPI
3312 RtlCreateTimerQueue(PHANDLE TimerQueue);
3313
3314 NTSYSAPI
3315 NTSTATUS
3316 NTAPI
3317 RtlDeleteTimer(
3318 _In_ HANDLE TimerQueue,
3319 _In_ HANDLE Timer,
3320 _In_ HANDLE CompletionEvent
3321 );
3322
3323 NTSYSAPI
3324 NTSTATUS
3325 NTAPI
3326 RtlUpdateTimer(
3327 _In_ HANDLE TimerQueue,
3328 _In_ HANDLE Timer,
3329 _In_ ULONG DueTime,
3330 _In_ ULONG Period
3331 );
3332
3333 NTSYSAPI
3334 NTSTATUS
3335 NTAPI
3336 RtlDeleteTimerQueueEx(
3337 _In_ HANDLE TimerQueue,
3338 _In_opt_ HANDLE CompletionEvent
3339 );
3340
3341 NTSYSAPI
3342 NTSTATUS
3343 NTAPI
3344 RtlDeleteTimerQueue(HANDLE TimerQueue);
3345
3346 //
3347 // SList functions
3348 //
3349 PSLIST_ENTRY
3350 FASTCALL
3351 InterlockedPushListSList(
3352 _Inout_ PSLIST_HEADER ListHead,
3353 _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
3354 _Inout_ PSLIST_ENTRY ListEnd,
3355 _In_ ULONG Count
3356 );
3357
3358 //
3359 // Range List functions
3360 //
3361 NTSYSAPI
3362 VOID
3363 NTAPI
3364 RtlInitializeRangeList(
3365 _Inout_ PRTL_RANGE_LIST RangeList
3366 );
3367
3368 NTSYSAPI
3369 VOID
3370 NTAPI
3371 RtlFreeRangeList(
3372 _In_ PRTL_RANGE_LIST RangeList
3373 );
3374
3375 NTSYSAPI
3376 NTSTATUS
3377 NTAPI
3378 RtlAddRange(
3379 _Inout_ PRTL_RANGE_LIST RangeList,
3380 _In_ ULONGLONG Start,
3381 _In_ ULONGLONG End,
3382 _In_ UCHAR Attributes,
3383 _In_ ULONG Flags,
3384 _In_opt_ PVOID UserData,
3385 _In_opt_ PVOID Owner
3386 );
3387
3388 //
3389 // Debug Functions
3390 //
3391 ULONG
3392 __cdecl
3393 DbgPrint(
3394 _In_z_ _Printf_format_string_ PCSTR Format,
3395 ...
3396 );
3397
3398 NTSYSAPI
3399 ULONG
3400 __cdecl
3401 DbgPrintEx(
3402 _In_ ULONG ComponentId,
3403 _In_ ULONG Level,
3404 _In_z_ _Printf_format_string_ PCSTR Format,
3405 ...
3406 );
3407
3408 NTSYSAPI
3409 ULONG
3410 NTAPI
3411 DbgPrompt(
3412 _In_z_ PCCH Prompt,
3413 _Out_writes_bytes_(MaximumResponseLength) PCH Response,
3414 _In_ ULONG MaximumResponseLength
3415 );
3416
3417 #undef DbgBreakPoint
3418 VOID
3419 NTAPI
3420 DbgBreakPoint(
3421 VOID
3422 );
3423
3424 VOID
3425 NTAPI
3426 DbgLoadImageSymbols(
3427 _In_ PSTRING Name,
3428 _In_ PVOID Base,
3429 _In_ ULONG_PTR ProcessId
3430 );
3431
3432 VOID
3433 NTAPI
3434 DbgUnLoadImageSymbols(
3435 _In_ PSTRING Name,
3436 _In_ PVOID Base,
3437 _In_ ULONG_PTR ProcessId
3438 );
3439
3440 VOID
3441 NTAPI
3442 DbgCommandString(
3443 _In_ PCCH Name,
3444 _In_ PCCH Command
3445 );
3446
3447 //
3448 // Generic Table Functions
3449 //
3450 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3451 NTSYSAPI
3452 PVOID
3453 NTAPI
3454 RtlInsertElementGenericTable(
3455 _In_ PRTL_GENERIC_TABLE Table,
3456 _In_reads_bytes_(BufferSize) PVOID Buffer,
3457 _In_ CLONG BufferSize,
3458 _Out_opt_ PBOOLEAN NewElement
3459 );
3460
3461 NTSYSAPI
3462 PVOID
3463 NTAPI
3464 RtlInsertElementGenericTableFull(
3465 _In_ PRTL_GENERIC_TABLE Table,
3466 _In_reads_bytes_(BufferSize) PVOID Buffer,
3467 _In_ CLONG BufferSize,
3468 _Out_opt_ PBOOLEAN NewElement,
3469 _In_ PVOID NodeOrParent,
3470 _In_ TABLE_SEARCH_RESULT SearchResult
3471 );
3472
3473 NTSYSAPI
3474 BOOLEAN
3475 NTAPI
3476 RtlIsGenericTableEmpty(
3477 _In_ PRTL_GENERIC_TABLE Table
3478 );
3479
3480 NTSYSAPI
3481 PVOID
3482 NTAPI
3483 RtlLookupElementGenericTableFull(
3484 _In_ PRTL_GENERIC_TABLE Table,
3485 _In_ PVOID Buffer,
3486 _Out_ PVOID *NodeOrParent,
3487 _Out_ TABLE_SEARCH_RESULT *SearchResult
3488 );
3489 #endif
3490
3491 //
3492 // Handle Table Functions
3493 //
3494 NTSYSAPI
3495 PRTL_HANDLE_TABLE_ENTRY
3496 NTAPI
3497 RtlAllocateHandle(
3498 _In_ PRTL_HANDLE_TABLE HandleTable,
3499 _Inout_ PULONG Index
3500 );
3501
3502 NTSYSAPI
3503 VOID
3504 NTAPI
3505 RtlDestroyHandleTable(
3506 _Inout_ PRTL_HANDLE_TABLE HandleTable);
3507
3508 NTSYSAPI
3509 BOOLEAN
3510 NTAPI
3511 RtlFreeHandle(
3512 _In_ PRTL_HANDLE_TABLE HandleTable,
3513 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3514 );
3515
3516 NTSYSAPI
3517 VOID
3518 NTAPI
3519 RtlInitializeHandleTable(
3520 _In_ ULONG TableSize,
3521 _In_ ULONG HandleSize,
3522 _In_ PRTL_HANDLE_TABLE HandleTable
3523 );
3524
3525 NTSYSAPI
3526 BOOLEAN
3527 NTAPI
3528 RtlIsValidHandle(
3529 _In_ PRTL_HANDLE_TABLE HandleTable,
3530 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3531 );
3532
3533 _Success_(return!=FALSE)
3534 NTSYSAPI
3535 BOOLEAN
3536 NTAPI
3537 RtlIsValidIndexHandle(
3538 _In_ PRTL_HANDLE_TABLE HandleTable,
3539 _In_ ULONG Index,
3540 _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle
3541 );
3542
3543 //
3544 // PE Functions
3545 //
3546 NTSYSAPI
3547 NTSTATUS
3548 NTAPI
3549 RtlFindMessage(
3550 _In_ PVOID BaseAddress,
3551 _In_ ULONG Type,
3552 _In_ ULONG Language,
3553 _In_ ULONG MessageId,
3554 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3555 );
3556
3557 NTSYSAPI
3558 ULONG
3559 NTAPI
3560 RtlGetNtGlobalFlags(VOID);
3561
3562 _Success_(return!=NULL)
3563 NTSYSAPI
3564 PVOID
3565 NTAPI
3566 RtlImageDirectoryEntryToData(
3567 _In_ PVOID BaseAddress,
3568 _In_ BOOLEAN MappedAsImage,
3569 _In_ USHORT Directory,
3570 _Out_ PULONG Size
3571 );
3572
3573 NTSYSAPI
3574 PVOID
3575 NTAPI
3576 RtlImageRvaToVa(
3577 _In_ PIMAGE_NT_HEADERS NtHeader,
3578 _In_ PVOID BaseAddress,
3579 _In_ ULONG Rva,
3580 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3581 );
3582
3583 NTSYSAPI
3584 PIMAGE_NT_HEADERS
3585 NTAPI
3586 RtlImageNtHeader(
3587 _In_ PVOID BaseAddress);
3588
3589 NTSYSAPI
3590 NTSTATUS
3591 NTAPI
3592 RtlImageNtHeaderEx(
3593 _In_ ULONG Flags,
3594 _In_ PVOID BaseAddress,
3595 _In_ ULONGLONG Size,
3596 _Out_ PIMAGE_NT_HEADERS *NtHeader
3597 );
3598
3599 NTSYSAPI
3600 PIMAGE_SECTION_HEADER
3601 NTAPI
3602 RtlImageRvaToSection(
3603 _In_ PIMAGE_NT_HEADERS NtHeader,
3604 _In_ PVOID BaseAddress,
3605 _In_ ULONG Rva
3606 );
3607
3608 NTSYSAPI
3609 ULONG
3610 NTAPI
3611 LdrRelocateImageWithBias(
3612 _In_ PVOID NewAddress,
3613 _In_ LONGLONG AdditionalBias,
3614 _In_ PCCH LoaderName,
3615 _In_ ULONG Success,
3616 _In_ ULONG Conflict,
3617 _In_ ULONG Invalid
3618 );
3619
3620 //
3621 // Activation Context Functions
3622 //
3623 #ifdef NTOS_MODE_USER
3624 NTSYSAPI
3625 NTSTATUS
3626 NTAPI
3627 RtlActivateActivationContextEx(
3628 _In_ ULONG Flags,
3629 _In_ PTEB Teb,
3630 _In_ PVOID Context,
3631 _Out_ PULONG_PTR Cookie
3632 );
3633
3634 NTSYSAPI
3635 NTSTATUS
3636 NTAPI
3637 RtlActivateActivationContext(
3638 _In_ ULONG Flags,
3639 _In_ HANDLE Handle,
3640 _Out_ PULONG_PTR Cookie
3641 );
3642
3643 NTSYSAPI
3644 VOID
3645 NTAPI
3646 RtlAddRefActivationContext(
3647 _In_ PVOID Context
3648 );
3649
3650 NTSYSAPI
3651 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3652 FASTCALL
3653 RtlActivateActivationContextUnsafeFast(
3654 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
3655 _In_ PVOID Context
3656 );
3657
3658 NTSYSAPI
3659 NTSTATUS
3660 NTAPI
3661 RtlAllocateActivationContextStack(
3662 _In_ PACTIVATION_CONTEXT_STACK *Stack
3663 );
3664
3665 NTSYSAPI
3666 NTSTATUS
3667 NTAPI
3668 RtlCreateActivationContext(
3669 _In_ ULONG Flags,
3670 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
3671 _In_ ULONG ExtraBytes,
3672 _In_ PVOID NotificationRoutine,
3673 _In_ PVOID NotificationContext,
3674 _Out_ PACTIVATION_CONTEXT *ActCtx
3675 );
3676
3677 NTSYSAPI
3678 NTSTATUS
3679 NTAPI
3680 RtlGetActiveActivationContext(
3681 _In_ PVOID *Context
3682 );
3683
3684 NTSYSAPI
3685 VOID
3686 NTAPI
3687 RtlReleaseActivationContext(
3688 _In_ HANDLE handle
3689 );
3690
3691 NTSYSAPI
3692 NTSTATUS
3693 NTAPI
3694 RtlDeactivateActivationContext(
3695 _In_ ULONG dwFlags,
3696 _In_ ULONG_PTR ulCookie
3697 );
3698
3699 NTSYSAPI
3700 VOID
3701 NTAPI
3702 RtlFreeActivationContextStack(
3703 _In_ PACTIVATION_CONTEXT_STACK Stack
3704 );
3705
3706 NTSYSAPI
3707 VOID
3708 NTAPI
3709 RtlFreeThreadActivationContextStack(VOID);
3710
3711 NTSYSAPI
3712 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3713 FASTCALL
3714 RtlDeactivateActivationContextUnsafeFast(
3715 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3716 );
3717
3718 NTSYSAPI
3719 NTSTATUS
3720 NTAPI
3721 RtlDosApplyFileIsolationRedirection_Ustr(
3722 _In_ ULONG Flags,
3723 _In_ PUNICODE_STRING OriginalName,
3724 _In_ PUNICODE_STRING Extension,
3725 _Inout_ PUNICODE_STRING StaticString,
3726 _Inout_ PUNICODE_STRING DynamicString,
3727 _Inout_ PUNICODE_STRING *NewName,
3728 _In_ PULONG NewFlags,
3729 _In_ PSIZE_T FileNameSize,
3730 _In_ PSIZE_T RequiredLength
3731 );
3732
3733 NTSYSAPI
3734 NTSTATUS
3735 NTAPI
3736 RtlFindActivationContextSectionString(
3737 _In_ ULONG dwFlags,
3738 _In_ const GUID *ExtensionGuid,
3739 _In_ ULONG SectionType,
3740 _In_ const UNICODE_STRING *SectionName,
3741 _Inout_ PVOID ReturnedData
3742 );
3743
3744 NTSYSAPI
3745 NTSTATUS
3746 NTAPI
3747 RtlQueryInformationActivationContext(
3748 _In_ DWORD dwFlags,
3749 _In_opt_ PVOID Context,
3750 _In_opt_ PVOID pvSubInstance,
3751 _In_ ULONG ulInfoClass,
3752 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3753 _In_opt_ SIZE_T cbBuffer,
3754 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3755 );
3756
3757 NTSYSAPI
3758 NTSTATUS
3759 NTAPI
3760 RtlQueryInformationActiveActivationContext(
3761 _In_ ULONG ulInfoClass,
3762 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3763 _In_opt_ SIZE_T cbBuffer,
3764 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3765 );
3766
3767 NTSYSAPI
3768 NTSTATUS
3769 NTAPI
3770 RtlZombifyActivationContext(
3771 PVOID Context
3772 );
3773
3774 //
3775 // WOW64 Functions
3776 //
3777 NTSYSAPI
3778 NTSTATUS
3779 NTAPI
3780 RtlWow64EnableFsRedirection(
3781 _In_ BOOLEAN Wow64FsEnableRedirection
3782 );
3783
3784 NTSYSAPI
3785 NTSTATUS
3786 NTAPI
3787 RtlWow64EnableFsRedirectionEx(
3788 _In_ PVOID Wow64FsEnableRedirection,
3789 _Out_ PVOID *OldFsRedirectionLevel
3790 );
3791
3792 #endif
3793
3794 //
3795 // Registry Functions
3796 //
3797 _IRQL_requires_max_(PASSIVE_LEVEL)
3798 _Must_inspect_result_
3799 NTSYSAPI
3800 NTSTATUS
3801 NTAPI
3802 RtlCheckRegistryKey(
3803 _In_ ULONG RelativeTo,
3804 _In_ PWSTR Path
3805 );
3806
3807 NTSYSAPI
3808 NTSTATUS
3809 NTAPI
3810 RtlCreateRegistryKey(
3811 _In_ ULONG RelativeTo,
3812 _In_ PWSTR Path
3813 );
3814
3815 NTSYSAPI
3816 NTSTATUS
3817 NTAPI
3818 RtlFormatCurrentUserKeyPath(
3819 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
3820 PUNICODE_STRING KeyPath
3821 );
3822
3823 NTSYSAPI
3824 NTSTATUS
3825 NTAPI
3826 RtlOpenCurrentUser(
3827 _In_ ACCESS_MASK DesiredAccess,
3828 _Out_ PHANDLE KeyHandle
3829 );
3830
3831 _IRQL_requires_max_(PASSIVE_LEVEL)
3832 NTSYSAPI
3833 NTSTATUS
3834 NTAPI
3835 RtlQueryRegistryValues(
3836 _In_ ULONG RelativeTo,
3837 _In_ PCWSTR Path,
3838 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
3839 PRTL_QUERY_REGISTRY_TABLE QueryTable,
3840 _In_opt_ PVOID Context,
3841 _In_opt_ PVOID Environment
3842 );
3843
3844 _IRQL_requires_max_(PASSIVE_LEVEL)
3845 NTSYSAPI
3846 NTSTATUS
3847 NTAPI
3848 RtlWriteRegistryValue(
3849 _In_ ULONG RelativeTo,
3850 _In_ PCWSTR Path,
3851 _In_z_ PCWSTR ValueName,
3852 _In_ ULONG ValueType,
3853 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
3854 _In_ ULONG ValueLength
3855 );
3856
3857 #ifdef NTOS_MODE_USER
3858 NTSYSAPI
3859 NTSTATUS
3860 NTAPI
3861 RtlpNtCreateKey(
3862 _Out_ HANDLE KeyHandle,
3863 _In_ ACCESS_MASK DesiredAccess,
3864 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3865 _In_ ULONG TitleIndex,
3866 _In_ PUNICODE_STRING Class,
3867 _Out_ PULONG Disposition
3868 );
3869
3870 NTSYSAPI
3871 NTSTATUS
3872 NTAPI
3873 RtlpNtEnumerateSubKey(
3874 _In_ HANDLE KeyHandle,
3875 _Inout_ PUNICODE_STRING SubKeyName,
3876 _In_ ULONG Index,
3877 _In_ ULONG Unused
3878 );
3879
3880 NTSYSAPI
3881 NTSTATUS
3882 NTAPI
3883 RtlpNtMakeTemporaryKey(
3884 _In_ HANDLE KeyHandle
3885 );
3886
3887 NTSYSAPI
3888 NTSTATUS
3889 NTAPI
3890 RtlpNtOpenKey(
3891 _Out_ HANDLE KeyHandle,
3892 _In_ ACCESS_MASK DesiredAccess,
3893 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3894 _In_ ULONG Unused
3895 );
3896
3897 NTSYSAPI
3898 NTSTATUS
3899 NTAPI
3900 RtlpNtQueryValueKey(
3901 _In_ HANDLE KeyHandle,
3902 _Out_opt_ PULONG Type,
3903 _Out_opt_ PVOID Data,
3904 _Inout_opt_ PULONG DataLength,
3905 _In_ ULONG Unused
3906 );
3907
3908 NTSYSAPI
3909 NTSTATUS
3910 NTAPI
3911 RtlpNtSetValueKey(
3912 _In_ HANDLE KeyHandle,
3913 _In_ ULONG Type,
3914 _In_ PVOID Data,
3915 _In_ ULONG DataLength
3916 );
3917 #endif
3918
3919 //
3920 // NLS Functions
3921 //
3922 NTSYSAPI
3923 VOID
3924 NTAPI
3925 RtlGetDefaultCodePage(
3926 _Out_ PUSHORT AnsiCodePage,
3927 _Out_ PUSHORT OemCodePage
3928 );
3929
3930 NTSYSAPI
3931 VOID
3932 NTAPI
3933 RtlInitNlsTables(
3934 _In_ PUSHORT AnsiTableBase,
3935 _In_ PUSHORT OemTableBase,
3936 _In_ PUSHORT CaseTableBase,
3937 _Out_ PNLSTABLEINFO NlsTable
3938 );
3939
3940 _IRQL_requires_max_(PASSIVE_LEVEL)
3941 NTSYSAPI
3942 VOID
3943 NTAPI
3944 RtlInitCodePageTable(
3945 _In_ PUSHORT TableBase,
3946 _Out_ PCPTABLEINFO CodePageTable
3947 );
3948
3949 NTSYSAPI
3950 VOID
3951 NTAPI
3952 RtlResetRtlTranslations(
3953 _In_ PNLSTABLEINFO NlsTable);
3954
3955 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3956
3957 //
3958 // Misc conversion functions
3959 //
3960 static __inline
3961 LARGE_INTEGER
3962 NTAPI_INLINE
3963 RtlConvertLongToLargeInteger(
3964 _In_ LONG SignedInteger
3965 )
3966 {
3967 LARGE_INTEGER Result;
3968
3969 Result.QuadPart = SignedInteger;
3970 return Result;
3971 }
3972
3973 static __inline
3974 LARGE_INTEGER
3975 NTAPI_INLINE
3976 RtlEnlargedIntegerMultiply(
3977 _In_ LONG Multiplicand,
3978 _In_ LONG Multiplier
3979 )
3980 {
3981 LARGE_INTEGER Product;
3982
3983 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
3984 return Product;
3985 }
3986
3987 static __inline
3988 ULONG
3989 NTAPI_INLINE
3990 RtlEnlargedUnsignedDivide(
3991 _In_ ULARGE_INTEGER Dividend,
3992 _In_ ULONG Divisor,
3993 _In_opt_ PULONG Remainder
3994 )
3995 {
3996 ULONG Quotient;
3997
3998 Quotient = (ULONG)(Dividend.QuadPart / Divisor);
3999 if (Remainder) {
4000 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
4001 }
4002
4003 return Quotient;
4004 }
4005
4006 static __inline
4007 LARGE_INTEGER
4008 NTAPI_INLINE
4009 RtlEnlargedU