[NDK]: One can use either RtlGetLengthWithoutTrailingPathSeparators or RtlGetLengthWi...
[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 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || \
1734 ((defined(_M_AMD64) || \
1735 defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
1736
1737 unsigned short __cdecl _byteswap_ushort(unsigned short);
1738 unsigned long __cdecl _byteswap_ulong (unsigned long);
1739 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1740 #pragma intrinsic(_byteswap_ushort)
1741 #pragma intrinsic(_byteswap_ulong)
1742 #pragma intrinsic(_byteswap_uint64)
1743 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1744 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1745 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1746
1747 #elif defined (__GNUC__)
1748
1749 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1750 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1751 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1752
1753 #else
1754
1755 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1756 NTSYSAPI
1757 USHORT
1758 FASTCALL
1759 RtlUshortByteSwap(IN USHORT Source);
1760
1761 NTSYSAPI
1762 ULONG
1763 FASTCALL
1764 RtlUlongByteSwap(IN ULONG Source);
1765
1766 NTSYSAPI
1767 ULONGLONG
1768 FASTCALL
1769 RtlUlonglongByteSwap(IN ULONGLONG Source);
1770 #endif
1771
1772 #endif
1773 #endif // NTOS_MODE_USER
1774
1775 //
1776 // Unicode->Ansi String Functions
1777 //
1778 NTSYSAPI
1779 ULONG
1780 NTAPI
1781 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
1782
1783 #ifdef NTOS_MODE_USER
1784
1785 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1786 NLS_MB_CODE_PAGE_TAG ? \
1787 RtlxUnicodeStringToAnsiSize(STRING) : \
1788 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1789 )
1790
1791 #endif
1792
1793 NTSYSAPI
1794 NTSTATUS
1795 NTAPI
1796 RtlUnicodeStringToAnsiString(
1797 PANSI_STRING DestinationString,
1798 PCUNICODE_STRING SourceString,
1799 BOOLEAN AllocateDestinationString
1800 );
1801
1802 //
1803 // Unicode->OEM String Functions
1804 //
1805 NTSYSAPI
1806 NTSTATUS
1807 NTAPI
1808 RtlUpcaseUnicodeStringToOemString(
1809 POEM_STRING DestinationString,
1810 PCUNICODE_STRING SourceString,
1811 BOOLEAN AllocateDestinationString
1812 );
1813
1814 _IRQL_requires_max_(PASSIVE_LEVEL)
1815 _Must_inspect_result_
1816 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1817 NTSYSAPI
1818 NTSTATUS
1819 NTAPI
1820 RtlUpcaseUnicodeStringToCountedOemString(
1821 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
1822 _When_(!AllocateDestinationString, _Inout_)
1823 POEM_STRING DestinationString,
1824 _In_ PCUNICODE_STRING SourceString,
1825 _In_ BOOLEAN AllocateDestinationString
1826 );
1827
1828 NTSYSAPI
1829 NTSTATUS
1830 NTAPI
1831 RtlUnicodeStringToOemString(
1832 POEM_STRING DestinationString,
1833 PCUNICODE_STRING SourceString,
1834 BOOLEAN AllocateDestinationString
1835 );
1836
1837 NTSYSAPI
1838 NTSTATUS
1839 NTAPI
1840 RtlUpcaseUnicodeToOemN(
1841 PCHAR OemString,
1842 ULONG OemSize,
1843 PULONG ResultSize,
1844 PCWCH UnicodeString,
1845 ULONG UnicodeSize
1846 );
1847
1848 NTSYSAPI
1849 ULONG
1850 NTAPI
1851 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
1852
1853 #ifdef NTOS_MODE_USER
1854
1855 #define RtlUnicodeStringToOemSize(STRING) ( \
1856 NLS_MB_OEM_CODE_PAGE_TAG ? \
1857 RtlxUnicodeStringToOemSize(STRING) : \
1858 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1859 )
1860
1861 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1862 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1863 )
1864
1865 #endif
1866
1867 NTSYSAPI
1868 NTSTATUS
1869 NTAPI
1870 RtlUnicodeToOemN(
1871 PCHAR OemString,
1872 ULONG OemSize,
1873 PULONG ResultSize,
1874 PCWCH UnicodeString,
1875 ULONG UnicodeSize
1876 );
1877
1878 //
1879 // Unicode->MultiByte String Functions
1880 //
1881 NTSYSAPI
1882 NTSTATUS
1883 NTAPI
1884 RtlUnicodeToMultiByteN(
1885 PCHAR MbString,
1886 ULONG MbSize,
1887 PULONG ResultSize,
1888 PCWCH UnicodeString,
1889 ULONG UnicodeSize
1890 );
1891
1892 NTSYSAPI
1893 NTSTATUS
1894 NTAPI
1895 RtlUpcaseUnicodeToMultiByteN(
1896 PCHAR MbString,
1897 ULONG MbSize,
1898 PULONG ResultSize,
1899 PCWCH UnicodeString,
1900 ULONG UnicodeSize
1901 );
1902
1903 NTSYSAPI
1904 NTSTATUS
1905 NTAPI
1906 RtlUnicodeToMultiByteSize(
1907 PULONG MbSize,
1908 PCWCH UnicodeString,
1909 ULONG UnicodeSize
1910 );
1911
1912 NTSYSAPI
1913 ULONG
1914 NTAPI
1915 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
1916
1917 //
1918 // OEM to Unicode Functions
1919 //
1920 NTSYSAPI
1921 NTSTATUS
1922 NTAPI
1923 RtlOemStringToUnicodeString(
1924 PUNICODE_STRING DestinationString,
1925 PCOEM_STRING SourceString,
1926 BOOLEAN AllocateDestinationString
1927 );
1928
1929 _IRQL_requires_max_(PASSIVE_LEVEL)
1930 NTSYSAPI
1931 NTSTATUS
1932 NTAPI
1933 RtlOemToUnicodeN(
1934 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
1935 _In_ ULONG MaxBytesInUnicodeString,
1936 _Out_opt_ PULONG BytesInUnicodeString,
1937 _In_reads_bytes_(BytesInOemString) PCCH OemString,
1938 _In_ ULONG BytesInOemString
1939 );
1940
1941 #ifdef NTOS_MODE_USER
1942
1943 #define RtlOemStringToUnicodeSize(STRING) ( \
1944 NLS_MB_OEM_CODE_PAGE_TAG ? \
1945 RtlxOemStringToUnicodeSize(STRING) : \
1946 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1947 )
1948
1949 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1950 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1951 )
1952
1953 #endif
1954
1955 //
1956 // Ansi->Unicode String Functions
1957 //
1958 NTSYSAPI
1959 ULONG
1960 NTAPI
1961 RtlxAnsiStringToUnicodeSize(
1962 PCANSI_STRING AnsiString
1963 );
1964
1965 NTSYSAPI
1966 NTSTATUS
1967 NTAPI
1968 RtlAnsiStringToUnicodeString(
1969 PUNICODE_STRING DestinationString,
1970 PCANSI_STRING SourceString,
1971 BOOLEAN AllocateDestinationString
1972 );
1973
1974 #ifdef NTOS_MODE_USER
1975
1976 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1977 NLS_MB_CODE_PAGE_TAG ? \
1978 RtlxAnsiStringToUnicodeSize(STRING) : \
1979 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1980 )
1981
1982 #endif
1983
1984 NTSYSAPI
1985 BOOLEAN
1986 NTAPI
1987 RtlCreateUnicodeStringFromAsciiz(
1988 _Out_ PUNICODE_STRING Destination,
1989 _In_ PCSZ Source
1990 );
1991
1992 //
1993 // Unicode String Functions
1994 //
1995 NTSYSAPI
1996 NTSTATUS
1997 NTAPI
1998 RtlAppendUnicodeToString(
1999 PUNICODE_STRING Destination,
2000 PCWSTR Source
2001 );
2002
2003 NTSYSAPI
2004 NTSTATUS
2005 NTAPI
2006 RtlAppendUnicodeStringToString(
2007 PUNICODE_STRING Destination,
2008 PCUNICODE_STRING Source
2009 );
2010
2011 NTSYSAPI
2012 LONG
2013 NTAPI
2014 RtlCompareUnicodeString(
2015 PCUNICODE_STRING String1,
2016 PCUNICODE_STRING String2,
2017 BOOLEAN CaseInsensitive
2018 );
2019
2020 NTSYSAPI
2021 VOID
2022 NTAPI
2023 RtlCopyUnicodeString(
2024 PUNICODE_STRING DestinationString,
2025 PCUNICODE_STRING SourceString
2026 );
2027
2028 NTSYSAPI
2029 BOOLEAN
2030 NTAPI
2031 RtlCreateUnicodeString(
2032 PUNICODE_STRING DestinationString,
2033 PCWSTR SourceString
2034 );
2035
2036 #ifdef NTOS_MODE_USER
2037
2038 NTSYSAPI
2039 NTSTATUS
2040 NTAPI
2041 RtlDowncaseUnicodeString(
2042 _Inout_ PUNICODE_STRING UniDest,
2043 _In_ PCUNICODE_STRING UniSource,
2044 _In_ BOOLEAN AllocateDestinationString
2045 );
2046
2047 NTSYSAPI
2048 NTSTATUS
2049 NTAPI
2050 RtlDuplicateUnicodeString(
2051 _In_ ULONG Flags,
2052 _In_ PCUNICODE_STRING SourceString,
2053 _Out_ PUNICODE_STRING DestinationString
2054 );
2055
2056 //
2057 // Memory Functions
2058 //
2059 NTSYSAPI
2060 VOID
2061 NTAPI
2062 RtlFillMemoryUlong(
2063 _In_ PVOID Destination,
2064 _In_ SIZE_T Length,
2065 _In_ ULONG Fill
2066 );
2067
2068 NTSYSAPI
2069 VOID
2070 NTAPI
2071 RtlFillMemoryUlonglong(
2072 _Out_ PVOID Destination,
2073 _In_ SIZE_T Length,
2074 _In_ ULONGLONG Pattern
2075 );
2076
2077
2078 NTSYSAPI
2079 SIZE_T
2080 NTAPI
2081 RtlCompareMemoryUlong(
2082 _In_ PVOID Source,
2083 _In_ SIZE_T Length,
2084 _In_ ULONG Pattern
2085 );
2086
2087 #define RtlEqualMemory(Destination, Source, Length) \
2088 (!memcmp(Destination, Source, Length))
2089
2090 #define RtlCopyBytes RtlCopyMemory
2091 #define RtlFillBytes RtlFillMemory
2092 #define RtlZeroBytes RtlZeroMemory
2093
2094 #endif
2095
2096 NTSYSAPI
2097 BOOLEAN
2098 NTAPI
2099 RtlEqualUnicodeString(
2100 PCUNICODE_STRING String1,
2101 PCUNICODE_STRING String2,
2102 BOOLEAN CaseInsensitive
2103 );
2104
2105 NTSYSAPI
2106 NTSTATUS
2107 NTAPI
2108 RtlFindCharInUnicodeString(
2109 _In_ ULONG Flags,
2110 _In_ PCUNICODE_STRING SearchString,
2111 _In_ PCUNICODE_STRING MatchString,
2112 _Out_ PUSHORT Position
2113 );
2114
2115 NTSYSAPI
2116 VOID
2117 NTAPI
2118 RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString);
2119
2120 NTSYSAPI
2121 NTSTATUS
2122 NTAPI
2123 RtlHashUnicodeString(
2124 _In_ CONST UNICODE_STRING *String,
2125 _In_ BOOLEAN CaseInSensitive,
2126 _In_ ULONG HashAlgorithm,
2127 _Out_ PULONG HashValue
2128 );
2129
2130 _IRQL_requires_max_(DISPATCH_LEVEL)
2131 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2132 _When_(SourceString != NULL,
2133 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
2134 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR))))
2135 _When_(SourceString == NULL,
2136 _At_(DestinationString->Length, _Post_equal_to_(0))
2137 _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2138 NTSYSAPI
2139 VOID
2140 NTAPI
2141 RtlInitUnicodeString(
2142 _Out_ PUNICODE_STRING DestinationString,
2143 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2144 );
2145
2146 _IRQL_requires_max_(DISPATCH_LEVEL)
2147 NTSYSAPI
2148 NTSTATUS
2149 NTAPI
2150 RtlInitUnicodeStringEx(
2151 _Out_ PUNICODE_STRING DestinationString,
2152 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2153 );
2154
2155 NTSYSAPI
2156 BOOLEAN
2157 NTAPI
2158 RtlIsTextUnicode(
2159 PVOID Buffer,
2160 INT Length,
2161 INT *Flags
2162 );
2163
2164 NTSYSAPI
2165 BOOLEAN
2166 NTAPI
2167 RtlPrefixString(
2168 PSTRING String1,
2169 PSTRING String2,
2170 BOOLEAN CaseInsensitive
2171 );
2172
2173 NTSYSAPI
2174 BOOLEAN
2175 NTAPI
2176 RtlPrefixUnicodeString(
2177 PCUNICODE_STRING String1,
2178 PCUNICODE_STRING String2,
2179 BOOLEAN CaseInsensitive
2180 );
2181
2182 _IRQL_requires_max_(PASSIVE_LEVEL)
2183 _When_(AllocateDestinationString, _Must_inspect_result_)
2184 NTSYSAPI
2185 NTSTATUS
2186 NTAPI
2187 RtlUpcaseUnicodeString(
2188 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
2189 _When_(!AllocateDestinationString, _Inout_)
2190 PUNICODE_STRING DestinationString,
2191 _In_ PCUNICODE_STRING SourceString,
2192 _In_ BOOLEAN AllocateDestinationString
2193 );
2194
2195 _IRQL_requires_max_(PASSIVE_LEVEL)
2196 NTSYSAPI
2197 NTSTATUS
2198 NTAPI
2199 RtlUnicodeStringToInteger(
2200 _In_ PCUNICODE_STRING String,
2201 _In_opt_ ULONG Base,
2202 _Out_ PULONG Value
2203 );
2204
2205 NTSYSAPI
2206 NTSTATUS
2207 NTAPI
2208 RtlValidateUnicodeString(
2209 _In_ ULONG Flags,
2210 _In_ PCUNICODE_STRING String
2211 );
2212
2213 //
2214 // Ansi String Functions
2215 //
2216 _IRQL_requires_max_(PASSIVE_LEVEL)
2217 NTSYSAPI
2218 VOID
2219 NTAPI
2220 RtlFreeAnsiString(
2221 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2222 PANSI_STRING AnsiString
2223 );
2224
2225 _IRQL_requires_max_(DISPATCH_LEVEL)
2226 NTSYSAPI
2227 VOID
2228 NTAPI
2229 RtlInitAnsiString(
2230 _Out_ PANSI_STRING DestinationString,
2231 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2232 );
2233
2234 _IRQL_requires_max_(DISPATCH_LEVEL)
2235 NTSYSAPI
2236 NTSTATUS
2237 NTAPI
2238 RtlInitAnsiStringEx(
2239 _Out_ PANSI_STRING DestinationString,
2240 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2241 );
2242
2243 //
2244 // OEM String Functions
2245 //
2246 _IRQL_requires_max_(PASSIVE_LEVEL)
2247 NTSYSAPI
2248 VOID
2249 NTAPI
2250 RtlFreeOemString(
2251 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2252 POEM_STRING OemString
2253 );
2254
2255 //
2256 // MultiByte->Unicode String Functions
2257 //
2258 _IRQL_requires_max_(PASSIVE_LEVEL)
2259 NTSYSAPI
2260 NTSTATUS
2261 NTAPI
2262 RtlMultiByteToUnicodeN(
2263 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2264 _In_ ULONG MaxBytesInUnicodeString,
2265 _Out_opt_ PULONG BytesInUnicodeString,
2266 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2267 _In_ ULONG BytesInMultiByteString
2268 );
2269
2270 _IRQL_requires_max_(PASSIVE_LEVEL)
2271 NTSYSAPI
2272 NTSTATUS
2273 NTAPI
2274 RtlMultiByteToUnicodeSize(
2275 _Out_ PULONG BytesInUnicodeString,
2276 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2277 _In_ ULONG BytesInMultiByteString
2278 );
2279
2280 //
2281 // Atom Functions
2282 //
2283 NTSYSAPI
2284 NTSTATUS
2285 NTAPI
2286 RtlAddAtomToAtomTable(
2287 _In_ PRTL_ATOM_TABLE AtomTable,
2288 _In_ PWSTR AtomName,
2289 _Out_ PRTL_ATOM Atom
2290 );
2291
2292 NTSYSAPI
2293 NTSTATUS
2294 NTAPI
2295 RtlCreateAtomTable(
2296 _In_ ULONG TableSize,
2297 _Inout_ PRTL_ATOM_TABLE *AtomTable
2298 );
2299
2300 NTSYSAPI
2301 NTSTATUS
2302 NTAPI
2303 RtlDeleteAtomFromAtomTable(
2304 _In_ PRTL_ATOM_TABLE AtomTable,
2305 _In_ RTL_ATOM Atom
2306 );
2307
2308 NTSYSAPI
2309 NTSTATUS
2310 NTAPI
2311 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
2312
2313 NTSYSAPI
2314 NTSTATUS
2315 NTAPI
2316 RtlQueryAtomInAtomTable(
2317 _In_ PRTL_ATOM_TABLE AtomTable,
2318 _In_ RTL_ATOM Atom,
2319 _Out_opt_ PULONG RefCount,
2320 _Out_opt_ PULONG PinCount,
2321 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2322 _Inout_opt_ PULONG NameLength
2323 );
2324
2325 NTSYSAPI
2326 NTSTATUS
2327 NTAPI
2328 RtlPinAtomInAtomTable(
2329 _In_ PRTL_ATOM_TABLE AtomTable,
2330 _In_ RTL_ATOM Atom
2331 );
2332
2333 NTSYSAPI
2334 NTSTATUS
2335 NTAPI
2336 RtlLookupAtomInAtomTable(
2337 _In_ PRTL_ATOM_TABLE AtomTable,
2338 _In_ PWSTR AtomName,
2339 _Out_ PRTL_ATOM Atom
2340 );
2341
2342 //
2343 // Process Management Functions
2344 //
2345 NTSYSAPI
2346 PPEB
2347 NTAPI
2348 RtlGetCurrentPeb(
2349 VOID
2350 );
2351
2352 NTSYSAPI
2353 VOID
2354 NTAPI
2355 RtlAcquirePebLock(VOID);
2356
2357 NTSYSAPI
2358 NTSTATUS
2359 NTAPI
2360 RtlCreateProcessParameters (
2361 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2362 _In_ PUNICODE_STRING ImagePathName,
2363 _In_opt_ PUNICODE_STRING DllPath,
2364 _In_opt_ PUNICODE_STRING CurrentDirectory,
2365 _In_opt_ PUNICODE_STRING CommandLine,
2366 _In_opt_ PWSTR Environment,
2367 _In_opt_ PUNICODE_STRING WindowTitle,
2368 _In_opt_ PUNICODE_STRING DesktopInfo,
2369 _In_opt_ PUNICODE_STRING ShellInfo,
2370 _In_opt_ PUNICODE_STRING RuntimeInfo
2371 );
2372
2373 NTSYSAPI
2374 NTSTATUS
2375 NTAPI
2376 RtlCreateUserProcess(
2377 _In_ PUNICODE_STRING ImageFileName,
2378 _In_ ULONG Attributes,
2379 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2380 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2381 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2382 _In_opt_ HANDLE ParentProcess,
2383 _In_ BOOLEAN CurrentDirectory,
2384 _In_opt_ HANDLE DebugPort,
2385 _In_opt_ HANDLE ExceptionPort,
2386 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2387 );
2388
2389 #if (NTDDI_VERSION >= NTDDI_WIN7)
2390 NTSYSAPI
2391 NTSTATUS
2392 NTAPI
2393 RtlCreateUserThread(
2394 _In_ PVOID ThreadContext,
2395 _Out_ HANDLE *OutThreadHandle,
2396 _Reserved_ PVOID Reserved1,
2397 _Reserved_ PVOID Reserved2,
2398 _Reserved_ PVOID Reserved3,
2399 _Reserved_ PVOID Reserved4,
2400 _Reserved_ PVOID Reserved5,
2401 _Reserved_ PVOID Reserved6,
2402 _Reserved_ PVOID Reserved7,
2403 _Reserved_ PVOID Reserved8
2404 );
2405 #else
2406 NTSYSAPI
2407 NTSTATUS
2408 NTAPI
2409 RtlCreateUserThread(
2410 _In_ HANDLE ProcessHandle,
2411 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2412 _In_ BOOLEAN CreateSuspended,
2413 _In_ ULONG StackZeroBits,
2414 _In_ SIZE_T StackReserve,
2415 _In_ SIZE_T StackCommit,
2416 _In_ PTHREAD_START_ROUTINE StartAddress,
2417 _In_ PVOID Parameter,
2418 _Out_opt_ PHANDLE ThreadHandle,
2419 _Out_opt_ PCLIENT_ID ClientId
2420 );
2421 #endif
2422
2423 NTSYSAPI
2424 PRTL_USER_PROCESS_PARAMETERS
2425 NTAPI
2426 RtlDeNormalizeProcessParams(
2427 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2428
2429 NTSYSAPI
2430 NTSTATUS
2431 NTAPI
2432 RtlDestroyProcessParameters(
2433 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2434
2435 NTSYSAPI
2436 VOID
2437 NTAPI
2438 RtlExitUserThread(
2439 _In_ NTSTATUS Status);
2440
2441 NTSYSAPI
2442 VOID
2443 NTAPI
2444 RtlInitializeContext(
2445 _In_ HANDLE ProcessHandle,
2446 _Out_ PCONTEXT ThreadContext,
2447 _In_opt_ PVOID ThreadStartParam,
2448 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2449 _In_ PINITIAL_TEB InitialTeb
2450 );
2451
2452 #ifdef _M_AMD64
2453 typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2454
2455 NTSYSAPI
2456 NTSTATUS
2457 NTAPI
2458 RtlWow64GetThreadContext(
2459 _In_ HANDLE ThreadHandle,
2460 _Inout_ PWOW64_CONTEXT ThreadContext
2461 );
2462
2463
2464 NTSYSAPI
2465 NTSTATUS
2466 NTAPI
2467 RtlWow64SetThreadContext(
2468 _In_ HANDLE ThreadHandle,
2469 _In_ PWOW64_CONTEXT ThreadContext
2470 );
2471 #endif
2472
2473 NTSYSAPI
2474 BOOLEAN
2475 NTAPI
2476 RtlIsThreadWithinLoaderCallout(VOID);
2477
2478 NTSYSAPI
2479 PRTL_USER_PROCESS_PARAMETERS
2480 NTAPI
2481 RtlNormalizeProcessParams(
2482 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2483
2484 NTSYSAPI
2485 VOID
2486 NTAPI
2487 RtlReleasePebLock(VOID);
2488
2489 NTSYSAPI
2490 NTSTATUS
2491 NTAPI
2492 RtlRemoteCall(
2493 _In_ HANDLE Process,
2494 _In_ HANDLE Thread,
2495 _In_ PVOID CallSite,
2496 _In_ ULONG ArgumentCount,
2497 _In_ PULONG Arguments,
2498 _In_ BOOLEAN PassContext,
2499 _In_ BOOLEAN AlreadySuspended
2500 );
2501
2502 NTSYSAPI
2503 NTSTATUS
2504 NTAPI
2505 RtlSetProcessIsCritical(
2506 _In_ BOOLEAN NewValue,
2507 _Out_opt_ PBOOLEAN OldValue,
2508 _In_ BOOLEAN NeedBreaks
2509 );
2510
2511 NTSYSAPI
2512 NTSTATUS
2513 NTAPI
2514 RtlSetThreadIsCritical(
2515 _In_ BOOLEAN NewValue,
2516 _Out_opt_ PBOOLEAN OldValue,
2517 _In_ BOOLEAN NeedBreaks
2518 );
2519
2520 NTSYSAPI
2521 ULONG
2522 NTAPI
2523 RtlGetCurrentProcessorNumber(
2524 VOID
2525 );
2526
2527 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2528
2529 //
2530 // Thread Pool Functions
2531 //
2532 //
2533 NTSTATUS
2534 NTAPI
2535 RtlSetThreadPoolStartFunc(
2536 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2537 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2538 );
2539
2540 NTSYSAPI
2541 NTSTATUS
2542 NTAPI
2543 RtlDeregisterWaitEx(
2544 _In_ HANDLE hWaitHandle,
2545 _In_opt_ HANDLE hCompletionEvent
2546 );
2547
2548 NTSYSAPI
2549 NTSTATUS
2550 NTAPI
2551 RtlDeregisterWait(
2552 _In_ HANDLE hWaitHandle
2553 );
2554
2555 NTSYSAPI
2556 NTSTATUS
2557 NTAPI
2558 RtlQueueWorkItem(
2559 _In_ WORKERCALLBACKFUNC Function,
2560 _In_opt_ PVOID Context,
2561 _In_ ULONG Flags
2562 );
2563
2564 NTSYSAPI
2565 NTSTATUS
2566 NTAPI
2567 RtlSetIoCompletionCallback(
2568 _In_ HANDLE FileHandle,
2569 _In_ PIO_APC_ROUTINE Callback,
2570 _In_ ULONG Flags
2571 );
2572
2573 NTSYSAPI
2574 NTSTATUS
2575 NTAPI
2576 RtlRegisterWait(
2577 _In_ PHANDLE phNewWaitObject,
2578 _In_ HANDLE hObject,
2579 _In_ WAITORTIMERCALLBACKFUNC Callback,
2580 _In_ PVOID pvContext,
2581 _In_ ULONG ulMilliseconds,
2582 _In_ ULONG ulFlags
2583 );
2584
2585 //
2586 // Environment/Path Functions
2587 //
2588 NTSYSAPI
2589 NTSTATUS
2590 NTAPI
2591 RtlCreateEnvironment(
2592 _In_ BOOLEAN Inherit,
2593 _Out_ PWSTR *Environment
2594 );
2595
2596 NTSYSAPI
2597 NTSTATUS
2598 NTAPI
2599 RtlComputePrivatizedDllName_U(
2600 _In_ PUNICODE_STRING DllName,
2601 _Out_ PUNICODE_STRING RealName,
2602 _Out_ PUNICODE_STRING LocalName
2603 );
2604
2605 NTSYSAPI
2606 VOID
2607 NTAPI
2608 RtlDestroyEnvironment(
2609 _In_ PWSTR Environment
2610 );
2611
2612 NTSYSAPI
2613 BOOLEAN
2614 NTAPI
2615 RtlDoesFileExists_U(
2616 _In_ PCWSTR FileName
2617 );
2618
2619 NTSYSAPI
2620 RTL_PATH_TYPE
2621 NTAPI
2622 RtlDetermineDosPathNameType_U(
2623 _In_ PCWSTR Path
2624 );
2625
2626 NTSYSAPI
2627 ULONG
2628 NTAPI
2629 RtlDosSearchPath_U(
2630 _In_ PCWSTR Path,
2631 _In_ PCWSTR FileName,
2632 _In_ PCWSTR Extension,
2633 _In_ ULONG BufferSize,
2634 _Out_ PWSTR Buffer,
2635 _Out_ PWSTR *PartName
2636 );
2637
2638 NTSYSAPI
2639 NTSTATUS
2640 NTAPI
2641 RtlDosSearchPath_Ustr(
2642 _In_ ULONG Flags,
2643 _In_ PUNICODE_STRING PathString,
2644 _In_ PUNICODE_STRING FileNameString,
2645 _In_ PUNICODE_STRING ExtensionString,
2646 _In_ PUNICODE_STRING CallerBuffer,
2647 _Inout_opt_ PUNICODE_STRING DynamicString,
2648 _Out_opt_ PUNICODE_STRING* FullNameOut,
2649 _Out_opt_ PSIZE_T FilePartSize,
2650 _Out_opt_ PSIZE_T LengthNeeded
2651 );
2652
2653 NTSYSAPI
2654 BOOLEAN
2655 NTAPI
2656 RtlDosPathNameToNtPathName_U(
2657 _In_opt_z_ PCWSTR DosPathName,
2658 _Out_ PUNICODE_STRING NtPathName,
2659 _Out_opt_ PCWSTR *NtFileNamePart,
2660 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2661 );
2662
2663 NTSYSAPI
2664 BOOLEAN
2665 NTAPI
2666 RtlDosPathNameToRelativeNtPathName_U(
2667 _In_ PCWSTR DosName,
2668 _Out_ PUNICODE_STRING NtName,
2669 _Out_ PCWSTR *PartName,
2670 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2671 );
2672
2673 _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength))
2674 NTSYSAPI
2675 NTSTATUS
2676 NTAPI
2677 RtlExpandEnvironmentStrings_U(
2678 _In_z_ PWSTR Environment,
2679 _In_ PUNICODE_STRING Source,
2680 _Inout_ PUNICODE_STRING Destination,
2681 _Out_ PULONG Length
2682 );
2683
2684 NTSYSAPI
2685 ULONG
2686 NTAPI
2687 RtlGetCurrentDirectory_U(
2688 _In_ ULONG MaximumLength,
2689 _Out_bytecap_(MaximumLength) PWSTR Buffer
2690 );
2691
2692 NTSYSAPI
2693 ULONG
2694 NTAPI
2695 RtlGetFullPathName_U(
2696 _In_ PCWSTR FileName,
2697 _In_ ULONG Size,
2698 _Out_z_bytecap_(Size) PWSTR Buffer,
2699 _Out_opt_ PWSTR *ShortName
2700 );
2701
2702 #if (NTDDI_VERSION >= NTDDI_WIN7)
2703 NTSYSAPI
2704 NTSTATUS
2705 NTAPI
2706 RtlGetFullPathName_UEx(
2707 _In_ PWSTR FileName,
2708 _In_ ULONG BufferLength,
2709 _Out_ PWSTR Buffer,
2710 _Out_opt_ PWSTR *FilePart,
2711 _Out_opt_ RTL_PATH_TYPE *InputPathType
2712 );
2713 #endif
2714
2715 NTSTATUS
2716 NTAPI
2717 RtlGetFullPathName_UstrEx(
2718 _In_ PUNICODE_STRING FileName,
2719 _In_opt_ PUNICODE_STRING StaticString,
2720 _In_opt_ PUNICODE_STRING DynamicString,
2721 _Out_opt_ PUNICODE_STRING *StringUsed,
2722 _Out_opt_ PSIZE_T FilePartSize,
2723 _Out_opt_ PBOOLEAN NameInvalid,
2724 _Out_ RTL_PATH_TYPE* PathType,
2725 _Out_opt_ PSIZE_T LengthNeeded
2726 );
2727
2728 NTSYSAPI
2729 NTSTATUS
2730 NTAPI
2731 RtlGetLengthWithoutTrailingPathSeparators(
2732 _In_ ULONG Flags,
2733 _In_ PCUNICODE_STRING PathString,
2734 _Out_ PULONG Length
2735 );
2736 /*
2737 * NOTE: the export is called RtlGetLengthWithoutTrailingPathSeperators
2738 * (with a 'e' instead of a 'a' in "Seperators").
2739 */
2740 #define RtlGetLengthWithoutTrailingPathSeperators \
2741 RtlGetLengthWithoutTrailingPathSeparators
2742
2743 NTSYSAPI
2744 ULONG
2745 NTAPI
2746 RtlGetLongestNtPathLength(
2747 VOID
2748 );
2749
2750 NTSYSAPI
2751 ULONG
2752 NTAPI
2753 RtlIsDosDeviceName_U(
2754 _In_ PCWSTR Name
2755 );
2756
2757 NTSYSAPI
2758 ULONG
2759 NTAPI
2760 RtlIsDosDeviceName_Ustr(
2761 _In_ PCUNICODE_STRING Name
2762 );
2763
2764 _IRQL_requires_max_(PASSIVE_LEVEL)
2765 _Must_inspect_result_
2766 NTSYSAPI
2767 BOOLEAN
2768 NTAPI
2769 RtlIsNameLegalDOS8Dot3(
2770 _In_ PCUNICODE_STRING Name,
2771 _Inout_opt_ POEM_STRING OemName,
2772 _Out_opt_ PBOOLEAN NameContainsSpaces
2773 );
2774
2775 NTSYSAPI
2776 NTSTATUS
2777 NTAPI
2778 RtlQueryEnvironmentVariable_U(
2779 _In_opt_ PWSTR Environment,
2780 _In_ PUNICODE_STRING Name,
2781 _Out_ PUNICODE_STRING Value
2782 );
2783
2784 VOID
2785 NTAPI
2786 RtlReleaseRelativeName(
2787 _In_ PRTL_RELATIVE_NAME_U RelativeName
2788 );
2789
2790 NTSYSAPI
2791 NTSTATUS
2792 NTAPI
2793 RtlSetCurrentDirectory_U(
2794 _In_ PUNICODE_STRING name
2795 );
2796
2797 NTSYSAPI
2798 NTSTATUS
2799 NTAPI
2800 RtlSetEnvironmentVariable(
2801 _In_z_ PWSTR *Environment,
2802 _In_ PUNICODE_STRING Name,
2803 _In_ PUNICODE_STRING Value
2804 );
2805
2806 //
2807 // Critical Section/Resource Functions
2808 //
2809 NTSYSAPI
2810 NTSTATUS
2811 NTAPI
2812 RtlDeleteCriticalSection (
2813 _In_ PRTL_CRITICAL_SECTION CriticalSection
2814 );
2815
2816 NTSYSAPI
2817 NTSTATUS
2818 NTAPI
2819 RtlEnterCriticalSection(
2820 _In_ PRTL_CRITICAL_SECTION CriticalSection
2821 );
2822
2823 NTSYSAPI
2824 NTSTATUS
2825 NTAPI
2826 RtlInitializeCriticalSection(
2827 _In_ PRTL_CRITICAL_SECTION CriticalSection
2828 );
2829
2830 NTSYSAPI
2831 NTSTATUS
2832 NTAPI
2833 RtlInitializeCriticalSectionAndSpinCount(
2834 _In_ PRTL_CRITICAL_SECTION CriticalSection,
2835 _In_ ULONG SpinCount
2836 );
2837
2838 NTSYSAPI
2839 NTSTATUS
2840 NTAPI
2841 RtlLeaveCriticalSection(
2842 _In_ PRTL_CRITICAL_SECTION CriticalSection
2843 );
2844
2845 NTSYSAPI
2846 BOOLEAN
2847 NTAPI
2848 RtlTryEnterCriticalSection(
2849 _In_ PRTL_CRITICAL_SECTION CriticalSection
2850 );
2851
2852 NTSYSAPI
2853 VOID
2854 NTAPI
2855 RtlpUnWaitCriticalSection(
2856 _In_ PRTL_CRITICAL_SECTION CriticalSection
2857 );
2858
2859 NTSYSAPI
2860 NTSTATUS
2861 NTAPI
2862 RtlpWaitForCriticalSection(
2863 _In_ PRTL_CRITICAL_SECTION CriticalSection
2864 );
2865
2866 NTSYSAPI
2867 BOOLEAN
2868 NTAPI
2869 RtlAcquireResourceExclusive(
2870 _In_ PRTL_RESOURCE Resource,
2871 _In_ BOOLEAN Wait
2872 );
2873
2874 NTSYSAPI
2875 BOOLEAN
2876 NTAPI
2877 RtlAcquireResourceShared(
2878 _In_ PRTL_RESOURCE Resource,
2879 _In_ BOOLEAN Wait
2880 );
2881
2882 NTSYSAPI
2883 VOID
2884 NTAPI
2885 RtlConvertExclusiveToShared(
2886 _In_ PRTL_RESOURCE Resource
2887 );
2888
2889 NTSYSAPI
2890 VOID
2891 NTAPI
2892 RtlConvertSharedToExclusive(
2893 _In_ PRTL_RESOURCE Resource
2894 );
2895
2896 NTSYSAPI
2897 VOID
2898 NTAPI
2899 RtlDeleteResource(
2900 _In_ PRTL_RESOURCE Resource
2901 );
2902
2903 NTSYSAPI
2904 VOID
2905 NTAPI
2906 RtlDumpResource(
2907 _In_ PRTL_RESOURCE Resource
2908 );
2909
2910 NTSYSAPI
2911 VOID
2912 NTAPI
2913 RtlInitializeResource(
2914 _In_ PRTL_RESOURCE Resource
2915 );
2916
2917 NTSYSAPI
2918 VOID
2919 NTAPI
2920 RtlReleaseResource(
2921 _In_ PRTL_RESOURCE Resource
2922 );
2923
2924 //
2925 // Compression Functions
2926 //
2927 NTSYSAPI //NT_RTL_COMPRESS_API
2928 NTSTATUS
2929 NTAPI
2930 RtlCompressBuffer(
2931 _In_ USHORT CompressionFormatAndEngine,
2932 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer,
2933 _In_ ULONG UncompressedBufferSize,
2934 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer,
2935 _In_ ULONG CompressedBufferSize,
2936 _In_ ULONG UncompressedChunkSize,
2937 _Out_ PULONG FinalCompressedSize,
2938 _In_ PVOID WorkSpace
2939 );
2940
2941 _IRQL_requires_max_(APC_LEVEL)
2942 NTSYSAPI //NT_RTL_COMPRESS_API
2943 NTSTATUS
2944 NTAPI
2945 RtlDecompressBuffer(
2946 _In_ USHORT CompressionFormat,
2947 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
2948 _In_ ULONG UncompressedBufferSize,
2949 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
2950 _In_ ULONG CompressedBufferSize,
2951 _Out_ PULONG FinalUncompressedSize
2952 );
2953
2954 NTSYSAPI
2955 NTSTATUS
2956 NTAPI
2957 RtlGetCompressionWorkSpaceSize(
2958 _In_ USHORT CompressionFormatAndEngine,
2959 _Out_ PULONG CompressBufferWorkSpaceSize,
2960 _Out_ PULONG CompressFragmentWorkSpaceSize
2961 );
2962
2963 //
2964 // Debug Info Functions
2965 //
2966 NTSYSAPI
2967 PRTL_DEBUG_INFORMATION
2968 NTAPI
2969 RtlCreateQueryDebugBuffer(
2970 _In_ ULONG Size,
2971 _In_ BOOLEAN EventPair
2972 );
2973
2974 NTSYSAPI
2975 NTSTATUS
2976 NTAPI
2977 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
2978
2979 NTSYSAPI
2980 NTSTATUS
2981 NTAPI
2982 RtlQueryProcessDebugInformation(
2983 _In_ ULONG ProcessId,
2984 _In_ ULONG DebugInfoClassMask,
2985 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
2986 );
2987
2988 //
2989 // Bitmap Functions
2990 //
2991 NTSYSAPI
2992 BOOLEAN
2993 NTAPI
2994 RtlAreBitsClear(
2995 _In_ PRTL_BITMAP BitMapHeader,
2996 _In_ ULONG StartingIndex,
2997 _In_ ULONG Length
2998 );
2999
3000 NTSYSAPI
3001 BOOLEAN
3002 NTAPI
3003 RtlAreBitsSet(
3004 _In_ PRTL_BITMAP BitMapHeader,
3005 _In_ ULONG StartingIndex,
3006 _In_ ULONG Length
3007 );
3008
3009 NTSYSAPI
3010 VOID
3011 NTAPI
3012 RtlClearAllBits(
3013 _In_ PRTL_BITMAP BitMapHeader
3014 );
3015
3016 NTSYSAPI
3017 VOID
3018 NTAPI
3019 RtlClearBits(
3020 _In_ PRTL_BITMAP BitMapHeader,
3021 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3022 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3023 );
3024
3025 NTSYSAPI
3026 ULONG
3027 NTAPI
3028 RtlFindClearBits(
3029 _In_ PRTL_BITMAP BitMapHeader,
3030 _In_ ULONG NumberToFind,
3031 _In_ ULONG HintIndex
3032 );
3033
3034 NTSYSAPI
3035 ULONG
3036 NTAPI
3037 RtlFindClearBitsAndSet(
3038 _In_ PRTL_BITMAP BitMapHeader,
3039 _In_ ULONG NumberToFind,
3040 _In_ ULONG HintIndex
3041 );
3042
3043 NTSYSAPI
3044 CCHAR
3045 NTAPI
3046 RtlFindLeastSignificantBit(
3047 _In_ ULONGLONG Value
3048 );
3049
3050 NTSYSAPI
3051 CCHAR
3052 NTAPI
3053 RtlFindMostSignificantBit(
3054 _In_ ULONGLONG Value
3055 );
3056
3057 NTSYSAPI
3058 ULONG
3059 NTAPI
3060 RtlFindNextForwardRunClear(
3061 _In_ PRTL_BITMAP BitMapHeader,
3062 _In_ ULONG FromIndex,
3063 _Out_ PULONG StartingRunIndex
3064 );
3065
3066 NTSYSAPI
3067 ULONG
3068 NTAPI
3069 RtlFindNextForwardRunSet(
3070 _In_ PRTL_BITMAP BitMapHeader,
3071 _In_ ULONG FromIndex,
3072 _Out_ PULONG StartingRunIndex
3073 );
3074
3075 NTSYSAPI
3076 ULONG
3077 NTAPI
3078 RtlFindSetBits(
3079 _In_ PRTL_BITMAP BitMapHeader,
3080 _In_ ULONG NumberToFind,
3081 _In_ ULONG HintIndex
3082 );
3083
3084 NTSYSAPI
3085 ULONG
3086 NTAPI
3087 RtlFindSetBitsAndClear(
3088 _In_ PRTL_BITMAP BitMapHeader,
3089 _In_ ULONG NumberToFind,
3090 _In_ ULONG HintIndex
3091 );
3092
3093 #ifdef _REACTOS_ // ReactOS improvement
3094 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3095 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3096 #endif
3097 NTSYSAPI
3098 VOID
3099 NTAPI
3100 RtlInitializeBitMap(
3101 _Out_ PRTL_BITMAP BitMapHeader,
3102 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3103 _In_opt_ ULONG SizeOfBitMap
3104 );
3105
3106 NTSYSAPI
3107 ULONG
3108 NTAPI
3109 RtlNumberOfClearBits(
3110 _In_ PRTL_BITMAP BitMapHeader
3111 );
3112
3113 NTSYSAPI
3114 ULONG
3115 NTAPI
3116 RtlNumberOfSetBits(
3117 _In_ PRTL_BITMAP BitMapHeader
3118 );
3119
3120 NTSYSAPI
3121 VOID
3122 NTAPI
3123 RtlSetBit(
3124 _In_ PRTL_BITMAP BitMapHeader,
3125 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3126 );
3127
3128 NTSYSAPI
3129 VOID
3130 NTAPI
3131 RtlSetBits(
3132 _In_ PRTL_BITMAP BitMapHeader,
3133 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3134 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3135 );
3136
3137 NTSYSAPI
3138 VOID
3139 NTAPI
3140 RtlSetAllBits(
3141 _In_ PRTL_BITMAP BitMapHeader
3142 );
3143
3144 _Must_inspect_result_
3145 NTSYSAPI
3146 BOOLEAN
3147 NTAPI
3148 RtlTestBit(
3149 _In_ PRTL_BITMAP BitMapHeader,
3150 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3151 );
3152
3153 //
3154 // Timer Functions
3155 //
3156 NTSYSAPI
3157 NTSTATUS
3158 NTAPI
3159 RtlCreateTimer(
3160 _In_ HANDLE TimerQueue,
3161 _In_ PHANDLE phNewTimer,
3162 _In_ WAITORTIMERCALLBACKFUNC Callback,
3163 _In_ PVOID Parameter,
3164 _In_ ULONG DueTime,
3165 _In_ ULONG Period,
3166 _In_ ULONG Flags
3167 );
3168
3169 NTSYSAPI
3170 NTSTATUS
3171 NTAPI
3172 RtlCreateTimerQueue(PHANDLE TimerQueue);
3173
3174 NTSYSAPI
3175 NTSTATUS
3176 NTAPI
3177 RtlDeleteTimer(
3178 _In_ HANDLE TimerQueue,
3179 _In_ HANDLE Timer,
3180 _In_ HANDLE CompletionEvent
3181 );
3182
3183 NTSYSAPI
3184 NTSTATUS
3185 NTAPI
3186 RtlUpdateTimer(
3187 _In_ HANDLE TimerQueue,
3188 _In_ HANDLE Timer,
3189 _In_ ULONG DueTime,
3190 _In_ ULONG Period
3191 );
3192
3193 NTSYSAPI
3194 NTSTATUS
3195 NTAPI
3196 RtlDeleteTimerQueueEx(
3197 _In_ HANDLE TimerQueue,
3198 _In_opt_ HANDLE CompletionEvent
3199 );
3200
3201 NTSYSAPI
3202 NTSTATUS
3203 NTAPI
3204 RtlDeleteTimerQueue(HANDLE TimerQueue);
3205
3206 //
3207 // SList functions
3208 //
3209 PSLIST_ENTRY
3210 FASTCALL
3211 InterlockedPushListSList(
3212 _Inout_ PSLIST_HEADER ListHead,
3213 _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
3214 _Inout_ PSLIST_ENTRY ListEnd,
3215 _In_ ULONG Count
3216 );
3217
3218 //
3219 // Range List functions
3220 //
3221 NTSYSAPI
3222 VOID
3223 NTAPI
3224 RtlInitializeRangeList(
3225 _Inout_ PRTL_RANGE_LIST RangeList
3226 );
3227
3228 NTSYSAPI
3229 VOID
3230 NTAPI
3231 RtlFreeRangeList(
3232 _In_ PRTL_RANGE_LIST RangeList
3233 );
3234
3235 NTSYSAPI
3236 NTSTATUS
3237 NTAPI
3238 RtlAddRange(
3239 _Inout_ PRTL_RANGE_LIST RangeList,
3240 _In_ ULONGLONG Start,
3241 _In_ ULONGLONG End,
3242 _In_ UCHAR Attributes,
3243 _In_ ULONG Flags,
3244 _In_opt_ PVOID UserData,
3245 _In_opt_ PVOID Owner
3246 );
3247
3248 //
3249 // Debug Functions
3250 //
3251 ULONG
3252 __cdecl
3253 DbgPrint(
3254 _In_z_ _Printf_format_string_ PCSTR Format,
3255 ...
3256 );
3257
3258 NTSYSAPI
3259 ULONG
3260 __cdecl
3261 DbgPrintEx(
3262 _In_ ULONG ComponentId,
3263 _In_ ULONG Level,
3264 _In_z_ _Printf_format_string_ PCSTR Format,
3265 ...
3266 );
3267
3268 NTSYSAPI
3269 ULONG
3270 NTAPI
3271 DbgPrompt(
3272 _In_z_ PCCH Prompt,
3273 _Out_writes_bytes_(MaximumResponseLength) PCH Response,
3274 _In_ ULONG MaximumResponseLength
3275 );
3276
3277 #undef DbgBreakPoint
3278 VOID
3279 NTAPI
3280 DbgBreakPoint(
3281 VOID
3282 );
3283
3284 VOID
3285 NTAPI
3286 DbgLoadImageSymbols(
3287 _In_ PSTRING Name,
3288 _In_ PVOID Base,
3289 _In_ ULONG_PTR ProcessId
3290 );
3291
3292 VOID
3293 NTAPI
3294 DbgUnLoadImageSymbols(
3295 _In_ PSTRING Name,
3296 _In_ PVOID Base,
3297 _In_ ULONG_PTR ProcessId
3298 );
3299
3300 VOID
3301 NTAPI
3302 DbgCommandString(
3303 _In_ PCCH Name,
3304 _In_ PCCH Command
3305 );
3306
3307 //
3308 // Generic Table Functions
3309 //
3310 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3311 NTSYSAPI
3312 PVOID
3313 NTAPI
3314 RtlInsertElementGenericTable(
3315 _In_ PRTL_GENERIC_TABLE Table,
3316 _In_reads_bytes_(BufferSize) PVOID Buffer,
3317 _In_ CLONG BufferSize,
3318 _Out_opt_ PBOOLEAN NewElement
3319 );
3320
3321 NTSYSAPI
3322 PVOID
3323 NTAPI
3324 RtlInsertElementGenericTableFull(
3325 _In_ PRTL_GENERIC_TABLE Table,
3326 _In_reads_bytes_(BufferSize) PVOID Buffer,
3327 _In_ CLONG BufferSize,
3328 _Out_opt_ PBOOLEAN NewElement,
3329 _In_ PVOID NodeOrParent,
3330 _In_ TABLE_SEARCH_RESULT SearchResult
3331 );
3332
3333 NTSYSAPI
3334 BOOLEAN
3335 NTAPI
3336 RtlIsGenericTableEmpty(
3337 _In_ PRTL_GENERIC_TABLE Table
3338 );
3339
3340 NTSYSAPI
3341 PVOID
3342 NTAPI
3343 RtlLookupElementGenericTableFull(
3344 _In_ PRTL_GENERIC_TABLE Table,
3345 _In_ PVOID Buffer,
3346 _Out_ PVOID *NodeOrParent,
3347 _Out_ TABLE_SEARCH_RESULT *SearchResult
3348 );
3349 #endif
3350
3351 //
3352 // Handle Table Functions
3353 //
3354 NTSYSAPI
3355 PRTL_HANDLE_TABLE_ENTRY
3356 NTAPI
3357 RtlAllocateHandle(
3358 _In_ PRTL_HANDLE_TABLE HandleTable,
3359 _Inout_ PULONG Index
3360 );
3361
3362 NTSYSAPI
3363 VOID
3364 NTAPI
3365 RtlDestroyHandleTable(
3366 _Inout_ PRTL_HANDLE_TABLE HandleTable);
3367
3368 NTSYSAPI
3369 BOOLEAN
3370 NTAPI
3371 RtlFreeHandle(
3372 _In_ PRTL_HANDLE_TABLE HandleTable,
3373 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3374 );
3375
3376 NTSYSAPI
3377 VOID
3378 NTAPI
3379 RtlInitializeHandleTable(
3380 _In_ ULONG TableSize,
3381 _In_ ULONG HandleSize,
3382 _In_ PRTL_HANDLE_TABLE HandleTable
3383 );
3384
3385 NTSYSAPI
3386 BOOLEAN
3387 NTAPI
3388 RtlIsValidHandle(
3389 _In_ PRTL_HANDLE_TABLE HandleTable,
3390 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3391 );
3392
3393 _Success_(return!=FALSE)
3394 NTSYSAPI
3395 BOOLEAN
3396 NTAPI
3397 RtlIsValidIndexHandle(
3398 _In_ PRTL_HANDLE_TABLE HandleTable,
3399 _In_ ULONG Index,
3400 _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle
3401 );
3402
3403 //
3404 // PE Functions
3405 //
3406 NTSYSAPI
3407 NTSTATUS
3408 NTAPI
3409 RtlFindMessage(
3410 _In_ PVOID BaseAddress,
3411 _In_ ULONG Type,
3412 _In_ ULONG Language,
3413 _In_ ULONG MessageId,
3414 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3415 );
3416
3417 NTSYSAPI
3418 ULONG
3419 NTAPI
3420 RtlGetNtGlobalFlags(VOID);
3421
3422 _Success_(return!=NULL)
3423 NTSYSAPI
3424 PVOID
3425 NTAPI
3426 RtlImageDirectoryEntryToData(
3427 _In_ PVOID BaseAddress,
3428 _In_ BOOLEAN MappedAsImage,
3429 _In_ USHORT Directory,
3430 _Out_ PULONG Size
3431 );
3432
3433 NTSYSAPI
3434 PVOID
3435 NTAPI
3436 RtlImageRvaToVa(
3437 _In_ PIMAGE_NT_HEADERS NtHeader,
3438 _In_ PVOID BaseAddress,
3439 _In_ ULONG Rva,
3440 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3441 );
3442
3443 NTSYSAPI
3444 PIMAGE_NT_HEADERS
3445 NTAPI
3446 RtlImageNtHeader(
3447 _In_ PVOID BaseAddress);
3448
3449 NTSYSAPI
3450 NTSTATUS
3451 NTAPI
3452 RtlImageNtHeaderEx(
3453 _In_ ULONG Flags,
3454 _In_ PVOID BaseAddress,
3455 _In_ ULONGLONG Size,
3456 _Out_ PIMAGE_NT_HEADERS *NtHeader
3457 );
3458
3459 NTSYSAPI
3460 PIMAGE_SECTION_HEADER
3461 NTAPI
3462 RtlImageRvaToSection(
3463 _In_ PIMAGE_NT_HEADERS NtHeader,
3464 _In_ PVOID BaseAddress,
3465 _In_ ULONG Rva
3466 );
3467
3468 NTSYSAPI
3469 ULONG
3470 NTAPI
3471 LdrRelocateImageWithBias(
3472 _In_ PVOID NewAddress,
3473 _In_ LONGLONG AdditionalBias,
3474 _In_ PCCH LoaderName,
3475 _In_ ULONG Success,
3476 _In_ ULONG Conflict,
3477 _In_ ULONG Invalid
3478 );
3479
3480 //
3481 // Activation Context Functions
3482 //
3483 #ifdef NTOS_MODE_USER
3484 NTSYSAPI
3485 NTSTATUS
3486 NTAPI
3487 RtlActivateActivationContextEx(
3488 _In_ ULONG Flags,
3489 _In_ PTEB Teb,
3490 _In_ PVOID Context,
3491 _Out_ PULONG_PTR Cookie
3492 );
3493
3494 NTSYSAPI
3495 NTSTATUS
3496 NTAPI
3497 RtlActivateActivationContext(
3498 _In_ ULONG Flags,
3499 _In_ HANDLE Handle,
3500 _Out_ PULONG_PTR Cookie
3501 );
3502
3503 NTSYSAPI
3504 VOID
3505 NTAPI
3506 RtlAddRefActivationContext(
3507 _In_ PVOID Context
3508 );
3509
3510 NTSYSAPI
3511 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3512 FASTCALL
3513 RtlActivateActivationContextUnsafeFast(
3514 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
3515 _In_ PVOID Context
3516 );
3517
3518 NTSYSAPI
3519 NTSTATUS
3520 NTAPI
3521 RtlAllocateActivationContextStack(
3522 _In_ PACTIVATION_CONTEXT_STACK *Stack
3523 );
3524
3525 NTSYSAPI
3526 NTSTATUS
3527 NTAPI
3528 RtlCreateActivationContext(
3529 _In_ ULONG Flags,
3530 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
3531 _In_ ULONG ExtraBytes,
3532 _In_ PVOID NotificationRoutine,
3533 _In_ PVOID NotificationContext,
3534 _Out_ PACTIVATION_CONTEXT *ActCtx
3535 );
3536
3537 NTSYSAPI
3538 NTSTATUS
3539 NTAPI
3540 RtlGetActiveActivationContext(
3541 _In_ PVOID *Context
3542 );
3543
3544 NTSYSAPI
3545 VOID
3546 NTAPI
3547 RtlReleaseActivationContext(
3548 _In_ HANDLE handle
3549 );
3550
3551 NTSYSAPI
3552 NTSTATUS
3553 NTAPI
3554 RtlDeactivateActivationContext(
3555 _In_ ULONG dwFlags,
3556 _In_ ULONG_PTR ulCookie
3557 );
3558
3559 NTSYSAPI
3560 VOID
3561 NTAPI
3562 RtlFreeActivationContextStack(
3563 _In_ PACTIVATION_CONTEXT_STACK Stack
3564 );
3565
3566 NTSYSAPI
3567 VOID
3568 NTAPI
3569 RtlFreeThreadActivationContextStack(VOID);
3570
3571 NTSYSAPI
3572 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3573 FASTCALL
3574 RtlDeactivateActivationContextUnsafeFast(
3575 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3576 );
3577
3578 NTSYSAPI
3579 NTSTATUS
3580 NTAPI
3581 RtlDosApplyFileIsolationRedirection_Ustr(
3582 _In_ ULONG Flags,
3583 _In_ PUNICODE_STRING OriginalName,
3584 _In_ PUNICODE_STRING Extension,
3585 _Inout_ PUNICODE_STRING StaticString,
3586 _Inout_ PUNICODE_STRING DynamicString,
3587 _Inout_ PUNICODE_STRING *NewName,
3588 _In_ PULONG NewFlags,
3589 _In_ PSIZE_T FileNameSize,
3590 _In_ PSIZE_T RequiredLength
3591 );
3592
3593 NTSYSAPI
3594 NTSTATUS
3595 NTAPI
3596 RtlFindActivationContextSectionString(
3597 _In_ ULONG dwFlags,
3598 _In_ const GUID *ExtensionGuid,
3599 _In_ ULONG SectionType,
3600 _In_ PUNICODE_STRING SectionName,
3601 _Inout_ PVOID ReturnedData
3602 );
3603
3604 NTSYSAPI
3605 NTSTATUS
3606 NTAPI
3607 RtlQueryInformationActivationContext(
3608 _In_ DWORD dwFlags,
3609 _In_opt_ PVOID Context,
3610 _In_opt_ PVOID pvSubInstance,
3611 _In_ ULONG ulInfoClass,
3612 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3613 _In_opt_ SIZE_T cbBuffer,
3614 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3615 );
3616
3617 NTSYSAPI
3618 NTSTATUS
3619 NTAPI
3620 RtlQueryInformationActiveActivationContext(
3621 _In_ ULONG ulInfoClass,
3622 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3623 _In_opt_ SIZE_T cbBuffer,
3624 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3625 );
3626
3627 NTSYSAPI
3628 NTSTATUS
3629 NTAPI
3630 RtlZombifyActivationContext(
3631 PVOID Context
3632 );
3633
3634 //
3635 // WOW64 Functions
3636 //
3637 NTSYSAPI
3638 NTSTATUS
3639 NTAPI
3640 RtlWow64EnableFsRedirection(
3641 _In_ BOOLEAN Wow64FsEnableRedirection
3642 );
3643
3644 NTSYSAPI
3645 NTSTATUS
3646 NTAPI
3647 RtlWow64EnableFsRedirectionEx(
3648 _In_ PVOID Wow64FsEnableRedirection,
3649 _Out_ PVOID *OldFsRedirectionLevel
3650 );
3651
3652 #endif
3653
3654 //
3655 // Registry Functions
3656 //
3657 _IRQL_requires_max_(PASSIVE_LEVEL)
3658 _Must_inspect_result_
3659 NTSYSAPI
3660 NTSTATUS
3661 NTAPI
3662 RtlCheckRegistryKey(
3663 _In_ ULONG RelativeTo,
3664 _In_ PWSTR Path
3665 );
3666
3667 NTSYSAPI
3668 NTSTATUS
3669 NTAPI
3670 RtlCreateRegistryKey(
3671 _In_ ULONG RelativeTo,
3672 _In_ PWSTR Path
3673 );
3674
3675 NTSYSAPI
3676 NTSTATUS
3677 NTAPI
3678 RtlFormatCurrentUserKeyPath(
3679 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
3680 PUNICODE_STRING KeyPath
3681 );
3682
3683 NTSYSAPI
3684 NTSTATUS
3685 NTAPI
3686 RtlOpenCurrentUser(
3687 _In_ ACCESS_MASK DesiredAccess,
3688 _Out_ PHANDLE KeyHandle
3689 );
3690
3691 _IRQL_requires_max_(PASSIVE_LEVEL)
3692 NTSYSAPI
3693 NTSTATUS
3694 NTAPI
3695 RtlQueryRegistryValues(
3696 _In_ ULONG RelativeTo,
3697 _In_ PCWSTR Path,
3698 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
3699 PRTL_QUERY_REGISTRY_TABLE QueryTable,
3700 _In_opt_ PVOID Context,
3701 _In_opt_ PVOID Environment
3702 );
3703
3704 _IRQL_requires_max_(PASSIVE_LEVEL)
3705 NTSYSAPI
3706 NTSTATUS
3707 NTAPI
3708 RtlWriteRegistryValue(
3709 _In_ ULONG RelativeTo,
3710 _In_ PCWSTR Path,
3711 _In_z_ PCWSTR ValueName,
3712 _In_ ULONG ValueType,
3713 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
3714 _In_ ULONG ValueLength
3715 );
3716
3717 #ifdef NTOS_MODE_USER
3718 NTSYSAPI
3719 NTSTATUS
3720 NTAPI
3721 RtlpNtCreateKey(
3722 _Out_ HANDLE KeyHandle,
3723 _In_ ACCESS_MASK DesiredAccess,
3724 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3725 _In_ ULONG TitleIndex,
3726 _In_ PUNICODE_STRING Class,
3727 _Out_ PULONG Disposition
3728 );
3729
3730 NTSYSAPI
3731 NTSTATUS
3732 NTAPI
3733 RtlpNtEnumerateSubKey(
3734 _In_ HANDLE KeyHandle,
3735 _Inout_ PUNICODE_STRING SubKeyName,
3736 _In_ ULONG Index,
3737 _In_ ULONG Unused
3738 );
3739
3740 NTSYSAPI
3741 NTSTATUS
3742 NTAPI
3743 RtlpNtMakeTemporaryKey(
3744 _In_ HANDLE KeyHandle
3745 );
3746
3747 NTSYSAPI
3748 NTSTATUS
3749 NTAPI
3750 RtlpNtOpenKey(
3751 _Out_ HANDLE KeyHandle,
3752 _In_ ACCESS_MASK DesiredAccess,
3753 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3754 _In_ ULONG Unused
3755 );
3756
3757 NTSYSAPI
3758 NTSTATUS
3759 NTAPI
3760 RtlpNtQueryValueKey(
3761 _In_ HANDLE KeyHandle,
3762 _Out_opt_ PULONG Type,
3763 _Out_opt_ PVOID Data,
3764 _Inout_opt_ PULONG DataLength,
3765 _In_ ULONG Unused
3766 );
3767
3768 NTSYSAPI
3769 NTSTATUS
3770 NTAPI
3771 RtlpNtSetValueKey(
3772 _In_ HANDLE KeyHandle,
3773 _In_ ULONG Type,
3774 _In_ PVOID Data,
3775 _In_ ULONG DataLength
3776 );
3777 #endif
3778
3779 //
3780 // NLS Functions
3781 //
3782 NTSYSAPI
3783 VOID
3784 NTAPI
3785 RtlGetDefaultCodePage(
3786 _Out_ PUSHORT AnsiCodePage,
3787 _Out_ PUSHORT OemCodePage
3788 );
3789
3790 NTSYSAPI
3791 VOID
3792 NTAPI
3793 RtlInitNlsTables(
3794 _In_ PUSHORT AnsiTableBase,
3795 _In_ PUSHORT OemTableBase,
3796 _In_ PUSHORT CaseTableBase,
3797 _Out_ PNLSTABLEINFO NlsTable
3798 );
3799
3800 _IRQL_requires_max_(PASSIVE_LEVEL)
3801 NTSYSAPI
3802 VOID
3803 NTAPI
3804 RtlInitCodePageTable(
3805 _In_ PUSHORT TableBase,
3806 _Out_ PCPTABLEINFO CodePageTable
3807 );
3808
3809 NTSYSAPI
3810 VOID
3811 NTAPI
3812 RtlResetRtlTranslations(
3813 _In_ PNLSTABLEINFO NlsTable);
3814
3815 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3816
3817 //
3818 // Misc conversion functions
3819 //
3820 static __inline
3821 LARGE_INTEGER
3822 NTAPI_INLINE
3823 RtlConvertLongToLargeInteger(
3824 _In_ LONG SignedInteger
3825 )
3826 {
3827 LARGE_INTEGER Result;
3828
3829 Result.QuadPart = SignedInteger;
3830 return Result;
3831 }
3832
3833 static __inline
3834 LARGE_INTEGER
3835 NTAPI_INLINE
3836 RtlEnlargedIntegerMultiply(
3837 _In_ LONG Multiplicand,
3838 _In_ LONG Multiplier
3839 )
3840 {
3841 LARGE_INTEGER Product;
3842
3843 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
3844 return Product;
3845 }
3846
3847 static __inline
3848 ULONG
3849 NTAPI_INLINE
3850 RtlEnlargedUnsignedDivide(
3851 _In_ ULARGE_INTEGER Dividend,
3852 _In_ ULONG Divisor,
3853 _In_opt_ PULONG Remainder
3854 )
3855 {
3856 ULONG Quotient;
3857
3858 Quotient = (ULONG)(Dividend.QuadPart / Divisor);
3859 if (Remainder) {
3860 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
3861 }
3862
3863 return Quotient;
3864 }
3865
3866 static __inline
3867 LARGE_INTEGER
3868 NTAPI_INLINE
3869 RtlEnlargedUnsignedMultiply(
3870 _In_ ULONG Multiplicand,
3871 _In_ ULONG Multiplier
3872 )
3873 {
3874 LARGE_INTEGER Product;
3875
3876 Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
3877 return Product;
3878 }
3879
3880 #if defined(_AMD64_) || defined(_IA64_)
3881 static __inline
3882 LARGE_INTEGER
3883 NTAPI_INLINE
3884 RtlExtendedLargeIntegerDivide(
3885 _In_ LARGE_INTEGER Dividend,
3886 _In_ ULONG Divisor,
3887 _Out_opt_ PULONG Remainder)
3888 {
3889 LARGE_INTEGER ret;
3890 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
3891 if (Remainder)
3892 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
3893 return ret;
3894 }
3895
3896 #else
3897 NTSYSAPI
3898 LARGE_INTEGER
3899 NTAPI
3900 RtlExtendedLargeIntegerDivide(
3901 _In_ LARGE_INTEGER Dividend,
3902 _In_ ULONG Divisor,
3903 _Out_opt_ PULONG Remainder
3904 );
3905
3906 #endif /* defined(_AMD64_) || defined(_IA64_) */
3907
3908 #endif
3909
3910
3911 NTSYSAPI
3912 ULONG
3913 NTAPI
3914 RtlUniform(
3915 _In_ PULONG Seed
3916 );
3917
3918 NTSYSAPI
3919 ULONG
3920 NTAPI
3921 RtlRandom(
3922 _Inout_ PULONG Seed
3923 );
3924
3925 NTSYSAPI
3926 ULONG
3927 NTAPI
3928 RtlComputeCrc32(
3929 _In_ ULONG InitialCrc,
3930 _In_ PUCHAR Buffer,
3931 _In_ ULONG Length
3932 );
3933
3934 //
3935 // Network Functions
3936 //
3937 NTSYSAPI
3938 NTSTATUS
3939 NTAPI
3940 RtlIpv4StringToAddressW(
3941 _In_ PCWSTR String,
3942 _In_ BOOLEAN Strict,
3943 _Out_ LPWSTR *Terminator,
3944 _Out_ struct in_addr *Addr
3945 );
3946
3947 NTSYSAPI
3948 NTSTATUS
3949 NTAPI
3950 RtlIpv6StringToAddressA(
3951 _In_ PCHAR Name,
3952 _Out_ PCHAR *Terminator,
3953 _Out_ struct in6_addr *Addr
3954 );
3955
3956 NTSYSAPI
3957 NTSTATUS
3958 NTAPI
3959 RtlIpv6StringToAddressW(
3960 _In_ PWCHAR Name,
3961 _Out_ PCHAR *Terminator,
3962 _Out_ struct in6_addr *Addr
3963 );
3964
3965 NTSYSAPI
3966 NTSTATUS
3967 NTAPI
3968 RtlIpv6StringToAddressExA(
3969 _In_ PCHAR AddressString,
3970 _In_ struct in6_addr *Address,
3971 _In_ PULONG ScopeId,
3972 _In_ PUSHORT Port
3973 );
3974
3975 NTSYSAPI
3976 NTSTATUS
3977 NTAPI
3978 RtlIpv6StringToAddressExW(
3979 _In_ PWCHAR AddressName,
3980 _In_ struct in6_addr *Address,
3981 _In_ PULONG ScopeId,
3982 _In_ PUSHORT Port
3983 );
3984
3985
3986 //
3987 // Time Functions
3988 //
3989 NTSYSAPI
3990 NTSTATUS
3991 NTAPI
3992 RtlQueryTimeZoneInformation(
3993 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
3994
3995 NTSYSAPI
3996 VOID
3997 NTAPI
3998 RtlSecondsSince1970ToTime(
3999 _In_ ULONG SecondsSince1970,
4000 _Out_ PLARGE_INTEGER Time
4001 );
4002
4003 NTSYSAPI
4004 NTSTATUS
4005 NTAPI
4006 RtlSetTimeZoneInformation(
4007 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
4008
4009 _Success_(return!=FALSE)
4010 _Must_inspect_result_
4011 NTSYSAPI
4012 BOOLEAN
4013 NTAPI
4014 RtlTimeFieldsToTime(
4015 _In_ PTIME_FIELDS TimeFields,
4016 _Out_ PLARGE_INTEGER Time
4017 );
4018
4019 _Success_(return != 0)
4020 _Must_inspect_result_
4021 NTSYSAPI
4022 BOOLEAN
4023 NTAPI
4024 RtlTimeToSecondsSince1970(
4025 _In_ PLARGE_INTEGER Time,
4026 _Out_ PULONG ElapsedSeconds
4027 );
4028
4029 NTSYSAPI
4030 VOID
4031 NTAPI
4032 RtlTimeToTimeFields(
4033 PLARGE_INTEGER Time,
4034 PTIME_FIELDS TimeFields
4035 );
4036
4037 NTSYSAPI
4038 NTSTATUS
4039 NTAPI
4040 RtlSystemTimeToLocalTime(
4041 _In_ PLARGE_INTEGER SystemTime,
4042 _Out_ PLARGE_INTEGER LocalTime
4043 );
4044
4045 //
4046 // Version Functions
4047 //
4048 _IRQL_requires_max_(PASSIVE_LEVEL)
4049 _Must_inspect_result_
4050 NTSYSAPI
4051 NTSTATUS
4052 NTAPI
4053 RtlVerifyVersionInfo(
4054 _In_ PRTL_OSVERSIONINFOEXW VersionInfo,
4055 _In_ ULONG TypeMask,
4056 _In_ ULONGLONG ConditionMask
4057 );
4058
4059 _IRQL_requires_max_(PASSIVE_LEVEL)
4060 NTSYSAPI
4061 NTSTATUS
4062 NTAPI
4063 RtlGetVersion(
4064 _Out_
4065 _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_)
4066 _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW),
4067 _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_))
4068 PRTL_OSVERSIONINFOW lpVersionInformation
4069 );