- Fix KeAttackProcess, KeStackAttachProcess, KeUnstackDetachProcess and KeDetachProce...
[reactos.git] / reactos / include / ndk / rtlfuncs.h
1 /*++ NDK Version: 0095
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 (alex.ionescu@reactos.com) 06-Oct-2004
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 <extypes.h>
28 #include <rtltypes.h>
29
30 #ifdef NTOS_MODE_USER
31
32 //
33 // List Functions
34 //
35 FORCEINLINE
36 VOID
37 InitializeListHead(
38 IN PLIST_ENTRY ListHead
39 )
40 {
41 ListHead->Flink = ListHead->Blink = ListHead;
42 }
43
44 FORCEINLINE
45 VOID
46 InsertHeadList(
47 IN PLIST_ENTRY ListHead,
48 IN PLIST_ENTRY Entry
49 )
50 {
51 PLIST_ENTRY OldFlink;
52 OldFlink = ListHead->Flink;
53 Entry->Flink = OldFlink;
54 Entry->Blink = ListHead;
55 OldFlink->Blink = Entry;
56 ListHead->Flink = Entry;
57 }
58
59 FORCEINLINE
60 VOID
61 InsertTailList(
62 IN PLIST_ENTRY ListHead,
63 IN PLIST_ENTRY Entry
64 )
65 {
66 PLIST_ENTRY OldBlink;
67 OldBlink = ListHead->Blink;
68 Entry->Flink = ListHead;
69 Entry->Blink = OldBlink;
70 OldBlink->Flink = Entry;
71 ListHead->Blink = Entry;
72 }
73
74 BOOLEAN
75 FORCEINLINE
76 IsListEmpty(
77 IN const LIST_ENTRY * ListHead
78 )
79 {
80 return (BOOLEAN)(ListHead->Flink == ListHead);
81 }
82
83 FORCEINLINE
84 PSINGLE_LIST_ENTRY
85 PopEntryList(
86 PSINGLE_LIST_ENTRY ListHead
87 )
88 {
89 PSINGLE_LIST_ENTRY FirstEntry;
90 FirstEntry = ListHead->Next;
91 if (FirstEntry != NULL) {
92 ListHead->Next = FirstEntry->Next;
93 }
94
95 return FirstEntry;
96 }
97
98 FORCEINLINE
99 VOID
100 PushEntryList(
101 PSINGLE_LIST_ENTRY ListHead,
102 PSINGLE_LIST_ENTRY Entry
103 )
104 {
105 Entry->Next = ListHead->Next;
106 ListHead->Next = Entry;
107 }
108
109 FORCEINLINE
110 BOOLEAN
111 RemoveEntryList(
112 IN PLIST_ENTRY Entry)
113 {
114 PLIST_ENTRY OldFlink;
115 PLIST_ENTRY OldBlink;
116
117 OldFlink = Entry->Flink;
118 OldBlink = Entry->Blink;
119 OldFlink->Blink = OldBlink;
120 OldBlink->Flink = OldFlink;
121 return (BOOLEAN)(OldFlink == OldBlink);
122 }
123
124 FORCEINLINE
125 PLIST_ENTRY
126 RemoveHeadList(
127 IN PLIST_ENTRY ListHead)
128 {
129 PLIST_ENTRY Flink;
130 PLIST_ENTRY Entry;
131
132 Entry = ListHead->Flink;
133 Flink = Entry->Flink;
134 ListHead->Flink = Flink;
135 Flink->Blink = ListHead;
136 return Entry;
137 }
138
139 FORCEINLINE
140 PLIST_ENTRY
141 RemoveTailList(
142 IN PLIST_ENTRY ListHead)
143 {
144 PLIST_ENTRY Blink;
145 PLIST_ENTRY Entry;
146
147 Entry = ListHead->Blink;
148 Blink = Entry->Blink;
149 ListHead->Blink = Blink;
150 Blink->Flink = ListHead;
151 return Entry;
152 }
153
154 //
155 // LUID Macros
156 //
157 #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
158 ((L1)->LowPart == (L2)->LowPart))
159
160 #endif
161
162 //
163 // RTL Splay Tree Functions
164 //
165 NTSYSAPI
166 PRTL_SPLAY_LINKS
167 NTAPI
168 RtlSplay(PRTL_SPLAY_LINKS Links);
169
170 NTSYSAPI
171 PRTL_SPLAY_LINKS
172 NTAPI
173 RtlDelete(PRTL_SPLAY_LINKS Links);
174
175 NTSYSAPI
176 VOID
177 NTAPI
178 RtlDeleteNoSplay(
179 PRTL_SPLAY_LINKS Links,
180 PRTL_SPLAY_LINKS *Root
181 );
182
183 NTSYSAPI
184 PRTL_SPLAY_LINKS
185 NTAPI
186 RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links);
187
188 NTSYSAPI
189 PRTL_SPLAY_LINKS
190 NTAPI
191 RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links);
192
193 NTSYSAPI
194 PRTL_SPLAY_LINKS
195 NTAPI
196 RtlRealSuccessor(PRTL_SPLAY_LINKS Links);
197
198 NTSYSAPI
199 PRTL_SPLAY_LINKS
200 NTAPI
201 RtlRealPredecessor(PRTL_SPLAY_LINKS Links);
202
203 #define RtlIsLeftChild(Links) \
204 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
205
206 #define RtlIsRightChild(Links) \
207 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
208
209 #define RtlRightChild(Links) \
210 ((PRTL_SPLAY_LINKS)(Links))->RightChild
211
212 #define RtlIsRoot(Links) \
213 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
214
215 #define RtlLeftChild(Links) \
216 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
217
218 #define RtlParent(Links) \
219 ((PRTL_SPLAY_LINKS)(Links))->Parent
220
221 #define RtlInitializeSplayLinks(Links) \
222 { \
223 PRTL_SPLAY_LINKS _SplayLinks; \
224 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
225 _SplayLinks->Parent = _SplayLinks; \
226 _SplayLinks->LeftChild = NULL; \
227 _SplayLinks->RightChild = NULL; \
228 }
229
230 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
231 { \
232 PRTL_SPLAY_LINKS _SplayParent; \
233 PRTL_SPLAY_LINKS _SplayChild; \
234 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
235 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
236 _SplayParent->LeftChild = _SplayChild; \
237 _SplayChild->Parent = _SplayParent; \
238 }
239
240 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
241 { \
242 PRTL_SPLAY_LINKS _SplayParent; \
243 PRTL_SPLAY_LINKS _SplayChild; \
244 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
245 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
246 _SplayParent->RightChild = _SplayChild; \
247 _SplayChild->Parent = _SplayParent; \
248 }
249
250 //
251 // Error and Exception Functions
252 //
253 NTSYSAPI
254 PVOID
255 NTAPI
256 RtlAddVectoredExceptionHandler(
257 IN ULONG FirstHandler,
258 IN PVECTORED_EXCEPTION_HANDLER VectoredHandler
259 );
260
261 NTSYSAPI
262 VOID
263 NTAPI
264 RtlAssert(
265 PVOID FailedAssertion,
266 PVOID FileName,
267 ULONG LineNumber,
268 PCHAR Message
269 );
270
271 NTSYSAPI
272 VOID
273 NTAPI
274 RtlCaptureContext(OUT PCONTEXT ContextRecord);
275
276 NTSYSAPI
277 PVOID
278 NTAPI
279 RtlEncodePointer(IN PVOID Pointer);
280
281 NTSYSAPI
282 PVOID
283 NTAPI
284 RtlDecodePointer(IN PVOID Pointer);
285
286 NTSYSAPI
287 BOOLEAN
288 NTAPI
289 RtlDispatchException(
290 IN PEXCEPTION_RECORD ExceptionRecord,
291 IN PCONTEXT Context
292 );
293
294 NTSYSAPI
295 ULONG
296 NTAPI
297 RtlNtStatusToDosError(IN NTSTATUS Status);
298
299 NTSYSAPI
300 VOID
301 NTAPI
302 RtlRaiseException(IN PEXCEPTION_RECORD ExceptionRecord);
303
304 NTSYSAPI
305 VOID
306 NTAPI
307 RtlRaiseStatus(NTSTATUS Status);
308
309 NTSYSAPI
310 LONG
311 NTAPI
312 RtlUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo);
313
314 NTSYSAPI
315 VOID
316 NTAPI
317 RtlUnwind(
318 IN PVOID TargetFrame OPTIONAL,
319 IN PVOID TargetIp OPTIONAL,
320 IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
321 IN PVOID ReturnValue
322 );
323
324 //
325 // Heap Functions
326 //
327 NTSYSAPI
328 PVOID
329 NTAPI
330 RtlAllocateHeap(
331 IN HANDLE HeapHandle,
332 IN ULONG Flags,
333 IN ULONG Size
334 );
335
336 NTSYSAPI
337 PVOID
338 NTAPI
339 RtlCreateHeap(
340 IN ULONG Flags,
341 IN PVOID BaseAddress OPTIONAL,
342 IN SIZE_T SizeToReserve OPTIONAL,
343 IN SIZE_T SizeToCommit OPTIONAL,
344 IN PVOID Lock OPTIONAL,
345 IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL
346 );
347
348 ULONG
349 NTAPI
350 RtlCompactHeap(
351 HANDLE heap,
352 ULONG flags
353 );
354
355 NTSYSAPI
356 HANDLE
357 NTAPI
358 RtlDestroyHeap(HANDLE hheap);
359
360 NTSYSAPI
361 BOOLEAN
362 NTAPI
363 RtlFreeHeap(
364 IN HANDLE HeapHandle,
365 IN ULONG Flags,
366 IN PVOID P
367 );
368
369 ULONG
370 NTAPI
371 RtlGetProcessHeaps(
372 ULONG HeapCount,
373 HANDLE *HeapArray
374 );
375
376 PVOID
377 NTAPI
378 RtlReAllocateHeap(
379 HANDLE Heap,
380 ULONG Flags,
381 PVOID Ptr,
382 ULONG Size
383 );
384
385 BOOLEAN
386 NTAPI
387 RtlLockHeap(IN HANDLE Heap);
388
389 BOOLEAN
390 NTAPI
391 RtlUnlockHeap(IN HANDLE Heap);
392
393 ULONG
394 NTAPI
395 RtlSizeHeap(
396 IN PVOID HeapHandle,
397 IN ULONG Flags,
398 IN PVOID MemoryPointer
399 );
400
401 BOOLEAN
402 NTAPI
403 RtlValidateHeap(
404 HANDLE Heap,
405 ULONG Flags,
406 PVOID pmem
407 );
408
409 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
410
411 //
412 // Security Functions
413 //
414 NTSYSAPI
415 NTSTATUS
416 NTAPI
417 RtlAbsoluteToSelfRelativeSD(
418 IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
419 IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
420 IN PULONG BufferLength
421 );
422
423 NTSYSAPI
424 NTSTATUS
425 NTAPI
426 RtlAddAccessAllowedAce(
427 PACL Acl,
428 ULONG Revision,
429 ACCESS_MASK AccessMask,
430 PSID Sid
431 );
432
433 NTSTATUS
434 NTAPI
435 RtlAddAccessAllowedAceEx(
436 IN OUT PACL pAcl,
437 IN ULONG dwAceRevision,
438 IN ULONG AceFlags,
439 IN ULONG AccessMask,
440 IN PSID pSid
441 );
442
443 NTSTATUS
444 NTAPI
445 RtlAddAccessDeniedAce(
446 PACL Acl,
447 ULONG Revision,
448 ACCESS_MASK AccessMask,
449 PSID Sid
450 );
451
452 NTSTATUS
453 NTAPI
454 RtlAddAccessDeniedAceEx(
455 IN OUT PACL Acl,
456 IN ULONG Revision,
457 IN ULONG Flags,
458 IN ACCESS_MASK AccessMask,
459 IN PSID Sid
460 );
461
462 NTSTATUS
463 NTAPI
464 RtlAddAuditAccessAceEx(
465 IN OUT PACL Acl,
466 IN ULONG Revision,
467 IN ULONG Flags,
468 IN ACCESS_MASK AccessMask,
469 IN PSID Sid,
470 IN BOOLEAN Success,
471 IN BOOLEAN Failure
472 );
473
474 NTSYSAPI
475 NTSTATUS
476 NTAPI
477 RtlAddAce(
478 PACL Acl,
479 ULONG AceRevision,
480 ULONG StartingAceIndex,
481 PVOID AceList,
482 ULONG AceListLength
483 );
484
485 NTSTATUS
486 NTAPI
487 RtlAddAuditAccessAce(
488 PACL Acl,
489 ULONG Revision,
490 ACCESS_MASK AccessMask,
491 PSID Sid,
492 BOOLEAN Success,
493 BOOLEAN Failure
494 );
495
496 NTSTATUS
497 NTAPI
498 RtlAdjustPrivilege(
499 IN ULONG Privilege,
500 IN BOOLEAN NewValue,
501 IN BOOLEAN ForThread,
502 OUT PBOOLEAN OldValue
503 );
504
505 NTSYSAPI
506 NTSTATUS
507 NTAPI
508 RtlAllocateAndInitializeSid(
509 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
510 IN UCHAR SubAuthorityCount,
511 IN ULONG SubAuthority0,
512 IN ULONG SubAuthority1,
513 IN ULONG SubAuthority2,
514 IN ULONG SubAuthority3,
515 IN ULONG SubAuthority4,
516 IN ULONG SubAuthority5,
517 IN ULONG SubAuthority6,
518 IN ULONG SubAuthority7,
519 OUT PSID *Sid
520 );
521
522 BOOLEAN
523 NTAPI
524 RtlAreAllAccessesGranted(
525 ACCESS_MASK GrantedAccess,
526 ACCESS_MASK DesiredAccess
527 );
528
529 BOOLEAN
530 NTAPI
531 RtlAreAnyAccessesGranted(
532 ACCESS_MASK GrantedAccess,
533 ACCESS_MASK DesiredAccess
534 );
535
536 NTSYSAPI
537 VOID
538 NTAPI
539 RtlCopyLuid(
540 IN PLUID LuidDest,
541 IN PLUID LuidSrc
542 );
543
544 VOID
545 NTAPI
546 RtlCopyLuidAndAttributesArray(
547 ULONG Count,
548 PLUID_AND_ATTRIBUTES Src,
549 PLUID_AND_ATTRIBUTES Dest
550 );
551
552 NTSTATUS
553 NTAPI
554 RtlCopySidAndAttributesArray(
555 ULONG Count,
556 PSID_AND_ATTRIBUTES Src,
557 ULONG SidAreaSize,
558 PSID_AND_ATTRIBUTES Dest,
559 PVOID SidArea,
560 PVOID* RemainingSidArea,
561 PULONG RemainingSidAreaSize
562 );
563
564 NTSTATUS
565 NTAPI
566 RtlConvertSidToUnicodeString(
567 OUT PUNICODE_STRING DestinationString,
568 IN PSID Sid,
569 IN BOOLEAN AllocateDestinationString
570 );
571
572 NTSYSAPI
573 NTSTATUS
574 NTAPI
575 RtlCopySid(
576 IN ULONG Length,
577 IN PSID Destination,
578 IN PSID Source
579 );
580
581 NTSYSAPI
582 NTSTATUS
583 NTAPI
584 RtlCreateAcl(
585 PACL Acl,
586 ULONG AclSize,
587 ULONG AclRevision
588 );
589
590 NTSYSAPI
591 NTSTATUS
592 NTAPI
593 RtlCreateSecurityDescriptor(
594 PSECURITY_DESCRIPTOR SecurityDescriptor,
595 ULONG Revision
596 );
597
598 NTSYSAPI
599 NTSTATUS
600 NTAPI
601 RtlCreateSecurityDescriptorRelative(
602 PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
603 ULONG Revision
604 );
605
606 NTSYSAPI
607 NTSTATUS
608 NTAPI
609 RtlDeleteAce(
610 PACL Acl,
611 ULONG AceIndex
612 );
613
614 NTSYSAPI
615 BOOLEAN
616 NTAPI
617 RtlEqualPrefixSid(
618 PSID Sid1,
619 PSID Sid2
620 );
621
622 NTSYSAPI
623 BOOLEAN
624 NTAPI
625 RtlEqualSid (
626 IN PSID Sid1,
627 IN PSID Sid2
628 );
629
630 BOOLEAN
631 NTAPI
632 RtlFirstFreeAce(
633 PACL Acl,
634 PACE* Ace
635 );
636
637 NTSYSAPI
638 PVOID
639 NTAPI
640 RtlFreeSid (
641 IN PSID Sid
642 );
643
644 NTSYSAPI
645 NTSTATUS
646 NTAPI
647 RtlGetAce(
648 PACL Acl,
649 ULONG AceIndex,
650 PVOID *Ace
651 );
652
653 NTSTATUS
654 NTAPI
655 RtlGetControlSecurityDescriptor(
656 PSECURITY_DESCRIPTOR SecurityDescriptor,
657 PSECURITY_DESCRIPTOR_CONTROL Control,
658 PULONG Revision
659 );
660
661 NTSYSAPI
662 NTSTATUS
663 NTAPI
664 RtlGetDaclSecurityDescriptor(
665 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
666 OUT PBOOLEAN DaclPresent,
667 OUT PACL *Dacl,
668 OUT PBOOLEAN DaclDefaulted
669 );
670
671 NTSYSAPI
672 NTSTATUS
673 NTAPI
674 RtlGetSaclSecurityDescriptor(
675 PSECURITY_DESCRIPTOR SecurityDescriptor,
676 PBOOLEAN SaclPresent,
677 PACL* Sacl,
678 PBOOLEAN SaclDefaulted
679 );
680
681 NTSYSAPI
682 NTSTATUS
683 NTAPI
684 RtlGetGroupSecurityDescriptor(
685 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
686 OUT PSID *Group,
687 OUT PBOOLEAN GroupDefaulted
688 );
689
690 NTSYSAPI
691 NTSTATUS
692 NTAPI
693 RtlGetOwnerSecurityDescriptor(
694 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
695 OUT PSID *Owner,
696 OUT PBOOLEAN OwnerDefaulted
697 );
698
699 NTSYSAPI
700 BOOLEAN
701 NTAPI
702 RtlGetSecurityDescriptorRMControl(
703 PSECURITY_DESCRIPTOR SecurityDescriptor,
704 PUCHAR RMControl
705 );
706
707 NTSYSAPI
708 PSID_IDENTIFIER_AUTHORITY
709 NTAPI
710 RtlIdentifierAuthoritySid(PSID Sid);
711
712 NTSYSAPI
713 NTSTATUS
714 NTAPI
715 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
716
717 NTSYSAPI
718 NTSTATUS
719 NTAPI
720 RtlInitializeSid(
721 IN OUT PSID Sid,
722 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
723 IN UCHAR SubAuthorityCount
724 );
725
726 NTSYSAPI
727 ULONG
728 NTAPI
729 RtlLengthRequiredSid(IN ULONG SubAuthorityCount);
730
731 NTSYSAPI
732 ULONG
733 NTAPI
734 RtlLengthSid(IN PSID Sid);
735
736 NTSYSAPI
737 VOID
738 NTAPI
739 RtlMapGenericMask(
740 PACCESS_MASK AccessMask,
741 PGENERIC_MAPPING GenericMapping
742 );
743
744 NTSYSAPI
745 NTSTATUS
746 NTAPI
747 RtlQueryInformationAcl(
748 PACL Acl,
749 PVOID Information,
750 ULONG InformationLength,
751 ACL_INFORMATION_CLASS InformationClass
752 );
753
754 NTSYSAPI
755 NTSTATUS
756 NTAPI
757 RtlSelfRelativeToAbsoluteSD(
758 IN PSECURITY_DESCRIPTOR SelfRelativeSD,
759 OUT PSECURITY_DESCRIPTOR AbsoluteSD,
760 IN PULONG AbsoluteSDSize,
761 IN PACL Dacl,
762 IN PULONG DaclSize,
763 IN PACL Sacl,
764 IN PULONG SaclSize,
765 IN PSID Owner,
766 IN PULONG OwnerSize,
767 IN PSID PrimaryGroup,
768 IN PULONG PrimaryGroupSize
769 );
770
771 NTSYSAPI
772 NTSTATUS
773 NTAPI
774 RtlSelfRelativeToAbsoluteSD2(
775 IN OUT PSECURITY_DESCRIPTOR SelfRelativeSD,
776 OUT PULONG BufferSize
777 );
778
779 NTSYSAPI
780 NTSTATUS
781 NTAPI
782 RtlSetControlSecurityDescriptor(
783 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
784 IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
785 IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
786 );
787
788 NTSYSAPI
789 NTSTATUS
790 NTAPI
791 RtlSetDaclSecurityDescriptor (
792 PSECURITY_DESCRIPTOR SecurityDescriptor,
793 BOOLEAN DaclPresent,
794 PACL Dacl,
795 BOOLEAN DaclDefaulted
796 );
797
798 NTSYSAPI
799 NTSTATUS
800 NTAPI
801 RtlSetGroupSecurityDescriptor(
802 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
803 IN PSID Group,
804 IN BOOLEAN GroupDefaulted
805 );
806
807 NTSYSAPI
808 NTSTATUS
809 NTAPI
810 RtlSetInformationAcl(
811 PACL Acl,
812 PVOID Information,
813 ULONG InformationLength,
814 ACL_INFORMATION_CLASS InformationClass
815 );
816
817 NTSYSAPI
818 NTSTATUS
819 NTAPI
820 RtlSetOwnerSecurityDescriptor(
821 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
822 IN PSID Owner,
823 IN BOOLEAN OwnerDefaulted
824 );
825
826 NTSYSAPI
827 NTSTATUS
828 NTAPI
829 RtlSetSaclSecurityDescriptor(
830 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
831 IN BOOLEAN SaclPresent,
832 IN PACL Sacl,
833 IN BOOLEAN SaclDefaulted
834 );
835
836 NTSYSAPI
837 VOID
838 NTAPI
839 RtlSetSecurityDescriptorRMControl(
840 PSECURITY_DESCRIPTOR SecurityDescriptor,
841 PUCHAR RMControl
842 );
843
844 NTSYSAPI
845 PUCHAR
846 NTAPI
847 RtlSubAuthorityCountSid(
848 IN PSID Sid
849 );
850
851 NTSYSAPI
852 PULONG
853 NTAPI
854 RtlSubAuthoritySid(
855 IN PSID Sid,
856 IN ULONG SubAuthority
857 );
858
859 NTSYSAPI
860 BOOLEAN
861 NTAPI
862 RtlValidRelativeSecurityDescriptor(
863 IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
864 IN ULONG SecurityDescriptorLength,
865 IN SECURITY_INFORMATION RequiredInformation
866 );
867
868 NTSYSAPI
869 BOOLEAN
870 NTAPI
871 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
872
873 NTSYSAPI
874 BOOLEAN
875 NTAPI
876 RtlValidSid(IN PSID Sid);
877
878 NTSYSAPI
879 BOOLEAN
880 NTAPI
881 RtlValidAcl(PACL Acl);
882
883 NTSYSAPI
884 NTSTATUS
885 NTAPI
886 RtlDeleteSecurityObject(
887 IN PSECURITY_DESCRIPTOR *ObjectDescriptor
888 );
889
890 NTSYSAPI
891 NTSTATUS
892 NTAPI
893 RtlNewSecurityObject(
894 IN PSECURITY_DESCRIPTOR ParentDescriptor,
895 IN PSECURITY_DESCRIPTOR CreatorDescriptor,
896 OUT PSECURITY_DESCRIPTOR *NewDescriptor,
897 IN BOOLEAN IsDirectoryObject,
898 IN HANDLE Token,
899 IN PGENERIC_MAPPING GenericMapping
900 );
901
902 NTSYSAPI
903 NTSTATUS
904 NTAPI
905 RtlQuerySecurityObject(
906 IN PSECURITY_DESCRIPTOR ObjectDescriptor,
907 IN SECURITY_INFORMATION SecurityInformation,
908 OUT PSECURITY_DESCRIPTOR ResultantDescriptor,
909 IN ULONG DescriptorLength,
910 OUT PULONG ReturnLength
911 );
912
913 NTSYSAPI
914 NTSTATUS
915 NTAPI
916 RtlSetSecurityObject(
917 IN SECURITY_INFORMATION SecurityInformation,
918 IN PSECURITY_DESCRIPTOR ModificationDescriptor,
919 OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
920 IN PGENERIC_MAPPING GenericMapping,
921 IN HANDLE Token
922 );
923
924 //
925 // Single-Character Functions
926 //
927 NTSYSAPI
928 NTSTATUS
929 NTAPI
930 RtlLargeIntegerToChar(
931 IN PLARGE_INTEGER Value,
932 IN ULONG Base,
933 IN ULONG Length,
934 IN OUT PCHAR String
935 );
936
937 NTSYSAPI
938 CHAR
939 NTAPI
940 RtlUpperChar(CHAR Source);
941
942 NTSYSAPI
943 WCHAR
944 NTAPI
945 RtlUpcaseUnicodeChar(WCHAR Source);
946
947 NTSYSAPI
948 WCHAR
949 NTAPI
950 RtlDowncaseUnicodeChar(IN WCHAR Source);
951
952 NTSYSAPI
953 NTSTATUS
954 NTAPI
955 RtlIntegerToChar(
956 IN ULONG Value,
957 IN ULONG Base,
958 IN ULONG Length,
959 IN OUT PCHAR String
960 );
961
962 NTSYSAPI
963 NTSTATUS
964 NTAPI
965 RtlIntegerToUnicode(
966 IN ULONG Value,
967 IN ULONG Base OPTIONAL,
968 IN ULONG Length OPTIONAL,
969 IN OUT LPWSTR String
970 );
971
972 NTSYSAPI
973 NTSTATUS
974 NTAPI
975 RtlIntegerToUnicodeString(
976 IN ULONG Value,
977 IN ULONG Base,
978 IN OUT PUNICODE_STRING String
979 );
980
981 NTSYSAPI
982 NTSTATUS
983 NTAPI
984 RtlCharToInteger(
985 PCSZ String,
986 ULONG Base,
987 PULONG Value
988 );
989
990 //
991 // Byte Swap Functions
992 //
993 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || \
994 ((defined(_M_AMD64) || \
995 defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
996
997 unsigned short __cdecl _byteswap_ushort(unsigned short);
998 unsigned long __cdecl _byteswap_ulong (unsigned long);
999 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1000 #pragma intrinsic(_byteswap_ushort)
1001 #pragma intrinsic(_byteswap_ulong)
1002 #pragma intrinsic(_byteswap_uint64)
1003 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1004 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1005 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1006
1007 #else
1008
1009 USHORT
1010 FASTCALL
1011 RtlUshortByteSwap(IN USHORT Source);
1012
1013 ULONG
1014 FASTCALL
1015 RtlUlongByteSwap(IN ULONG Source);
1016
1017 ULONGLONG
1018 FASTCALL
1019 RtlUlonglongByteSwap(IN ULONGLONG Source);
1020
1021 #endif
1022
1023 //
1024 // Unicode->Ansi String Functions
1025 //
1026 NTSYSAPI
1027 ULONG
1028 NTAPI
1029 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
1030
1031 #ifdef NTOS_MODE_USER
1032
1033 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1034 NLS_MB_CODE_PAGE_TAG ? \
1035 RtlxUnicodeStringToAnsiSize(STRING) : \
1036 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1037 )
1038
1039 #endif
1040
1041 NTSYSAPI
1042 NTSTATUS
1043 NTAPI
1044 RtlUnicodeStringToAnsiString(
1045 PANSI_STRING DestinationString,
1046 PCUNICODE_STRING SourceString,
1047 BOOLEAN AllocateDestinationString
1048 );
1049
1050 //
1051 // Unicode->OEM String Functions
1052 //
1053 NTSYSAPI
1054 NTSTATUS
1055 NTAPI
1056 RtlUpcaseUnicodeStringToOemString(
1057 POEM_STRING DestinationString,
1058 PCUNICODE_STRING SourceString,
1059 BOOLEAN AllocateDestinationString
1060 );
1061
1062 NTSYSAPI
1063 NTSTATUS
1064 NTAPI
1065 RtlUpcaseUnicodeStringToCountedOemString(
1066 IN OUT POEM_STRING DestinationString,
1067 IN PCUNICODE_STRING SourceString,
1068 IN BOOLEAN AllocateDestinationString
1069 );
1070
1071 NTSYSAPI
1072 NTSTATUS
1073 NTAPI
1074 RtlUnicodeStringToOemString(
1075 POEM_STRING DestinationString,
1076 PCUNICODE_STRING SourceString,
1077 BOOLEAN AllocateDestinationString
1078 );
1079
1080 NTSYSAPI
1081 NTSTATUS
1082 NTAPI
1083 RtlUpcaseUnicodeToOemN(
1084 PCHAR OemString,
1085 ULONG OemSize,
1086 PULONG ResultSize,
1087 PWCHAR UnicodeString,
1088 ULONG UnicodeSize
1089 );
1090
1091 NTSYSAPI
1092 ULONG
1093 NTAPI
1094 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
1095
1096 #ifdef NTOS_MODE_USER
1097
1098 #define RtlUnicodeStringToOemSize(STRING) ( \
1099 NLS_MB_OEM_CODE_PAGE_TAG ? \
1100 RtlxUnicodeStringToOemSize(STRING) : \
1101 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1102 )
1103
1104 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1105 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1106 )
1107
1108 #endif
1109
1110 NTSYSAPI
1111 NTSTATUS
1112 NTAPI
1113 RtlUnicodeToOemN(
1114 PCHAR OemString,
1115 ULONG OemSize,
1116 PULONG ResultSize,
1117 PWCHAR UnicodeString,
1118 ULONG UnicodeSize
1119 );
1120
1121 //
1122 // Unicode->MultiByte String Functions
1123 //
1124 NTSYSAPI
1125 NTSTATUS
1126 NTAPI
1127 RtlUnicodeToMultiByteN(
1128 PCHAR MbString,
1129 ULONG MbSize,
1130 PULONG ResultSize,
1131 PWCHAR UnicodeString,
1132 ULONG UnicodeSize
1133 );
1134
1135 NTSYSAPI
1136 NTSTATUS
1137 NTAPI
1138 RtlUpcaseUnicodeToMultiByteN(
1139 PCHAR MbString,
1140 ULONG MbSize,
1141 PULONG ResultSize,
1142 PWCHAR UnicodeString,
1143 ULONG UnicodeSize
1144 );
1145
1146 NTSYSAPI
1147 NTSTATUS
1148 NTAPI
1149 RtlUnicodeToMultiByteSize(
1150 PULONG MbSize,
1151 PWCHAR UnicodeString,
1152 ULONG UnicodeSize
1153 );
1154
1155 NTSYSAPI
1156 ULONG
1157 NTAPI
1158 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
1159
1160 //
1161 // OEM to Unicode Functions
1162 //
1163 NTSYSAPI
1164 NTSTATUS
1165 NTAPI
1166 RtlOemStringToUnicodeString(
1167 PUNICODE_STRING DestinationString,
1168 PCOEM_STRING SourceString,
1169 BOOLEAN AllocateDestinationString
1170 );
1171
1172 NTSYSAPI
1173 NTSTATUS
1174 NTAPI
1175 RtlOemToUnicodeN(
1176 PWSTR UnicodeString,
1177 ULONG MaxBytesInUnicodeString,
1178 PULONG BytesInUnicodeString,
1179 IN PCHAR OemString,
1180 ULONG BytesInOemString
1181 );
1182
1183 #ifdef NTOS_MODE_USER
1184
1185 #define RtlOemStringToUnicodeSize(STRING) ( \
1186 NLS_MB_OEM_CODE_PAGE_TAG ? \
1187 RtlxOemStringToUnicodeSize(STRING) : \
1188 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1189 )
1190
1191 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1192 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1193 )
1194
1195 #endif
1196
1197 //
1198 // Ansi->Unicode String Functions
1199 //
1200 NTSYSAPI
1201 ULONG
1202 NTAPI
1203 RtlxAnsiStringToUnicodeSize(
1204 PCANSI_STRING AnsiString
1205 );
1206
1207 NTSYSAPI
1208 NTSTATUS
1209 NTAPI
1210 RtlAnsiStringToUnicodeString(
1211 PUNICODE_STRING DestinationString,
1212 PCANSI_STRING SourceString,
1213 BOOLEAN AllocateDestinationString
1214 );
1215
1216 #ifdef NTOS_MODE_USER
1217
1218 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1219 NLS_MB_CODE_PAGE_TAG ? \
1220 RtlxAnsiStringToUnicodeSize(STRING) : \
1221 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1222 )
1223
1224 #endif
1225
1226 NTSYSAPI
1227 BOOLEAN
1228 NTAPI
1229 RtlCreateUnicodeStringFromAsciiz(
1230 OUT PUNICODE_STRING Destination,
1231 IN PCSZ Source
1232 );
1233
1234 //
1235 // Unicode String Functions
1236 //
1237 NTSYSAPI
1238 NTSTATUS
1239 NTAPI
1240 RtlAppendUnicodeToString(
1241 PUNICODE_STRING Destination,
1242 PCWSTR Source
1243 );
1244
1245 NTSYSAPI
1246 NTSTATUS
1247 NTAPI
1248 RtlAppendUnicodeStringToString(
1249 PUNICODE_STRING Destination,
1250 PCUNICODE_STRING Source
1251 );
1252
1253 NTSYSAPI
1254 LONG
1255 NTAPI
1256 RtlCompareUnicodeString(
1257 PCUNICODE_STRING String1,
1258 PCUNICODE_STRING String2,
1259 BOOLEAN CaseInsensitive
1260 );
1261
1262 NTSYSAPI
1263 VOID
1264 NTAPI
1265 RtlCopyUnicodeString(
1266 PUNICODE_STRING DestinationString,
1267 PCUNICODE_STRING SourceString
1268 );
1269
1270 NTSYSAPI
1271 BOOLEAN
1272 NTAPI
1273 RtlCreateUnicodeString(
1274 PUNICODE_STRING DestinationString,
1275 PCWSTR SourceString
1276 );
1277
1278 #ifdef NTOS_MODE_USER
1279
1280 NTSYSAPI
1281 NTSTATUS
1282 NTAPI
1283 RtlDowncaseUnicodeString(
1284 IN OUT PUNICODE_STRING UniDest,
1285 IN PCUNICODE_STRING UniSource,
1286 IN BOOLEAN AllocateDestinationString
1287 );
1288
1289 #endif
1290
1291 NTSYSAPI
1292 NTSTATUS
1293 NTAPI
1294 RtlDuplicateUnicodeString(
1295 IN ULONG Flags,
1296 IN PCUNICODE_STRING SourceString,
1297 OUT PUNICODE_STRING DestinationString
1298 );
1299
1300 NTSYSAPI
1301 BOOLEAN
1302 NTAPI
1303 RtlEqualUnicodeString(
1304 PCUNICODE_STRING String1,
1305 PCUNICODE_STRING String2,
1306 BOOLEAN CaseInsensitive
1307 );
1308
1309 NTSYSAPI
1310 VOID
1311 NTAPI
1312 RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString);
1313
1314 NTSYSAPI
1315 NTSTATUS
1316 NTAPI
1317 RtlHashUnicodeString(
1318 IN CONST UNICODE_STRING *String,
1319 IN BOOLEAN CaseInSensitive,
1320 IN ULONG HashAlgorithm,
1321 OUT PULONG HashValue
1322 );
1323
1324 NTSYSAPI
1325 VOID
1326 NTAPI
1327 RtlInitUnicodeString(
1328 IN OUT PUNICODE_STRING DestinationString,
1329 IN PCWSTR SourceString);
1330
1331 NTSYSAPI
1332 ULONG
1333 NTAPI
1334 RtlIsTextUnicode(
1335 PVOID Buffer,
1336 ULONG Length,
1337 ULONG *Flags
1338 );
1339
1340 NTSYSAPI
1341 BOOLEAN
1342 NTAPI
1343 RtlPrefixString(
1344 PCANSI_STRING String1,
1345 PCANSI_STRING String2,
1346 BOOLEAN CaseInsensitive
1347 );
1348
1349 NTSYSAPI
1350 BOOLEAN
1351 NTAPI
1352 RtlPrefixUnicodeString(
1353 PCUNICODE_STRING String1,
1354 PCUNICODE_STRING String2,
1355 BOOLEAN CaseInsensitive
1356 );
1357
1358 NTSYSAPI
1359 NTSTATUS
1360 NTAPI
1361 RtlUpcaseUnicodeString(
1362 PUNICODE_STRING DestinationString,
1363 PCUNICODE_STRING SourceString,
1364 BOOLEAN AllocateDestinationString
1365 );
1366
1367 NTSYSAPI
1368 NTSTATUS
1369 NTAPI
1370 RtlUnicodeStringToInteger(
1371 PCUNICODE_STRING String,
1372 ULONG Base,
1373 PULONG Value
1374 );
1375
1376 //
1377 // Ansi String Functions
1378 //
1379 NTSYSAPI
1380 VOID
1381 NTAPI
1382 RtlFreeAnsiString(IN PANSI_STRING AnsiString);
1383
1384 NTSYSAPI
1385 VOID
1386 NTAPI
1387 RtlInitAnsiString(
1388 PANSI_STRING DestinationString,
1389 PCSZ SourceString
1390 );
1391
1392 //
1393 // OEM String Functions
1394 //
1395 NTSYSAPI
1396 VOID
1397 NTAPI
1398 RtlFreeOemString(IN POEM_STRING OemString);
1399
1400 //
1401 // MultiByte->Unicode String Functions
1402 //
1403 NTSYSAPI
1404 NTSTATUS
1405 NTAPI
1406 RtlMultiByteToUnicodeN(
1407 PWCHAR UnicodeString,
1408 ULONG UnicodeSize,
1409 PULONG ResultSize,
1410 PCSTR MbString,
1411 ULONG MbSize
1412 );
1413
1414 NTSYSAPI
1415 NTSTATUS
1416 NTAPI
1417 RtlMultiByteToUnicodeSize(
1418 PULONG UnicodeSize,
1419 PCSTR MbString,
1420 ULONG MbSize
1421 );
1422
1423 //
1424 // Atom Functions
1425 //
1426 NTSYSAPI
1427 NTSTATUS
1428 NTAPI
1429 RtlAddAtomToAtomTable(
1430 IN PRTL_ATOM_TABLE AtomTable,
1431 IN PWSTR AtomName,
1432 OUT PRTL_ATOM Atom
1433 );
1434
1435 NTSYSAPI
1436 NTSTATUS
1437 NTAPI
1438 RtlCreateAtomTable(
1439 IN ULONG TableSize,
1440 IN OUT PRTL_ATOM_TABLE *AtomTable
1441 );
1442
1443 NTSYSAPI
1444 NTSTATUS
1445 NTAPI
1446 RtlDeleteAtomFromAtomTable(
1447 IN PRTL_ATOM_TABLE AtomTable,
1448 IN RTL_ATOM Atom
1449 );
1450
1451 NTSYSAPI
1452 NTSTATUS
1453 NTAPI
1454 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
1455
1456 NTSYSAPI
1457 NTSTATUS
1458 NTAPI
1459 RtlQueryAtomInAtomTable(
1460 IN PRTL_ATOM_TABLE AtomTable,
1461 IN RTL_ATOM Atom,
1462 IN OUT PULONG RefCount OPTIONAL,
1463 IN OUT PULONG PinCount OPTIONAL,
1464 IN OUT PWSTR AtomName OPTIONAL,
1465 IN OUT PULONG NameLength OPTIONAL
1466 );
1467
1468 NTSYSAPI
1469 NTSTATUS
1470 NTAPI
1471 RtlPinAtomInAtomTable(
1472 IN PRTL_ATOM_TABLE AtomTable,
1473 IN RTL_ATOM Atom
1474 );
1475
1476 NTSYSAPI
1477 NTSTATUS
1478 NTAPI
1479 RtlLookupAtomInAtomTable(
1480 IN PRTL_ATOM_TABLE AtomTable,
1481 IN PWSTR AtomName,
1482 OUT PRTL_ATOM Atom
1483 );
1484
1485 //
1486 // Memory Functions
1487 //
1488 NTSYSAPI
1489 VOID
1490 NTAPI
1491 RtlFillMemoryUlong(
1492 IN PVOID Destination,
1493 IN ULONG Length,
1494 IN ULONG Fill
1495 );
1496
1497 //
1498 // Process Management Functions
1499 //
1500 NTSYSAPI
1501 VOID
1502 NTAPI
1503 RtlAcquirePebLock(VOID);
1504
1505 NTSYSAPI
1506 NTSTATUS
1507 NTAPI
1508 RtlCreateProcessParameters (
1509 OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
1510 IN PUNICODE_STRING ImagePathName OPTIONAL,
1511 IN PUNICODE_STRING DllPath OPTIONAL,
1512 IN PUNICODE_STRING CurrentDirectory OPTIONAL,
1513 IN PUNICODE_STRING CommandLine OPTIONAL,
1514 IN PWSTR Environment OPTIONAL,
1515 IN PUNICODE_STRING WindowTitle OPTIONAL,
1516 IN PUNICODE_STRING DesktopInfo OPTIONAL,
1517 IN PUNICODE_STRING ShellInfo OPTIONAL,
1518 IN PUNICODE_STRING RuntimeInfo OPTIONAL
1519 );
1520
1521 NTSYSAPI
1522 NTSTATUS
1523 NTAPI
1524 RtlCreateUserProcess(
1525 IN PUNICODE_STRING ImageFileName,
1526 IN ULONG Attributes,
1527 IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
1528 IN PSECURITY_DESCRIPTOR ProcessSecutityDescriptor OPTIONAL,
1529 IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL,
1530 IN HANDLE ParentProcess OPTIONAL,
1531 IN BOOLEAN CurrentDirectory,
1532 IN HANDLE DebugPort OPTIONAL,
1533 IN HANDLE ExceptionPort OPTIONAL,
1534 OUT PRTL_USER_PROCESS_INFORMATION ProcessInfo
1535 );
1536
1537 NTSYSAPI
1538 NTSTATUS
1539 NTAPI
1540 RtlCreateUserThread(
1541 IN HANDLE ProcessHandle,
1542 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
1543 IN BOOLEAN CreateSuspended,
1544 IN LONG StackZeroBits,
1545 IN ULONG StackReserve,
1546 IN ULONG StackCommit,
1547 IN PTHREAD_START_ROUTINE StartAddress,
1548 IN PVOID Parameter,
1549 IN OUT PHANDLE ThreadHandle,
1550 IN OUT PCLIENT_ID ClientId
1551 );
1552
1553 NTSYSAPI
1554 PRTL_USER_PROCESS_PARAMETERS
1555 NTAPI
1556 RtlDeNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
1557
1558 NTSYSAPI
1559 NTSTATUS
1560 NTAPI
1561 RtlDestroyProcessParameters(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
1562
1563 NTSYSAPI
1564 VOID
1565 NTAPI
1566 RtlExitUserThread(NTSTATUS Status);
1567
1568 NTSYSAPI
1569 VOID
1570 NTAPI
1571 RtlInitializeContext(
1572 IN HANDLE ProcessHandle,
1573 OUT PCONTEXT ThreadContext,
1574 IN PVOID ThreadStartParam OPTIONAL,
1575 IN PTHREAD_START_ROUTINE ThreadStartAddress,
1576 IN PINITIAL_TEB InitialTeb
1577 );
1578
1579 NTSYSAPI
1580 PRTL_USER_PROCESS_PARAMETERS
1581 NTAPI
1582 RtlNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
1583
1584 NTSYSAPI
1585 VOID
1586 NTAPI
1587 RtlReleasePebLock(VOID);
1588
1589 NTSYSAPI
1590 VOID
1591 NTAPI
1592 RtlSetProcessIsCritical(
1593 IN BOOLEAN NewValue,
1594 OUT PBOOLEAN OldValue OPTIONAL,
1595 IN BOOLEAN IsWinlogon
1596 );
1597
1598 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1599
1600 //
1601 // Environment/Path Functions
1602 //
1603 NTSYSAPI
1604 NTSTATUS
1605 NTAPI
1606 RtlCreateEnvironment(
1607 BOOLEAN Inherit,
1608 PWSTR *Environment
1609 );
1610
1611 NTSYSAPI
1612 VOID
1613 NTAPI
1614 RtlDestroyEnvironment(PWSTR Environment);
1615
1616 NTSYSAPI
1617 BOOLEAN
1618 NTAPI
1619 RtlDoesFileExists_U(PWSTR FileName);
1620
1621 NTSYSAPI
1622 ULONG
1623 NTAPI
1624 RtlDetermineDosPathNameType_U(PCWSTR Path);
1625
1626 NTSYSAPI
1627 ULONG
1628 NTAPI
1629 RtlDosSearchPath_U(
1630 WCHAR *sp,
1631 WCHAR *name,
1632 WCHAR *ext,
1633 ULONG buf_sz,
1634 WCHAR *buffer,
1635 WCHAR **shortname
1636 );
1637
1638 NTSYSAPI
1639 BOOLEAN
1640 NTAPI
1641 RtlDosPathNameToNtPathName_U(
1642 PWSTR DosName,
1643 PUNICODE_STRING NtName,
1644 PWSTR *ShortName,
1645 PCURDIR CurrentDirectory
1646 );
1647
1648 NTSYSAPI
1649 NTSTATUS
1650 NTAPI
1651 RtlExpandEnvironmentStrings_U(
1652 PWSTR Environment,
1653 PUNICODE_STRING Source,
1654 PUNICODE_STRING Destination,
1655 PULONG Length
1656 );
1657
1658 NTSYSAPI
1659 ULONG
1660 NTAPI
1661 RtlGetCurrentDirectory_U(
1662 ULONG MaximumLength,
1663 PWSTR Buffer
1664 );
1665
1666 NTSYSAPI
1667 ULONG
1668 NTAPI
1669 RtlGetFullPathName_U(
1670 const WCHAR *dosname,
1671 ULONG size,
1672 WCHAR *buf,
1673 WCHAR **shortname
1674 );
1675
1676 NTSYSAPI
1677 BOOLEAN
1678 NTAPI
1679 RtlIsNameLegalDOS8Dot3(
1680 IN PUNICODE_STRING UnicodeName,
1681 IN PANSI_STRING AnsiName,
1682 PBOOLEAN Unknown
1683 );
1684
1685 NTSYSAPI
1686 NTSTATUS
1687 NTAPI
1688 RtlQueryEnvironmentVariable_U(
1689 PWSTR Environment,
1690 PUNICODE_STRING Name,
1691 PUNICODE_STRING Value
1692 );
1693
1694 NTSYSAPI
1695 NTSTATUS
1696 NTAPI
1697 RtlSetCurrentDirectory_U(PUNICODE_STRING name);
1698
1699 NTSYSAPI
1700 NTSTATUS
1701 NTAPI
1702 RtlSetEnvironmentVariable(
1703 PWSTR *Environment,
1704 PUNICODE_STRING Name,
1705 PUNICODE_STRING Value
1706 );
1707
1708 //
1709 // Critical Section/Resource Functions
1710 //
1711 NTSYSAPI
1712 NTSTATUS
1713 NTAPI
1714 RtlDeleteCriticalSection (
1715 IN PRTL_CRITICAL_SECTION CriticalSection
1716 );
1717
1718 NTSYSAPI
1719 NTSTATUS
1720 NTAPI
1721 RtlEnterCriticalSection(
1722 IN PRTL_CRITICAL_SECTION CriticalSection
1723 );
1724
1725 NTSYSAPI
1726 NTSTATUS
1727 NTAPI
1728 RtlInitializeCriticalSection(
1729 IN PRTL_CRITICAL_SECTION CriticalSection
1730 );
1731
1732 NTSYSAPI
1733 NTSTATUS
1734 NTAPI
1735 RtlInitializeCriticalSectionAndSpinCount(
1736 IN PRTL_CRITICAL_SECTION CriticalSection,
1737 IN ULONG SpinCount
1738 );
1739
1740 NTSYSAPI
1741 NTSTATUS
1742 NTAPI
1743 RtlLeaveCriticalSection(
1744 IN PRTL_CRITICAL_SECTION CriticalSection
1745 );
1746
1747 NTSYSAPI
1748 VOID
1749 NTAPI
1750 RtlpUnWaitCriticalSection(
1751 IN PRTL_CRITICAL_SECTION CriticalSection
1752 );
1753
1754 NTSYSAPI
1755 NTSTATUS
1756 NTAPI
1757 RtlpWaitForCriticalSection(
1758 IN PRTL_CRITICAL_SECTION CriticalSection
1759 );
1760
1761 NTSYSAPI
1762 BOOLEAN
1763 NTAPI
1764 RtlAcquireResourceExclusive(
1765 IN PRTL_RESOURCE Resource,
1766 IN BOOLEAN Wait
1767 );
1768
1769 NTSYSAPI
1770 BOOLEAN
1771 NTAPI
1772 RtlAcquireResourceShared(
1773 IN PRTL_RESOURCE Resource,
1774 IN BOOLEAN Wait
1775 );
1776
1777 NTSYSAPI
1778 VOID
1779 NTAPI
1780 RtlConvertExclusiveToShared(
1781 IN PRTL_RESOURCE Resource
1782 );
1783
1784 NTSYSAPI
1785 VOID
1786 NTAPI
1787 RtlConvertSharedToExclusive(
1788 IN PRTL_RESOURCE Resource
1789 );
1790
1791 NTSYSAPI
1792 VOID
1793 NTAPI
1794 RtlDeleteResource(
1795 IN PRTL_RESOURCE Resource
1796 );
1797
1798 NTSYSAPI
1799 VOID
1800 NTAPI
1801 RtlDumpResource(
1802 IN PRTL_RESOURCE Resource
1803 );
1804
1805 NTSYSAPI
1806 VOID
1807 NTAPI
1808 RtlInitializeResource(
1809 IN PRTL_RESOURCE Resource
1810 );
1811
1812 NTSYSAPI
1813 VOID
1814 NTAPI
1815 RtlReleaseResource(
1816 IN PRTL_RESOURCE Resource
1817 );
1818
1819 //
1820 // Compression Functions
1821 //
1822 NTSYSAPI
1823 NTSTATUS
1824 NTAPI
1825 RtlCompressBuffer(
1826 IN USHORT CompressionFormatAndEngine,
1827 IN PUCHAR UncompressedBuffer,
1828 IN ULONG UncompressedBufferSize,
1829 OUT PUCHAR CompressedBuffer,
1830 IN ULONG CompressedBufferSize,
1831 IN ULONG UncompressedChunkSize,
1832 OUT PULONG FinalCompressedSize,
1833 IN PVOID WorkSpace
1834 );
1835
1836 NTSYSAPI
1837 NTSTATUS
1838 NTAPI
1839 RtlDecompressBuffer(
1840 IN USHORT CompressionFormat,
1841 OUT PUCHAR UncompressedBuffer,
1842 IN ULONG UncompressedBufferSize,
1843 IN PUCHAR CompressedBuffer,
1844 IN ULONG CompressedBufferSize,
1845 OUT PULONG FinalUncompressedSize
1846 );
1847
1848 NTSYSAPI
1849 NTSTATUS
1850 NTAPI
1851 RtlGetCompressionWorkSpaceSize(
1852 IN USHORT CompressionFormatAndEngine,
1853 OUT PULONG CompressBufferWorkSpaceSize,
1854 OUT PULONG CompressFragmentWorkSpaceSize
1855 );
1856
1857 //
1858 // Debug Info Functions
1859 //
1860 NTSYSAPI
1861 PRTL_DEBUG_BUFFER
1862 NTAPI
1863 RtlCreateQueryDebugBuffer(
1864 IN ULONG Size,
1865 IN BOOLEAN EventPair
1866 );
1867
1868 NTSYSAPI
1869 NTSTATUS
1870 NTAPI
1871 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_BUFFER DebugBuffer);
1872
1873 NTSYSAPI
1874 NTSTATUS
1875 NTAPI
1876 RtlQueryProcessDebugInformation(
1877 IN ULONG ProcessId,
1878 IN ULONG DebugInfoClassMask,
1879 IN OUT PRTL_DEBUG_BUFFER DebugBuffer
1880 );
1881
1882 //
1883 // Bitmap Functions
1884 //
1885 NTSYSAPI
1886 BOOLEAN
1887 NTAPI
1888 RtlAreBitsClear(
1889 IN PRTL_BITMAP BitMapHeader,
1890 IN ULONG StartingIndex,
1891 IN ULONG Length
1892 );
1893
1894 NTSYSAPI
1895 BOOLEAN
1896 NTAPI
1897 RtlAreBitsSet(
1898 IN PRTL_BITMAP BitMapHeader,
1899 IN ULONG StartingIndex,
1900 IN ULONG Length
1901 );
1902
1903 NTSYSAPI
1904 VOID
1905 NTAPI
1906 RtlClearBits(
1907 IN PRTL_BITMAP BitMapHeader,
1908 IN ULONG StartingIndex,
1909 IN ULONG NumberToClear
1910 );
1911
1912 NTSYSAPI
1913 ULONG
1914 NTAPI
1915 RtlFindClearBits(
1916 IN PRTL_BITMAP BitMapHeader,
1917 IN ULONG NumberToFind,
1918 IN ULONG HintIndex
1919 );
1920
1921 NTSYSAPI
1922 ULONG
1923 NTAPI
1924 RtlFindClearBitsAndSet(
1925 IN PRTL_BITMAP BitMapHeader,
1926 IN ULONG NumberToFind,
1927 IN ULONG HintIndex
1928 );
1929
1930 NTSYSAPI
1931 VOID
1932 NTAPI
1933 RtlInitializeBitMap(
1934 IN PRTL_BITMAP BitMapHeader,
1935 IN PULONG BitMapBuffer,
1936 IN ULONG SizeOfBitMap
1937 );
1938
1939 NTSYSAPI
1940 VOID
1941 NTAPI
1942 RtlSetBits (
1943 IN PRTL_BITMAP BitMapHeader,
1944 IN ULONG StartingIndex,
1945 IN ULONG NumberToSet
1946 );
1947
1948 //
1949 // Timer Functions
1950 //
1951 NTSYSAPI
1952 NTSTATUS
1953 NTAPI
1954 RtlCreateTimer(
1955 HANDLE TimerQueue,
1956 PHANDLE phNewTimer,
1957 WAITORTIMERCALLBACKFUNC Callback,
1958 PVOID Parameter,
1959 ULONG DueTime,
1960 ULONG Period,
1961 ULONG Flags
1962 );
1963
1964 NTSYSAPI
1965 NTSTATUS
1966 NTAPI
1967 RtlCreateTimerQueue(PHANDLE TimerQueue);
1968
1969 NTSYSAPI
1970 NTSTATUS
1971 NTAPI
1972 RtlDeleteTimer(
1973 HANDLE TimerQueue,
1974 HANDLE Timer,
1975 HANDLE CompletionEvent
1976 );
1977
1978 NTSYSAPI
1979 NTSTATUS
1980 NTAPI
1981 RtlUpdateTimer(
1982 HANDLE TimerQueue,
1983 HANDLE Timer,
1984 ULONG DueTime,
1985 ULONG Period
1986 );
1987
1988 NTSYSAPI
1989 NTSTATUS
1990 NTAPI
1991 RtlDeleteTimerQueueEx(
1992 HANDLE TimerQueue,
1993 HANDLE CompletionEvent
1994 );
1995
1996 NTSYSAPI
1997 NTSTATUS
1998 NTAPI
1999 RtlDeleteTimerQueue(HANDLE TimerQueue);
2000
2001 //
2002 // Debug Functions
2003 //
2004 ULONG
2005 __cdecl
2006 DbgPrint(
2007 IN PCH Format,
2008 IN ...
2009 );
2010
2011 VOID
2012 NTAPI
2013 DbgBreakPoint(VOID);
2014
2015 //
2016 // Handle Table Functions
2017 //
2018 NTSYSAPI
2019 PRTL_HANDLE_TABLE_ENTRY
2020 NTAPI
2021 RtlAllocateHandle(
2022 IN PRTL_HANDLE_TABLE HandleTable,
2023 IN OUT PULONG Index
2024 );
2025
2026 NTSYSAPI
2027 VOID
2028 NTAPI
2029 RtlDestroyHandleTable(IN PRTL_HANDLE_TABLE HandleTable);
2030
2031 NTSYSAPI
2032 BOOLEAN
2033 NTAPI
2034 RtlFreeHandle(
2035 IN PRTL_HANDLE_TABLE HandleTable,
2036 IN PRTL_HANDLE_TABLE_ENTRY Handle
2037 );
2038
2039 NTSYSAPI
2040 VOID
2041 NTAPI
2042 RtlInitializeHandleTable(
2043 IN ULONG TableSize,
2044 IN ULONG HandleSize,
2045 IN PRTL_HANDLE_TABLE HandleTable
2046 );
2047
2048 NTSYSAPI
2049 BOOLEAN
2050 NTAPI
2051 RtlIsValidHandle(
2052 IN PRTL_HANDLE_TABLE HandleTable,
2053 IN PRTL_HANDLE_TABLE_ENTRY Handle
2054 );
2055
2056 NTSYSAPI
2057 BOOLEAN
2058 NTAPI
2059 RtlIsValidIndexHandle(
2060 IN PRTL_HANDLE_TABLE HandleTable,
2061 IN ULONG Index,
2062 OUT PRTL_HANDLE_TABLE_ENTRY *Handle
2063 );
2064
2065 //
2066 // PE Functions
2067 //
2068 NTSYSAPI
2069 NTSTATUS
2070 NTAPI
2071 RtlFindMessage(
2072 IN PVOID BaseAddress,
2073 IN ULONG Type,
2074 IN ULONG Language,
2075 IN ULONG MessageId,
2076 OUT PRTL_MESSAGE_RESOURCE_ENTRY *MessageResourceEntry
2077 );
2078
2079 NTSYSAPI
2080 ULONG
2081 NTAPI
2082 RtlGetNtGlobalFlags(VOID);
2083
2084 NTSYSAPI
2085 PVOID
2086 NTAPI
2087 RtlImageDirectoryEntryToData(
2088 PVOID BaseAddress,
2089 BOOLEAN bFlag,
2090 ULONG Directory,
2091 PULONG Size
2092 );
2093
2094 NTSYSAPI
2095 ULONG
2096 NTAPI
2097 RtlImageRvaToVa(
2098 PIMAGE_NT_HEADERS NtHeader,
2099 PVOID BaseAddress,
2100 ULONG Rva,
2101 PIMAGE_SECTION_HEADER *SectionHeader
2102 );
2103
2104 NTSYSAPI
2105 PIMAGE_NT_HEADERS
2106 NTAPI
2107 RtlImageNtHeader(IN PVOID BaseAddress);
2108
2109 NTSYSAPI
2110 PIMAGE_SECTION_HEADER
2111 NTAPI
2112 RtlImageRvaToSection(
2113 PIMAGE_NT_HEADERS NtHeader,
2114 PVOID BaseAddress,
2115 ULONG Rva
2116 );
2117
2118 //
2119 // Registry Functions
2120 //
2121 NTSYSAPI
2122 NTSTATUS
2123 NTAPI
2124 RtlCheckRegistryKey(
2125 ULONG RelativeTo,
2126 PWSTR Path
2127 );
2128
2129 NTSYSAPI
2130 NTSTATUS
2131 NTAPI
2132 RtlFormatCurrentUserKeyPath(IN OUT PUNICODE_STRING KeyPath);
2133
2134 NTSYSAPI
2135 NTSTATUS
2136 NTAPI
2137 RtlpNtOpenKey(
2138 OUT HANDLE KeyHandle,
2139 IN ACCESS_MASK DesiredAccess,
2140 IN POBJECT_ATTRIBUTES ObjectAttributes,
2141 IN ULONG Unused
2142 );
2143
2144 NTSYSAPI
2145 NTSTATUS
2146 NTAPI
2147 RtlOpenCurrentUser(
2148 IN ACCESS_MASK DesiredAccess,
2149 OUT PHANDLE KeyHandle
2150 );
2151
2152 NTSYSAPI
2153 NTSTATUS
2154 NTAPI
2155 RtlQueryRegistryValues(
2156 IN ULONG RelativeTo,
2157 IN PCWSTR Path,
2158 IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
2159 IN PVOID Context,
2160 IN PVOID Environment
2161 );
2162
2163 NTSYSAPI
2164 NTSTATUS
2165 NTAPI
2166 RtlWriteRegistryValue(
2167 ULONG RelativeTo,
2168 PCWSTR Path,
2169 PCWSTR ValueName,
2170 ULONG ValueType,
2171 PVOID ValueData,
2172 ULONG ValueLength
2173 );
2174
2175 //
2176 // NLS Functions
2177 //
2178 NTSYSAPI
2179 VOID
2180 NTAPI
2181 RtlInitNlsTables(
2182 IN PUSHORT AnsiTableBase,
2183 IN PUSHORT OemTableBase,
2184 IN PUSHORT CaseTableBase,
2185 OUT PNLSTABLEINFO NlsTable
2186 );
2187
2188 NTSYSAPI
2189 VOID
2190 NTAPI
2191 RtlInitCodePageTable(
2192 IN PUSHORT TableBase,
2193 OUT PCPTABLEINFO CodePageTable
2194 );
2195
2196 NTSYSAPI
2197 VOID
2198 NTAPI
2199 RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable);
2200
2201 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
2202
2203 //
2204 // Misc conversion functions
2205 //
2206 static __inline
2207 LARGE_INTEGER
2208 NTAPI_INLINE
2209 RtlConvertLongToLargeInteger(
2210 LONG SignedInteger
2211 )
2212 {
2213 LARGE_INTEGER Result;
2214
2215 Result.QuadPart = SignedInteger;
2216 return Result;
2217 }
2218
2219 static __inline
2220 LARGE_INTEGER
2221 NTAPI_INLINE
2222 RtlEnlargedIntegerMultiply(
2223 LONG Multiplicand,
2224 LONG Multiplier
2225 )
2226 {
2227 LARGE_INTEGER Product;
2228
2229 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2230 return Product;
2231 }
2232
2233 static __inline
2234 ULONG
2235 NTAPI_INLINE
2236 RtlEnlargedUnsignedDivide(
2237 IN ULARGE_INTEGER Dividend,
2238 IN ULONG Divisor,
2239 IN PULONG Remainder OPTIONAL
2240 )
2241 {
2242 ULONG Quotient;
2243
2244 Quotient = (ULONG)(Dividend.QuadPart / Divisor);
2245 if (Remainder) {
2246 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
2247 }
2248
2249 return Quotient;
2250 }
2251
2252 static __inline
2253 LARGE_INTEGER
2254 NTAPI_INLINE
2255 RtlEnlargedUnsignedMultiply(
2256 ULONG Multiplicand,
2257 ULONG Multiplier
2258 )
2259 {
2260 LARGE_INTEGER Product;
2261
2262 Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
2263 return Product;
2264 }
2265 #endif
2266
2267 NTSYSAPI
2268 ULONG
2269 NTAPI
2270 RtlUniform(PULONG Seed);
2271
2272 //
2273 // Network Functions
2274 //
2275 NTSYSAPI
2276 NTSTATUS
2277 NTAPI
2278 RtlIpv4StringToAddressW(
2279 IN LPWSTR IpString,
2280 IN ULONG Base,
2281 OUT PULONG PtrToIpAddr,
2282 OUT PULONG IpAddr
2283 );
2284
2285 NTSYSAPI
2286 NTSTATUS
2287 NTAPI
2288 RtlIpv6StringToAddressA(
2289 IN LPSTR Name,
2290 OUT PULONG Unknown,
2291 OUT PVOID IpAddr
2292 );
2293
2294 NTSYSAPI
2295 NTSTATUS
2296 NTAPI
2297 RtlIpv6StringToAddressW(
2298 IN LPWSTR Name,
2299 OUT PULONG Unknown,
2300 OUT PVOID IpAddr
2301 );
2302
2303 NTSYSAPI
2304 NTSTATUS
2305 NTAPI
2306 RtlIpv6StringToAddressExA(
2307 IN LPSTR AddressName,
2308 IN PVOID Address,
2309 IN PULONG ScopeId,
2310 IN PWORD Port
2311 );
2312
2313 NTSYSAPI
2314 NTSTATUS
2315 NTAPI
2316 RtlIpv6StringToAddressExW(
2317 IN LPWSTR AddressName,
2318 IN PVOID Address,
2319 IN PULONG ScopeId,
2320 IN PWORD Port
2321 );
2322
2323
2324 //
2325 // Time Functions
2326 //
2327 NTSYSAPI
2328 NTSTATUS
2329 NTAPI
2330 RtlQueryTimeZoneInformation(LPTIME_ZONE_INFORMATION TimeZoneInformation);
2331
2332 NTSYSAPI
2333 VOID
2334 NTAPI
2335 RtlSecondsSince1970ToTime(
2336 IN ULONG SecondsSince1970,
2337 OUT PLARGE_INTEGER Time
2338 );
2339
2340 NTSYSAPI
2341 NTSTATUS
2342 NTAPI
2343 RtlSetTimeZoneInformation(LPTIME_ZONE_INFORMATION TimeZoneInformation);
2344
2345 NTSYSAPI
2346 BOOLEAN
2347 NTAPI
2348 RtlTimeFieldsToTime(
2349 PTIME_FIELDS TimeFields,
2350 PLARGE_INTEGER Time
2351 );
2352
2353 NTSYSAPI
2354 VOID
2355 NTAPI
2356 RtlTimeToTimeFields(
2357 PLARGE_INTEGER Time,
2358 PTIME_FIELDS TimeFields
2359 );
2360
2361 //
2362 // Version Functions
2363 //
2364 NTSYSAPI
2365 NTSTATUS
2366 NTAPI
2367 RtlVerifyVersionInfo(
2368 IN PRTL_OSVERSIONINFOEXW VersionInfo,
2369 IN ULONG TypeMask,
2370 IN ULONGLONG ConditionMask
2371 );
2372
2373 NTSYSAPI
2374 NTSTATUS
2375 NTAPI
2376 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
2377
2378 NTSYSAPI
2379 BOOLEAN
2380 NTAPI
2381 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType);
2382
2383 #endif