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