10dcd4685d8a6c058317f1df0688fc5bb604516c
[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 _IRQL_requires_max_(PASSIVE_LEVEL)
2116 NTSYSAPI
2117 VOID
2118 NTAPI
2119 RtlFreeUnicodeString(
2120 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem))
2121 PUNICODE_STRING UnicodeString
2122 );
2123
2124 NTSYSAPI
2125 VOID
2126 NTAPI
2127 RtlEraseUnicodeString(
2128 _Inout_ PUNICODE_STRING String
2129 );
2130
2131 NTSYSAPI
2132 NTSTATUS
2133 NTAPI
2134 RtlHashUnicodeString(
2135 _In_ CONST UNICODE_STRING *String,
2136 _In_ BOOLEAN CaseInSensitive,
2137 _In_ ULONG HashAlgorithm,
2138 _Out_ PULONG HashValue
2139 );
2140
2141 _IRQL_requires_max_(DISPATCH_LEVEL)
2142 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2143 _When_(SourceString != NULL,
2144 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
2145 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR))))
2146 _When_(SourceString == NULL,
2147 _At_(DestinationString->Length, _Post_equal_to_(0))
2148 _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2149 NTSYSAPI
2150 VOID
2151 NTAPI
2152 RtlInitUnicodeString(
2153 _Out_ PUNICODE_STRING DestinationString,
2154 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2155 );
2156
2157 _IRQL_requires_max_(DISPATCH_LEVEL)
2158 NTSYSAPI
2159 NTSTATUS
2160 NTAPI
2161 RtlInitUnicodeStringEx(
2162 _Out_ PUNICODE_STRING DestinationString,
2163 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2164 );
2165
2166 NTSYSAPI
2167 BOOLEAN
2168 NTAPI
2169 RtlIsTextUnicode(
2170 PVOID Buffer,
2171 INT Length,
2172 INT *Flags
2173 );
2174
2175 _IRQL_requires_max_(PASSIVE_LEVEL)
2176 _Must_inspect_result_
2177 NTSYSAPI
2178 BOOLEAN
2179 NTAPI
2180 RtlPrefixString(
2181 _In_ const STRING *String1,
2182 _In_ const STRING *String2,
2183 _In_ BOOLEAN CaseInsensitive
2184 );
2185
2186 _IRQL_requires_max_(PASSIVE_LEVEL)
2187 _Must_inspect_result_
2188 NTSYSAPI
2189 BOOLEAN
2190 NTAPI
2191 RtlPrefixUnicodeString(
2192 _In_ PCUNICODE_STRING String1,
2193 _In_ PCUNICODE_STRING String2,
2194 _In_ BOOLEAN CaseInsensitive
2195 );
2196
2197 _IRQL_requires_max_(PASSIVE_LEVEL)
2198 NTSYSAPI
2199 VOID
2200 NTAPI
2201 RtlUpperString(
2202 _Inout_ PSTRING DestinationString,
2203 _In_ const STRING *SourceString
2204 );
2205
2206 _IRQL_requires_max_(PASSIVE_LEVEL)
2207 _Must_inspect_result_
2208 NTSYSAPI
2209 LONG
2210 NTAPI
2211 RtlCompareString(
2212 _In_ const STRING *String1,
2213 _In_ const STRING *String2,
2214 _In_ BOOLEAN CaseInSensitive
2215 );
2216
2217 NTSYSAPI
2218 VOID
2219 NTAPI
2220 RtlCopyString(
2221 _Out_ PSTRING DestinationString,
2222 _In_opt_ const STRING *SourceString
2223 );
2224
2225 _IRQL_requires_max_(PASSIVE_LEVEL)
2226 _Must_inspect_result_
2227 NTSYSAPI
2228 BOOLEAN
2229 NTAPI
2230 RtlEqualString(
2231 _In_ const STRING *String1,
2232 _In_ const STRING *String2,
2233 _In_ BOOLEAN CaseInSensitive
2234 );
2235
2236 _IRQL_requires_max_(APC_LEVEL)
2237 NTSYSAPI
2238 NTSTATUS
2239 NTAPI
2240 RtlAppendStringToString(
2241 _Inout_ PSTRING Destination,
2242 _In_ const STRING *Source
2243 );
2244
2245 _IRQL_requires_max_(PASSIVE_LEVEL)
2246 _When_(AllocateDestinationString, _Must_inspect_result_)
2247 NTSYSAPI
2248 NTSTATUS
2249 NTAPI
2250 RtlUpcaseUnicodeString(
2251 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
2252 _When_(!AllocateDestinationString, _Inout_)
2253 PUNICODE_STRING DestinationString,
2254 _In_ PCUNICODE_STRING SourceString,
2255 _In_ BOOLEAN AllocateDestinationString
2256 );
2257
2258 _IRQL_requires_max_(PASSIVE_LEVEL)
2259 NTSYSAPI
2260 NTSTATUS
2261 NTAPI
2262 RtlUnicodeStringToInteger(
2263 _In_ PCUNICODE_STRING String,
2264 _In_opt_ ULONG Base,
2265 _Out_ PULONG Value
2266 );
2267
2268 NTSYSAPI
2269 NTSTATUS
2270 NTAPI
2271 RtlValidateUnicodeString(
2272 _In_ ULONG Flags,
2273 _In_ PCUNICODE_STRING String
2274 );
2275
2276 //
2277 // Ansi String Functions
2278 //
2279 _IRQL_requires_max_(PASSIVE_LEVEL)
2280 NTSYSAPI
2281 VOID
2282 NTAPI
2283 RtlFreeAnsiString(
2284 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2285 PANSI_STRING AnsiString
2286 );
2287
2288 _IRQL_requires_max_(DISPATCH_LEVEL)
2289 NTSYSAPI
2290 VOID
2291 NTAPI
2292 RtlInitAnsiString(
2293 _Out_ PANSI_STRING DestinationString,
2294 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2295 );
2296
2297 _IRQL_requires_max_(DISPATCH_LEVEL)
2298 NTSYSAPI
2299 NTSTATUS
2300 NTAPI
2301 RtlInitAnsiStringEx(
2302 _Out_ PANSI_STRING DestinationString,
2303 _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2304 );
2305
2306 //
2307 // OEM String Functions
2308 //
2309 _IRQL_requires_max_(PASSIVE_LEVEL)
2310 NTSYSAPI
2311 VOID
2312 NTAPI
2313 RtlFreeOemString(
2314 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2315 POEM_STRING OemString
2316 );
2317
2318 //
2319 // MultiByte->Unicode String Functions
2320 //
2321 _IRQL_requires_max_(PASSIVE_LEVEL)
2322 NTSYSAPI
2323 NTSTATUS
2324 NTAPI
2325 RtlMultiByteToUnicodeN(
2326 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2327 _In_ ULONG MaxBytesInUnicodeString,
2328 _Out_opt_ PULONG BytesInUnicodeString,
2329 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2330 _In_ ULONG BytesInMultiByteString
2331 );
2332
2333 _IRQL_requires_max_(PASSIVE_LEVEL)
2334 NTSYSAPI
2335 NTSTATUS
2336 NTAPI
2337 RtlMultiByteToUnicodeSize(
2338 _Out_ PULONG BytesInUnicodeString,
2339 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2340 _In_ ULONG BytesInMultiByteString
2341 );
2342
2343 //
2344 // Atom Functions
2345 //
2346 NTSYSAPI
2347 NTSTATUS
2348 NTAPI
2349 RtlAddAtomToAtomTable(
2350 _In_ PRTL_ATOM_TABLE AtomTable,
2351 _In_ PWSTR AtomName,
2352 _Out_ PRTL_ATOM Atom
2353 );
2354
2355 NTSYSAPI
2356 NTSTATUS
2357 NTAPI
2358 RtlCreateAtomTable(
2359 _In_ ULONG TableSize,
2360 _Inout_ PRTL_ATOM_TABLE *AtomTable
2361 );
2362
2363 NTSYSAPI
2364 NTSTATUS
2365 NTAPI
2366 RtlDeleteAtomFromAtomTable(
2367 _In_ PRTL_ATOM_TABLE AtomTable,
2368 _In_ RTL_ATOM Atom
2369 );
2370
2371 NTSYSAPI
2372 NTSTATUS
2373 NTAPI
2374 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
2375
2376 NTSYSAPI
2377 NTSTATUS
2378 NTAPI
2379 RtlQueryAtomInAtomTable(
2380 _In_ PRTL_ATOM_TABLE AtomTable,
2381 _In_ RTL_ATOM Atom,
2382 _Out_opt_ PULONG RefCount,
2383 _Out_opt_ PULONG PinCount,
2384 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2385 _Inout_opt_ PULONG NameLength
2386 );
2387
2388 NTSYSAPI
2389 NTSTATUS
2390 NTAPI
2391 RtlPinAtomInAtomTable(
2392 _In_ PRTL_ATOM_TABLE AtomTable,
2393 _In_ RTL_ATOM Atom
2394 );
2395
2396 NTSYSAPI
2397 NTSTATUS
2398 NTAPI
2399 RtlLookupAtomInAtomTable(
2400 _In_ PRTL_ATOM_TABLE AtomTable,
2401 _In_ PWSTR AtomName,
2402 _Out_ PRTL_ATOM Atom
2403 );
2404
2405 //
2406 // Process Management Functions
2407 //
2408 NTSYSAPI
2409 PPEB
2410 NTAPI
2411 RtlGetCurrentPeb(
2412 VOID
2413 );
2414
2415 NTSYSAPI
2416 VOID
2417 NTAPI
2418 RtlAcquirePebLock(VOID);
2419
2420 NTSYSAPI
2421 NTSTATUS
2422 NTAPI
2423 RtlCreateProcessParameters (
2424 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2425 _In_ PUNICODE_STRING ImagePathName,
2426 _In_opt_ PUNICODE_STRING DllPath,
2427 _In_opt_ PUNICODE_STRING CurrentDirectory,
2428 _In_opt_ PUNICODE_STRING CommandLine,
2429 _In_opt_ PWSTR Environment,
2430 _In_opt_ PUNICODE_STRING WindowTitle,
2431 _In_opt_ PUNICODE_STRING DesktopInfo,
2432 _In_opt_ PUNICODE_STRING ShellInfo,
2433 _In_opt_ PUNICODE_STRING RuntimeInfo
2434 );
2435
2436 NTSYSAPI
2437 NTSTATUS
2438 NTAPI
2439 RtlCreateUserProcess(
2440 _In_ PUNICODE_STRING ImageFileName,
2441 _In_ ULONG Attributes,
2442 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2443 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2444 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2445 _In_opt_ HANDLE ParentProcess,
2446 _In_ BOOLEAN CurrentDirectory,
2447 _In_opt_ HANDLE DebugPort,
2448 _In_opt_ HANDLE ExceptionPort,
2449 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2450 );
2451
2452 #if (NTDDI_VERSION >= NTDDI_WIN7)
2453 NTSYSAPI
2454 NTSTATUS
2455 NTAPI
2456 RtlCreateUserThread(
2457 _In_ PVOID ThreadContext,
2458 _Out_ HANDLE *OutThreadHandle,
2459 _Reserved_ PVOID Reserved1,
2460 _Reserved_ PVOID Reserved2,
2461 _Reserved_ PVOID Reserved3,
2462 _Reserved_ PVOID Reserved4,
2463 _Reserved_ PVOID Reserved5,
2464 _Reserved_ PVOID Reserved6,
2465 _Reserved_ PVOID Reserved7,
2466 _Reserved_ PVOID Reserved8
2467 );
2468 #else
2469 NTSYSAPI
2470 NTSTATUS
2471 NTAPI
2472 RtlCreateUserThread(
2473 _In_ HANDLE ProcessHandle,
2474 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2475 _In_ BOOLEAN CreateSuspended,
2476 _In_ ULONG StackZeroBits,
2477 _In_ SIZE_T StackReserve,
2478 _In_ SIZE_T StackCommit,
2479 _In_ PTHREAD_START_ROUTINE StartAddress,
2480 _In_ PVOID Parameter,
2481 _Out_opt_ PHANDLE ThreadHandle,
2482 _Out_opt_ PCLIENT_ID ClientId
2483 );
2484 #endif
2485
2486 NTSYSAPI
2487 PRTL_USER_PROCESS_PARAMETERS
2488 NTAPI
2489 RtlDeNormalizeProcessParams(
2490 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2491
2492 NTSYSAPI
2493 NTSTATUS
2494 NTAPI
2495 RtlDestroyProcessParameters(
2496 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2497
2498 NTSYSAPI
2499 VOID
2500 NTAPI
2501 RtlExitUserThread(
2502 _In_ NTSTATUS Status);
2503
2504 NTSYSAPI
2505 VOID
2506 NTAPI
2507 RtlInitializeContext(
2508 _In_ HANDLE ProcessHandle,
2509 _Out_ PCONTEXT ThreadContext,
2510 _In_opt_ PVOID ThreadStartParam,
2511 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2512 _In_ PINITIAL_TEB InitialTeb
2513 );
2514
2515 #ifdef _M_AMD64
2516 typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2517
2518 NTSYSAPI
2519 NTSTATUS
2520 NTAPI
2521 RtlWow64GetThreadContext(
2522 _In_ HANDLE ThreadHandle,
2523 _Inout_ PWOW64_CONTEXT ThreadContext
2524 );
2525
2526
2527 NTSYSAPI
2528 NTSTATUS
2529 NTAPI
2530 RtlWow64SetThreadContext(
2531 _In_ HANDLE ThreadHandle,
2532 _In_ PWOW64_CONTEXT ThreadContext
2533 );
2534 #endif
2535
2536 NTSYSAPI
2537 BOOLEAN
2538 NTAPI
2539 RtlIsThreadWithinLoaderCallout(VOID);
2540
2541 NTSYSAPI
2542 PRTL_USER_PROCESS_PARAMETERS
2543 NTAPI
2544 RtlNormalizeProcessParams(
2545 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2546
2547 NTSYSAPI
2548 VOID
2549 NTAPI
2550 RtlReleasePebLock(VOID);
2551
2552 NTSYSAPI
2553 NTSTATUS
2554 NTAPI
2555 RtlRemoteCall(
2556 _In_ HANDLE Process,
2557 _In_ HANDLE Thread,
2558 _In_ PVOID CallSite,
2559 _In_ ULONG ArgumentCount,
2560 _In_ PULONG Arguments,
2561 _In_ BOOLEAN PassContext,
2562 _In_ BOOLEAN AlreadySuspended
2563 );
2564
2565 NTSYSAPI
2566 NTSTATUS
2567 NTAPI
2568 RtlSetProcessIsCritical(
2569 _In_ BOOLEAN NewValue,
2570 _Out_opt_ PBOOLEAN OldValue,
2571 _In_ BOOLEAN NeedBreaks
2572 );
2573
2574 NTSYSAPI
2575 NTSTATUS
2576 NTAPI
2577 RtlSetThreadIsCritical(
2578 _In_ BOOLEAN NewValue,
2579 _Out_opt_ PBOOLEAN OldValue,
2580 _In_ BOOLEAN NeedBreaks
2581 );
2582
2583 NTSYSAPI
2584 ULONG
2585 NTAPI
2586 RtlGetCurrentProcessorNumber(
2587 VOID
2588 );
2589
2590 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
2591
2592 //
2593 // Thread Pool Functions
2594 //
2595 //
2596 NTSTATUS
2597 NTAPI
2598 RtlSetThreadPoolStartFunc(
2599 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2600 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2601 );
2602
2603 NTSYSAPI
2604 NTSTATUS
2605 NTAPI
2606 RtlDeregisterWaitEx(
2607 _In_ HANDLE hWaitHandle,
2608 _In_opt_ HANDLE hCompletionEvent
2609 );
2610
2611 NTSYSAPI
2612 NTSTATUS
2613 NTAPI
2614 RtlDeregisterWait(
2615 _In_ HANDLE hWaitHandle
2616 );
2617
2618 NTSYSAPI
2619 NTSTATUS
2620 NTAPI
2621 RtlQueueWorkItem(
2622 _In_ WORKERCALLBACKFUNC Function,
2623 _In_opt_ PVOID Context,
2624 _In_ ULONG Flags
2625 );
2626
2627 NTSYSAPI
2628 NTSTATUS
2629 NTAPI
2630 RtlSetIoCompletionCallback(
2631 _In_ HANDLE FileHandle,
2632 _In_ PIO_APC_ROUTINE Callback,
2633 _In_ ULONG Flags
2634 );
2635
2636 NTSYSAPI
2637 NTSTATUS
2638 NTAPI
2639 RtlRegisterWait(
2640 _In_ PHANDLE phNewWaitObject,
2641 _In_ HANDLE hObject,
2642 _In_ WAITORTIMERCALLBACKFUNC Callback,
2643 _In_ PVOID pvContext,
2644 _In_ ULONG ulMilliseconds,
2645 _In_ ULONG ulFlags
2646 );
2647
2648 //
2649 // Environment/Path Functions
2650 //
2651 NTSYSAPI
2652 NTSTATUS
2653 NTAPI
2654 RtlCreateEnvironment(
2655 _In_ BOOLEAN Inherit,
2656 _Out_ PWSTR *Environment
2657 );
2658
2659 NTSYSAPI
2660 NTSTATUS
2661 NTAPI
2662 RtlComputePrivatizedDllName_U(
2663 _In_ PUNICODE_STRING DllName,
2664 _Out_ PUNICODE_STRING RealName,
2665 _Out_ PUNICODE_STRING LocalName
2666 );
2667
2668 NTSYSAPI
2669 VOID
2670 NTAPI
2671 RtlDestroyEnvironment(
2672 _In_ PWSTR Environment
2673 );
2674
2675 NTSYSAPI
2676 BOOLEAN
2677 NTAPI
2678 RtlDoesFileExists_U(
2679 _In_ PCWSTR FileName
2680 );
2681
2682 NTSYSAPI
2683 RTL_PATH_TYPE
2684 NTAPI
2685 RtlDetermineDosPathNameType_U(
2686 _In_ PCWSTR Path
2687 );
2688
2689 NTSYSAPI
2690 ULONG
2691 NTAPI
2692 RtlDosSearchPath_U(
2693 _In_ PCWSTR Path,
2694 _In_ PCWSTR FileName,
2695 _In_ PCWSTR Extension,
2696 _In_ ULONG BufferSize,
2697 _Out_ PWSTR Buffer,
2698 _Out_ PWSTR *PartName
2699 );
2700
2701 NTSYSAPI
2702 NTSTATUS
2703 NTAPI
2704 RtlDosSearchPath_Ustr(
2705 _In_ ULONG Flags,
2706 _In_ PUNICODE_STRING PathString,
2707 _In_ PUNICODE_STRING FileNameString,
2708 _In_ PUNICODE_STRING ExtensionString,
2709 _In_ PUNICODE_STRING CallerBuffer,
2710 _Inout_opt_ PUNICODE_STRING DynamicString,
2711 _Out_opt_ PUNICODE_STRING* FullNameOut,
2712 _Out_opt_ PSIZE_T FilePartSize,
2713 _Out_opt_ PSIZE_T LengthNeeded
2714 );
2715
2716 NTSYSAPI
2717 BOOLEAN
2718 NTAPI
2719 RtlDosPathNameToNtPathName_U(
2720 _In_opt_z_ PCWSTR DosPathName,
2721 _Out_ PUNICODE_STRING NtPathName,
2722 _Out_opt_ PCWSTR *NtFileNamePart,
2723 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2724 );
2725
2726 NTSYSAPI
2727 BOOLEAN
2728 NTAPI
2729 RtlDosPathNameToRelativeNtPathName_U(
2730 _In_ PCWSTR DosName,
2731 _Out_ PUNICODE_STRING NtName,
2732 _Out_ PCWSTR *PartName,
2733 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2734 );
2735
2736 _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength))
2737 NTSYSAPI
2738 NTSTATUS
2739 NTAPI
2740 RtlExpandEnvironmentStrings_U(
2741 _In_z_ PWSTR Environment,
2742 _In_ PUNICODE_STRING Source,
2743 _Inout_ PUNICODE_STRING Destination,
2744 _Out_ PULONG Length
2745 );
2746
2747 NTSYSAPI
2748 ULONG
2749 NTAPI
2750 RtlGetCurrentDirectory_U(
2751 _In_ ULONG MaximumLength,
2752 _Out_bytecap_(MaximumLength) PWSTR Buffer
2753 );
2754
2755 NTSYSAPI
2756 ULONG
2757 NTAPI
2758 RtlGetFullPathName_U(
2759 _In_ PCWSTR FileName,
2760 _In_ ULONG Size,
2761 _Out_z_bytecap_(Size) PWSTR Buffer,
2762 _Out_opt_ PWSTR *ShortName
2763 );
2764
2765 #if (NTDDI_VERSION >= NTDDI_WIN7)
2766 NTSYSAPI
2767 NTSTATUS
2768 NTAPI
2769 RtlGetFullPathName_UEx(
2770 _In_ PWSTR FileName,
2771 _In_ ULONG BufferLength,
2772 _Out_ PWSTR Buffer,
2773 _Out_opt_ PWSTR *FilePart,
2774 _Out_opt_ RTL_PATH_TYPE *InputPathType
2775 );
2776 #endif
2777
2778 NTSTATUS
2779 NTAPI
2780 RtlGetFullPathName_UstrEx(
2781 _In_ PUNICODE_STRING FileName,
2782 _In_opt_ PUNICODE_STRING StaticString,
2783 _In_opt_ PUNICODE_STRING DynamicString,
2784 _Out_opt_ PUNICODE_STRING *StringUsed,
2785 _Out_opt_ PSIZE_T FilePartSize,
2786 _Out_opt_ PBOOLEAN NameInvalid,
2787 _Out_ RTL_PATH_TYPE* PathType,
2788 _Out_opt_ PSIZE_T LengthNeeded
2789 );
2790
2791 NTSYSAPI
2792 NTSTATUS
2793 NTAPI
2794 RtlGetLengthWithoutTrailingPathSeperators(
2795 _Reserved_ ULONG Flags,
2796 _In_ PCUNICODE_STRING PathString,
2797 _Out_ PULONG Length
2798 );
2799
2800 NTSYSAPI
2801 ULONG
2802 NTAPI
2803 RtlGetLongestNtPathLength(
2804 VOID
2805 );
2806
2807 NTSYSAPI
2808 ULONG
2809 NTAPI
2810 RtlIsDosDeviceName_U(
2811 _In_ PCWSTR Name
2812 );
2813
2814 NTSYSAPI
2815 ULONG
2816 NTAPI
2817 RtlIsDosDeviceName_Ustr(
2818 _In_ PCUNICODE_STRING Name
2819 );
2820
2821 _IRQL_requires_max_(PASSIVE_LEVEL)
2822 _Must_inspect_result_
2823 NTSYSAPI
2824 BOOLEAN
2825 NTAPI
2826 RtlIsNameLegalDOS8Dot3(
2827 _In_ PCUNICODE_STRING Name,
2828 _Inout_opt_ POEM_STRING OemName,
2829 _Out_opt_ PBOOLEAN NameContainsSpaces
2830 );
2831
2832 NTSYSAPI
2833 NTSTATUS
2834 NTAPI
2835 RtlQueryEnvironmentVariable_U(
2836 _In_opt_ PWSTR Environment,
2837 _In_ PUNICODE_STRING Name,
2838 _Out_ PUNICODE_STRING Value
2839 );
2840
2841 VOID
2842 NTAPI
2843 RtlReleaseRelativeName(
2844 _In_ PRTL_RELATIVE_NAME_U RelativeName
2845 );
2846
2847 NTSYSAPI
2848 NTSTATUS
2849 NTAPI
2850 RtlSetCurrentDirectory_U(
2851 _In_ PUNICODE_STRING name
2852 );
2853
2854 NTSYSAPI
2855 NTSTATUS
2856 NTAPI
2857 RtlSetEnvironmentVariable(
2858 _In_z_ PWSTR *Environment,
2859 _In_ PUNICODE_STRING Name,
2860 _In_ PUNICODE_STRING Value
2861 );
2862
2863 //
2864 // Critical Section/Resource Functions
2865 //
2866 NTSYSAPI
2867 NTSTATUS
2868 NTAPI
2869 RtlDeleteCriticalSection (
2870 _In_ PRTL_CRITICAL_SECTION CriticalSection
2871 );
2872
2873 NTSYSAPI
2874 NTSTATUS
2875 NTAPI
2876 RtlEnterCriticalSection(
2877 _In_ PRTL_CRITICAL_SECTION CriticalSection
2878 );
2879
2880 NTSYSAPI
2881 NTSTATUS
2882 NTAPI
2883 RtlInitializeCriticalSection(
2884 _In_ PRTL_CRITICAL_SECTION CriticalSection
2885 );
2886
2887 NTSYSAPI
2888 NTSTATUS
2889 NTAPI
2890 RtlInitializeCriticalSectionAndSpinCount(
2891 _In_ PRTL_CRITICAL_SECTION CriticalSection,
2892 _In_ ULONG SpinCount
2893 );
2894
2895 NTSYSAPI
2896 NTSTATUS
2897 NTAPI
2898 RtlLeaveCriticalSection(
2899 _In_ PRTL_CRITICAL_SECTION CriticalSection
2900 );
2901
2902 NTSYSAPI
2903 BOOLEAN
2904 NTAPI
2905 RtlTryEnterCriticalSection(
2906 _In_ PRTL_CRITICAL_SECTION CriticalSection
2907 );
2908
2909 NTSYSAPI
2910 VOID
2911 NTAPI
2912 RtlpUnWaitCriticalSection(
2913 _In_ PRTL_CRITICAL_SECTION CriticalSection
2914 );
2915
2916 NTSYSAPI
2917 NTSTATUS
2918 NTAPI
2919 RtlpWaitForCriticalSection(
2920 _In_ PRTL_CRITICAL_SECTION CriticalSection
2921 );
2922
2923 NTSYSAPI
2924 BOOLEAN
2925 NTAPI
2926 RtlAcquireResourceExclusive(
2927 _In_ PRTL_RESOURCE Resource,
2928 _In_ BOOLEAN Wait
2929 );
2930
2931 NTSYSAPI
2932 BOOLEAN
2933 NTAPI
2934 RtlAcquireResourceShared(
2935 _In_ PRTL_RESOURCE Resource,
2936 _In_ BOOLEAN Wait
2937 );
2938
2939 NTSYSAPI
2940 VOID
2941 NTAPI
2942 RtlConvertExclusiveToShared(
2943 _In_ PRTL_RESOURCE Resource
2944 );
2945
2946 NTSYSAPI
2947 VOID
2948 NTAPI
2949 RtlConvertSharedToExclusive(
2950 _In_ PRTL_RESOURCE Resource
2951 );
2952
2953 NTSYSAPI
2954 VOID
2955 NTAPI
2956 RtlDeleteResource(
2957 _In_ PRTL_RESOURCE Resource
2958 );
2959
2960 NTSYSAPI
2961 VOID
2962 NTAPI
2963 RtlDumpResource(
2964 _In_ PRTL_RESOURCE Resource
2965 );
2966
2967 NTSYSAPI
2968 VOID
2969 NTAPI
2970 RtlInitializeResource(
2971 _In_ PRTL_RESOURCE Resource
2972 );
2973
2974 NTSYSAPI
2975 VOID
2976 NTAPI
2977 RtlReleaseResource(
2978 _In_ PRTL_RESOURCE Resource
2979 );
2980
2981 //
2982 // Compression Functions
2983 //
2984 NTSYSAPI //NT_RTL_COMPRESS_API
2985 NTSTATUS
2986 NTAPI
2987 RtlCompressBuffer(
2988 _In_ USHORT CompressionFormatAndEngine,
2989 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer,
2990 _In_ ULONG UncompressedBufferSize,
2991 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer,
2992 _In_ ULONG CompressedBufferSize,
2993 _In_ ULONG UncompressedChunkSize,
2994 _Out_ PULONG FinalCompressedSize,
2995 _In_ PVOID WorkSpace
2996 );
2997
2998 _IRQL_requires_max_(APC_LEVEL)
2999 NTSYSAPI //NT_RTL_COMPRESS_API
3000 NTSTATUS
3001 NTAPI
3002 RtlDecompressBuffer(
3003 _In_ USHORT CompressionFormat,
3004 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
3005 _In_ ULONG UncompressedBufferSize,
3006 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
3007 _In_ ULONG CompressedBufferSize,
3008 _Out_ PULONG FinalUncompressedSize
3009 );
3010
3011 NTSYSAPI
3012 NTSTATUS
3013 NTAPI
3014 RtlGetCompressionWorkSpaceSize(
3015 _In_ USHORT CompressionFormatAndEngine,
3016 _Out_ PULONG CompressBufferWorkSpaceSize,
3017 _Out_ PULONG CompressFragmentWorkSpaceSize
3018 );
3019
3020 //
3021 // Debug Info Functions
3022 //
3023 NTSYSAPI
3024 PRTL_DEBUG_INFORMATION
3025 NTAPI
3026 RtlCreateQueryDebugBuffer(
3027 _In_ ULONG Size,
3028 _In_ BOOLEAN EventPair
3029 );
3030
3031 NTSYSAPI
3032 NTSTATUS
3033 NTAPI
3034 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
3035
3036 NTSYSAPI
3037 NTSTATUS
3038 NTAPI
3039 RtlQueryProcessDebugInformation(
3040 _In_ ULONG ProcessId,
3041 _In_ ULONG DebugInfoClassMask,
3042 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3043 );
3044
3045 //
3046 // Bitmap Functions
3047 //
3048 NTSYSAPI
3049 BOOLEAN
3050 NTAPI
3051 RtlAreBitsClear(
3052 _In_ PRTL_BITMAP BitMapHeader,
3053 _In_ ULONG StartingIndex,
3054 _In_ ULONG Length
3055 );
3056
3057 NTSYSAPI
3058 BOOLEAN
3059 NTAPI
3060 RtlAreBitsSet(
3061 _In_ PRTL_BITMAP BitMapHeader,
3062 _In_ ULONG StartingIndex,
3063 _In_ ULONG Length
3064 );
3065
3066 NTSYSAPI
3067 VOID
3068 NTAPI
3069 RtlClearAllBits(
3070 _In_ PRTL_BITMAP BitMapHeader
3071 );
3072
3073 NTSYSAPI
3074 VOID
3075 NTAPI
3076 RtlClearBits(
3077 _In_ PRTL_BITMAP BitMapHeader,
3078 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3079 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3080 );
3081
3082 NTSYSAPI
3083 ULONG
3084 NTAPI
3085 RtlFindClearBits(
3086 _In_ PRTL_BITMAP BitMapHeader,
3087 _In_ ULONG NumberToFind,
3088 _In_ ULONG HintIndex
3089 );
3090
3091 NTSYSAPI
3092 ULONG
3093 NTAPI
3094 RtlFindClearBitsAndSet(
3095 _In_ PRTL_BITMAP BitMapHeader,
3096 _In_ ULONG NumberToFind,
3097 _In_ ULONG HintIndex
3098 );
3099
3100 NTSYSAPI
3101 CCHAR
3102 NTAPI
3103 RtlFindLeastSignificantBit(
3104 _In_ ULONGLONG Value
3105 );
3106
3107 NTSYSAPI
3108 CCHAR
3109 NTAPI
3110 RtlFindMostSignificantBit(
3111 _In_ ULONGLONG Value
3112 );
3113
3114 NTSYSAPI
3115 ULONG
3116 NTAPI
3117 RtlFindNextForwardRunClear(
3118 _In_ PRTL_BITMAP BitMapHeader,
3119 _In_ ULONG FromIndex,
3120 _Out_ PULONG StartingRunIndex
3121 );
3122
3123 NTSYSAPI
3124 ULONG
3125 NTAPI
3126 RtlFindNextForwardRunSet(
3127 _In_ PRTL_BITMAP BitMapHeader,
3128 _In_ ULONG FromIndex,
3129 _Out_ PULONG StartingRunIndex
3130 );
3131
3132 NTSYSAPI
3133 ULONG
3134 NTAPI
3135 RtlFindSetBits(
3136 _In_ PRTL_BITMAP BitMapHeader,
3137 _In_ ULONG NumberToFind,
3138 _In_ ULONG HintIndex
3139 );
3140
3141 NTSYSAPI
3142 ULONG
3143 NTAPI
3144 RtlFindSetBitsAndClear(
3145 _In_ PRTL_BITMAP BitMapHeader,
3146 _In_ ULONG NumberToFind,
3147 _In_ ULONG HintIndex
3148 );
3149
3150 #ifdef _REACTOS_ // ReactOS improvement
3151 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3152 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3153 #endif
3154 NTSYSAPI
3155 VOID
3156 NTAPI
3157 RtlInitializeBitMap(
3158 _Out_ PRTL_BITMAP BitMapHeader,
3159 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3160 _In_opt_ ULONG SizeOfBitMap
3161 );
3162
3163 NTSYSAPI
3164 ULONG
3165 NTAPI
3166 RtlNumberOfClearBits(
3167 _In_ PRTL_BITMAP BitMapHeader
3168 );
3169
3170 NTSYSAPI
3171 ULONG
3172 NTAPI
3173 RtlNumberOfSetBits(
3174 _In_ PRTL_BITMAP BitMapHeader
3175 );
3176
3177 NTSYSAPI
3178 VOID
3179 NTAPI
3180 RtlSetBit(
3181 _In_ PRTL_BITMAP BitMapHeader,
3182 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3183 );
3184
3185 NTSYSAPI
3186 VOID
3187 NTAPI
3188 RtlSetBits(
3189 _In_ PRTL_BITMAP BitMapHeader,
3190 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3191 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3192 );
3193
3194 NTSYSAPI
3195 VOID
3196 NTAPI
3197 RtlSetAllBits(
3198 _In_ PRTL_BITMAP BitMapHeader
3199 );
3200
3201 _Must_inspect_result_
3202 NTSYSAPI
3203 BOOLEAN
3204 NTAPI
3205 RtlTestBit(
3206 _In_ PRTL_BITMAP BitMapHeader,
3207 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3208 );
3209
3210 //
3211 // Timer Functions
3212 //
3213 NTSYSAPI
3214 NTSTATUS
3215 NTAPI
3216 RtlCreateTimer(
3217 _In_ HANDLE TimerQueue,
3218 _In_ PHANDLE phNewTimer,
3219 _In_ WAITORTIMERCALLBACKFUNC Callback,
3220 _In_ PVOID Parameter,
3221 _In_ ULONG DueTime,
3222 _In_ ULONG Period,
3223 _In_ ULONG Flags
3224 );
3225
3226 NTSYSAPI
3227 NTSTATUS
3228 NTAPI
3229 RtlCreateTimerQueue(PHANDLE TimerQueue);
3230
3231 NTSYSAPI
3232 NTSTATUS
3233 NTAPI
3234 RtlDeleteTimer(
3235 _In_ HANDLE TimerQueue,
3236 _In_ HANDLE Timer,
3237 _In_ HANDLE CompletionEvent
3238 );
3239
3240 NTSYSAPI
3241 NTSTATUS
3242 NTAPI
3243 RtlUpdateTimer(
3244 _In_ HANDLE TimerQueue,
3245 _In_ HANDLE Timer,
3246 _In_ ULONG DueTime,
3247 _In_ ULONG Period
3248 );
3249
3250 NTSYSAPI
3251 NTSTATUS
3252 NTAPI
3253 RtlDeleteTimerQueueEx(
3254 _In_ HANDLE TimerQueue,
3255 _In_opt_ HANDLE CompletionEvent
3256 );
3257
3258 NTSYSAPI
3259 NTSTATUS
3260 NTAPI
3261 RtlDeleteTimerQueue(HANDLE TimerQueue);
3262
3263 //
3264 // SList functions
3265 //
3266 PSLIST_ENTRY
3267 FASTCALL
3268 InterlockedPushListSList(
3269 _Inout_ PSLIST_HEADER ListHead,
3270 _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
3271 _Inout_ PSLIST_ENTRY ListEnd,
3272 _In_ ULONG Count
3273 );
3274
3275 //
3276 // Range List functions
3277 //
3278 NTSYSAPI
3279 VOID
3280 NTAPI
3281 RtlInitializeRangeList(
3282 _Inout_ PRTL_RANGE_LIST RangeList
3283 );
3284
3285 NTSYSAPI
3286 VOID
3287 NTAPI
3288 RtlFreeRangeList(
3289 _In_ PRTL_RANGE_LIST RangeList
3290 );
3291
3292 NTSYSAPI
3293 NTSTATUS
3294 NTAPI
3295 RtlAddRange(
3296 _Inout_ PRTL_RANGE_LIST RangeList,
3297 _In_ ULONGLONG Start,
3298 _In_ ULONGLONG End,
3299 _In_ UCHAR Attributes,
3300 _In_ ULONG Flags,
3301 _In_opt_ PVOID UserData,
3302 _In_opt_ PVOID Owner
3303 );
3304
3305 //
3306 // Debug Functions
3307 //
3308 ULONG
3309 __cdecl
3310 DbgPrint(
3311 _In_z_ _Printf_format_string_ PCSTR Format,
3312 ...
3313 );
3314
3315 NTSYSAPI
3316 ULONG
3317 __cdecl
3318 DbgPrintEx(
3319 _In_ ULONG ComponentId,
3320 _In_ ULONG Level,
3321 _In_z_ _Printf_format_string_ PCSTR Format,
3322 ...
3323 );
3324
3325 NTSYSAPI
3326 ULONG
3327 NTAPI
3328 DbgPrompt(
3329 _In_z_ PCCH Prompt,
3330 _Out_writes_bytes_(MaximumResponseLength) PCH Response,
3331 _In_ ULONG MaximumResponseLength
3332 );
3333
3334 #undef DbgBreakPoint
3335 VOID
3336 NTAPI
3337 DbgBreakPoint(
3338 VOID
3339 );
3340
3341 VOID
3342 NTAPI
3343 DbgLoadImageSymbols(
3344 _In_ PSTRING Name,
3345 _In_ PVOID Base,
3346 _In_ ULONG_PTR ProcessId
3347 );
3348
3349 VOID
3350 NTAPI
3351 DbgUnLoadImageSymbols(
3352 _In_ PSTRING Name,
3353 _In_ PVOID Base,
3354 _In_ ULONG_PTR ProcessId
3355 );
3356
3357 VOID
3358 NTAPI
3359 DbgCommandString(
3360 _In_ PCCH Name,
3361 _In_ PCCH Command
3362 );
3363
3364 //
3365 // Generic Table Functions
3366 //
3367 #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3368 NTSYSAPI
3369 PVOID
3370 NTAPI
3371 RtlInsertElementGenericTable(
3372 _In_ PRTL_GENERIC_TABLE Table,
3373 _In_reads_bytes_(BufferSize) PVOID Buffer,
3374 _In_ CLONG BufferSize,
3375 _Out_opt_ PBOOLEAN NewElement
3376 );
3377
3378 NTSYSAPI
3379 PVOID
3380 NTAPI
3381 RtlInsertElementGenericTableFull(
3382 _In_ PRTL_GENERIC_TABLE Table,
3383 _In_reads_bytes_(BufferSize) PVOID Buffer,
3384 _In_ CLONG BufferSize,
3385 _Out_opt_ PBOOLEAN NewElement,
3386 _In_ PVOID NodeOrParent,
3387 _In_ TABLE_SEARCH_RESULT SearchResult
3388 );
3389
3390 NTSYSAPI
3391 BOOLEAN
3392 NTAPI
3393 RtlIsGenericTableEmpty(
3394 _In_ PRTL_GENERIC_TABLE Table
3395 );
3396
3397 NTSYSAPI
3398 PVOID
3399 NTAPI
3400 RtlLookupElementGenericTableFull(
3401 _In_ PRTL_GENERIC_TABLE Table,
3402 _In_ PVOID Buffer,
3403 _Out_ PVOID *NodeOrParent,
3404 _Out_ TABLE_SEARCH_RESULT *SearchResult
3405 );
3406 #endif
3407
3408 //
3409 // Handle Table Functions
3410 //
3411 NTSYSAPI
3412 PRTL_HANDLE_TABLE_ENTRY
3413 NTAPI
3414 RtlAllocateHandle(
3415 _In_ PRTL_HANDLE_TABLE HandleTable,
3416 _Inout_ PULONG Index
3417 );
3418
3419 NTSYSAPI
3420 VOID
3421 NTAPI
3422 RtlDestroyHandleTable(
3423 _Inout_ PRTL_HANDLE_TABLE HandleTable);
3424
3425 NTSYSAPI
3426 BOOLEAN
3427 NTAPI
3428 RtlFreeHandle(
3429 _In_ PRTL_HANDLE_TABLE HandleTable,
3430 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3431 );
3432
3433 NTSYSAPI
3434 VOID
3435 NTAPI
3436 RtlInitializeHandleTable(
3437 _In_ ULONG TableSize,
3438 _In_ ULONG HandleSize,
3439 _In_ PRTL_HANDLE_TABLE HandleTable
3440 );
3441
3442 NTSYSAPI
3443 BOOLEAN
3444 NTAPI
3445 RtlIsValidHandle(
3446 _In_ PRTL_HANDLE_TABLE HandleTable,
3447 _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3448 );
3449
3450 _Success_(return!=FALSE)
3451 NTSYSAPI
3452 BOOLEAN
3453 NTAPI
3454 RtlIsValidIndexHandle(
3455 _In_ PRTL_HANDLE_TABLE HandleTable,
3456 _In_ ULONG Index,
3457 _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle
3458 );
3459
3460 //
3461 // PE Functions
3462 //
3463 NTSYSAPI
3464 NTSTATUS
3465 NTAPI
3466 RtlFindMessage(
3467 _In_ PVOID BaseAddress,
3468 _In_ ULONG Type,
3469 _In_ ULONG Language,
3470 _In_ ULONG MessageId,
3471 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3472 );
3473
3474 NTSYSAPI
3475 ULONG
3476 NTAPI
3477 RtlGetNtGlobalFlags(VOID);
3478
3479 _Success_(return!=NULL)
3480 NTSYSAPI
3481 PVOID
3482 NTAPI
3483 RtlImageDirectoryEntryToData(
3484 _In_ PVOID BaseAddress,
3485 _In_ BOOLEAN MappedAsImage,
3486 _In_ USHORT Directory,
3487 _Out_ PULONG Size
3488 );
3489
3490 NTSYSAPI
3491 PVOID
3492 NTAPI
3493 RtlImageRvaToVa(
3494 _In_ PIMAGE_NT_HEADERS NtHeader,
3495 _In_ PVOID BaseAddress,
3496 _In_ ULONG Rva,
3497 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3498 );
3499
3500 NTSYSAPI
3501 PIMAGE_NT_HEADERS
3502 NTAPI
3503 RtlImageNtHeader(
3504 _In_ PVOID BaseAddress);
3505
3506 NTSYSAPI
3507 NTSTATUS
3508 NTAPI
3509 RtlImageNtHeaderEx(
3510 _In_ ULONG Flags,
3511 _In_ PVOID BaseAddress,
3512 _In_ ULONGLONG Size,
3513 _Out_ PIMAGE_NT_HEADERS *NtHeader
3514 );
3515
3516 NTSYSAPI
3517 PIMAGE_SECTION_HEADER
3518 NTAPI
3519 RtlImageRvaToSection(
3520 _In_ PIMAGE_NT_HEADERS NtHeader,
3521 _In_ PVOID BaseAddress,
3522 _In_ ULONG Rva
3523 );
3524
3525 NTSYSAPI
3526 ULONG
3527 NTAPI
3528 LdrRelocateImageWithBias(
3529 _In_ PVOID NewAddress,
3530 _In_ LONGLONG AdditionalBias,
3531 _In_ PCCH LoaderName,
3532 _In_ ULONG Success,
3533 _In_ ULONG Conflict,
3534 _In_ ULONG Invalid
3535 );
3536
3537 //
3538 // Activation Context Functions
3539 //
3540 #ifdef NTOS_MODE_USER
3541 NTSYSAPI
3542 NTSTATUS
3543 NTAPI
3544 RtlActivateActivationContextEx(
3545 _In_ ULONG Flags,
3546 _In_ PTEB Teb,
3547 _In_ PVOID Context,
3548 _Out_ PULONG_PTR Cookie
3549 );
3550
3551 NTSYSAPI
3552 NTSTATUS
3553 NTAPI
3554 RtlActivateActivationContext(
3555 _In_ ULONG Flags,
3556 _In_ HANDLE Handle,
3557 _Out_ PULONG_PTR Cookie
3558 );
3559
3560 NTSYSAPI
3561 VOID
3562 NTAPI
3563 RtlAddRefActivationContext(
3564 _In_ PVOID Context
3565 );
3566
3567 NTSYSAPI
3568 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3569 FASTCALL
3570 RtlActivateActivationContextUnsafeFast(
3571 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
3572 _In_ PVOID Context
3573 );
3574
3575 NTSYSAPI
3576 NTSTATUS
3577 NTAPI
3578 RtlAllocateActivationContextStack(
3579 _In_ PACTIVATION_CONTEXT_STACK *Stack
3580 );
3581
3582 NTSYSAPI
3583 NTSTATUS
3584 NTAPI
3585 RtlCreateActivationContext(
3586 _In_ ULONG Flags,
3587 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
3588 _In_ ULONG ExtraBytes,
3589 _In_ PVOID NotificationRoutine,
3590 _In_ PVOID NotificationContext,
3591 _Out_ PACTIVATION_CONTEXT *ActCtx
3592 );
3593
3594 NTSYSAPI
3595 NTSTATUS
3596 NTAPI
3597 RtlGetActiveActivationContext(
3598 _In_ PVOID *Context
3599 );
3600
3601 NTSYSAPI
3602 VOID
3603 NTAPI
3604 RtlReleaseActivationContext(
3605 _In_ HANDLE handle
3606 );
3607
3608 NTSYSAPI
3609 NTSTATUS
3610 NTAPI
3611 RtlDeactivateActivationContext(
3612 _In_ ULONG dwFlags,
3613 _In_ ULONG_PTR ulCookie
3614 );
3615
3616 NTSYSAPI
3617 VOID
3618 NTAPI
3619 RtlFreeActivationContextStack(
3620 _In_ PACTIVATION_CONTEXT_STACK Stack
3621 );
3622
3623 NTSYSAPI
3624 VOID
3625 NTAPI
3626 RtlFreeThreadActivationContextStack(VOID);
3627
3628 NTSYSAPI
3629 PRTL_ACTIVATION_CONTEXT_STACK_FRAME
3630 FASTCALL
3631 RtlDeactivateActivationContextUnsafeFast(
3632 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
3633 );
3634
3635 NTSYSAPI
3636 NTSTATUS
3637 NTAPI
3638 RtlDosApplyFileIsolationRedirection_Ustr(
3639 _In_ ULONG Flags,
3640 _In_ PUNICODE_STRING OriginalName,
3641 _In_ PUNICODE_STRING Extension,
3642 _Inout_ PUNICODE_STRING StaticString,
3643 _Inout_ PUNICODE_STRING DynamicString,
3644 _Inout_ PUNICODE_STRING *NewName,
3645 _In_ PULONG NewFlags,
3646 _In_ PSIZE_T FileNameSize,
3647 _In_ PSIZE_T RequiredLength
3648 );
3649
3650 NTSYSAPI
3651 NTSTATUS
3652 NTAPI
3653 RtlFindActivationContextSectionString(
3654 _In_ ULONG dwFlags,
3655 _In_ const GUID *ExtensionGuid,
3656 _In_ ULONG SectionType,
3657 _In_ PUNICODE_STRING SectionName,
3658 _Inout_ PVOID ReturnedData
3659 );
3660
3661 NTSYSAPI
3662 NTSTATUS
3663 NTAPI
3664 RtlQueryInformationActivationContext(
3665 _In_ DWORD dwFlags,
3666 _In_opt_ PVOID Context,
3667 _In_opt_ PVOID pvSubInstance,
3668 _In_ ULONG ulInfoClass,
3669 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3670 _In_opt_ SIZE_T cbBuffer,
3671 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3672 );
3673
3674 NTSYSAPI
3675 NTSTATUS
3676 NTAPI
3677 RtlQueryInformationActiveActivationContext(
3678 _In_ ULONG ulInfoClass,
3679 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
3680 _In_opt_ SIZE_T cbBuffer,
3681 _Out_opt_ SIZE_T *pcbWrittenOrRequired
3682 );
3683
3684 NTSYSAPI
3685 NTSTATUS
3686 NTAPI
3687 RtlZombifyActivationContext(
3688 PVOID Context
3689 );
3690
3691 //
3692 // WOW64 Functions
3693 //
3694 NTSYSAPI
3695 NTSTATUS
3696 NTAPI
3697 RtlWow64EnableFsRedirection(
3698 _In_ BOOLEAN Wow64FsEnableRedirection
3699 );
3700
3701 NTSYSAPI
3702 NTSTATUS
3703 NTAPI
3704 RtlWow64EnableFsRedirectionEx(
3705 _In_ PVOID Wow64FsEnableRedirection,
3706 _Out_ PVOID *OldFsRedirectionLevel
3707 );
3708
3709 #endif
3710
3711 //
3712 // Registry Functions
3713 //
3714 _IRQL_requires_max_(PASSIVE_LEVEL)
3715 _Must_inspect_result_
3716 NTSYSAPI
3717 NTSTATUS
3718 NTAPI
3719 RtlCheckRegistryKey(
3720 _In_ ULONG RelativeTo,
3721 _In_ PWSTR Path
3722 );
3723
3724 NTSYSAPI
3725 NTSTATUS
3726 NTAPI
3727 RtlCreateRegistryKey(
3728 _In_ ULONG RelativeTo,
3729 _In_ PWSTR Path
3730 );
3731
3732 NTSYSAPI
3733 NTSTATUS
3734 NTAPI
3735 RtlFormatCurrentUserKeyPath(
3736 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
3737 PUNICODE_STRING KeyPath
3738 );
3739
3740 NTSYSAPI
3741 NTSTATUS
3742 NTAPI
3743 RtlOpenCurrentUser(
3744 _In_ ACCESS_MASK DesiredAccess,
3745 _Out_ PHANDLE KeyHandle
3746 );
3747
3748 _IRQL_requires_max_(PASSIVE_LEVEL)
3749 NTSYSAPI
3750 NTSTATUS
3751 NTAPI
3752 RtlQueryRegistryValues(
3753 _In_ ULONG RelativeTo,
3754 _In_ PCWSTR Path,
3755 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
3756 PRTL_QUERY_REGISTRY_TABLE QueryTable,
3757 _In_opt_ PVOID Context,
3758 _In_opt_ PVOID Environment
3759 );
3760
3761 _IRQL_requires_max_(PASSIVE_LEVEL)
3762 NTSYSAPI
3763 NTSTATUS
3764 NTAPI
3765 RtlWriteRegistryValue(
3766 _In_ ULONG RelativeTo,
3767 _In_ PCWSTR Path,
3768 _In_z_ PCWSTR ValueName,
3769 _In_ ULONG ValueType,
3770 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
3771 _In_ ULONG ValueLength
3772 );
3773
3774 #ifdef NTOS_MODE_USER
3775 NTSYSAPI
3776 NTSTATUS
3777 NTAPI
3778 RtlpNtCreateKey(
3779 _Out_ HANDLE KeyHandle,
3780 _In_ ACCESS_MASK DesiredAccess,
3781 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3782 _In_ ULONG TitleIndex,
3783 _In_ PUNICODE_STRING Class,
3784 _Out_ PULONG Disposition
3785 );
3786
3787 NTSYSAPI
3788 NTSTATUS
3789 NTAPI
3790 RtlpNtEnumerateSubKey(
3791 _In_ HANDLE KeyHandle,
3792 _Inout_ PUNICODE_STRING SubKeyName,
3793 _In_ ULONG Index,
3794 _In_ ULONG Unused
3795 );
3796
3797 NTSYSAPI
3798 NTSTATUS
3799 NTAPI
3800 RtlpNtMakeTemporaryKey(
3801 _In_ HANDLE KeyHandle
3802 );
3803
3804 NTSYSAPI
3805 NTSTATUS
3806 NTAPI
3807 RtlpNtOpenKey(
3808 _Out_ HANDLE KeyHandle,
3809 _In_ ACCESS_MASK DesiredAccess,
3810 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
3811 _In_ ULONG Unused
3812 );
3813
3814 NTSYSAPI
3815 NTSTATUS
3816 NTAPI
3817 RtlpNtQueryValueKey(
3818 _In_ HANDLE KeyHandle,
3819 _Out_opt_ PULONG Type,
3820 _Out_opt_ PVOID Data,
3821 _Inout_opt_ PULONG DataLength,
3822 _In_ ULONG Unused
3823 );
3824
3825 NTSYSAPI
3826 NTSTATUS
3827 NTAPI
3828 RtlpNtSetValueKey(
3829 _In_ HANDLE KeyHandle,
3830 _In_ ULONG Type,
3831 _In_ PVOID Data,
3832 _In_ ULONG DataLength
3833 );
3834 #endif
3835
3836 //
3837 // NLS Functions
3838 //
3839 NTSYSAPI
3840 VOID
3841 NTAPI
3842 RtlGetDefaultCodePage(
3843 _Out_ PUSHORT AnsiCodePage,
3844 _Out_ PUSHORT OemCodePage
3845 );
3846
3847 NTSYSAPI
3848 VOID
3849 NTAPI
3850 RtlInitNlsTables(
3851 _In_ PUSHORT AnsiTableBase,
3852 _In_ PUSHORT OemTableBase,
3853 _In_ PUSHORT CaseTableBase,
3854 _Out_ PNLSTABLEINFO NlsTable
3855 );
3856
3857 _IRQL_requires_max_(PASSIVE_LEVEL)
3858 NTSYSAPI
3859 VOID
3860 NTAPI
3861 RtlInitCodePageTable(
3862 _In_ PUSHORT TableBase,
3863 _Out_ PCPTABLEINFO CodePageTable
3864 );
3865
3866 NTSYSAPI
3867 VOID
3868 NTAPI
3869 RtlResetRtlTranslations(
3870 _In_ PNLSTABLEINFO NlsTable);
3871
3872 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
3873
3874 //
3875 // Misc conversion functions
3876 //
3877 static __inline
3878 LARGE_INTEGER
3879 NTAPI_INLINE
3880 RtlConvertLongToLargeInteger(
3881 _In_ LONG SignedInteger
3882 )
3883 {
3884 LARGE_INTEGER Result;
3885
3886 Result.QuadPart = SignedInteger;
3887 return Result;
3888 }
3889
3890 static __inline
3891 LARGE_INTEGER
3892 NTAPI_INLINE
3893 RtlEnlargedIntegerMultiply(
3894 _In_ LONG Multiplicand,
3895 _In_ LONG Multiplier
3896 )
3897 {
3898 LARGE_INTEGER Product;
3899
3900 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
3901 return Product;
3902 }
3903
3904 static __inline
3905 ULONG
3906 NTAPI_INLINE
3907 RtlEnlargedUnsignedDivide(
3908 _In_ ULARGE_INTEGER Dividend,
3909 _In_ ULONG Divisor,
3910 _In_opt_ PULONG Remainder
3911 )
3912 {
3913 ULONG Quotient;
3914
3915 Quotient = (ULONG)(Dividend.QuadPart / Divisor);
3916 if (Remainder) {
3917 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
3918 }
3919
3920 return Quotient;
3921 }
3922
3923 static __inline
3924 LARGE_INTEGER
3925 NTAPI_INLINE
3926 RtlEnlargedUnsignedMultiply(
3927 _In_ ULONG Multiplicand,
3928 _In_ ULONG Multiplier
3929 )
3930 {
3931 LARGE_INTEGER Product;
3932
3933 Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
3934 return Product;
3935 }
3936
3937 #if defined(_AMD64_) || defined(_IA64_)
3938 static __inline
3939 LARGE_INTEGER
3940 NTAPI_INLINE
3941 RtlExtendedLargeIntegerDivide(
3942 _In_ LARGE_INTEGER Dividend,
3943 _In_ ULONG Divisor,
3944 _Out_opt_ PULONG Remainder)
3945 {
3946 LARGE_INTEGER ret;
3947 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
3948 if (Remainder)
3949 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
3950 return ret;
3951 }
3952
3953 #else
3954 NTSYSAPI
3955 LARGE_INTEGER
3956 NTAPI
3957 RtlExtendedLargeIntegerDivide(
3958 _In_ LARGE_INTEGER Dividend,
3959 _In_ ULONG Divisor,
3960 _Out_opt_ PULONG Remainder
3961 );
3962
3963 #endif /* defined(_AMD64_) || defined(_IA64_) */
3964
3965 #endif
3966
3967
3968 NTSYSAPI
3969 ULONG
3970 NTAPI
3971 RtlUniform(
3972 _In_ PULONG Seed
3973 );
3974
3975 NTSYSAPI
3976 ULONG
3977 NTAPI
3978 RtlRandom(
3979 _Inout_ PULONG Seed
3980 );
3981
3982 NTSYSAPI
3983 ULONG
3984 NTAPI
3985 RtlComputeCrc32(
3986 _In_ ULONG InitialCrc,
3987 _In_ PUCHAR Buffer,
3988 _In_ ULONG Length
3989 );
3990
3991 //
3992 // Network Functions
3993 //
3994 NTSYSAPI
3995 NTSTATUS
3996 NTAPI
3997 RtlIpv4StringToAddressW(
3998 _In_ PCWSTR String,
3999 _In_ BOOLEAN Strict,
4000 _Out_ LPWSTR *Terminator,
4001 _Out_ struct in_addr *Addr
4002 );
4003
4004 NTSYSAPI
4005 NTSTATUS
4006 NTAPI
4007 RtlIpv6StringToAddressA(
4008 _In_ PCHAR Name,
4009 _Out_ PCHAR *Terminator,
4010 _Out_ struct in6_addr *Addr
4011 );
4012
4013 NTSYSAPI
4014 NTSTATUS
4015 NTAPI
4016 RtlIpv6StringToAddressW(
4017 _In_ PWCHAR Name,
4018 _Out_ PCHAR *Terminator,
4019 _Out_ struct in6_addr *Addr
4020 );
4021
4022 NTSYSAPI
4023 NTSTATUS
4024 NTAPI
4025 RtlIpv6StringToAddressExA(
4026 _In_ PCHAR AddressString,
4027 _In_ struct in6_addr *Address,
4028 _In_ PULONG ScopeId,
4029 _In_ PUSHORT Port
4030 );
4031
4032 NTSYSAPI
4033 NTSTATUS
4034 NTAPI
4035 RtlIpv6StringToAddressExW(
4036 _In_ PWCHAR AddressName,
4037 _In_ struct in6_addr *Address,
4038 _In_ PULONG ScopeId,
4039 _In_ PUSHORT Port
4040 );
4041
4042
4043 //
4044 // Time Functions
4045 //
4046 NTSYSAPI
4047 NTSTATUS
4048 NTAPI
4049 RtlQueryTimeZoneInformation(
4050 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
4051
4052 NTSYSAPI
4053 VOID
4054 NTAPI
4055 RtlSecondsSince1970ToTime(
4056 _In_ ULONG SecondsSince1970,
4057 _Out_ PLARGE_INTEGER Time
4058 );
4059
4060 NTSYSAPI
4061 NTSTATUS
4062 NTAPI
4063 RtlSetTimeZoneInformation(
4064 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
4065
4066 _Success_(return!=FALSE)
4067 _Must_inspect_result_
4068 NTSYSAPI
4069 BOOLEAN
4070 NTAPI
4071 RtlTimeFieldsToTime(
4072 _In_ PTIME_FIELDS TimeFields,
4073 _Out_ PLARGE_INTEGER Time
4074 );
4075
4076 _Success_(return != 0)
4077 _Must_inspect_result_
4078 NTSYSAPI
4079 BOOLEAN
4080 NTAPI
4081 RtlTimeToSecondsSince1970(
4082 _In_ PLARGE_INTEGER Time,
4083 _Out_ PULONG ElapsedSeconds
4084 );
4085
4086 NTSYSAPI
4087 VOID
4088 NTAPI
4089 RtlTimeToTimeFields(
4090 PLARGE_INTEGER Time,
4091 PTIME_FIELDS TimeFields
4092 );
4093
4094 NTSYSAPI
4095 NTSTATUS
4096 NTAPI
4097 RtlSystemTimeToLocalTime(
4098 _In_ PLARGE_INTEGER SystemTime,
4099 _Out_ PLARGE_INTEGER LocalTime
4100 );
4101
4102 //
4103 // Version Functions
4104 //
4105 _IRQL_requires_max_(PASSIVE_LEVEL)
4106 _Must_inspect_result_
4107 NTSYSAPI
4108 NTSTATUS
4109 NTAPI
4110 RtlVerifyVersionInfo(
4111 _In_ PRTL_OSVERSIONINFOEXW VersionInfo,
4112 _In_ ULONG TypeMask,
4113 _In_ ULONGLONG ConditionMask
4114 );
4115
4116 _IRQL_requires_max_(PASSIVE_LEVEL)
4117 NTSYSAPI
4118 NTSTATUS
4119 NTAPI
4120 RtlGetVersion(
4121 _Out_
4122 _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_)
4123 _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW),
4124 _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_))
4125 PRTL_OSVERSIONINFOW lpVersionInformation
4126 );
4127
4128 NTSYSAPI
4129 BOOLEAN
4130 NTAPI
4131 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType);
4132
4133 //
4134 // Secure Memory Functions
4135 //
4136 #ifdef NTOS_MODE_USER
4137 NTSYSAPI
4138 NTSTATUS
4139 NTAPI
4140 RtlRegisterSecureMemoryCacheCallback(
4141 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback);
4142
4143 NTSYSAPI
4144 BOOLEAN
4145 NTAPI
4146 RtlFlushSecureMemoryCache(
4147 _In_ PVOID MemoryCache,
4148 _In_opt_ SIZE_T MemoryLength
4149 );
4150 #endif
4151
4152 //
4153 // Boot Status Data Functions
4154 //
4155 #ifdef NTOS_MODE_USER
4156 NTSYSAPI
4157 NTSTATUS
4158 NTAPI
4159 RtlCreateBootStatusDataFile(
4160 VOID
4161 );
4162
4163 NTSYSAPI
4164 NTSTATUS
4165 NTAPI
4166 RtlGetSetBootStatusData(
4167 _In_ HANDLE FileHandle,
4168 _In_ BOOLEAN WriteMode,
4169 _In_ RTL_BSD_ITEM_TYPE DataClass,
4170 _In_ PVOID Buffer,
4171 _In_ ULONG BufferSize,
4172 _Out_opt_ PULONG ReturnLength
4173 );
4174
4175 NTSYSAPI
4176 NTSTATUS
4177 NTAPI
4178 RtlLockBootStatusData(
4179 _Out_ PHANDLE FileHandle
4180 );
4181
4182 NTSYSAPI
4183 NTSTATUS
4184 NTAPI
4185 RtlUnlockBootStatusData(
4186 _In_ HANDLE FileHandle
4187 );
4188 #endif
4189
4190 #ifdef NTOS_MODE_USER
4191 _Must_inspect_result_
4192 NTSYSAPI
4193 NTSTATUS
4194 NTAPI
4195 RtlGUIDFromString(
4196 _In_ PUNICODE_STRING GuidString,
4197 _Out_ GUID *Guid);
4198
4199 _Must_inspect_result_
4200 NTSYSAPI
4201 NTSTATUS
4202 NTAPI
4203 RtlStringFromGUID(
4204 _In_ REFGUID Guid,
4205 _Out_ _At_(GuidString->Buffer, __drv_allocatesMem(Mem))
4206 PUNICODE_STRING GuidString);
4207
4208 NTSYSAPI
4209 NTSTATUS
4210 NTAPI
4211 RtlComputeImportTableHash(
4212 _In_ HANDLE hFile,
4213 _Out_ PCHAR Hash,
4214 _In_ ULONG ImportTableHashRevision
4215 );
4216 #endif
4217
4218 //
4219 // MemoryStream functions
4220 //
4221 #ifdef NTOS_MODE_USER
4222
4223 NTSYSAPI
4224 VOID
4225 NTAPI
4226 RtlInitMemoryStream(
4227 _Out_ PRTL_MEMORY_STREAM Stream
4228 );
4229
4230 NTSYSAPI
4231 VOID
4232 NTAPI
4233 RtlInitOutOfProcessMemoryStream(
4234 _Out_ PRTL_MEMORY_STREAM Stream
4235 );
4236
4237 NTSYSAPI
4238 VOID
4239 NTAPI
4240 RtlFinalReleaseOutOfProcessMemoryStream(
4241 _In_ PRTL_MEMORY_STREAM Stream
4242 );
4243
4244 NTSYSAPI
4245 HRESULT
4246 NTAPI
4247 RtlQueryInterfaceMemoryStream(
4248 _In_ struct IStream *This,
4249 _In_ REFIID RequestedIid,
4250 _Outptr_ PVOID *ResultObject
4251 );
4252
4253 NTSYSAPI
4254 ULONG
4255 NTAPI
4256 RtlAddRefMemoryStream(
4257 _In_ struct IStream *This
4258 );
4259
4260 NTSYSAPI
4261 ULONG
4262 NTAPI
4263 RtlReleaseMemoryStream(
4264 _In_ struct IStream *This
4265 );
4266
4267 NTSYSAPI
4268 HRESULT
4269 NTAPI
4270 RtlReadMemoryStream(
4271 _In_ struct IStream *This,
4272 _Out_writes_bytes_(Length) PVOID Buffer,
4273 _In_ ULONG Length,
4274 _Out_opt_ PULONG BytesRead
4275 );
4276
4277 NTSYSAPI
4278 HRESULT
4279 NTAPI
4280 RtlReadOutOfProcessMemoryStream(
4281 _In_ struct IStream *This,
4282 _Out_writes_bytes_(Length) PVOID Buffer,
4283 _In_ ULONG Length,
4284 _Out_opt_ PULONG BytesRead
4285 );
4286
4287 NTSYSAPI
4288 HRESULT
4289 NTAPI
4290 RtlSeekMemoryStream(
4291 _In_ struct IStream *This,
4292 _In_ LARGE_INTEGER RelativeOffset,
4293 _In_ ULONG Origin,
4294 _Out_opt_ PULARGE_INTEGER ResultOffset
4295 );
4296
4297 NTSYSAPI
4298 HRESULT
4299 NTAPI
4300 RtlCopyMemoryStreamTo(
4301 _In_ struct IStream *This,
4302 _In_ struct IStream *Target,
4303 _In_ ULARGE_INTEGER Length,
4304 _Out_opt_ PULARGE_INTEGER BytesRead,
4305 _Out_opt_ PULARGE_INTEGER BytesWritten
4306 );
4307
4308 NTSYSAPI
4309 HRESULT
4310 NTAPI
4311 RtlCopyOutOfProcessMemoryStreamTo(
4312 _In_ struct IStream *This,
4313 _In_ struct IStream *Target,
4314 _In_ ULARGE_INTEGER Length,
4315 _Out_opt_ PULARGE_INTEGER BytesRead,
4316 _Out_opt_ PULARGE_INTEGER BytesWritten
4317 );
4318
4319 NTSYSAPI
4320 HRESULT
4321 NTAPI
4322 RtlStatMemoryStream(
4323 _In_ struct IStream *This,
4324 _Out_ struct tagSTATSTG *Stats,
4325 _In_ ULONG Flags
4326 );
4327
4328 // Dummy functions
4329 NTSYSAPI
4330 HRESULT
4331 NTAPI
4332 RtlWriteMemoryStream(
4333 _In_ struct IStream *This,
4334 _In_reads_bytes_(Length) CONST VOID *Buffer,
4335 _In_ ULONG Length,
4336 _Out_opt_ PULONG BytesWritten
4337 );
4338
4339 NTSYSAPI
4340 HRESULT
4341 NTAPI
4342 RtlSetMemoryStreamSize(
4343 _In_ struct IStream *This,
4344 _In_ ULARGE_INTEGER NewSize
4345 );
4346
4347 NTSYSAPI
4348 HRESULT
4349 NTAPI
4350 RtlCommitMemoryStream(
4351 _In_ struct IStream *This,
4352 _In_ ULONG CommitFlags
4353 );
4354
4355 NTSYSAPI
4356 HRESULT
4357 NTAPI
4358 RtlRevertMemoryStream(
4359 _In_ struct IStream *This
4360 );
4361
4362 NTSYSAPI
4363 HRESULT
4364 NTAPI
4365 RtlLockMemoryStreamRegion(
4366 _In_ struct IStream *This,
4367 _In_ ULARGE_INTEGER Offset,
4368 _In_ ULARGE_INTEGER Length,
4369 _In_ ULONG LockType
4370 );
4371
4372 NTSYSAPI
4373 HRESULT
4374 NTAPI
4375 RtlUnlockMemoryStreamRegion(
4376 _In_ struct IStream *This,
4377 _In_ ULARGE_INTEGER Offset,
4378 _In_ ULARGE_INTEGER Length,
4379 _In_ ULONG LockType
4380 );
4381
4382 NTSYSAPI
4383 HRESULT
4384 NTAPI
4385 RtlCloneMemoryStream(
4386 _In_ struct IStream *This,
4387 _Outptr_ struct IStream **ResultStream
4388 );
4389
4390 #endif // NTOS_MODE_USER
4391
4392 #ifdef __cplusplus
4393 }
4394 #endif
4395
4396 #endif