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