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 _Must_inspect_result_ 214 NTSYSAPI 215 NTSTATUS 216 NTAPI 217 RtlUTF8ToUnicodeN( 218 _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) 219 PWSTR UnicodeStringDestination, 220 _In_ ULONG UnicodeStringMaxByteCount, 221 _Out_ PULONG UnicodeStringActualByteCount, 222 _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource, 223 _In_ ULONG UTF8StringByteCount); 224 225 // 226 // ASSERT Macros 227 // 228 #ifndef ASSERT 229 #if DBG 230 231 #define ASSERT( exp ) \ 232 ((void)((!(exp)) ? \ 233 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \ 234 TRUE)) 235 236 #define ASSERTMSG( msg, exp ) \ 237 ((void)((!(exp)) ? \ 238 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \ 239 TRUE)) 240 241 #else 242 243 #define ASSERT( exp ) ((void) 0) 244 #define ASSERTMSG( msg, exp ) ((void) 0) 245 246 #endif 247 #endif 248 249 #ifdef NTOS_KERNEL_RUNTIME 250 251 // 252 // Executing RTL functions at DISPATCH_LEVEL or higher will result in a 253 // bugcheck. 254 // 255 #define RTL_PAGED_CODE PAGED_CODE 256 257 #else 258 259 // 260 // This macro does nothing in user mode 261 // 262 #define RTL_PAGED_CODE() 263 264 #endif 265 266 // 267 // RTL Splay Tree Functions 268 // 269 #ifndef RTL_USE_AVL_TABLES 270 271 NTSYSAPI 272 VOID 273 NTAPI 274 RtlInitializeGenericTable( 275 _Out_ PRTL_GENERIC_TABLE Table, 276 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, 277 _In_opt_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, 278 _In_opt_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine, 279 _In_opt_ PVOID TableContext 280 ); 281 282 NTSYSAPI 283 PVOID 284 NTAPI 285 RtlInsertElementGenericTable( 286 _In_ PRTL_GENERIC_TABLE Table, 287 _In_reads_bytes_(BufferSize) PVOID Buffer, 288 _In_ CLONG BufferSize, 289 _Out_opt_ PBOOLEAN NewElement 290 ); 291 292 NTSYSAPI 293 PVOID 294 NTAPI 295 RtlInsertElementGenericTableFull( 296 _In_ PRTL_GENERIC_TABLE Table, 297 _In_reads_bytes_(BufferSize) PVOID Buffer, 298 _In_ CLONG BufferSize, 299 _Out_opt_ PBOOLEAN NewElement, 300 _In_ PVOID NodeOrParent, 301 _In_ TABLE_SEARCH_RESULT SearchResult 302 ); 303 304 NTSYSAPI 305 BOOLEAN 306 NTAPI 307 RtlDeleteElementGenericTable( 308 _In_ PRTL_GENERIC_TABLE Table, 309 _In_ PVOID Buffer 310 ); 311 312 _Must_inspect_result_ 313 NTSYSAPI 314 PVOID 315 NTAPI 316 RtlLookupElementGenericTable( 317 _In_ PRTL_GENERIC_TABLE Table, 318 _In_ PVOID Buffer 319 ); 320 321 NTSYSAPI 322 PVOID 323 NTAPI 324 RtlLookupElementGenericTableFull( 325 _In_ PRTL_GENERIC_TABLE Table, 326 _In_ PVOID Buffer, 327 _Out_ PVOID *NodeOrParent, 328 _Out_ TABLE_SEARCH_RESULT *SearchResult 329 ); 330 331 _Must_inspect_result_ 332 NTSYSAPI 333 PVOID 334 NTAPI 335 RtlEnumerateGenericTable( 336 _In_ PRTL_GENERIC_TABLE Table, 337 _In_ BOOLEAN Restart 338 ); 339 340 _Must_inspect_result_ 341 NTSYSAPI 342 PVOID 343 NTAPI 344 RtlEnumerateGenericTableWithoutSplaying( 345 _In_ PRTL_GENERIC_TABLE Table, 346 _Inout_ PVOID *RestartKey 347 ); 348 349 _Must_inspect_result_ 350 NTSYSAPI 351 PVOID 352 NTAPI 353 RtlGetElementGenericTable( 354 _In_ PRTL_GENERIC_TABLE Table, 355 _In_ ULONG I 356 ); 357 358 NTSYSAPI 359 ULONG 360 NTAPI 361 RtlNumberGenericTableElements( 362 _In_ PRTL_GENERIC_TABLE Table 363 ); 364 365 _Must_inspect_result_ 366 NTSYSAPI 367 BOOLEAN 368 NTAPI 369 RtlIsGenericTableEmpty( 370 _In_ PRTL_GENERIC_TABLE Table 371 ); 372 373 #endif /* !RTL_USE_AVL_TABLES */ 374 375 NTSYSAPI 376 PRTL_SPLAY_LINKS 377 NTAPI 378 RtlSplay( 379 _Inout_ PRTL_SPLAY_LINKS Links 380 ); 381 382 NTSYSAPI 383 PRTL_SPLAY_LINKS 384 NTAPI 385 RtlDelete( 386 _In_ PRTL_SPLAY_LINKS Links 387 ); 388 389 NTSYSAPI 390 VOID 391 NTAPI 392 RtlDeleteNoSplay( 393 _In_ PRTL_SPLAY_LINKS Links, 394 _Inout_ PRTL_SPLAY_LINKS *Root 395 ); 396 397 _Must_inspect_result_ 398 NTSYSAPI 399 PRTL_SPLAY_LINKS 400 NTAPI 401 RtlSubtreeSuccessor( 402 _In_ PRTL_SPLAY_LINKS Links 403 ); 404 405 _Must_inspect_result_ 406 NTSYSAPI 407 PRTL_SPLAY_LINKS 408 NTAPI 409 RtlSubtreePredecessor( 410 _In_ PRTL_SPLAY_LINKS Links 411 ); 412 413 _Must_inspect_result_ 414 NTSYSAPI 415 PRTL_SPLAY_LINKS 416 NTAPI 417 RtlRealSuccessor( 418 _In_ PRTL_SPLAY_LINKS Links 419 ); 420 421 _Must_inspect_result_ 422 NTSYSAPI 423 PRTL_SPLAY_LINKS 424 NTAPI 425 RtlRealPredecessor( 426 _In_ PRTL_SPLAY_LINKS Links 427 ); 428 429 #define RtlIsLeftChild(Links) \ 430 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) 431 432 #define RtlIsRightChild(Links) \ 433 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) 434 435 #define RtlRightChild(Links) \ 436 ((PRTL_SPLAY_LINKS)(Links))->RightChild 437 438 #define RtlIsRoot(Links) \ 439 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) 440 441 #define RtlLeftChild(Links) \ 442 ((PRTL_SPLAY_LINKS)(Links))->LeftChild 443 444 #define RtlParent(Links) \ 445 ((PRTL_SPLAY_LINKS)(Links))->Parent 446 447 // FIXME: use inline function 448 449 #define RtlInitializeSplayLinks(Links) \ 450 { \ 451 PRTL_SPLAY_LINKS _SplayLinks; \ 452 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ 453 _SplayLinks->Parent = _SplayLinks; \ 454 _SplayLinks->LeftChild = NULL; \ 455 _SplayLinks->RightChild = NULL; \ 456 } 457 458 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ 459 { \ 460 PRTL_SPLAY_LINKS _SplayParent; \ 461 PRTL_SPLAY_LINKS _SplayChild; \ 462 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ 463 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ 464 _SplayParent->LeftChild = _SplayChild; \ 465 _SplayChild->Parent = _SplayParent; \ 466 } 467 468 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ 469 { \ 470 PRTL_SPLAY_LINKS _SplayParent; \ 471 PRTL_SPLAY_LINKS _SplayChild; \ 472 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ 473 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ 474 _SplayParent->RightChild = _SplayChild; \ 475 _SplayChild->Parent = _SplayParent; \ 476 } 477 478 // 479 // RTL AVL Tree Functions 480 // 481 NTSYSAPI 482 VOID 483 NTAPI 484 RtlInitializeGenericTableAvl( 485 _Out_ PRTL_AVL_TABLE Table, 486 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine, 487 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, 488 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine, 489 _In_opt_ PVOID TableContext 490 ); 491 492 NTSYSAPI 493 PVOID 494 NTAPI 495 RtlInsertElementGenericTableAvl( 496 _In_ PRTL_AVL_TABLE Table, 497 _In_reads_bytes_(BufferSize) PVOID Buffer, 498 _In_ CLONG BufferSize, 499 _Out_opt_ PBOOLEAN NewElement 500 ); 501 502 NTSYSAPI 503 PVOID 504 NTAPI 505 RtlInsertElementGenericTableFullAvl( 506 _In_ PRTL_AVL_TABLE Table, 507 _In_reads_bytes_(BufferSize) PVOID Buffer, 508 _In_ CLONG BufferSize, 509 _Out_opt_ PBOOLEAN NewElement, 510 _In_ PVOID NodeOrParent, 511 _In_ TABLE_SEARCH_RESULT SearchResult 512 ); 513 514 NTSYSAPI 515 BOOLEAN 516 NTAPI 517 RtlDeleteElementGenericTableAvl( 518 _In_ PRTL_AVL_TABLE Table, 519 _In_ PVOID Buffer 520 ); 521 522 _Must_inspect_result_ 523 NTSYSAPI 524 PVOID 525 NTAPI 526 RtlLookupElementGenericTableAvl( 527 _In_ PRTL_AVL_TABLE Table, 528 _In_ PVOID Buffer 529 ); 530 531 NTSYSAPI 532 PVOID 533 NTAPI 534 RtlLookupElementGenericTableFullAvl( 535 _In_ PRTL_AVL_TABLE Table, 536 _In_ PVOID Buffer, 537 _Out_ PVOID *NodeOrParent, 538 _Out_ TABLE_SEARCH_RESULT *SearchResult 539 ); 540 541 _Must_inspect_result_ 542 NTSYSAPI 543 PVOID 544 NTAPI 545 RtlEnumerateGenericTableAvl( 546 _In_ PRTL_AVL_TABLE Table, 547 _In_ BOOLEAN Restart 548 ); 549 550 _Must_inspect_result_ 551 NTSYSAPI 552 PVOID 553 NTAPI 554 RtlEnumerateGenericTableWithoutSplayingAvl( 555 _In_ PRTL_AVL_TABLE Table, 556 _Inout_ PVOID *RestartKey 557 ); 558 559 _Must_inspect_result_ 560 NTSYSAPI 561 PVOID 562 NTAPI 563 RtlLookupFirstMatchingElementGenericTableAvl( 564 _In_ PRTL_AVL_TABLE Table, 565 _In_ PVOID Buffer, 566 _Out_ PVOID *RestartKey 567 ); 568 569 _Must_inspect_result_ 570 NTSYSAPI 571 PVOID 572 NTAPI 573 RtlEnumerateGenericTableLikeADirectory( 574 _In_ PRTL_AVL_TABLE Table, 575 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction, 576 _In_opt_ PVOID MatchData, 577 _In_ ULONG NextFlag, 578 _Inout_ PVOID *RestartKey, 579 _Inout_ PULONG DeleteCount, 580 _In_ PVOID Buffer 581 ); 582 583 _Must_inspect_result_ 584 NTSYSAPI 585 PVOID 586 NTAPI 587 RtlGetElementGenericTableAvl( 588 _In_ PRTL_AVL_TABLE Table, 589 _In_ ULONG I 590 ); 591 592 NTSYSAPI 593 ULONG 594 NTAPI 595 RtlNumberGenericTableElementsAvl( 596 _In_ PRTL_AVL_TABLE Table 597 ); 598 599 _Must_inspect_result_ 600 NTSYSAPI 601 BOOLEAN 602 NTAPI 603 RtlIsGenericTableEmptyAvl( 604 _In_ PRTL_AVL_TABLE Table 605 ); 606 607 #ifdef RTL_USE_AVL_TABLES 608 609 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl 610 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl 611 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl 612 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl 613 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl 614 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl 615 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl 616 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl 617 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl 618 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl 619 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl 620 621 #endif /* RTL_USE_AVL_TABLES */ 622 623 // 624 // Exception and Error Functions 625 // 626 NTSYSAPI 627 PVOID 628 NTAPI 629 RtlAddVectoredExceptionHandler( 630 _In_ ULONG FirstHandler, 631 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler 632 ); 633 634 NTSYSAPI 635 ULONG 636 NTAPI 637 RtlRemoveVectoredExceptionHandler( 638 _In_ PVOID VectoredHandlerHandle 639 ); 640 641 NTSYSAPI 642 PVOID 643 NTAPI 644 RtlAddVectoredContinueHandler( 645 _In_ ULONG FirstHandler, 646 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler 647 ); 648 649 NTSYSAPI 650 ULONG 651 NTAPI 652 RtlRemoveVectoredContinueHandler( 653 _In_ PVOID VectoredHandlerHandle 654 ); 655 656 NTSYSAPI 657 VOID 658 NTAPI 659 RtlSetUnhandledExceptionFilter( 660 _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter 661 ); 662 663 NTSYSAPI 664 LONG 665 NTAPI 666 RtlUnhandledExceptionFilter( 667 _In_ struct _EXCEPTION_POINTERS* ExceptionInfo 668 ); 669 670 __analysis_noreturn 671 NTSYSAPI 672 VOID 673 NTAPI 674 RtlAssert( 675 _In_ PVOID FailedAssertion, 676 _In_ PVOID FileName, 677 _In_ ULONG LineNumber, 678 _In_opt_z_ PCHAR Message 679 ); 680 681 NTSYSAPI 682 PVOID 683 NTAPI 684 RtlEncodePointer( 685 _In_ PVOID Pointer 686 ); 687 688 NTSYSAPI 689 PVOID 690 NTAPI 691 RtlDecodePointer( 692 _In_ PVOID Pointer 693 ); 694 695 NTSYSAPI 696 PVOID 697 NTAPI 698 RtlEncodeSystemPointer( 699 _In_ PVOID Pointer 700 ); 701 702 NTSYSAPI 703 PVOID 704 NTAPI 705 RtlDecodeSystemPointer( 706 _In_ PVOID Pointer 707 ); 708 709 NTSYSAPI 710 NTSTATUS 711 NTAPI 712 RtlGetLastNtStatus( 713 VOID 714 ); 715 716 NTSYSAPI 717 ULONG 718 NTAPI 719 RtlGetLastWin32Error( 720 VOID 721 ); 722 723 NTSYSAPI 724 VOID 725 NTAPI 726 RtlSetLastWin32Error( 727 _In_ ULONG LastError 728 ); 729 730 NTSYSAPI 731 VOID 732 NTAPI 733 RtlSetLastWin32ErrorAndNtStatusFromNtStatus( 734 _In_ NTSTATUS Status 735 ); 736 737 NTSYSAPI 738 NTSTATUS 739 NTAPI 740 RtlSetThreadErrorMode( 741 _In_ ULONG NewMode, 742 _Out_opt_ PULONG OldMode 743 ); 744 745 NTSYSAPI 746 ULONG 747 NTAPI 748 RtlGetThreadErrorMode( 749 VOID 750 ); 751 752 #endif /* NTOS_MODE_USER */ 753 754 NTSYSAPI 755 VOID 756 NTAPI 757 RtlCaptureContext( 758 _Out_ PCONTEXT ContextRecord 759 ); 760 761 NTSYSAPI 762 BOOLEAN 763 NTAPI 764 RtlDispatchException( 765 _In_ PEXCEPTION_RECORD ExceptionRecord, 766 _In_ PCONTEXT Context 767 ); 768 769 _IRQL_requires_max_(APC_LEVEL) 770 _When_(Status < 0, _Out_range_(>, 0)) 771 _When_(Status >= 0, _Out_range_(==, 0)) 772 NTSYSAPI 773 ULONG 774 NTAPI 775 RtlNtStatusToDosError( 776 _In_ NTSTATUS Status 777 ); 778 779 _When_(Status < 0, _Out_range_(>, 0)) 780 _When_(Status >= 0, _Out_range_(==, 0)) 781 NTSYSAPI 782 ULONG 783 NTAPI 784 RtlNtStatusToDosErrorNoTeb( 785 _In_ NTSTATUS Status 786 ); 787 788 NTSYSAPI 789 NTSTATUS 790 NTAPI 791 RtlMapSecurityErrorToNtStatus( 792 _In_ ULONG SecurityError 793 ); 794 795 NTSYSAPI 796 VOID 797 NTAPI 798 RtlRaiseException( 799 _In_ PEXCEPTION_RECORD ExceptionRecord 800 ); 801 802 DECLSPEC_NORETURN 803 NTSYSAPI 804 VOID 805 NTAPI 806 RtlRaiseStatus( 807 _In_ NTSTATUS Status 808 ); 809 810 NTSYSAPI 811 VOID 812 NTAPI 813 RtlUnwind( 814 _In_opt_ PVOID TargetFrame, 815 _In_opt_ PVOID TargetIp, 816 _In_opt_ PEXCEPTION_RECORD ExceptionRecord, 817 _In_ PVOID ReturnValue 818 ); 819 820 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 821 822 #ifdef _M_AMD64 823 824 NTSYSAPI 825 PRUNTIME_FUNCTION 826 NTAPI 827 RtlLookupFunctionEntry( 828 _In_ DWORD64 ControlPc, 829 _Out_ PDWORD64 ImageBase, 830 _Inout_opt_ PUNWIND_HISTORY_TABLE HistoryTable 831 ); 832 833 NTSYSAPI 834 PEXCEPTION_ROUTINE 835 NTAPI 836 RtlVirtualUnwind( 837 _In_ ULONG HandlerType, 838 _In_ ULONG64 ImageBase, 839 _In_ ULONG64 ControlPc, 840 _In_ PRUNTIME_FUNCTION FunctionEntry, 841 _Inout_ PCONTEXT Context, 842 _Outptr_ PVOID* HandlerData, 843 _Out_ PULONG64 EstablisherFrame, 844 _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers 845 ); 846 847 #endif // _M_AMD64 848 849 // 850 // Tracing Functions 851 // 852 NTSYSAPI 853 ULONG 854 NTAPI 855 RtlWalkFrameChain( 856 _Out_writes_(Count - (Flags >> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT)) PVOID *Callers, 857 _In_ ULONG Count, 858 _In_ ULONG Flags 859 ); 860 861 NTSYSAPI 862 USHORT 863 NTAPI 864 RtlLogStackBackTrace( 865 VOID 866 ); 867 868 #ifdef NTOS_MODE_USER 869 // 870 // Heap Functions 871 // 872 _Must_inspect_result_ 873 _Ret_maybenull_ 874 _Post_writable_byte_size_(Size) 875 NTSYSAPI 876 PVOID 877 NTAPI 878 RtlAllocateHeap( 879 _In_ PVOID HeapHandle, 880 _In_opt_ ULONG Flags, 881 _In_ SIZE_T Size 882 ); 883 884 _Must_inspect_result_ 885 NTSYSAPI 886 PVOID 887 NTAPI 888 RtlCreateHeap( 889 _In_ ULONG Flags, 890 _In_opt_ PVOID BaseAddress, 891 _In_opt_ SIZE_T SizeToReserve, 892 _In_opt_ SIZE_T SizeToCommit, 893 _In_opt_ PVOID Lock, 894 _In_opt_ PRTL_HEAP_PARAMETERS Parameters 895 ); 896 897 NTSYSAPI 898 ULONG 899 NTAPI 900 RtlCreateTagHeap( 901 _In_ HANDLE HeapHandle, 902 _In_ ULONG Flags, 903 _In_opt_ PWSTR TagName, 904 _In_ PWSTR TagSubName 905 ); 906 907 ULONG 908 NTAPI 909 RtlCompactHeap( 910 _In_ HANDLE Heap, 911 _In_ ULONG Flags 912 ); 913 914 _Must_inspect_result_ 915 NTSYSAPI 916 PVOID 917 NTAPI 918 RtlDebugCreateHeap( 919 _In_ ULONG Flags, 920 _In_opt_ PVOID BaseAddress, 921 _In_opt_ SIZE_T SizeToReserve, 922 _In_opt_ SIZE_T SizeToCommit, 923 _In_opt_ PVOID Lock, 924 _In_opt_ PRTL_HEAP_PARAMETERS Parameters 925 ); 926 927 NTSYSAPI 928 HANDLE 929 NTAPI 930 RtlDestroyHeap( 931 _In_ _Post_invalid_ HANDLE Heap 932 ); 933 934 NTSYSAPI 935 ULONG 936 NTAPI 937 RtlExtendHeap( 938 _In_ HANDLE Heap, 939 _In_ ULONG Flags, 940 _In_ PVOID P, 941 _In_ SIZE_T Size 942 ); 943 944 _Success_(return != 0) 945 NTSYSAPI 946 BOOLEAN 947 NTAPI 948 RtlFreeHeap( 949 _In_ HANDLE HeapHandle, 950 _In_opt_ ULONG Flags, 951 _In_ _Post_invalid_ PVOID P 952 ); 953 954 ULONG 955 NTAPI 956 RtlGetProcessHeaps( 957 _In_ ULONG HeapCount, 958 _Out_cap_(HeapCount) HANDLE *HeapArray 959 ); 960 961 _Success_(return != 0) 962 BOOLEAN 963 NTAPI 964 RtlGetUserInfoHeap( 965 _In_ PVOID HeapHandle, 966 _In_ ULONG Flags, 967 _In_ PVOID BaseAddress, 968 _Inout_opt_ PVOID *UserValue, 969 _Out_opt_ PULONG UserFlags 970 ); 971 972 NTSYSAPI 973 PVOID 974 NTAPI 975 RtlProtectHeap( 976 _In_ PVOID HeapHandle, 977 _In_ BOOLEAN Protect 978 ); 979 980 NTSYSAPI 981 NTSTATUS 982 NTAPI 983 RtlQueryHeapInformation( 984 _In_ PVOID HeapHandle, 985 _In_ HEAP_INFORMATION_CLASS HeapInformationClass, 986 _Out_ PVOID HeapInformation, 987 _In_ SIZE_T HeapInformationLength, 988 _When_(HeapInformationClass==HeapCompatibilityInformation, _On_failure_(_Out_opt_)) 989 _Out_opt_ PSIZE_T ReturnLength 990 ); 991 992 _Ret_opt_z_ 993 NTSYSAPI 994 PWSTR 995 NTAPI 996 RtlQueryTagHeap( 997 _In_ PVOID HeapHandle, 998 _In_ ULONG Flags, 999 _In_ USHORT TagIndex, 1000 _In_ BOOLEAN ResetCounters, 1001 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo 1002 ); 1003 1004 _Must_inspect_result_ 1005 _Ret_maybenull_ 1006 _Post_writable_byte_size_(Size) 1007 NTSYSAPI 1008 PVOID 1009 NTAPI 1010 RtlReAllocateHeap( 1011 _In_ HANDLE Heap, 1012 _In_opt_ ULONG Flags, 1013 _In_ _Post_invalid_ PVOID Ptr, 1014 _In_ SIZE_T Size 1015 ); 1016 1017 NTSYSAPI 1018 NTSTATUS 1019 NTAPI 1020 RtlSetHeapInformation( 1021 _In_ PVOID HeapHandle, 1022 _In_ HEAP_INFORMATION_CLASS HeapInformationClass, 1023 _When_(HeapInformationClass==HeapCompatibilityInformation,_In_) PVOID HeapInformation, 1024 _In_ SIZE_T HeapInformationLength 1025 ); 1026 1027 NTSYSAPI 1028 BOOLEAN 1029 NTAPI 1030 RtlLockHeap( 1031 _In_ HANDLE Heap 1032 ); 1033 1034 NTSYSAPI 1035 ULONG 1036 NTAPI 1037 RtlMultipleAllocateHeap( 1038 _In_ HANDLE HeapHandle, 1039 _In_ ULONG Flags, 1040 _In_ SIZE_T Size, 1041 _In_ ULONG Count, 1042 _Out_cap_(Count) _Deref_post_bytecap_(Size) PVOID * Array 1043 ); 1044 1045 NTSYSAPI 1046 ULONG 1047 NTAPI 1048 RtlMultipleFreeHeap( 1049 _In_ HANDLE HeapHandle, 1050 _In_ ULONG Flags, 1051 _In_ ULONG Count, 1052 _In_count_(Count) /* _Deref_ _Post_invalid_ */ PVOID * Array 1053 ); 1054 1055 NTSYSAPI 1056 NTSTATUS 1057 NTAPI 1058 RtlUsageHeap( 1059 _In_ HANDLE Heap, 1060 _In_ ULONG Flags, 1061 _Out_ PRTL_HEAP_USAGE Usage 1062 ); 1063 1064 NTSYSAPI 1065 BOOLEAN 1066 NTAPI 1067 RtlUnlockHeap( 1068 _In_ HANDLE Heap 1069 ); 1070 1071 BOOLEAN 1072 NTAPI 1073 RtlSetUserValueHeap( 1074 _In_ PVOID HeapHandle, 1075 _In_ ULONG Flags, 1076 _In_ PVOID BaseAddress, 1077 _In_ PVOID UserValue 1078 ); 1079 1080 BOOLEAN 1081 NTAPI 1082 RtlSetUserFlagsHeap( 1083 _In_ PVOID HeapHandle, 1084 _In_ ULONG Flags, 1085 _In_ PVOID BaseAddress, 1086 _In_ ULONG UserFlagsReset, 1087 _In_ ULONG UserFlagsSet 1088 ); 1089 1090 NTSYSAPI 1091 BOOLEAN 1092 NTAPI 1093 RtlValidateHeap( 1094 _In_ HANDLE Heap, 1095 _In_ ULONG Flags, 1096 _In_opt_ PVOID P 1097 ); 1098 1099 NTSYSAPI 1100 NTSTATUS 1101 NTAPI 1102 RtlWalkHeap( 1103 _In_ HANDLE HeapHandle, 1104 _In_ PVOID HeapEntry 1105 ); 1106 1107 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap) 1108 1109 #endif // NTOS_MODE_USER 1110 1111 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock) 1112 1113 NTSYSAPI 1114 SIZE_T 1115 NTAPI 1116 RtlSizeHeap( 1117 _In_ PVOID HeapHandle, 1118 _In_ ULONG Flags, 1119 _In_ PVOID MemoryPointer 1120 ); 1121 1122 1123 // 1124 // Security Functions 1125 // 1126 _IRQL_requires_max_(APC_LEVEL) 1127 NTSYSAPI 1128 NTSTATUS 1129 NTAPI 1130 RtlAbsoluteToSelfRelativeSD( 1131 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, 1132 _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, 1133 _Inout_ PULONG BufferLength 1134 ); 1135 1136 _IRQL_requires_max_(APC_LEVEL) 1137 NTSYSAPI 1138 NTSTATUS 1139 NTAPI 1140 RtlAddAccessAllowedAce( 1141 _Inout_ PACL Acl, 1142 _In_ ULONG Revision, 1143 _In_ ACCESS_MASK AccessMask, 1144 _In_ PSID Sid 1145 ); 1146 1147 _IRQL_requires_max_(APC_LEVEL) 1148 NTSYSAPI 1149 NTSTATUS 1150 NTAPI 1151 RtlAddAccessAllowedAceEx( 1152 _Inout_ PACL pAcl, 1153 _In_ ULONG dwAceRevision, 1154 _In_ ULONG AceFlags, 1155 _In_ ACCESS_MASK AccessMask, 1156 _In_ PSID pSid 1157 ); 1158 1159 NTSYSAPI 1160 NTSTATUS 1161 NTAPI 1162 RtlAddAccessAllowedObjectAce( 1163 _Inout_ PACL pAcl, 1164 _In_ ULONG dwAceRevision, 1165 _In_ ULONG AceFlags, 1166 _In_ ACCESS_MASK AccessMask, 1167 _In_opt_ GUID *ObjectTypeGuid, 1168 _In_opt_ GUID *InheritedObjectTypeGuid, 1169 _In_ PSID pSid 1170 ); 1171 1172 NTSYSAPI 1173 NTSTATUS 1174 NTAPI 1175 RtlAddAccessDeniedAce( 1176 _Inout_ PACL Acl, 1177 _In_ ULONG Revision, 1178 _In_ ACCESS_MASK AccessMask, 1179 _In_ PSID Sid 1180 ); 1181 1182 NTSYSAPI 1183 NTSTATUS 1184 NTAPI 1185 RtlAddAccessDeniedAceEx( 1186 _Inout_ PACL Acl, 1187 _In_ ULONG Revision, 1188 _In_ ULONG Flags, 1189 _In_ ACCESS_MASK AccessMask, 1190 _In_ PSID Sid 1191 ); 1192 1193 NTSYSAPI 1194 NTSTATUS 1195 NTAPI 1196 RtlAddAccessDeniedObjectAce( 1197 _Inout_ PACL pAcl, 1198 _In_ ULONG dwAceRevision, 1199 _In_ ULONG AceFlags, 1200 _In_ ACCESS_MASK AccessMask, 1201 _In_opt_ GUID *ObjectTypeGuid, 1202 _In_opt_ GUID *InheritedObjectTypeGuid, 1203 _In_ PSID pSid 1204 ); 1205 1206 NTSYSAPI 1207 NTSTATUS 1208 NTAPI 1209 RtlAddAce( 1210 _Inout_ PACL Acl, 1211 _In_ ULONG AceRevision, 1212 _In_ ULONG StartingAceIndex, 1213 _In_reads_bytes_(AceListLength) PVOID AceList, 1214 _In_ ULONG AceListLength 1215 ); 1216 1217 NTSYSAPI 1218 NTSTATUS 1219 NTAPI 1220 RtlAddAuditAccessAce( 1221 _Inout_ PACL Acl, 1222 _In_ ULONG Revision, 1223 _In_ ACCESS_MASK AccessMask, 1224 _In_ PSID Sid, 1225 _In_ BOOLEAN Success, 1226 _In_ BOOLEAN Failure 1227 ); 1228 1229 NTSYSAPI 1230 NTSTATUS 1231 NTAPI 1232 RtlAcquirePrivilege( 1233 _In_ PULONG Privilege, 1234 _In_ ULONG NumPriv, 1235 _In_ ULONG Flags, 1236 _Out_ PVOID *ReturnedState 1237 ); 1238 1239 NTSYSAPI 1240 NTSTATUS 1241 NTAPI 1242 RtlAddAuditAccessAceEx( 1243 _Inout_ PACL Acl, 1244 _In_ ULONG Revision, 1245 _In_ ULONG Flags, 1246 _In_ ACCESS_MASK AccessMask, 1247 _In_ PSID Sid, 1248 _In_ BOOLEAN Success, 1249 _In_ BOOLEAN Failure 1250 ); 1251 1252 NTSYSAPI 1253 NTSTATUS 1254 NTAPI 1255 RtlAddAuditAccessObjectAce( 1256 _Inout_ PACL Acl, 1257 _In_ ULONG Revision, 1258 _In_ ULONG Flags, 1259 _In_ ACCESS_MASK AccessMask, 1260 _In_opt_ GUID *ObjectTypeGuid, 1261 _In_opt_ GUID *InheritedObjectTypeGuid, 1262 _In_ PSID Sid, 1263 _In_ BOOLEAN Success, 1264 _In_ BOOLEAN Failure 1265 ); 1266 1267 NTSYSAPI 1268 NTSTATUS 1269 NTAPI 1270 RtlAddMandatoryAce( 1271 _Inout_ PACL Acl, 1272 _In_ ULONG Revision, 1273 _In_ ULONG Flags, 1274 _In_ ULONG MandatoryFlags, 1275 _In_ UCHAR AceType, 1276 _In_ PSID LabelSid); 1277 1278 NTSYSAPI 1279 NTSTATUS 1280 NTAPI 1281 RtlAdjustPrivilege( 1282 _In_ ULONG Privilege, 1283 _In_ BOOLEAN NewValue, 1284 _In_ BOOLEAN ForThread, 1285 _Out_ PBOOLEAN OldValue 1286 ); 1287 1288 _Must_inspect_result_ 1289 NTSYSAPI 1290 NTSTATUS 1291 NTAPI 1292 RtlAllocateAndInitializeSid( 1293 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, 1294 _In_ UCHAR SubAuthorityCount, 1295 _In_ ULONG SubAuthority0, 1296 _In_ ULONG SubAuthority1, 1297 _In_ ULONG SubAuthority2, 1298 _In_ ULONG SubAuthority3, 1299 _In_ ULONG SubAuthority4, 1300 _In_ ULONG SubAuthority5, 1301 _In_ ULONG SubAuthority6, 1302 _In_ ULONG SubAuthority7, 1303 _Outptr_ PSID *Sid 1304 ); 1305 1306 NTSYSAPI 1307 BOOLEAN 1308 NTAPI 1309 RtlAreAllAccessesGranted( 1310 ACCESS_MASK GrantedAccess, 1311 ACCESS_MASK DesiredAccess 1312 ); 1313 1314 NTSYSAPI 1315 BOOLEAN 1316 NTAPI 1317 RtlAreAnyAccessesGranted( 1318 ACCESS_MASK GrantedAccess, 1319 ACCESS_MASK DesiredAccess 1320 ); 1321 1322 _IRQL_requires_max_(APC_LEVEL) 1323 NTSYSAPI 1324 VOID 1325 NTAPI 1326 RtlCopyLuid ( 1327 _Out_ PLUID DestinationLuid, 1328 _In_ PLUID SourceLuid 1329 ); 1330 1331 NTSYSAPI 1332 VOID 1333 NTAPI 1334 RtlCopyLuidAndAttributesArray( 1335 ULONG Count, 1336 PLUID_AND_ATTRIBUTES Src, 1337 PLUID_AND_ATTRIBUTES Dest 1338 ); 1339 1340 NTSYSAPI 1341 NTSTATUS 1342 NTAPI 1343 RtlCopySidAndAttributesArray( 1344 _In_ ULONG Count, 1345 _In_ PSID_AND_ATTRIBUTES Src, 1346 _In_ ULONG SidAreaSize, 1347 _In_ PSID_AND_ATTRIBUTES Dest, 1348 _In_ PSID SidArea, 1349 _Out_ PSID* RemainingSidArea, 1350 _Out_ PULONG RemainingSidAreaSize 1351 ); 1352 1353 _IRQL_requires_max_(APC_LEVEL) 1354 NTSYSAPI 1355 NTSTATUS 1356 NTAPI 1357 RtlConvertSidToUnicodeString( 1358 _Inout_ PUNICODE_STRING UnicodeString, 1359 _In_ PSID Sid, 1360 _In_ BOOLEAN AllocateDestinationString 1361 ); 1362 1363 _IRQL_requires_max_(APC_LEVEL) 1364 NTSYSAPI 1365 NTSTATUS 1366 NTAPI 1367 RtlCopySid( 1368 _In_ ULONG DestinationSidLength, 1369 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid, 1370 _In_ PSID SourceSid 1371 ); 1372 1373 NTSYSAPI 1374 NTSTATUS 1375 NTAPI 1376 RtlCreateAcl( 1377 PACL Acl, 1378 ULONG AclSize, 1379 ULONG AclRevision 1380 ); 1381 1382 NTSYSAPI 1383 NTSTATUS 1384 NTAPI 1385 RtlCreateSecurityDescriptor( 1386 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1387 _In_ ULONG Revision 1388 ); 1389 1390 NTSYSAPI 1391 NTSTATUS 1392 NTAPI 1393 RtlCreateSecurityDescriptorRelative( 1394 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor, 1395 _In_ ULONG Revision 1396 ); 1397 1398 NTSYSAPI 1399 NTSTATUS 1400 NTAPI 1401 RtlCopySecurityDescriptor( 1402 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor, 1403 _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor 1404 ); 1405 1406 NTSYSAPI 1407 NTSTATUS 1408 NTAPI 1409 RtlDeleteAce( 1410 PACL Acl, 1411 ULONG AceIndex 1412 ); 1413 1414 NTSYSAPI 1415 BOOLEAN 1416 NTAPI 1417 RtlEqualPrefixSid( 1418 PSID Sid1, 1419 PSID Sid2 1420 ); 1421 1422 NTSYSAPI 1423 BOOLEAN 1424 NTAPI 1425 RtlEqualSid ( 1426 _In_ PSID Sid1, 1427 _In_ PSID Sid2 1428 ); 1429 1430 NTSYSAPI 1431 BOOLEAN 1432 NTAPI 1433 RtlFirstFreeAce( 1434 PACL Acl, 1435 PACE* Ace 1436 ); 1437 1438 NTSYSAPI 1439 PVOID 1440 NTAPI 1441 RtlFreeSid( 1442 _In_ _Post_invalid_ PSID Sid 1443 ); 1444 1445 NTSYSAPI 1446 NTSTATUS 1447 NTAPI 1448 RtlGetAce( 1449 PACL Acl, 1450 ULONG AceIndex, 1451 PVOID *Ace 1452 ); 1453 1454 NTSYSAPI 1455 NTSTATUS 1456 NTAPI 1457 RtlGetControlSecurityDescriptor( 1458 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1459 _Out_ PSECURITY_DESCRIPTOR_CONTROL Control, 1460 _Out_ PULONG Revision 1461 ); 1462 1463 NTSYSAPI 1464 NTSTATUS 1465 NTAPI 1466 RtlGetDaclSecurityDescriptor( 1467 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1468 _Out_ PBOOLEAN DaclPresent, 1469 _Out_ PACL *Dacl, 1470 _Out_ PBOOLEAN DaclDefaulted 1471 ); 1472 1473 NTSYSAPI 1474 NTSTATUS 1475 NTAPI 1476 RtlGetSaclSecurityDescriptor( 1477 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1478 _Out_ PBOOLEAN SaclPresent, 1479 _Out_ PACL* Sacl, 1480 _Out_ PBOOLEAN SaclDefaulted 1481 ); 1482 1483 NTSYSAPI 1484 NTSTATUS 1485 NTAPI 1486 RtlGetGroupSecurityDescriptor( 1487 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1488 _Out_ PSID *Group, 1489 _Out_ PBOOLEAN GroupDefaulted 1490 ); 1491 1492 NTSYSAPI 1493 NTSTATUS 1494 NTAPI 1495 RtlGetOwnerSecurityDescriptor( 1496 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1497 _Out_ PSID *Owner, 1498 _Out_ PBOOLEAN OwnerDefaulted 1499 ); 1500 1501 NTSYSAPI 1502 BOOLEAN 1503 NTAPI 1504 RtlGetSecurityDescriptorRMControl( 1505 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1506 _Out_ PUCHAR RMControl 1507 ); 1508 1509 NTSYSAPI 1510 PSID_IDENTIFIER_AUTHORITY 1511 NTAPI 1512 RtlIdentifierAuthoritySid(PSID Sid); 1513 1514 NTSYSAPI 1515 NTSTATUS 1516 NTAPI 1517 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel); 1518 1519 _IRQL_requires_max_(APC_LEVEL) 1520 NTSYSAPI 1521 NTSTATUS 1522 NTAPI 1523 RtlInitializeSid( 1524 _Out_ PSID Sid, 1525 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, 1526 _In_ UCHAR SubAuthorityCount 1527 ); 1528 1529 NTSYSAPI 1530 ULONG 1531 NTAPI 1532 RtlLengthRequiredSid(IN ULONG SubAuthorityCount); 1533 1534 _IRQL_requires_max_(APC_LEVEL) 1535 NTSYSAPI 1536 ULONG 1537 NTAPI 1538 RtlLengthSecurityDescriptor( 1539 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor); 1540 1541 NTSYSAPI 1542 ULONG 1543 NTAPI 1544 RtlLengthSid(IN PSID Sid); 1545 1546 NTSYSAPI 1547 NTSTATUS 1548 NTAPI 1549 RtlMakeSelfRelativeSD( 1550 _In_ PSECURITY_DESCRIPTOR AbsoluteSD, 1551 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD, 1552 _Inout_ PULONG BufferLength); 1553 1554 NTSYSAPI 1555 VOID 1556 NTAPI 1557 RtlMapGenericMask( 1558 PACCESS_MASK AccessMask, 1559 PGENERIC_MAPPING GenericMapping 1560 ); 1561 1562 #ifdef NTOS_MODE_USER 1563 1564 NTSYSAPI 1565 NTSTATUS 1566 NTAPI 1567 RtlQueryInformationAcl( 1568 PACL Acl, 1569 PVOID Information, 1570 ULONG InformationLength, 1571 ACL_INFORMATION_CLASS InformationClass 1572 ); 1573 1574 #endif 1575 1576 NTSYSAPI 1577 VOID 1578 NTAPI 1579 RtlReleasePrivilege( 1580 _In_ PVOID ReturnedState 1581 ); 1582 1583 #if (NTDDI_VERSION >= NTDDI_VISTA) 1584 1585 NTSYSAPI 1586 NTSTATUS 1587 NTAPI 1588 RtlRemovePrivileges( 1589 _In_ HANDLE TokenHandle, 1590 _In_reads_opt_(PrivilegeCount) _When_(PrivilegeCount != 0, _Notnull_) 1591 PULONG PrivilegesToKeep, 1592 _In_ ULONG PrivilegeCount 1593 ); 1594 1595 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 1596 1597 _IRQL_requires_max_(APC_LEVEL) 1598 NTSYSAPI 1599 NTSTATUS 1600 NTAPI 1601 RtlSelfRelativeToAbsoluteSD( 1602 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, 1603 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, 1604 _Inout_ PULONG AbsoluteSecurityDescriptorSize, 1605 _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl, 1606 _Inout_ PULONG DaclSize, 1607 _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl, 1608 _Inout_ PULONG SaclSize, 1609 _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner, 1610 _Inout_ PULONG OwnerSize, 1611 _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup, 1612 _Inout_ PULONG PrimaryGroupSize 1613 ); 1614 1615 NTSYSAPI 1616 NTSTATUS 1617 NTAPI 1618 RtlSelfRelativeToAbsoluteSD2( 1619 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD, 1620 _Out_ PULONG BufferSize 1621 ); 1622 1623 NTSYSAPI 1624 NTSTATUS 1625 NTAPI 1626 RtlSetAttributesSecurityDescriptor( 1627 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1628 _In_ SECURITY_DESCRIPTOR_CONTROL Control, 1629 _Out_ PULONG Revision 1630 ); 1631 1632 NTSYSAPI 1633 NTSTATUS 1634 NTAPI 1635 RtlSetControlSecurityDescriptor( 1636 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1637 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, 1638 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet 1639 ); 1640 1641 _IRQL_requires_max_(APC_LEVEL) 1642 NTSYSAPI 1643 NTSTATUS 1644 NTAPI 1645 RtlSetDaclSecurityDescriptor( 1646 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1647 _In_ BOOLEAN DaclPresent, 1648 _In_opt_ PACL Dacl, 1649 _In_opt_ BOOLEAN DaclDefaulted 1650 ); 1651 1652 _IRQL_requires_max_(APC_LEVEL) 1653 NTSYSAPI 1654 NTSTATUS 1655 NTAPI 1656 RtlSetGroupSecurityDescriptor( 1657 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1658 _In_opt_ PSID Group, 1659 _In_opt_ BOOLEAN GroupDefaulted 1660 ); 1661 1662 #ifdef NTOS_MODE_USER 1663 1664 NTSYSAPI 1665 NTSTATUS 1666 NTAPI 1667 RtlSetInformationAcl( 1668 PACL Acl, 1669 PVOID Information, 1670 ULONG InformationLength, 1671 ACL_INFORMATION_CLASS InformationClass 1672 ); 1673 1674 #endif 1675 1676 _IRQL_requires_max_(APC_LEVEL) 1677 NTSYSAPI 1678 NTSTATUS 1679 NTAPI 1680 RtlSetOwnerSecurityDescriptor( 1681 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1682 _In_opt_ PSID Owner, 1683 _In_opt_ BOOLEAN OwnerDefaulted 1684 ); 1685 1686 NTSYSAPI 1687 NTSTATUS 1688 NTAPI 1689 RtlSetSaclSecurityDescriptor( 1690 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1691 _In_ BOOLEAN SaclPresent, 1692 _In_ PACL Sacl, 1693 _In_ BOOLEAN SaclDefaulted 1694 ); 1695 1696 NTSYSAPI 1697 VOID 1698 NTAPI 1699 RtlSetSecurityDescriptorRMControl( 1700 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1701 _In_ PUCHAR RMControl 1702 ); 1703 1704 NTSYSAPI 1705 PUCHAR 1706 NTAPI 1707 RtlSubAuthorityCountSid( 1708 _In_ PSID Sid 1709 ); 1710 1711 NTSYSAPI 1712 PULONG 1713 NTAPI 1714 RtlSubAuthoritySid( 1715 _In_ PSID Sid, 1716 _In_ ULONG SubAuthority 1717 ); 1718 1719 _IRQL_requires_max_(APC_LEVEL) 1720 _Must_inspect_result_ 1721 NTSYSAPI 1722 BOOLEAN 1723 NTAPI 1724 RtlValidRelativeSecurityDescriptor( 1725 _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput, 1726 _In_ ULONG SecurityDescriptorLength, 1727 _In_ SECURITY_INFORMATION RequiredInformation 1728 ); 1729 1730 NTSYSAPI 1731 BOOLEAN 1732 NTAPI 1733 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor); 1734 1735 NTSYSAPI 1736 BOOLEAN 1737 NTAPI 1738 RtlValidSid(IN PSID Sid); 1739 1740 NTSYSAPI 1741 BOOLEAN 1742 NTAPI 1743 RtlValidAcl(PACL Acl); 1744 1745 NTSYSAPI 1746 NTSTATUS 1747 NTAPI 1748 RtlDeleteSecurityObject( 1749 _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor 1750 ); 1751 1752 NTSYSAPI 1753 NTSTATUS 1754 NTAPI 1755 RtlNewSecurityObject( 1756 _In_ PSECURITY_DESCRIPTOR ParentDescriptor, 1757 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor, 1758 _Out_ PSECURITY_DESCRIPTOR *NewDescriptor, 1759 _In_ BOOLEAN IsDirectoryObject, 1760 _In_ HANDLE Token, 1761 _In_ PGENERIC_MAPPING GenericMapping 1762 ); 1763 1764 NTSYSAPI 1765 NTSTATUS 1766 NTAPI 1767 RtlQuerySecurityObject( 1768 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor, 1769 _In_ SECURITY_INFORMATION SecurityInformation, 1770 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor, 1771 _In_ ULONG DescriptorLength, 1772 _Out_ PULONG ReturnLength 1773 ); 1774 1775 NTSYSAPI 1776 NTSTATUS 1777 NTAPI 1778 RtlSetSecurityObject( 1779 _In_ SECURITY_INFORMATION SecurityInformation, 1780 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor, 1781 _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, 1782 _In_ PGENERIC_MAPPING GenericMapping, 1783 _In_ HANDLE Token 1784 ); 1785 1786 // 1787 // Single-Character Functions 1788 // 1789 NTSYSAPI 1790 NTSTATUS 1791 NTAPI 1792 RtlLargeIntegerToChar( 1793 _In_ PLARGE_INTEGER Value, 1794 _In_ ULONG Base, 1795 _In_ ULONG Length, 1796 _Out_ PCHAR String 1797 ); 1798 1799 NTSYSAPI 1800 CHAR 1801 NTAPI 1802 RtlUpperChar(CHAR Source); 1803 1804 NTSYSAPI 1805 WCHAR 1806 NTAPI 1807 RtlUpcaseUnicodeChar(WCHAR Source); 1808 1809 NTSYSAPI 1810 WCHAR 1811 NTAPI 1812 RtlDowncaseUnicodeChar(IN WCHAR Source); 1813 1814 NTSYSAPI 1815 NTSTATUS 1816 NTAPI 1817 RtlIntegerToChar( 1818 _In_ ULONG Value, 1819 _In_ ULONG Base, 1820 _In_ ULONG Length, 1821 _Out_ PCHAR String 1822 ); 1823 1824 NTSYSAPI 1825 NTSTATUS 1826 NTAPI 1827 RtlIntegerToUnicode( 1828 _In_ ULONG Value, 1829 _In_opt_ ULONG Base, 1830 _In_opt_ ULONG Length, 1831 _Inout_ LPWSTR String 1832 ); 1833 1834 _IRQL_requires_max_(PASSIVE_LEVEL) 1835 _At_(String->MaximumLength, _Const_) 1836 NTSYSAPI 1837 NTSTATUS 1838 NTAPI 1839 RtlIntegerToUnicodeString( 1840 _In_ ULONG Value, 1841 _In_opt_ ULONG Base, 1842 _Inout_ PUNICODE_STRING String 1843 ); 1844 1845 NTSYSAPI 1846 NTSTATUS 1847 NTAPI 1848 RtlCharToInteger( 1849 PCSZ String, 1850 ULONG Base, 1851 PULONG Value 1852 ); 1853 1854 // 1855 // Byte Swap Functions 1856 // 1857 #ifdef NTOS_MODE_USER 1858 1859 unsigned short __cdecl _byteswap_ushort(unsigned short); 1860 unsigned long __cdecl _byteswap_ulong (unsigned long); 1861 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64); 1862 #ifdef _MSC_VER 1863 #pragma intrinsic(_byteswap_ushort) 1864 #pragma intrinsic(_byteswap_ulong) 1865 #pragma intrinsic(_byteswap_uint64) 1866 #endif // _MSC_VER 1867 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x)) 1868 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) 1869 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x)) 1870 1871 #endif // NTOS_MODE_USER 1872 1873 // 1874 // Unicode->Ansi String Functions 1875 // 1876 NTSYSAPI 1877 ULONG 1878 NTAPI 1879 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString); 1880 1881 #ifdef NTOS_MODE_USER 1882 1883 #define RtlUnicodeStringToAnsiSize(STRING) ( \ 1884 NLS_MB_CODE_PAGE_TAG ? \ 1885 RtlxUnicodeStringToAnsiSize(STRING) : \ 1886 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ 1887 ) 1888 1889 #endif 1890 1891 NTSYSAPI 1892 NTSTATUS 1893 NTAPI 1894 RtlUnicodeStringToAnsiString( 1895 PANSI_STRING DestinationString, 1896 PCUNICODE_STRING SourceString, 1897 BOOLEAN AllocateDestinationString 1898 ); 1899 1900 // 1901 // Unicode->OEM String Functions 1902 // 1903 NTSYSAPI 1904 NTSTATUS 1905 NTAPI 1906 RtlUpcaseUnicodeStringToOemString( 1907 POEM_STRING DestinationString, 1908 PCUNICODE_STRING SourceString, 1909 BOOLEAN AllocateDestinationString 1910 ); 1911 1912 _IRQL_requires_max_(PASSIVE_LEVEL) 1913 _Must_inspect_result_ 1914 //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length)) 1915 NTSYSAPI 1916 NTSTATUS 1917 NTAPI 1918 RtlUpcaseUnicodeStringToCountedOemString( 1919 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1920 _When_(!AllocateDestinationString, _Inout_) 1921 POEM_STRING DestinationString, 1922 _In_ PCUNICODE_STRING SourceString, 1923 _In_ BOOLEAN AllocateDestinationString 1924 ); 1925 1926 NTSYSAPI 1927 NTSTATUS 1928 NTAPI 1929 RtlUnicodeStringToOemString( 1930 POEM_STRING DestinationString, 1931 PCUNICODE_STRING SourceString, 1932 BOOLEAN AllocateDestinationString 1933 ); 1934 1935 _IRQL_requires_max_(PASSIVE_LEVEL) 1936 _Must_inspect_result_ 1937 NTSYSAPI 1938 NTSTATUS 1939 NTAPI 1940 RtlUnicodeStringToCountedOemString( 1941 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1942 _When_(!AllocateDestinationString, _Inout_) 1943 POEM_STRING DestinationString, 1944 _In_ PCUNICODE_STRING SourceString, 1945 _In_ BOOLEAN AllocateDestinationString 1946 ); 1947 1948 NTSYSAPI 1949 NTSTATUS 1950 NTAPI 1951 RtlUpcaseUnicodeToOemN( 1952 PCHAR OemString, 1953 ULONG OemSize, 1954 PULONG ResultSize, 1955 PCWCH UnicodeString, 1956 ULONG UnicodeSize 1957 ); 1958 1959 NTSYSAPI 1960 ULONG 1961 NTAPI 1962 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString); 1963 1964 #ifdef NTOS_MODE_USER 1965 1966 #define RtlUnicodeStringToOemSize(STRING) ( \ 1967 NLS_MB_OEM_CODE_PAGE_TAG ? \ 1968 RtlxUnicodeStringToOemSize(STRING) : \ 1969 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ 1970 ) 1971 1972 #define RtlUnicodeStringToCountedOemSize(STRING) ( \ 1973 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \ 1974 ) 1975 1976 #endif 1977 1978 NTSYSAPI 1979 NTSTATUS 1980 NTAPI 1981 RtlUnicodeToOemN( 1982 PCHAR OemString, 1983 ULONG OemSize, 1984 PULONG ResultSize, 1985 PCWCH UnicodeString, 1986 ULONG UnicodeSize 1987 ); 1988 1989 // 1990 // Unicode->MultiByte String Functions 1991 // 1992 NTSYSAPI 1993 NTSTATUS 1994 NTAPI 1995 RtlUnicodeToMultiByteN( 1996 PCHAR MbString, 1997 ULONG MbSize, 1998 PULONG ResultSize, 1999 PCWCH UnicodeString, 2000 ULONG UnicodeSize 2001 ); 2002 2003 NTSYSAPI 2004 NTSTATUS 2005 NTAPI 2006 RtlUpcaseUnicodeToMultiByteN( 2007 PCHAR MbString, 2008 ULONG MbSize, 2009 PULONG ResultSize, 2010 PCWCH UnicodeString, 2011 ULONG UnicodeSize 2012 ); 2013 2014 NTSYSAPI 2015 NTSTATUS 2016 NTAPI 2017 RtlUnicodeToMultiByteSize( 2018 PULONG MbSize, 2019 PCWCH UnicodeString, 2020 ULONG UnicodeSize 2021 ); 2022 2023 NTSYSAPI 2024 ULONG 2025 NTAPI 2026 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString); 2027 2028 // 2029 // OEM to Unicode Functions 2030 // 2031 NTSYSAPI 2032 NTSTATUS 2033 NTAPI 2034 RtlOemStringToUnicodeString( 2035 PUNICODE_STRING DestinationString, 2036 PCOEM_STRING SourceString, 2037 BOOLEAN AllocateDestinationString 2038 ); 2039 2040 _IRQL_requires_max_(PASSIVE_LEVEL) 2041 NTSYSAPI 2042 NTSTATUS 2043 NTAPI 2044 RtlOemToUnicodeN( 2045 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, 2046 _In_ ULONG MaxBytesInUnicodeString, 2047 _Out_opt_ PULONG BytesInUnicodeString, 2048 _In_reads_bytes_(BytesInOemString) PCCH OemString, 2049 _In_ ULONG BytesInOemString 2050 ); 2051 2052 #ifdef NTOS_MODE_USER 2053 2054 #define RtlOemStringToUnicodeSize(STRING) ( \ 2055 NLS_MB_OEM_CODE_PAGE_TAG ? \ 2056 RtlxOemStringToUnicodeSize(STRING) : \ 2057 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ 2058 ) 2059 2060 #define RtlOemStringToCountedUnicodeSize(STRING) ( \ 2061 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \ 2062 ) 2063 2064 #endif 2065 2066 // 2067 // Ansi->Unicode String Functions 2068 // 2069 _IRQL_requires_max_(APC_LEVEL) 2070 NTSYSAPI 2071 WCHAR 2072 NTAPI 2073 RtlAnsiCharToUnicodeChar( 2074 _Inout_ PUCHAR *SourceCharacter); 2075 2076 NTSYSAPI 2077 NTSTATUS 2078 NTAPI 2079 RtlAnsiStringToUnicodeString( 2080 PUNICODE_STRING DestinationString, 2081 PCANSI_STRING SourceString, 2082 BOOLEAN AllocateDestinationString 2083 ); 2084 2085 NTSYSAPI 2086 ULONG 2087 NTAPI 2088 RtlxAnsiStringToUnicodeSize( 2089 PCANSI_STRING AnsiString 2090 ); 2091 2092 #ifdef NTOS_MODE_USER 2093 2094 #define RtlAnsiStringToUnicodeSize(STRING) ( \ 2095 NLS_MB_CODE_PAGE_TAG ? \ 2096 RtlxAnsiStringToUnicodeSize(STRING) : \ 2097 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ 2098 ) 2099 2100 #endif 2101 2102 NTSYSAPI 2103 BOOLEAN 2104 NTAPI 2105 RtlCreateUnicodeStringFromAsciiz( 2106 _Out_ PUNICODE_STRING Destination, 2107 _In_ PCSZ Source 2108 ); 2109 2110 // 2111 // Unicode String Functions 2112 // 2113 NTSYSAPI 2114 NTSTATUS 2115 NTAPI 2116 RtlAppendUnicodeToString( 2117 PUNICODE_STRING Destination, 2118 PCWSTR Source 2119 ); 2120 2121 NTSYSAPI 2122 NTSTATUS 2123 NTAPI 2124 RtlAppendUnicodeStringToString( 2125 PUNICODE_STRING Destination, 2126 PCUNICODE_STRING Source 2127 ); 2128 2129 NTSYSAPI 2130 LONG 2131 NTAPI 2132 RtlCompareUnicodeString( 2133 PCUNICODE_STRING String1, 2134 PCUNICODE_STRING String2, 2135 BOOLEAN CaseInsensitive 2136 ); 2137 2138 _Must_inspect_result_ 2139 NTSYSAPI 2140 LONG 2141 NTAPI 2142 RtlCompareUnicodeStrings( 2143 _In_reads_(String1Length) PCWCH String1, 2144 _In_ SIZE_T String1Length, 2145 _In_reads_(String2Length) PCWCH String2, 2146 _In_ SIZE_T String2Length, 2147 _In_ BOOLEAN CaseInSensitive 2148 ); 2149 2150 NTSYSAPI 2151 VOID 2152 NTAPI 2153 RtlCopyUnicodeString( 2154 PUNICODE_STRING DestinationString, 2155 PCUNICODE_STRING SourceString 2156 ); 2157 2158 NTSYSAPI 2159 BOOLEAN 2160 NTAPI 2161 RtlCreateUnicodeString( 2162 PUNICODE_STRING DestinationString, 2163 PCWSTR SourceString 2164 ); 2165 2166 #ifdef NTOS_MODE_USER 2167 2168 NTSYSAPI 2169 NTSTATUS 2170 NTAPI 2171 RtlDowncaseUnicodeString( 2172 _Inout_ PUNICODE_STRING UniDest, 2173 _In_ PCUNICODE_STRING UniSource, 2174 _In_ BOOLEAN AllocateDestinationString 2175 ); 2176 2177 NTSYSAPI 2178 NTSTATUS 2179 NTAPI 2180 RtlDuplicateUnicodeString( 2181 _In_ ULONG Flags, 2182 _In_ PCUNICODE_STRING SourceString, 2183 _Out_ PUNICODE_STRING DestinationString 2184 ); 2185 2186 NTSYSAPI 2187 NTSTATUS 2188 NTAPI 2189 RtlFindCharInUnicodeString( 2190 _In_ ULONG Flags, 2191 _In_ PCUNICODE_STRING SearchString, 2192 _In_ PCUNICODE_STRING MatchString, 2193 _Out_ PUSHORT Position 2194 ); 2195 2196 // 2197 // Memory Functions 2198 // 2199 #if defined(_M_AMD64) 2200 2201 FORCEINLINE 2202 VOID 2203 RtlFillMemoryUlong( 2204 _Out_writes_bytes_all_(Length) PVOID Destination, 2205 _In_ SIZE_T Length, 2206 _In_ ULONG Pattern) 2207 { 2208 PULONG Address = (PULONG)Destination; 2209 if ((Length /= 4) != 0) { 2210 if (((ULONG64)Address & 4) != 0) { 2211 *Address = Pattern; 2212 if ((Length -= 1) == 0) { 2213 return; 2214 } 2215 Address += 1; 2216 } 2217 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2); 2218 if ((Length & 1) != 0) Address[Length - 1] = Pattern; 2219 } 2220 return; 2221 } 2222 2223 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \ 2224 __stosq((PULONG64)(Destination), Pattern, (Length) / 8) 2225 2226 #else 2227 2228 NTSYSAPI 2229 VOID 2230 NTAPI 2231 RtlFillMemoryUlong( 2232 _Out_writes_bytes_all_(Length) PVOID Destination, 2233 _In_ SIZE_T Length, 2234 _In_ ULONG Pattern 2235 ); 2236 2237 NTSYSAPI 2238 VOID 2239 NTAPI 2240 RtlFillMemoryUlonglong( 2241 _Out_ PVOID Destination, 2242 _In_ SIZE_T Length, 2243 _In_ ULONGLONG Pattern 2244 ); 2245 2246 #endif 2247 2248 NTSYSAPI 2249 NTSTATUS 2250 NTAPI 2251 RtlCopyMappedMemory( 2252 _Out_writes_bytes_all_(Size) PVOID Destination, 2253 _In_reads_bytes_(Size) const VOID *Source, 2254 _In_ SIZE_T Size 2255 ); 2256 2257 NTSYSAPI 2258 SIZE_T 2259 NTAPI 2260 RtlCompareMemoryUlong( 2261 _In_ PVOID Source, 2262 _In_ SIZE_T Length, 2263 _In_ ULONG Pattern 2264 ); 2265 2266 #ifndef RtlEqualMemory 2267 #define RtlEqualMemory(Destination, Source, Length) \ 2268 (!memcmp(Destination, Source, Length)) 2269 #endif 2270 2271 #define RtlCopyBytes RtlCopyMemory 2272 #define RtlFillBytes RtlFillMemory 2273 #define RtlZeroBytes RtlZeroMemory 2274 2275 #endif 2276 2277 NTSYSAPI 2278 BOOLEAN 2279 NTAPI 2280 RtlEqualUnicodeString( 2281 PCUNICODE_STRING String1, 2282 PCUNICODE_STRING String2, 2283 BOOLEAN CaseInsensitive 2284 ); 2285 2286 _IRQL_requires_max_(PASSIVE_LEVEL) 2287 NTSYSAPI 2288 VOID 2289 NTAPI 2290 RtlFreeUnicodeString( 2291 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem)) 2292 PUNICODE_STRING UnicodeString 2293 ); 2294 2295 NTSYSAPI 2296 VOID 2297 NTAPI 2298 RtlEraseUnicodeString( 2299 _Inout_ PUNICODE_STRING String 2300 ); 2301 2302 NTSYSAPI 2303 NTSTATUS 2304 NTAPI 2305 RtlHashUnicodeString( 2306 _In_ CONST UNICODE_STRING *String, 2307 _In_ BOOLEAN CaseInSensitive, 2308 _In_ ULONG HashAlgorithm, 2309 _Out_ PULONG HashValue 2310 ); 2311 2312 _IRQL_requires_max_(DISPATCH_LEVEL) 2313 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString)) 2314 _When_(SourceString != NULL, 2315 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString))) 2316 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(CHAR)))) 2317 _When_(SourceString == NULL, 2318 _At_(DestinationString->Length, _Post_equal_to_(0)) 2319 _At_(DestinationString->MaximumLength, _Post_equal_to_(0))) 2320 NTSYSAPI 2321 VOID 2322 NTAPI 2323 RtlInitString( 2324 _Out_ PSTRING DestinationString, 2325 _In_opt_z_ __drv_aliasesMem PCSTR SourceString 2326 ); 2327 2328 _IRQL_requires_max_(DISPATCH_LEVEL) 2329 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString)) 2330 _When_(SourceString != NULL, 2331 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR))) 2332 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR)))) 2333 _When_(SourceString == NULL, 2334 _At_(DestinationString->Length, _Post_equal_to_(0)) 2335 _At_(DestinationString->MaximumLength, _Post_equal_to_(0))) 2336 NTSYSAPI 2337 VOID 2338 NTAPI 2339 RtlInitUnicodeString( 2340 _Out_ PUNICODE_STRING DestinationString, 2341 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString 2342 ); 2343 2344 _IRQL_requires_max_(DISPATCH_LEVEL) 2345 NTSYSAPI 2346 NTSTATUS 2347 NTAPI 2348 RtlInitUnicodeStringEx( 2349 _Out_ PUNICODE_STRING DestinationString, 2350 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString 2351 ); 2352 2353 NTSYSAPI 2354 BOOLEAN 2355 NTAPI 2356 RtlIsTextUnicode( 2357 _In_ CONST VOID* Buffer, 2358 _In_ INT Size, 2359 _Inout_opt_ INT* Flags 2360 ); 2361 2362 _IRQL_requires_max_(PASSIVE_LEVEL) 2363 _Must_inspect_result_ 2364 NTSYSAPI 2365 BOOLEAN 2366 NTAPI 2367 RtlPrefixString( 2368 _In_ const STRING *String1, 2369 _In_ const STRING *String2, 2370 _In_ BOOLEAN CaseInsensitive 2371 ); 2372 2373 _IRQL_requires_max_(PASSIVE_LEVEL) 2374 _Must_inspect_result_ 2375 NTSYSAPI 2376 BOOLEAN 2377 NTAPI 2378 RtlPrefixUnicodeString( 2379 _In_ PCUNICODE_STRING String1, 2380 _In_ PCUNICODE_STRING String2, 2381 _In_ BOOLEAN CaseInsensitive 2382 ); 2383 2384 _IRQL_requires_max_(PASSIVE_LEVEL) 2385 NTSYSAPI 2386 VOID 2387 NTAPI 2388 RtlUpperString( 2389 _Inout_ PSTRING DestinationString, 2390 _In_ const STRING *SourceString 2391 ); 2392 2393 _IRQL_requires_max_(PASSIVE_LEVEL) 2394 _Must_inspect_result_ 2395 NTSYSAPI 2396 LONG 2397 NTAPI 2398 RtlCompareString( 2399 _In_ const STRING *String1, 2400 _In_ const STRING *String2, 2401 _In_ BOOLEAN CaseInSensitive 2402 ); 2403 2404 NTSYSAPI 2405 VOID 2406 NTAPI 2407 RtlCopyString( 2408 _Out_ PSTRING DestinationString, 2409 _In_opt_ const STRING *SourceString 2410 ); 2411 2412 _IRQL_requires_max_(PASSIVE_LEVEL) 2413 _Must_inspect_result_ 2414 NTSYSAPI 2415 BOOLEAN 2416 NTAPI 2417 RtlEqualString( 2418 _In_ const STRING *String1, 2419 _In_ const STRING *String2, 2420 _In_ BOOLEAN CaseInSensitive 2421 ); 2422 2423 _IRQL_requires_max_(APC_LEVEL) 2424 NTSYSAPI 2425 NTSTATUS 2426 NTAPI 2427 RtlAppendStringToString( 2428 _Inout_ PSTRING Destination, 2429 _In_ const STRING *Source 2430 ); 2431 2432 _IRQL_requires_max_(PASSIVE_LEVEL) 2433 _When_(AllocateDestinationString, _Must_inspect_result_) 2434 NTSYSAPI 2435 NTSTATUS 2436 NTAPI 2437 RtlUpcaseUnicodeString( 2438 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 2439 _When_(!AllocateDestinationString, _Inout_) 2440 PUNICODE_STRING DestinationString, 2441 _In_ PCUNICODE_STRING SourceString, 2442 _In_ BOOLEAN AllocateDestinationString 2443 ); 2444 2445 _IRQL_requires_max_(PASSIVE_LEVEL) 2446 NTSYSAPI 2447 NTSTATUS 2448 NTAPI 2449 RtlUnicodeStringToInteger( 2450 _In_ PCUNICODE_STRING String, 2451 _In_opt_ ULONG Base, 2452 _Out_ PULONG Value 2453 ); 2454 2455 NTSYSAPI 2456 NTSTATUS 2457 NTAPI 2458 RtlValidateUnicodeString( 2459 _In_ ULONG Flags, 2460 _In_ PCUNICODE_STRING String 2461 ); 2462 2463 #define RTL_SKIP_BUFFER_COPY 0x00000001 2464 2465 NTSYSAPI 2466 NTSTATUS 2467 NTAPI 2468 RtlpEnsureBufferSize( 2469 _In_ ULONG Flags, 2470 _Inout_ PRTL_BUFFER Buffer, 2471 _In_ SIZE_T RequiredSize 2472 ); 2473 2474 #ifdef NTOS_MODE_USER 2475 2476 FORCEINLINE 2477 VOID 2478 RtlInitBuffer( 2479 _Inout_ PRTL_BUFFER Buffer, 2480 _In_ PUCHAR Data, 2481 _In_ ULONG DataSize 2482 ) 2483 { 2484 Buffer->Buffer = Buffer->StaticBuffer = Data; 2485 Buffer->Size = Buffer->StaticSize = DataSize; 2486 Buffer->ReservedForAllocatedSize = 0; 2487 Buffer->ReservedForIMalloc = NULL; 2488 } 2489 2490 FORCEINLINE 2491 NTSTATUS 2492 RtlEnsureBufferSize( 2493 _In_ ULONG Flags, 2494 _Inout_ PRTL_BUFFER Buffer, 2495 _In_ ULONG RequiredSize 2496 ) 2497 { 2498 if (Buffer && RequiredSize <= Buffer->Size) 2499 return STATUS_SUCCESS; 2500 return RtlpEnsureBufferSize(Flags, Buffer, RequiredSize); 2501 } 2502 2503 FORCEINLINE 2504 VOID 2505 RtlFreeBuffer( 2506 _Inout_ PRTL_BUFFER Buffer 2507 ) 2508 { 2509 if (Buffer->Buffer != Buffer->StaticBuffer && Buffer->Buffer) 2510 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer->Buffer); 2511 Buffer->Buffer = Buffer->StaticBuffer; 2512 Buffer->Size = Buffer->StaticSize; 2513 } 2514 2515 NTSYSAPI 2516 VOID 2517 NTAPI 2518 RtlRunEncodeUnicodeString( 2519 _Inout_ PUCHAR Hash, 2520 _Inout_ PUNICODE_STRING String 2521 ); 2522 2523 NTSYSAPI 2524 VOID 2525 NTAPI 2526 RtlRunDecodeUnicodeString( 2527 _In_ UCHAR Hash, 2528 _Inout_ PUNICODE_STRING String 2529 ); 2530 2531 #endif /* NTOS_MODE_USER */ 2532 2533 // 2534 // Ansi String Functions 2535 // 2536 _IRQL_requires_max_(PASSIVE_LEVEL) 2537 NTSYSAPI 2538 VOID 2539 NTAPI 2540 RtlFreeAnsiString( 2541 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem)) 2542 PANSI_STRING AnsiString 2543 ); 2544 2545 _IRQL_requires_max_(DISPATCH_LEVEL) 2546 NTSYSAPI 2547 VOID 2548 NTAPI 2549 RtlInitAnsiString( 2550 _Out_ PANSI_STRING DestinationString, 2551 _In_opt_z_ __drv_aliasesMem PCSZ SourceString 2552 ); 2553 2554 _IRQL_requires_max_(DISPATCH_LEVEL) 2555 NTSYSAPI 2556 NTSTATUS 2557 NTAPI 2558 RtlInitAnsiStringEx( 2559 _Out_ PANSI_STRING DestinationString, 2560 _In_opt_z_ __drv_aliasesMem PCSZ SourceString 2561 ); 2562 2563 // 2564 // OEM String Functions 2565 // 2566 _IRQL_requires_max_(PASSIVE_LEVEL) 2567 NTSYSAPI 2568 VOID 2569 NTAPI 2570 RtlFreeOemString( 2571 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem)) 2572 POEM_STRING OemString 2573 ); 2574 2575 // 2576 // MultiByte->Unicode String Functions 2577 // 2578 _IRQL_requires_max_(PASSIVE_LEVEL) 2579 NTSYSAPI 2580 NTSTATUS 2581 NTAPI 2582 RtlMultiByteToUnicodeN( 2583 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, 2584 _In_ ULONG MaxBytesInUnicodeString, 2585 _Out_opt_ PULONG BytesInUnicodeString, 2586 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString, 2587 _In_ ULONG BytesInMultiByteString 2588 ); 2589 2590 _IRQL_requires_max_(PASSIVE_LEVEL) 2591 NTSYSAPI 2592 NTSTATUS 2593 NTAPI 2594 RtlMultiByteToUnicodeSize( 2595 _Out_ PULONG BytesInUnicodeString, 2596 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString, 2597 _In_ ULONG BytesInMultiByteString 2598 ); 2599 2600 // 2601 // Atom Functions 2602 // 2603 NTSYSAPI 2604 NTSTATUS 2605 NTAPI 2606 RtlAddAtomToAtomTable( 2607 _In_ PRTL_ATOM_TABLE AtomTable, 2608 _In_ PWSTR AtomName, 2609 _Out_ PRTL_ATOM Atom 2610 ); 2611 2612 NTSYSAPI 2613 NTSTATUS 2614 NTAPI 2615 RtlCreateAtomTable( 2616 _In_ ULONG TableSize, 2617 _Inout_ PRTL_ATOM_TABLE *AtomTable 2618 ); 2619 2620 NTSYSAPI 2621 NTSTATUS 2622 NTAPI 2623 RtlDeleteAtomFromAtomTable( 2624 _In_ PRTL_ATOM_TABLE AtomTable, 2625 _In_ RTL_ATOM Atom 2626 ); 2627 2628 NTSYSAPI 2629 NTSTATUS 2630 NTAPI 2631 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable); 2632 2633 NTSYSAPI 2634 NTSTATUS 2635 NTAPI 2636 RtlQueryAtomInAtomTable( 2637 _In_ PRTL_ATOM_TABLE AtomTable, 2638 _In_ RTL_ATOM Atom, 2639 _Out_opt_ PULONG RefCount, 2640 _Out_opt_ PULONG PinCount, 2641 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName, 2642 _Inout_opt_ PULONG NameLength 2643 ); 2644 2645 NTSYSAPI 2646 NTSTATUS 2647 NTAPI 2648 RtlPinAtomInAtomTable( 2649 _In_ PRTL_ATOM_TABLE AtomTable, 2650 _In_ RTL_ATOM Atom 2651 ); 2652 2653 NTSYSAPI 2654 NTSTATUS 2655 NTAPI 2656 RtlLookupAtomInAtomTable( 2657 _In_ PRTL_ATOM_TABLE AtomTable, 2658 _In_ PWSTR AtomName, 2659 _Out_ PRTL_ATOM Atom 2660 ); 2661 2662 // 2663 // Process Management Functions 2664 // 2665 NTSYSAPI 2666 PPEB 2667 NTAPI 2668 RtlGetCurrentPeb( 2669 VOID 2670 ); 2671 2672 NTSYSAPI 2673 VOID 2674 NTAPI 2675 RtlAcquirePebLock(VOID); 2676 2677 NTSYSAPI 2678 NTSTATUS 2679 NTAPI 2680 RtlCreateProcessParameters ( 2681 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, 2682 _In_ PUNICODE_STRING ImagePathName, 2683 _In_opt_ PUNICODE_STRING DllPath, 2684 _In_opt_ PUNICODE_STRING CurrentDirectory, 2685 _In_opt_ PUNICODE_STRING CommandLine, 2686 _In_opt_ PWSTR Environment, 2687 _In_opt_ PUNICODE_STRING WindowTitle, 2688 _In_opt_ PUNICODE_STRING DesktopInfo, 2689 _In_opt_ PUNICODE_STRING ShellInfo, 2690 _In_opt_ PUNICODE_STRING RuntimeInfo 2691 ); 2692 2693 NTSYSAPI 2694 NTSTATUS 2695 NTAPI 2696 RtlCreateUserProcess( 2697 _In_ PUNICODE_STRING ImageFileName, 2698 _In_ ULONG Attributes, 2699 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters, 2700 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor, 2701 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, 2702 _In_opt_ HANDLE ParentProcess, 2703 _In_ BOOLEAN CurrentDirectory, 2704 _In_opt_ HANDLE DebugPort, 2705 _In_opt_ HANDLE ExceptionPort, 2706 _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo 2707 ); 2708 2709 #if (NTDDI_VERSION >= NTDDI_WIN7) 2710 NTSYSAPI 2711 NTSTATUS 2712 NTAPI 2713 RtlCreateUserThread( 2714 _In_ PVOID ThreadContext, 2715 _Out_ HANDLE *OutThreadHandle, 2716 _Reserved_ PVOID Reserved1, 2717 _Reserved_ PVOID Reserved2, 2718 _Reserved_ PVOID Reserved3, 2719 _Reserved_ PVOID Reserved4, 2720 _Reserved_ PVOID Reserved5, 2721 _Reserved_ PVOID Reserved6, 2722 _Reserved_ PVOID Reserved7, 2723 _Reserved_ PVOID Reserved8 2724 ); 2725 #else 2726 NTSYSAPI 2727 NTSTATUS 2728 NTAPI 2729 RtlCreateUserThread( 2730 _In_ HANDLE ProcessHandle, 2731 _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor, 2732 _In_ BOOLEAN CreateSuspended, 2733 _In_ ULONG StackZeroBits, 2734 _In_ SIZE_T StackReserve, 2735 _In_ SIZE_T StackCommit, 2736 _In_ PTHREAD_START_ROUTINE StartAddress, 2737 _In_ PVOID Parameter, 2738 _Out_opt_ PHANDLE ThreadHandle, 2739 _Out_opt_ PCLIENT_ID ClientId 2740 ); 2741 #endif 2742 2743 NTSYSAPI 2744 PRTL_USER_PROCESS_PARAMETERS 2745 NTAPI 2746 RtlDeNormalizeProcessParams( 2747 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters); 2748 2749 NTSYSAPI 2750 NTSTATUS 2751 NTAPI 2752 RtlDestroyProcessParameters( 2753 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters); 2754 2755 NTSYSAPI 2756 VOID 2757 NTAPI 2758 RtlExitUserThread( 2759 _In_ NTSTATUS Status); 2760 2761 NTSYSAPI 2762 VOID 2763 NTAPI 2764 RtlInitializeContext( 2765 _In_ HANDLE ProcessHandle, 2766 _Out_ PCONTEXT ThreadContext, 2767 _In_opt_ PVOID ThreadStartParam, 2768 _In_ PTHREAD_START_ROUTINE ThreadStartAddress, 2769 _In_ PINITIAL_TEB InitialTeb 2770 ); 2771 2772 #ifdef _M_AMD64 2773 typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT; 2774 2775 NTSYSAPI 2776 NTSTATUS 2777 NTAPI 2778 RtlWow64GetThreadContext( 2779 _In_ HANDLE ThreadHandle, 2780 _Inout_ PWOW64_CONTEXT ThreadContext 2781 ); 2782 2783 2784 NTSYSAPI 2785 NTSTATUS 2786 NTAPI 2787 RtlWow64SetThreadContext( 2788 _In_ HANDLE ThreadHandle, 2789 _In_ PWOW64_CONTEXT ThreadContext 2790 ); 2791 #endif 2792 2793 NTSYSAPI 2794 BOOLEAN 2795 NTAPI 2796 RtlIsThreadWithinLoaderCallout(VOID); 2797 2798 NTSYSAPI 2799 PRTL_USER_PROCESS_PARAMETERS 2800 NTAPI 2801 RtlNormalizeProcessParams( 2802 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters); 2803 2804 NTSYSAPI 2805 VOID 2806 NTAPI 2807 RtlReleasePebLock(VOID); 2808 2809 NTSYSAPI 2810 NTSTATUS 2811 NTAPI 2812 RtlRemoteCall( 2813 _In_ HANDLE Process, 2814 _In_ HANDLE Thread, 2815 _In_ PVOID CallSite, 2816 _In_ ULONG ArgumentCount, 2817 _In_ PULONG Arguments, 2818 _In_ BOOLEAN PassContext, 2819 _In_ BOOLEAN AlreadySuspended 2820 ); 2821 2822 NTSYSAPI 2823 NTSTATUS 2824 __cdecl 2825 RtlSetProcessIsCritical( 2826 _In_ BOOLEAN NewValue, 2827 _Out_opt_ PBOOLEAN OldValue, 2828 _In_ BOOLEAN NeedBreaks 2829 ); 2830 2831 NTSYSAPI 2832 NTSTATUS 2833 __cdecl 2834 RtlSetThreadIsCritical( 2835 _In_ BOOLEAN NewValue, 2836 _Out_opt_ PBOOLEAN OldValue, 2837 _In_ BOOLEAN NeedBreaks 2838 ); 2839 2840 NTSYSAPI 2841 ULONG 2842 NTAPI 2843 RtlGetCurrentProcessorNumber( 2844 VOID 2845 ); 2846 2847 2848 // 2849 // Thread Pool Functions 2850 // 2851 // 2852 NTSTATUS 2853 NTAPI 2854 RtlSetThreadPoolStartFunc( 2855 _In_ PRTL_START_POOL_THREAD StartPoolThread, 2856 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread 2857 ); 2858 2859 NTSYSAPI 2860 NTSTATUS 2861 NTAPI 2862 RtlDeregisterWaitEx( 2863 _In_ HANDLE hWaitHandle, 2864 _In_opt_ HANDLE hCompletionEvent 2865 ); 2866 2867 NTSYSAPI 2868 NTSTATUS 2869 NTAPI 2870 RtlDeregisterWait( 2871 _In_ HANDLE hWaitHandle 2872 ); 2873 2874 NTSYSAPI 2875 NTSTATUS 2876 NTAPI 2877 RtlQueueWorkItem( 2878 _In_ WORKERCALLBACKFUNC Function, 2879 _In_opt_ PVOID Context, 2880 _In_ ULONG Flags 2881 ); 2882 2883 NTSYSAPI 2884 NTSTATUS 2885 NTAPI 2886 RtlSetIoCompletionCallback( 2887 _In_ HANDLE FileHandle, 2888 _In_ PIO_APC_ROUTINE Callback, 2889 _In_ ULONG Flags 2890 ); 2891 2892 NTSYSAPI 2893 NTSTATUS 2894 NTAPI 2895 RtlRegisterWait( 2896 _In_ PHANDLE phNewWaitObject, 2897 _In_ HANDLE hObject, 2898 _In_ WAITORTIMERCALLBACKFUNC Callback, 2899 _In_ PVOID pvContext, 2900 _In_ ULONG ulMilliseconds, 2901 _In_ ULONG ulFlags 2902 ); 2903 2904 // 2905 // Environment/Path Functions 2906 // 2907 NTSYSAPI 2908 NTSTATUS 2909 NTAPI 2910 RtlCreateEnvironment( 2911 _In_ BOOLEAN Inherit, 2912 _Out_ PWSTR *Environment 2913 ); 2914 2915 NTSYSAPI 2916 NTSTATUS 2917 NTAPI 2918 RtlComputePrivatizedDllName_U( 2919 _In_ PUNICODE_STRING DllName, 2920 _Inout_ PUNICODE_STRING RealName, 2921 _Inout_ PUNICODE_STRING LocalName 2922 ); 2923 2924 NTSYSAPI 2925 VOID 2926 NTAPI 2927 RtlDestroyEnvironment( 2928 _In_ PWSTR Environment 2929 ); 2930 2931 NTSYSAPI 2932 BOOLEAN 2933 NTAPI 2934 RtlDoesFileExists_U( 2935 _In_ PCWSTR FileName 2936 ); 2937 2938 NTSYSAPI 2939 RTL_PATH_TYPE 2940 NTAPI 2941 RtlDetermineDosPathNameType_U( 2942 _In_ PCWSTR Path 2943 ); 2944 2945 NTSYSAPI 2946 ULONG 2947 NTAPI 2948 RtlDosSearchPath_U( 2949 _In_ PCWSTR Path, 2950 _In_ PCWSTR FileName, 2951 _In_ PCWSTR Extension, 2952 _In_ ULONG BufferSize, 2953 _Out_ PWSTR Buffer, 2954 _Out_ PWSTR *PartName 2955 ); 2956 2957 NTSYSAPI 2958 NTSTATUS 2959 NTAPI 2960 RtlDosSearchPath_Ustr( 2961 _In_ ULONG Flags, 2962 _In_ PUNICODE_STRING PathString, 2963 _In_ PUNICODE_STRING FileNameString, 2964 _In_ PUNICODE_STRING ExtensionString, 2965 _In_ PUNICODE_STRING CallerBuffer, 2966 _Inout_opt_ PUNICODE_STRING DynamicString, 2967 _Out_opt_ PUNICODE_STRING* FullNameOut, 2968 _Out_opt_ PSIZE_T FilePartSize, 2969 _Out_opt_ PSIZE_T LengthNeeded 2970 ); 2971 2972 NTSYSAPI 2973 BOOLEAN 2974 NTAPI 2975 RtlDosPathNameToNtPathName_U( 2976 _In_opt_z_ PCWSTR DosPathName, 2977 _Out_ PUNICODE_STRING NtPathName, 2978 _Out_opt_ PCWSTR *NtFileNamePart, 2979 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo 2980 ); 2981 2982 2983 #define RTL_UNCHANGED_UNK_PATH 1 2984 #define RTL_CONVERTED_UNC_PATH 2 2985 #define RTL_CONVERTED_NT_PATH 3 2986 #define RTL_UNCHANGED_DOS_PATH 4 2987 2988 NTSYSAPI 2989 NTSTATUS 2990 NTAPI 2991 RtlNtPathNameToDosPathName( 2992 _In_ ULONG Flags, 2993 _Inout_ PRTL_UNICODE_STRING_BUFFER Path, 2994 _Out_opt_ PULONG PathType, 2995 _Out_opt_ PULONG Unknown 2996 ); 2997 2998 2999 NTSYSAPI 3000 BOOLEAN 3001 NTAPI 3002 RtlDosPathNameToRelativeNtPathName_U( 3003 _In_ PCWSTR DosName, 3004 _Out_ PUNICODE_STRING NtName, 3005 _Out_ PCWSTR *PartName, 3006 _Out_ PRTL_RELATIVE_NAME_U RelativeName 3007 ); 3008 3009 _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength)) 3010 NTSYSAPI 3011 NTSTATUS 3012 NTAPI 3013 RtlExpandEnvironmentStrings_U( 3014 _In_z_ PWSTR Environment, 3015 _In_ PUNICODE_STRING Source, 3016 _Inout_ PUNICODE_STRING Destination, 3017 _Out_ PULONG Length 3018 ); 3019 3020 NTSYSAPI 3021 ULONG 3022 NTAPI 3023 RtlGetCurrentDirectory_U( 3024 _In_ ULONG MaximumLength, 3025 _Out_bytecap_(MaximumLength) PWSTR Buffer 3026 ); 3027 3028 NTSYSAPI 3029 ULONG 3030 NTAPI 3031 RtlGetFullPathName_U( 3032 _In_ PCWSTR FileName, 3033 _In_ ULONG Size, 3034 _Out_z_bytecap_(Size) PWSTR Buffer, 3035 _Out_opt_ PWSTR *ShortName 3036 ); 3037 3038 #if (NTDDI_VERSION >= NTDDI_WIN7) 3039 NTSYSAPI 3040 NTSTATUS 3041 NTAPI 3042 RtlGetFullPathName_UEx( 3043 _In_ PWSTR FileName, 3044 _In_ ULONG BufferLength, 3045 _Out_ PWSTR Buffer, 3046 _Out_opt_ PWSTR *FilePart, 3047 _Out_opt_ RTL_PATH_TYPE *InputPathType 3048 ); 3049 #endif 3050 3051 NTSTATUS 3052 NTAPI 3053 RtlGetFullPathName_UstrEx( 3054 _In_ PUNICODE_STRING FileName, 3055 _In_opt_ PUNICODE_STRING StaticString, 3056 _In_opt_ PUNICODE_STRING DynamicString, 3057 _Out_opt_ PUNICODE_STRING *StringUsed, 3058 _Out_opt_ PSIZE_T FilePartSize, 3059 _Out_opt_ PBOOLEAN NameInvalid, 3060 _Out_ RTL_PATH_TYPE* PathType, 3061 _Out_opt_ PSIZE_T LengthNeeded 3062 ); 3063 3064 NTSYSAPI 3065 NTSTATUS 3066 NTAPI 3067 RtlGetLengthWithoutTrailingPathSeperators( 3068 _Reserved_ ULONG Flags, 3069 _In_ PCUNICODE_STRING PathString, 3070 _Out_ PULONG Length 3071 ); 3072 3073 NTSYSAPI 3074 ULONG 3075 NTAPI 3076 RtlGetLongestNtPathLength( 3077 VOID 3078 ); 3079 3080 NTSYSAPI 3081 ULONG 3082 NTAPI 3083 RtlIsDosDeviceName_U( 3084 _In_ PCWSTR Name 3085 ); 3086 3087 NTSYSAPI 3088 ULONG 3089 NTAPI 3090 RtlIsDosDeviceName_Ustr( 3091 _In_ PCUNICODE_STRING Name 3092 ); 3093 3094 _IRQL_requires_max_(PASSIVE_LEVEL) 3095 _Must_inspect_result_ 3096 NTSYSAPI 3097 BOOLEAN 3098 NTAPI 3099 RtlIsNameLegalDOS8Dot3( 3100 _In_ PCUNICODE_STRING Name, 3101 _Inout_opt_ POEM_STRING OemName, 3102 _Out_opt_ PBOOLEAN NameContainsSpaces 3103 ); 3104 3105 NTSYSAPI 3106 NTSTATUS 3107 NTAPI 3108 RtlQueryEnvironmentVariable_U( 3109 _In_opt_ PWSTR Environment, 3110 _In_ PCUNICODE_STRING Name, 3111 _Out_ PUNICODE_STRING Value 3112 ); 3113 3114 VOID 3115 NTAPI 3116 RtlReleaseRelativeName( 3117 _In_ PRTL_RELATIVE_NAME_U RelativeName 3118 ); 3119 3120 NTSYSAPI 3121 NTSTATUS 3122 NTAPI 3123 RtlSetCurrentDirectory_U( 3124 _In_ PUNICODE_STRING name 3125 ); 3126 3127 NTSYSAPI 3128 NTSTATUS 3129 NTAPI 3130 RtlSetEnvironmentVariable( 3131 _In_z_ PWSTR *Environment, 3132 _In_ PUNICODE_STRING Name, 3133 _In_ PUNICODE_STRING Value 3134 ); 3135 3136 // 3137 // Critical Section/Resource Functions 3138 // 3139 NTSYSAPI 3140 NTSTATUS 3141 NTAPI 3142 RtlDeleteCriticalSection ( 3143 _In_ PRTL_CRITICAL_SECTION CriticalSection 3144 ); 3145 3146 NTSYSAPI 3147 NTSTATUS 3148 NTAPI 3149 RtlEnterCriticalSection( 3150 _In_ PRTL_CRITICAL_SECTION CriticalSection 3151 ); 3152 3153 NTSYSAPI 3154 NTSTATUS 3155 NTAPI 3156 RtlInitializeCriticalSection( 3157 _In_ PRTL_CRITICAL_SECTION CriticalSection 3158 ); 3159 3160 NTSYSAPI 3161 NTSTATUS 3162 NTAPI 3163 RtlInitializeCriticalSectionAndSpinCount( 3164 _In_ PRTL_CRITICAL_SECTION CriticalSection, 3165 _In_ ULONG SpinCount 3166 ); 3167 3168 NTSYSAPI 3169 ULONG 3170 NTAPI 3171 RtlIsCriticalSectionLocked( 3172 _In_ PRTL_CRITICAL_SECTION CriticalSection 3173 ); 3174 3175 NTSYSAPI 3176 ULONG 3177 NTAPI 3178 RtlIsCriticalSectionLockedByThread( 3179 _In_ PRTL_CRITICAL_SECTION CriticalSection 3180 ); 3181 3182 NTSYSAPI 3183 NTSTATUS 3184 NTAPI 3185 RtlLeaveCriticalSection( 3186 _In_ PRTL_CRITICAL_SECTION CriticalSection 3187 ); 3188 3189 NTSYSAPI 3190 BOOLEAN 3191 NTAPI 3192 RtlTryEnterCriticalSection( 3193 _In_ PRTL_CRITICAL_SECTION CriticalSection 3194 ); 3195 3196 NTSYSAPI 3197 VOID 3198 NTAPI 3199 RtlpUnWaitCriticalSection( 3200 _In_ PRTL_CRITICAL_SECTION CriticalSection 3201 ); 3202 3203 NTSYSAPI 3204 NTSTATUS 3205 NTAPI 3206 RtlpWaitForCriticalSection( 3207 _In_ PRTL_CRITICAL_SECTION CriticalSection 3208 ); 3209 3210 NTSYSAPI 3211 BOOLEAN 3212 NTAPI 3213 RtlAcquireResourceExclusive( 3214 _In_ PRTL_RESOURCE Resource, 3215 _In_ BOOLEAN Wait 3216 ); 3217 3218 NTSYSAPI 3219 BOOLEAN 3220 NTAPI 3221 RtlAcquireResourceShared( 3222 _In_ PRTL_RESOURCE Resource, 3223 _In_ BOOLEAN Wait 3224 ); 3225 3226 NTSYSAPI 3227 VOID 3228 NTAPI 3229 RtlConvertExclusiveToShared( 3230 _In_ PRTL_RESOURCE Resource 3231 ); 3232 3233 NTSYSAPI 3234 VOID 3235 NTAPI 3236 RtlConvertSharedToExclusive( 3237 _In_ PRTL_RESOURCE Resource 3238 ); 3239 3240 NTSYSAPI 3241 VOID 3242 NTAPI 3243 RtlDeleteResource( 3244 _In_ PRTL_RESOURCE Resource 3245 ); 3246 3247 NTSYSAPI 3248 VOID 3249 NTAPI 3250 RtlDumpResource( 3251 _In_ PRTL_RESOURCE Resource 3252 ); 3253 3254 NTSYSAPI 3255 VOID 3256 NTAPI 3257 RtlInitializeResource( 3258 _In_ PRTL_RESOURCE Resource 3259 ); 3260 3261 NTSYSAPI 3262 VOID 3263 NTAPI 3264 RtlReleaseResource( 3265 _In_ PRTL_RESOURCE Resource 3266 ); 3267 3268 // 3269 // Compression Functions 3270 // 3271 NTSYSAPI //NT_RTL_COMPRESS_API 3272 NTSTATUS 3273 NTAPI 3274 RtlCompressBuffer( 3275 _In_ USHORT CompressionFormatAndEngine, 3276 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, 3277 _In_ ULONG UncompressedBufferSize, 3278 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer, 3279 _In_ ULONG CompressedBufferSize, 3280 _In_ ULONG UncompressedChunkSize, 3281 _Out_ PULONG FinalCompressedSize, 3282 _In_ PVOID WorkSpace 3283 ); 3284 3285 _IRQL_requires_max_(APC_LEVEL) 3286 NTSYSAPI //NT_RTL_COMPRESS_API 3287 NTSTATUS 3288 NTAPI 3289 RtlDecompressBuffer( 3290 _In_ USHORT CompressionFormat, 3291 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, 3292 _In_ ULONG UncompressedBufferSize, 3293 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, 3294 _In_ ULONG CompressedBufferSize, 3295 _Out_ PULONG FinalUncompressedSize 3296 ); 3297 3298 NTSYSAPI 3299 NTSTATUS 3300 NTAPI 3301 RtlGetCompressionWorkSpaceSize( 3302 _In_ USHORT CompressionFormatAndEngine, 3303 _Out_ PULONG CompressBufferWorkSpaceSize, 3304 _Out_ PULONG CompressFragmentWorkSpaceSize 3305 ); 3306 3307 // 3308 // Frame Functions 3309 // 3310 NTSYSAPI 3311 VOID 3312 NTAPI 3313 RtlPopFrame( 3314 _In_ PTEB_ACTIVE_FRAME Frame 3315 ); 3316 3317 NTSYSAPI 3318 VOID 3319 NTAPI 3320 RtlPushFrame( 3321 _In_ PTEB_ACTIVE_FRAME Frame 3322 ); 3323 3324 NTSYSAPI 3325 PTEB_ACTIVE_FRAME 3326 NTAPI 3327 RtlGetFrame( 3328 VOID 3329 ); 3330 3331 // 3332 // Debug Info Functions 3333 // 3334 NTSYSAPI 3335 PRTL_DEBUG_INFORMATION 3336 NTAPI 3337 RtlCreateQueryDebugBuffer( 3338 _In_ ULONG Size, 3339 _In_ BOOLEAN EventPair 3340 ); 3341 3342 NTSYSAPI 3343 NTSTATUS 3344 NTAPI 3345 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer); 3346 3347 NTSYSAPI 3348 NTSTATUS 3349 NTAPI 3350 RtlQueryProcessDebugInformation( 3351 _In_ ULONG ProcessId, 3352 _In_ ULONG DebugInfoClassMask, 3353 _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer 3354 ); 3355 3356 // 3357 // Bitmap Functions 3358 // 3359 #ifdef NTOS_MODE_USER 3360 3361 NTSYSAPI 3362 BOOLEAN 3363 NTAPI 3364 RtlAreBitsClear( 3365 _In_ PRTL_BITMAP BitMapHeader, 3366 _In_ ULONG StartingIndex, 3367 _In_ ULONG Length 3368 ); 3369 3370 NTSYSAPI 3371 BOOLEAN 3372 NTAPI 3373 RtlAreBitsSet( 3374 _In_ PRTL_BITMAP BitMapHeader, 3375 _In_ ULONG StartingIndex, 3376 _In_ ULONG Length 3377 ); 3378 3379 NTSYSAPI 3380 VOID 3381 NTAPI 3382 RtlClearAllBits( 3383 _In_ PRTL_BITMAP BitMapHeader 3384 ); 3385 3386 NTSYSAPI 3387 VOID 3388 NTAPI 3389 RtlClearBit( 3390 _In_ PRTL_BITMAP BitMapHeader, 3391 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber 3392 ); 3393 3394 NTSYSAPI 3395 VOID 3396 NTAPI 3397 RtlClearBits( 3398 _In_ PRTL_BITMAP BitMapHeader, 3399 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, 3400 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear 3401 ); 3402 3403 NTSYSAPI 3404 ULONG 3405 NTAPI 3406 RtlFindClearBits( 3407 _In_ PRTL_BITMAP BitMapHeader, 3408 _In_ ULONG NumberToFind, 3409 _In_ ULONG HintIndex 3410 ); 3411 3412 NTSYSAPI 3413 ULONG 3414 NTAPI 3415 RtlFindClearBitsAndSet( 3416 _In_ PRTL_BITMAP BitMapHeader, 3417 _In_ ULONG NumberToFind, 3418 _In_ ULONG HintIndex 3419 ); 3420 3421 NTSYSAPI 3422 ULONG 3423 NTAPI 3424 RtlFindFirstRunClear( 3425 _In_ PRTL_BITMAP BitMapHeader, 3426 _Out_ PULONG StartingIndex 3427 ); 3428 3429 NTSYSAPI 3430 ULONG 3431 NTAPI 3432 RtlFindClearRuns( 3433 _In_ PRTL_BITMAP BitMapHeader, 3434 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray, 3435 _In_range_(>, 0) ULONG SizeOfRunArray, 3436 _In_ BOOLEAN LocateLongestRuns 3437 ); 3438 3439 NTSYSAPI 3440 ULONG 3441 NTAPI 3442 RtlFindLastBackwardRunClear( 3443 _In_ PRTL_BITMAP BitMapHeader, 3444 _In_ ULONG FromIndex, 3445 _Out_ PULONG StartingRunIndex 3446 ); 3447 3448 NTSYSAPI 3449 CCHAR 3450 NTAPI 3451 RtlFindLeastSignificantBit( 3452 _In_ ULONGLONG Value 3453 ); 3454 3455 NTSYSAPI 3456 ULONG 3457 NTAPI 3458 RtlFindLongestRunClear( 3459 _In_ PRTL_BITMAP BitMapHeader, 3460 _Out_ PULONG StartingIndex 3461 ); 3462 3463 NTSYSAPI 3464 CCHAR 3465 NTAPI 3466 RtlFindMostSignificantBit( 3467 _In_ ULONGLONG Value 3468 ); 3469 3470 NTSYSAPI 3471 ULONG 3472 NTAPI 3473 RtlFindNextForwardRunClear( 3474 _In_ PRTL_BITMAP BitMapHeader, 3475 _In_ ULONG FromIndex, 3476 _Out_ PULONG StartingRunIndex 3477 ); 3478 3479 NTSYSAPI 3480 ULONG 3481 NTAPI 3482 RtlFindNextForwardRunSet( 3483 _In_ PRTL_BITMAP BitMapHeader, 3484 _In_ ULONG FromIndex, 3485 _Out_ PULONG StartingRunIndex 3486 ); 3487 3488 NTSYSAPI 3489 ULONG 3490 NTAPI 3491 RtlFindSetBits( 3492 _In_ PRTL_BITMAP BitMapHeader, 3493 _In_ ULONG NumberToFind, 3494 _In_ ULONG HintIndex 3495 ); 3496 3497 NTSYSAPI 3498 ULONG 3499 NTAPI 3500 RtlFindSetBitsAndClear( 3501 _In_ PRTL_BITMAP BitMapHeader, 3502 _In_ ULONG NumberToFind, 3503 _In_ ULONG HintIndex 3504 ); 3505 3506 #ifdef __REACTOS__ // ReactOS improvement 3507 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap)) 3508 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer)) 3509 #endif 3510 NTSYSAPI 3511 VOID 3512 NTAPI 3513 RtlInitializeBitMap( 3514 _Out_ PRTL_BITMAP BitMapHeader, 3515 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer, 3516 _In_opt_ ULONG SizeOfBitMap 3517 ); 3518 3519 NTSYSAPI 3520 ULONG 3521 NTAPI 3522 RtlNumberOfClearBits( 3523 _In_ PRTL_BITMAP BitMapHeader 3524 ); 3525 3526 NTSYSAPI 3527 ULONG 3528 NTAPI 3529 RtlNumberOfSetBits( 3530 _In_ PRTL_BITMAP BitMapHeader 3531 ); 3532 3533 NTSYSAPI 3534 VOID 3535 NTAPI 3536 RtlSetBit( 3537 _In_ PRTL_BITMAP BitMapHeader, 3538 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber 3539 ); 3540 3541 NTSYSAPI 3542 VOID 3543 NTAPI 3544 RtlSetBits( 3545 _In_ PRTL_BITMAP BitMapHeader, 3546 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, 3547 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet 3548 ); 3549 3550 NTSYSAPI 3551 VOID 3552 NTAPI 3553 RtlSetAllBits( 3554 _In_ PRTL_BITMAP BitMapHeader 3555 ); 3556 3557 _Must_inspect_result_ 3558 NTSYSAPI 3559 BOOLEAN 3560 NTAPI 3561 RtlTestBit( 3562 _In_ PRTL_BITMAP BitMapHeader, 3563 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber 3564 ); 3565 3566 #if defined(_M_AMD64) 3567 _Must_inspect_result_ 3568 FORCEINLINE 3569 BOOLEAN 3570 RtlCheckBit( 3571 _In_ PRTL_BITMAP BitMapHeader, 3572 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition) 3573 { 3574 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); 3575 } 3576 #else 3577 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) 3578 #endif /* defined(_M_AMD64) */ 3579 3580 #endif // NTOS_MODE_USER 3581 3582 3583 // 3584 // Timer Functions 3585 // 3586 NTSYSAPI 3587 NTSTATUS 3588 NTAPI 3589 RtlCreateTimer( 3590 _In_ HANDLE TimerQueue, 3591 _In_ PHANDLE phNewTimer, 3592 _In_ WAITORTIMERCALLBACKFUNC Callback, 3593 _In_ PVOID Parameter, 3594 _In_ ULONG DueTime, 3595 _In_ ULONG Period, 3596 _In_ ULONG Flags 3597 ); 3598 3599 NTSYSAPI 3600 NTSTATUS 3601 NTAPI 3602 RtlCreateTimerQueue(PHANDLE TimerQueue); 3603 3604 NTSYSAPI 3605 NTSTATUS 3606 NTAPI 3607 RtlDeleteTimer( 3608 _In_ HANDLE TimerQueue, 3609 _In_ HANDLE Timer, 3610 _In_ HANDLE CompletionEvent 3611 ); 3612 3613 NTSYSAPI 3614 NTSTATUS 3615 NTAPI 3616 RtlUpdateTimer( 3617 _In_ HANDLE TimerQueue, 3618 _In_ HANDLE Timer, 3619 _In_ ULONG DueTime, 3620 _In_ ULONG Period 3621 ); 3622 3623 NTSYSAPI 3624 NTSTATUS 3625 NTAPI 3626 RtlDeleteTimerQueueEx( 3627 _In_ HANDLE TimerQueue, 3628 _In_opt_ HANDLE CompletionEvent 3629 ); 3630 3631 NTSYSAPI 3632 NTSTATUS 3633 NTAPI 3634 RtlDeleteTimerQueue(HANDLE TimerQueue); 3635 3636 // 3637 // SList functions 3638 // 3639 PSLIST_ENTRY 3640 FASTCALL 3641 InterlockedPushListSList( 3642 _Inout_ PSLIST_HEADER ListHead, 3643 _Inout_ __drv_aliasesMem PSLIST_ENTRY List, 3644 _Inout_ PSLIST_ENTRY ListEnd, 3645 _In_ ULONG Count 3646 ); 3647 3648 // 3649 // Range List functions 3650 // 3651 NTSYSAPI 3652 VOID 3653 NTAPI 3654 RtlInitializeRangeList( 3655 _Out_ PRTL_RANGE_LIST RangeList 3656 ); 3657 3658 NTSYSAPI 3659 VOID 3660 NTAPI 3661 RtlFreeRangeList( 3662 _In_ PRTL_RANGE_LIST RangeList 3663 ); 3664 3665 NTSYSAPI 3666 NTSTATUS 3667 NTAPI 3668 RtlCopyRangeList( 3669 _Out_ PRTL_RANGE_LIST CopyRangeList, 3670 _In_ PRTL_RANGE_LIST RangeList 3671 ); 3672 3673 NTSYSAPI 3674 NTSTATUS 3675 NTAPI 3676 RtlMergeRangeLists( 3677 _Out_ PRTL_RANGE_LIST MergedRangeList, 3678 _In_ PRTL_RANGE_LIST RangeList1, 3679 _In_ PRTL_RANGE_LIST RangeList2, 3680 _In_ ULONG Flags 3681 ); 3682 3683 NTSYSAPI 3684 NTSTATUS 3685 NTAPI 3686 RtlInvertRangeList( 3687 _Out_ PRTL_RANGE_LIST InvertedRangeList, 3688 _In_ PRTL_RANGE_LIST RangeList 3689 ); 3690 3691 NTSYSAPI 3692 NTSTATUS 3693 NTAPI 3694 RtlAddRange( 3695 _Inout_ PRTL_RANGE_LIST RangeList, 3696 _In_ ULONGLONG Start, 3697 _In_ ULONGLONG End, 3698 _In_ UCHAR Attributes, 3699 _In_ ULONG Flags, 3700 _In_opt_ PVOID UserData, 3701 _In_opt_ PVOID Owner 3702 ); 3703 3704 NTSYSAPI 3705 NTSTATUS 3706 NTAPI 3707 RtlDeleteRange( 3708 _Inout_ PRTL_RANGE_LIST RangeList, 3709 _In_ ULONGLONG Start, 3710 _In_ ULONGLONG End, 3711 _In_ PVOID Owner 3712 ); 3713 3714 NTSYSAPI 3715 NTSTATUS 3716 NTAPI 3717 RtlDeleteOwnersRanges( 3718 _Inout_ PRTL_RANGE_LIST RangeList, 3719 _In_ _Maybenull_ PVOID Owner 3720 ); 3721 3722 NTSYSAPI 3723 NTSTATUS 3724 NTAPI 3725 RtlFindRange( 3726 _In_ PRTL_RANGE_LIST RangeList, 3727 _In_ ULONGLONG Minimum, 3728 _In_ ULONGLONG Maximum, 3729 _In_ ULONG Length, 3730 _In_ ULONG Alignment, 3731 _In_ ULONG Flags, 3732 _In_ UCHAR AttributeAvailableMask, 3733 _In_opt_ PVOID Context, 3734 _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback, 3735 _Out_ PULONGLONG Start 3736 ); 3737 3738 NTSYSAPI 3739 NTSTATUS 3740 NTAPI 3741 RtlIsRangeAvailable( 3742 _In_ PRTL_RANGE_LIST RangeList, 3743 _In_ ULONGLONG Start, 3744 _In_ ULONGLONG End, 3745 _In_ ULONG Flags, 3746 _In_ UCHAR AttributeAvailableMask, 3747 _In_opt_ PVOID Context, 3748 _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback, 3749 _Out_ PBOOLEAN Available 3750 ); 3751 3752 NTSYSAPI 3753 NTSTATUS 3754 NTAPI 3755 RtlGetFirstRange( 3756 _In_ PRTL_RANGE_LIST RangeList, 3757 _Out_ PRTL_RANGE_LIST_ITERATOR Iterator, 3758 _Outptr_ PRTL_RANGE *Range 3759 ); 3760 3761 NTSYSAPI 3762 NTSTATUS 3763 NTAPI 3764 RtlGetNextRange( 3765 _Inout_ PRTL_RANGE_LIST_ITERATOR Iterator, 3766 _Outptr_ PRTL_RANGE *Range, 3767 _In_ BOOLEAN MoveForwards 3768 ); 3769 3770 // 3771 // Debug Functions 3772 // 3773 ULONG 3774 __cdecl 3775 DbgPrint( 3776 _In_z_ _Printf_format_string_ PCSTR Format, 3777 ... 3778 ); 3779 3780 NTSYSAPI 3781 ULONG 3782 __cdecl 3783 DbgPrintEx( 3784 _In_ ULONG ComponentId, 3785 _In_ ULONG Level, 3786 _In_z_ _Printf_format_string_ PCSTR Format, 3787 ... 3788 ); 3789 3790 NTSYSAPI 3791 ULONG 3792 NTAPI 3793 DbgPrompt( 3794 _In_z_ PCCH Prompt, 3795 _Out_writes_bytes_(MaximumResponseLength) PCH Response, 3796 _In_ ULONG MaximumResponseLength 3797 ); 3798 3799 #undef DbgBreakPoint 3800 VOID 3801 NTAPI 3802 DbgBreakPoint( 3803 VOID 3804 ); 3805 3806 VOID 3807 NTAPI 3808 DbgLoadImageSymbols( 3809 _In_ PSTRING Name, 3810 _In_ PVOID Base, 3811 _In_ ULONG_PTR ProcessId 3812 ); 3813 3814 VOID 3815 NTAPI 3816 DbgUnLoadImageSymbols( 3817 _In_ PSTRING Name, 3818 _In_ PVOID Base, 3819 _In_ ULONG_PTR ProcessId 3820 ); 3821 3822 VOID 3823 NTAPI 3824 DbgCommandString( 3825 _In_ PCCH Name, 3826 _In_ PCCH Command 3827 ); 3828 3829 // 3830 // Generic Table Functions 3831 // 3832 #if defined(NTOS_MODE_USER) || defined(_NTIFS_) 3833 NTSYSAPI 3834 PVOID 3835 NTAPI 3836 RtlInsertElementGenericTable( 3837 _In_ PRTL_GENERIC_TABLE Table, 3838 _In_reads_bytes_(BufferSize) PVOID Buffer, 3839 _In_ CLONG BufferSize, 3840 _Out_opt_ PBOOLEAN NewElement 3841 ); 3842 3843 NTSYSAPI 3844 PVOID 3845 NTAPI 3846 RtlInsertElementGenericTableFull( 3847 _In_ PRTL_GENERIC_TABLE Table, 3848 _In_reads_bytes_(BufferSize) PVOID Buffer, 3849 _In_ CLONG BufferSize, 3850 _Out_opt_ PBOOLEAN NewElement, 3851 _In_ PVOID NodeOrParent, 3852 _In_ TABLE_SEARCH_RESULT SearchResult 3853 ); 3854 3855 NTSYSAPI 3856 BOOLEAN 3857 NTAPI 3858 RtlIsGenericTableEmpty( 3859 _In_ PRTL_GENERIC_TABLE Table 3860 ); 3861 3862 NTSYSAPI 3863 PVOID 3864 NTAPI 3865 RtlLookupElementGenericTableFull( 3866 _In_ PRTL_GENERIC_TABLE Table, 3867 _In_ PVOID Buffer, 3868 _Out_ PVOID *NodeOrParent, 3869 _Out_ TABLE_SEARCH_RESULT *SearchResult 3870 ); 3871 #endif 3872 3873 // 3874 // Handle Table Functions 3875 // 3876 NTSYSAPI 3877 PRTL_HANDLE_TABLE_ENTRY 3878 NTAPI 3879 RtlAllocateHandle( 3880 _In_ PRTL_HANDLE_TABLE HandleTable, 3881 _Inout_ PULONG Index 3882 ); 3883 3884 NTSYSAPI 3885 VOID 3886 NTAPI 3887 RtlDestroyHandleTable( 3888 _Inout_ PRTL_HANDLE_TABLE HandleTable); 3889 3890 NTSYSAPI 3891 BOOLEAN 3892 NTAPI 3893 RtlFreeHandle( 3894 _In_ PRTL_HANDLE_TABLE HandleTable, 3895 _In_ PRTL_HANDLE_TABLE_ENTRY Handle 3896 ); 3897 3898 NTSYSAPI 3899 VOID 3900 NTAPI 3901 RtlInitializeHandleTable( 3902 _In_ ULONG TableSize, 3903 _In_ ULONG HandleSize, 3904 _In_ PRTL_HANDLE_TABLE HandleTable 3905 ); 3906 3907 NTSYSAPI 3908 BOOLEAN 3909 NTAPI 3910 RtlIsValidHandle( 3911 _In_ PRTL_HANDLE_TABLE HandleTable, 3912 _In_ PRTL_HANDLE_TABLE_ENTRY Handle 3913 ); 3914 3915 _Success_(return!=FALSE) 3916 NTSYSAPI 3917 BOOLEAN 3918 NTAPI 3919 RtlIsValidIndexHandle( 3920 _In_ PRTL_HANDLE_TABLE HandleTable, 3921 _In_ ULONG Index, 3922 _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle 3923 ); 3924 3925 // 3926 // PE Functions 3927 // 3928 NTSYSAPI 3929 NTSTATUS 3930 NTAPI 3931 RtlFindMessage( 3932 _In_ PVOID BaseAddress, 3933 _In_ ULONG Type, 3934 _In_ ULONG Language, 3935 _In_ ULONG MessageId, 3936 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry 3937 ); 3938 3939 NTSYSAPI 3940 ULONG 3941 NTAPI 3942 RtlGetNtGlobalFlags(VOID); 3943 3944 _Success_(return!=NULL) 3945 NTSYSAPI 3946 PVOID 3947 NTAPI 3948 RtlImageDirectoryEntryToData( 3949 _In_ PVOID BaseAddress, 3950 _In_ BOOLEAN MappedAsImage, 3951 _In_ USHORT Directory, 3952 _Out_ PULONG Size 3953 ); 3954 3955 NTSYSAPI 3956 PVOID 3957 NTAPI 3958 RtlImageRvaToVa( 3959 _In_ PIMAGE_NT_HEADERS NtHeader, 3960 _In_ PVOID BaseAddress, 3961 _In_ ULONG Rva, 3962 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader 3963 ); 3964 3965 NTSYSAPI 3966 PIMAGE_NT_HEADERS 3967 NTAPI 3968 RtlImageNtHeader( 3969 _In_ PVOID BaseAddress); 3970 3971 NTSYSAPI 3972 NTSTATUS 3973 NTAPI 3974 RtlImageNtHeaderEx( 3975 _In_ ULONG Flags, 3976 _In_ PVOID BaseAddress, 3977 _In_ ULONGLONG Size, 3978 _Out_ PIMAGE_NT_HEADERS *NtHeader 3979 ); 3980 3981 NTSYSAPI 3982 PIMAGE_SECTION_HEADER 3983 NTAPI 3984 RtlImageRvaToSection( 3985 _In_ PIMAGE_NT_HEADERS NtHeader, 3986 _In_ PVOID BaseAddress, 3987 _In_ ULONG Rva 3988 ); 3989 3990 ULONG 3991 NTAPI 3992 LdrRelocateImageWithBias( 3993 _In_ PVOID BaseAddress, 3994 _In_ LONGLONG AdditionalBias, 3995 _In_opt_ PCSTR LoaderName, 3996 _In_ ULONG Success, 3997 _In_ ULONG Conflict, 3998 _In_ ULONG Invalid 3999 ); 4000 4001 // 4002 // Activation Context Functions 4003 // 4004 #ifdef NTOS_MODE_USER 4005 NTSYSAPI 4006 NTSTATUS 4007 NTAPI 4008 RtlActivateActivationContextEx( 4009 _In_ ULONG Flags, 4010 _In_ PTEB Teb, 4011 _In_ PVOID Context, 4012 _Out_ PULONG_PTR Cookie 4013 ); 4014 4015 NTSYSAPI 4016 NTSTATUS 4017 NTAPI 4018 RtlActivateActivationContext( 4019 _In_ ULONG Flags, 4020 _In_ HANDLE Handle, 4021 _Out_ PULONG_PTR Cookie 4022 ); 4023 4024 NTSYSAPI 4025 VOID 4026 NTAPI 4027 RtlAddRefActivationContext( 4028 _In_ PVOID Context 4029 ); 4030 4031 NTSYSAPI 4032 PRTL_ACTIVATION_CONTEXT_STACK_FRAME 4033 FASTCALL 4034 RtlActivateActivationContextUnsafeFast( 4035 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, 4036 _In_ PVOID Context 4037 ); 4038 4039 NTSYSAPI 4040 NTSTATUS 4041 NTAPI 4042 RtlAllocateActivationContextStack( 4043 _In_ PACTIVATION_CONTEXT_STACK *Stack 4044 ); 4045 4046 NTSYSAPI 4047 NTSTATUS 4048 NTAPI 4049 RtlCreateActivationContext( 4050 _In_ ULONG Flags, 4051 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData, 4052 _In_ ULONG ExtraBytes, 4053 _In_ PVOID NotificationRoutine, 4054 _In_ PVOID NotificationContext, 4055 _Out_ PACTIVATION_CONTEXT *ActCtx 4056 ); 4057 4058 NTSYSAPI 4059 NTSTATUS 4060 NTAPI 4061 RtlGetActiveActivationContext( 4062 _In_ PVOID *Context 4063 ); 4064 4065 NTSYSAPI 4066 VOID 4067 NTAPI 4068 RtlReleaseActivationContext( 4069 _In_ HANDLE handle 4070 ); 4071 4072 NTSYSAPI 4073 NTSTATUS 4074 NTAPI 4075 RtlDeactivateActivationContext( 4076 _In_ ULONG dwFlags, 4077 _In_ ULONG_PTR ulCookie 4078 ); 4079 4080 NTSYSAPI 4081 VOID 4082 NTAPI 4083 RtlFreeActivationContextStack( 4084 _In_ PACTIVATION_CONTEXT_STACK Stack 4085 ); 4086 4087 NTSYSAPI 4088 VOID 4089 NTAPI 4090 RtlFreeThreadActivationContextStack(VOID); 4091 4092 NTSYSAPI 4093 PRTL_ACTIVATION_CONTEXT_STACK_FRAME 4094 FASTCALL 4095 RtlDeactivateActivationContextUnsafeFast( 4096 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame 4097 ); 4098 4099 NTSYSAPI 4100 NTSTATUS 4101 NTAPI 4102 RtlDosApplyFileIsolationRedirection_Ustr( 4103 _In_ ULONG Flags, 4104 _In_ PUNICODE_STRING OriginalName, 4105 _In_ PUNICODE_STRING Extension, 4106 _Inout_ PUNICODE_STRING StaticString, 4107 _Inout_ PUNICODE_STRING DynamicString, 4108 _Inout_ PUNICODE_STRING *NewName, 4109 _In_ PULONG NewFlags, 4110 _In_ PSIZE_T FileNameSize, 4111 _In_ PSIZE_T RequiredLength 4112 ); 4113 4114 NTSYSAPI 4115 NTSTATUS 4116 NTAPI 4117 RtlFindActivationContextSectionString( 4118 _In_ ULONG dwFlags, 4119 _In_ const GUID *ExtensionGuid, 4120 _In_ ULONG SectionType, 4121 _In_ const UNICODE_STRING *SectionName, 4122 _Inout_ PVOID ReturnedData 4123 ); 4124 4125 NTSYSAPI 4126 NTSTATUS 4127 NTAPI 4128 RtlQueryInformationActivationContext( 4129 _In_ DWORD dwFlags, 4130 _In_opt_ PVOID Context, 4131 _In_opt_ PVOID pvSubInstance, 4132 _In_ ULONG ulInfoClass, 4133 _Out_bytecap_(cbBuffer) PVOID pvBuffer, 4134 _In_opt_ SIZE_T cbBuffer, 4135 _Out_opt_ SIZE_T *pcbWrittenOrRequired 4136 ); 4137 4138 NTSYSAPI 4139 NTSTATUS 4140 NTAPI 4141 RtlQueryInformationActiveActivationContext( 4142 _In_ ULONG ulInfoClass, 4143 _Out_bytecap_(cbBuffer) PVOID pvBuffer, 4144 _In_opt_ SIZE_T cbBuffer, 4145 _Out_opt_ SIZE_T *pcbWrittenOrRequired 4146 ); 4147 4148 NTSYSAPI 4149 NTSTATUS 4150 NTAPI 4151 RtlZombifyActivationContext( 4152 PVOID Context 4153 ); 4154 4155 // 4156 // WOW64 Functions 4157 // 4158 NTSYSAPI 4159 NTSTATUS 4160 NTAPI 4161 RtlWow64EnableFsRedirection( 4162 _In_ BOOLEAN Wow64FsEnableRedirection 4163 ); 4164 4165 NTSYSAPI 4166 NTSTATUS 4167 NTAPI 4168 RtlWow64EnableFsRedirectionEx( 4169 _In_ PVOID Wow64FsEnableRedirection, 4170 _Out_ PVOID *OldFsRedirectionLevel 4171 ); 4172 4173 #endif 4174 4175 // 4176 // Registry Functions 4177 // 4178 _IRQL_requires_max_(PASSIVE_LEVEL) 4179 _Must_inspect_result_ 4180 NTSYSAPI 4181 NTSTATUS 4182 NTAPI 4183 RtlCheckRegistryKey( 4184 _In_ ULONG RelativeTo, 4185 _In_ PWSTR Path 4186 ); 4187 4188 NTSYSAPI 4189 NTSTATUS 4190 NTAPI 4191 RtlCreateRegistryKey( 4192 _In_ ULONG RelativeTo, 4193 _In_ PWSTR Path 4194 ); 4195 4196 NTSYSAPI 4197 NTSTATUS 4198 NTAPI 4199 RtlFormatCurrentUserKeyPath( 4200 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length)) 4201 PUNICODE_STRING KeyPath 4202 ); 4203 4204 NTSYSAPI 4205 NTSTATUS 4206 NTAPI 4207 RtlOpenCurrentUser( 4208 _In_ ACCESS_MASK DesiredAccess, 4209 _Out_ PHANDLE KeyHandle 4210 ); 4211 4212 _IRQL_requires_max_(PASSIVE_LEVEL) 4213 NTSYSAPI 4214 NTSTATUS 4215 NTAPI 4216 RtlQueryRegistryValues( 4217 _In_ ULONG RelativeTo, 4218 _In_ PCWSTR Path, 4219 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_) 4220 PRTL_QUERY_REGISTRY_TABLE QueryTable, 4221 _In_opt_ PVOID Context, 4222 _In_opt_ PVOID Environment 4223 ); 4224 4225 _IRQL_requires_max_(PASSIVE_LEVEL) 4226 NTSYSAPI 4227 NTSTATUS 4228 NTAPI 4229 RtlWriteRegistryValue( 4230 _In_ ULONG RelativeTo, 4231 _In_ PCWSTR Path, 4232 _In_z_ PCWSTR ValueName, 4233 _In_ ULONG ValueType, 4234 _In_reads_bytes_opt_(ValueLength) PVOID ValueData, 4235 _In_ ULONG ValueLength 4236 ); 4237 4238 #ifdef NTOS_MODE_USER 4239 NTSYSAPI 4240 NTSTATUS 4241 NTAPI 4242 RtlpNtCreateKey( 4243 _Out_ HANDLE KeyHandle, 4244 _In_ ACCESS_MASK DesiredAccess, 4245 _In_ POBJECT_ATTRIBUTES ObjectAttributes, 4246 _In_ ULONG TitleIndex, 4247 _In_ PUNICODE_STRING Class, 4248 _Out_ PULONG Disposition 4249 ); 4250 4251 NTSYSAPI 4252 NTSTATUS 4253 NTAPI 4254 RtlpNtEnumerateSubKey( 4255 _In_ HANDLE KeyHandle, 4256 _Inout_ PUNICODE_STRING SubKeyName, 4257 _In_ ULONG Index, 4258 _In_ ULONG Unused 4259 ); 4260 4261 NTSYSAPI 4262 NTSTATUS 4263 NTAPI 4264 RtlpNtMakeTemporaryKey( 4265 _In_ HANDLE KeyHandle 4266 ); 4267 4268 NTSYSAPI 4269 NTSTATUS 4270 NTAPI 4271 RtlpNtOpenKey( 4272 _Out_ HANDLE KeyHandle, 4273 _In_ ACCESS_MASK DesiredAccess, 4274 _In_ POBJECT_ATTRIBUTES ObjectAttributes, 4275 _In_ ULONG Unused 4276 ); 4277 4278 NTSYSAPI 4279 NTSTATUS 4280 NTAPI 4281 RtlpNtQueryValueKey( 4282 _In_ HANDLE KeyHandle, 4283 _Out_opt_ PULONG Type, 4284 _Out_opt_ PVOID Data, 4285 _Inout_opt_ PULONG DataLength, 4286 _In_ ULONG Unused 4287 ); 4288 4289 NTSYSAPI 4290 NTSTATUS 4291 NTAPI 4292 RtlpNtSetValueKey( 4293 _In_ HANDLE KeyHandle, 4294 _In_ ULONG Type, 4295 _In_ PVOID Data, 4296 _In_ ULONG DataLength 4297 ); 4298 #endif 4299 4300 // 4301 // NLS Functions 4302 // 4303 NTSYSAPI 4304 VOID 4305 NTAPI 4306 RtlGetDefaultCodePage( 4307 _Out_ PUSHORT AnsiCodePage, 4308 _Out_ PUSHORT OemCodePage 4309 ); 4310 4311 NTSYSAPI 4312 VOID 4313 NTAPI 4314 RtlInitNlsTables( 4315 _In_ PUSHORT AnsiTableBase, 4316 _In_ PUSHORT OemTableBase, 4317 _In_ PUSHORT CaseTableBase, 4318 _Out_ PNLSTABLEINFO NlsTable 4319 ); 4320 4321 _IRQL_requires_max_(PASSIVE_LEVEL) 4322 NTSYSAPI 4323 VOID 4324 NTAPI 4325 RtlInitCodePageTable( 4326 _In_ PUSHORT TableBase, 4327 _Out_ PCPTABLEINFO CodePageTable 4328 ); 4329 4330 NTSYSAPI 4331 VOID 4332 NTAPI 4333 RtlResetRtlTranslations( 4334 _In_ PNLSTABLEINFO NlsTable); 4335 4336 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES) 4337 4338 // 4339 // Misc conversion functions 4340 // 4341 static __inline 4342 LARGE_INTEGER 4343 NTAPI_INLINE 4344 RtlConvertLongToLargeInteger( 4345 _In_ LONG SignedInteger 4346 ) 4347 { 4348 LARGE_INTEGER Result; 4349 4350 Result.QuadPart = SignedInteger; 4351 return Result; 4352 } 4353 4354 static __inline 4355 LARGE_INTEGER 4356 NTAPI_INLINE 4357 RtlEnlargedIntegerMultiply( 4358 _In_ LONG Multiplicand, 4359 _In_ LONG Multiplier 4360 ) 4361 { 4362 LARGE_INTEGER Product; 4363 4364 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; 4365 return Product; 4366 } 4367 4368 static __inline 4369 ULONG 4370 NTAPI_INLINE 4371 RtlEnlargedUnsignedDivide( 4372 _In_ ULARGE_INTEGER Dividend, 4373 _In_ ULONG Divisor, 4374 _In_opt_ PULONG Remainder 4375 ) 4376 { 4377 ULONG Quotient; 4378 4379 Quotient = (ULONG)(Dividend.QuadPart / Divisor); 4380 if (Remainder) { 4381 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 4382 } 4383 4384 return Quotient; 4385 } 4386 4387 static __inline 4388 LARGE_INTEGER 4389 NTAPI_INLINE 4390 RtlEnlargedUnsignedMultiply( 4391 _In_ ULONG Multiplicand, 4392 _In_ ULONG Multiplier 4393 ) 4394 { 4395 LARGE_INTEGER Product; 4396 4397 Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; 4398 return Product; 4399 } 4400 4401 #if defined(_AMD64_) || defined(_IA64_) 4402 static __inline 4403 LARGE_INTEGER 4404 NTAPI_INLINE 4405 RtlExtendedLargeIntegerDivide( 4406 _In_ LARGE_INTEGER Dividend, 4407 _In_ ULONG Divisor, 4408 _Out_opt_ PULONG Remainder) 4409 { 4410 LARGE_INTEGER ret; 4411 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; 4412 if (Remainder) 4413 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 4414 return ret; 4415 } 4416 4417 #else 4418 NTSYSAPI 4419 LARGE_INTEGER 4420 NTAPI 4421 RtlExtendedLargeIntegerDivide( 4422 _In_ LARGE_INTEGER Dividend, 4423 _In_ ULONG Divisor, 4424 _Out_opt_ PULONG Remainder 4425 ); 4426 4427 #endif /* defined(_AMD64_) || defined(_IA64_) */ 4428 4429 #endif 4430 4431 4432 NTSYSAPI 4433 ULONG 4434 NTAPI 4435 RtlUniform( 4436 _In_ PULONG Seed 4437 ); 4438 4439 NTSYSAPI 4440 ULONG 4441 NTAPI 4442 RtlRandom( 4443 _Inout_ PULONG Seed 4444 ); 4445 4446 NTSYSAPI 4447 ULONG 4448 NTAPI 4449 RtlComputeCrc32( 4450 _In_ ULONG InitialCrc, 4451 _In_ const UCHAR *Buffer, 4452 _In_ ULONG Length 4453 ); 4454 4455 // 4456 // Network Functions 4457 // 4458 NTSYSAPI 4459 PSTR 4460 NTAPI 4461 RtlIpv4AddressToStringA( 4462 _In_ const struct in_addr *Addr, 4463 _Out_writes_(16) PCHAR S 4464 ); 4465 4466 NTSYSAPI 4467 PWSTR 4468 NTAPI 4469 RtlIpv4AddressToStringW( 4470 _In_ const struct in_addr *Addr, 4471 _Out_writes_(16) PWCHAR S 4472 ); 4473 4474 NTSYSAPI 4475 NTSTATUS 4476 NTAPI 4477 RtlIpv4AddressToStringExA( 4478 _In_ const struct in_addr *Address, 4479 _In_ USHORT Port, 4480 _Out_writes_to_(*AddressStringLength, *AddressStringLength) PCHAR AddressString, 4481 _Inout_ PULONG AddressStringLength 4482 ); 4483 4484 NTSTATUS 4485 NTAPI 4486 RtlIpv4AddressToStringExW( 4487 _In_ const struct in_addr *Address, 4488 _In_ USHORT Port, 4489 _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWCHAR AddressString, 4490 _Inout_ PULONG AddressStringLength 4491 ); 4492 4493 NTSYSAPI 4494 NTSTATUS 4495 NTAPI 4496 RtlIpv4StringToAddressA( 4497 _In_ PCSTR String, 4498 _In_ BOOLEAN Strict, 4499 _Out_ PCSTR *Terminator, 4500 _Out_ struct in_addr *Addr 4501 ); 4502 4503 NTSYSAPI 4504 NTSTATUS 4505 NTAPI 4506 RtlIpv4StringToAddressW( 4507 _In_ PCWSTR String, 4508 _In_ BOOLEAN Strict, 4509 _Out_ PCWSTR *Terminator, 4510 _Out_ struct in_addr *Addr 4511 ); 4512 4513 NTSYSAPI 4514 NTSTATUS 4515 NTAPI 4516 RtlIpv4StringToAddressExA( 4517 _In_ PCSTR AddressString, 4518 _In_ BOOLEAN Strict, 4519 _Out_ struct in_addr *Address, 4520 _Out_ PUSHORT Port 4521 ); 4522 4523 NTSYSAPI 4524 NTSTATUS 4525 NTAPI 4526 RtlIpv4StringToAddressExW( 4527 _In_ PCWSTR AddressString, 4528 _In_ BOOLEAN Strict, 4529 _Out_ struct in_addr *Address, 4530 _Out_ PUSHORT Port 4531 ); 4532 4533 NTSYSAPI 4534 PSTR 4535 NTAPI 4536 RtlIpv6AddressToStringA( 4537 _In_ const struct in6_addr *Addr, 4538 _Out_writes_(46) PSTR S 4539 ); 4540 4541 NTSYSAPI 4542 PWSTR 4543 NTAPI 4544 RtlIpv6AddressToStringW( 4545 _In_ const struct in6_addr *Addr, 4546 _Out_writes_(46) PWSTR S 4547 ); 4548 4549 NTSYSAPI 4550 NTSTATUS 4551 NTAPI 4552 RtlIpv6AddressToStringExA( 4553 _In_ const struct in6_addr *Address, 4554 _In_ ULONG ScopeId, 4555 _In_ USHORT Port, 4556 _Out_writes_to_(*AddressStringLength, *AddressStringLength) PSTR AddressString, 4557 _Inout_ PULONG AddressStringLength 4558 ); 4559 4560 NTSYSAPI 4561 NTSTATUS 4562 NTAPI 4563 RtlIpv6AddressToStringExW( 4564 _In_ const struct in6_addr *Address, 4565 _In_ ULONG ScopeId, 4566 _In_ USHORT Port, 4567 _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWCHAR AddressString, 4568 _Inout_ PULONG AddressStringLength 4569 ); 4570 4571 NTSYSAPI 4572 NTSTATUS 4573 NTAPI 4574 RtlIpv6StringToAddressA( 4575 _In_ PCSTR String, 4576 _Out_ PCSTR *Terminator, 4577 _Out_ struct in6_addr *Addr 4578 ); 4579 4580 NTSYSAPI 4581 NTSTATUS 4582 NTAPI 4583 RtlIpv6StringToAddressW( 4584 _In_ PCWSTR String, 4585 _Out_ PCWSTR *Terminator, 4586 _Out_ struct in6_addr *Addr 4587 ); 4588 4589 NTSYSAPI 4590 NTSTATUS 4591 NTAPI 4592 RtlIpv6StringToAddressExA( 4593 _In_ PCSTR AddressString, 4594 _Out_ struct in6_addr *Address, 4595 _Out_ PULONG ScopeId, 4596 _Out_ PUSHORT Port 4597 ); 4598 4599 NTSYSAPI 4600 NTSTATUS 4601 NTAPI 4602 RtlIpv6StringToAddressExW( 4603 _In_ PCWSTR AddressString, 4604 _Out_ struct in6_addr *Address, 4605 _Out_ PULONG ScopeId, 4606 _Out_ PUSHORT Port 4607 ); 4608 4609 4610 // 4611 // Time Functions 4612 // 4613 NTSYSAPI 4614 BOOLEAN 4615 NTAPI 4616 RtlCutoverTimeToSystemTime( 4617 _In_ PTIME_FIELDS CutoverTimeFields, 4618 _Out_ PLARGE_INTEGER SystemTime, 4619 _In_ PLARGE_INTEGER CurrentTime, 4620 _In_ BOOLEAN ThisYearsCutoverOnly); 4621 4622 NTSYSAPI 4623 NTSTATUS 4624 NTAPI 4625 RtlQueryTimeZoneInformation( 4626 _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation); 4627 4628 NTSYSAPI 4629 VOID 4630 NTAPI 4631 RtlSecondsSince1970ToTime( 4632 _In_ ULONG SecondsSince1970, 4633 _Out_ PLARGE_INTEGER Time 4634 ); 4635 4636 NTSYSAPI 4637 NTSTATUS 4638 NTAPI 4639 RtlSetTimeZoneInformation( 4640 _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation); 4641 4642 _Success_(return != FALSE) 4643 NTSYSAPI 4644 BOOLEAN 4645 NTAPI 4646 RtlTimeFieldsToTime( 4647 _In_ PTIME_FIELDS TimeFields, 4648 _Out_ PLARGE_INTEGER Time 4649 ); 4650 4651 _Success_(return != FALSE) 4652 NTSYSAPI 4653 BOOLEAN 4654 NTAPI 4655 RtlTimeToSecondsSince1970( 4656 _In_ PLARGE_INTEGER Time, 4657 _Out_ PULONG ElapsedSeconds 4658 ); 4659 4660 NTSYSAPI 4661 VOID 4662 NTAPI 4663 RtlTimeToTimeFields( 4664 PLARGE_INTEGER Time, 4665 PTIME_FIELDS TimeFields 4666 ); 4667 4668 NTSYSAPI 4669 NTSTATUS 4670 NTAPI 4671 RtlSystemTimeToLocalTime( 4672 _In_ PLARGE_INTEGER SystemTime, 4673 _Out_ PLARGE_INTEGER LocalTime 4674 ); 4675 4676 // 4677 // Version Functions 4678 // 4679 _IRQL_requires_max_(PASSIVE_LEVEL) 4680 _Must_inspect_result_ 4681 NTSYSAPI 4682 NTSTATUS 4683 NTAPI 4684 RtlVerifyVersionInfo( 4685 _In_ PRTL_OSVERSIONINFOEXW VersionInfo, 4686 _In_ ULONG TypeMask, 4687 _In_ ULONGLONG ConditionMask 4688 ); 4689 4690 _IRQL_requires_max_(PASSIVE_LEVEL) 4691 NTSYSAPI 4692 NTSTATUS 4693 NTAPI 4694 RtlGetVersion( 4695 _Out_ 4696 _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_) 4697 _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW), 4698 _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_)) 4699 PRTL_OSVERSIONINFOW lpVersionInformation 4700 ); 4701 4702 _IRQL_requires_max_(PASSIVE_LEVEL) 4703 NTSYSAPI 4704 BOOLEAN 4705 NTAPI 4706 RtlGetNtProductType(_Out_ PNT_PRODUCT_TYPE ProductType); 4707 4708 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) 4709 // 4710 // Synchronization functions 4711 // 4712 NTSYSAPI 4713 VOID 4714 NTAPI 4715 RtlInitializeConditionVariable( 4716 _Out_ PRTL_CONDITION_VARIABLE ConditionVariable); 4717 4718 NTSYSAPI 4719 VOID 4720 NTAPI 4721 RtlWakeConditionVariable( 4722 _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable); 4723 4724 NTSYSAPI 4725 VOID 4726 NTAPI 4727 RtlWakeAllConditionVariable( 4728 _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable); 4729 4730 NTSYSAPI 4731 NTSTATUS 4732 NTAPI 4733 RtlSleepConditionVariableCS( 4734 _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable, 4735 _Inout_ PRTL_CRITICAL_SECTION CriticalSection, 4736 _In_opt_ PLARGE_INTEGER TimeOut); 4737 4738 NTSYSAPI 4739 NTSTATUS 4740 NTAPI 4741 RtlSleepConditionVariableSRW( 4742 _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable, 4743 _Inout_ PRTL_SRWLOCK SRWLock, 4744 _In_opt_ PLARGE_INTEGER TimeOut, 4745 _In_ ULONG Flags); 4746 #endif 4747 4748 // 4749 // Secure Memory Functions 4750 // 4751 #ifdef NTOS_MODE_USER 4752 NTSYSAPI 4753 NTSTATUS 4754 NTAPI 4755 RtlRegisterSecureMemoryCacheCallback( 4756 _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback); 4757 4758 NTSYSAPI 4759 BOOLEAN 4760 NTAPI 4761 RtlFlushSecureMemoryCache( 4762 _In_ PVOID MemoryCache, 4763 _In_opt_ SIZE_T MemoryLength 4764 ); 4765 #endif 4766 4767 // 4768 // Boot Status Data Functions 4769 // 4770 #ifdef NTOS_MODE_USER 4771 NTSYSAPI 4772 NTSTATUS 4773 NTAPI 4774 RtlCreateBootStatusDataFile( 4775 VOID 4776 ); 4777 4778 NTSYSAPI 4779 NTSTATUS 4780 NTAPI 4781 RtlGetSetBootStatusData( 4782 _In_ HANDLE FileHandle, 4783 _In_ BOOLEAN WriteMode, 4784 _In_ RTL_BSD_ITEM_TYPE DataClass, 4785 _In_ PVOID Buffer, 4786 _In_ ULONG BufferSize, 4787 _Out_opt_ PULONG ReturnLength 4788 ); 4789 4790 NTSYSAPI 4791 NTSTATUS 4792 NTAPI 4793 RtlLockBootStatusData( 4794 _Out_ PHANDLE FileHandle 4795 ); 4796 4797 NTSYSAPI 4798 NTSTATUS 4799 NTAPI 4800 RtlUnlockBootStatusData( 4801 _In_ HANDLE FileHandle 4802 ); 4803 #endif 4804 4805 #ifdef NTOS_MODE_USER 4806 _Must_inspect_result_ 4807 NTSYSAPI 4808 NTSTATUS 4809 NTAPI 4810 RtlGUIDFromString( 4811 _In_ PUNICODE_STRING GuidString, 4812 _Out_ GUID *Guid); 4813 4814 _Must_inspect_result_ 4815 NTSYSAPI 4816 NTSTATUS 4817 NTAPI 4818 RtlStringFromGUID( 4819 _In_ REFGUID Guid, 4820 _Out_ _At_(GuidString->Buffer, __drv_allocatesMem(Mem)) 4821 PUNICODE_STRING GuidString); 4822 4823 NTSYSAPI 4824 NTSTATUS 4825 NTAPI 4826 RtlComputeImportTableHash( 4827 _In_ HANDLE hFile, 4828 _Out_ PCHAR Hash, 4829 _In_ ULONG ImportTableHashRevision 4830 ); 4831 #endif 4832 4833 // 4834 // MemoryStream functions 4835 // 4836 #ifdef NTOS_MODE_USER 4837 4838 NTSYSAPI 4839 VOID 4840 NTAPI 4841 RtlInitMemoryStream( 4842 _Out_ PRTL_MEMORY_STREAM Stream 4843 ); 4844 4845 NTSYSAPI 4846 VOID 4847 NTAPI 4848 RtlInitOutOfProcessMemoryStream( 4849 _Out_ PRTL_MEMORY_STREAM Stream 4850 ); 4851 4852 NTSYSAPI 4853 VOID 4854 NTAPI 4855 RtlFinalReleaseOutOfProcessMemoryStream( 4856 _In_ PRTL_MEMORY_STREAM Stream 4857 ); 4858 4859 NTSYSAPI 4860 HRESULT 4861 NTAPI 4862 RtlQueryInterfaceMemoryStream( 4863 _In_ struct IStream *This, 4864 _In_ REFIID RequestedIid, 4865 _Outptr_ PVOID *ResultObject 4866 ); 4867 4868 NTSYSAPI 4869 ULONG 4870 NTAPI 4871 RtlAddRefMemoryStream( 4872 _In_ struct IStream *This 4873 ); 4874 4875 NTSYSAPI 4876 ULONG 4877 NTAPI 4878 RtlReleaseMemoryStream( 4879 _In_ struct IStream *This 4880 ); 4881 4882 NTSYSAPI 4883 HRESULT 4884 NTAPI 4885 RtlReadMemoryStream( 4886 _In_ struct IStream *This, 4887 _Out_writes_bytes_(Length) PVOID Buffer, 4888 _In_ ULONG Length, 4889 _Out_opt_ PULONG BytesRead 4890 ); 4891 4892 NTSYSAPI 4893 HRESULT 4894 NTAPI 4895 RtlReadOutOfProcessMemoryStream( 4896 _In_ struct IStream *This, 4897 _Out_writes_bytes_(Length) PVOID Buffer, 4898 _In_ ULONG Length, 4899 _Out_opt_ PULONG BytesRead 4900 ); 4901 4902 NTSYSAPI 4903 HRESULT 4904 NTAPI 4905 RtlSeekMemoryStream( 4906 _In_ struct IStream *This, 4907 _In_ LARGE_INTEGER RelativeOffset, 4908 _In_ ULONG Origin, 4909 _Out_opt_ PULARGE_INTEGER ResultOffset 4910 ); 4911 4912 NTSYSAPI 4913 HRESULT 4914 NTAPI 4915 RtlCopyMemoryStreamTo( 4916 _In_ struct IStream *This, 4917 _In_ struct IStream *Target, 4918 _In_ ULARGE_INTEGER Length, 4919 _Out_opt_ PULARGE_INTEGER BytesRead, 4920 _Out_opt_ PULARGE_INTEGER BytesWritten 4921 ); 4922 4923 NTSYSAPI 4924 HRESULT 4925 NTAPI 4926 RtlCopyOutOfProcessMemoryStreamTo( 4927 _In_ struct IStream *This, 4928 _In_ struct IStream *Target, 4929 _In_ ULARGE_INTEGER Length, 4930 _Out_opt_ PULARGE_INTEGER BytesRead, 4931 _Out_opt_ PULARGE_INTEGER BytesWritten 4932 ); 4933 4934 NTSYSAPI 4935 HRESULT 4936 NTAPI 4937 RtlStatMemoryStream( 4938 _In_ struct IStream *This, 4939 _Out_ struct tagSTATSTG *Stats, 4940 _In_ ULONG Flags 4941 ); 4942 4943 // Dummy functions 4944 NTSYSAPI 4945 HRESULT 4946 NTAPI 4947 RtlWriteMemoryStream( 4948 _In_ struct IStream *This, 4949 _In_reads_bytes_(Length) CONST VOID *Buffer, 4950 _In_ ULONG Length, 4951 _Out_opt_ PULONG BytesWritten 4952 ); 4953 4954 NTSYSAPI 4955 HRESULT 4956 NTAPI 4957 RtlSetMemoryStreamSize( 4958 _In_ struct IStream *This, 4959 _In_ ULARGE_INTEGER NewSize 4960 ); 4961 4962 NTSYSAPI 4963 HRESULT 4964 NTAPI 4965 RtlCommitMemoryStream( 4966 _In_ struct IStream *This, 4967 _In_ ULONG CommitFlags 4968 ); 4969 4970 NTSYSAPI 4971 HRESULT 4972 NTAPI 4973 RtlRevertMemoryStream( 4974 _In_ struct IStream *This 4975 ); 4976 4977 NTSYSAPI 4978 HRESULT 4979 NTAPI 4980 RtlLockMemoryStreamRegion( 4981 _In_ struct IStream *This, 4982 _In_ ULARGE_INTEGER Offset, 4983 _In_ ULARGE_INTEGER Length, 4984 _In_ ULONG LockType 4985 ); 4986 4987 NTSYSAPI 4988 HRESULT 4989 NTAPI 4990 RtlUnlockMemoryStreamRegion( 4991 _In_ struct IStream *This, 4992 _In_ ULARGE_INTEGER Offset, 4993 _In_ ULARGE_INTEGER Length, 4994 _In_ ULONG LockType 4995 ); 4996 4997 NTSYSAPI 4998 HRESULT 4999 NTAPI 5000 RtlCloneMemoryStream( 5001 _In_ struct IStream *This, 5002 _Outptr_ struct IStream **ResultStream 5003 ); 5004 5005 NTSYSAPI 5006 NTSTATUS 5007 NTAPI 5008 RtlGetNativeSystemInformation( 5009 _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, 5010 _Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID SystemInformation, 5011 _In_ ULONG SystemInformationLength, 5012 _Out_opt_ PULONG ReturnLength 5013 ); 5014 5015 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA) 5016 5017 NTSYSAPI 5018 VOID 5019 NTAPI 5020 RtlRunOnceInitialize( 5021 _Out_ PRTL_RUN_ONCE RunOnce); 5022 5023 _Maybe_raises_SEH_exception_ 5024 NTSYSAPI 5025 NTSTATUS 5026 NTAPI 5027 RtlRunOnceExecuteOnce( 5028 _Inout_ PRTL_RUN_ONCE RunOnce, 5029 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn, 5030 _Inout_opt_ PVOID Parameter, 5031 _Outptr_opt_result_maybenull_ PVOID *Context); 5032 5033 _Must_inspect_result_ 5034 NTSYSAPI 5035 NTSTATUS 5036 NTAPI 5037 RtlRunOnceBeginInitialize( 5038 _Inout_ PRTL_RUN_ONCE RunOnce, 5039 _In_ ULONG Flags, 5040 _Outptr_opt_result_maybenull_ PVOID *Context); 5041 5042 NTSYSAPI 5043 NTSTATUS 5044 NTAPI 5045 RtlRunOnceComplete( 5046 _Inout_ PRTL_RUN_ONCE RunOnce, 5047 _In_ ULONG Flags, 5048 _In_opt_ PVOID Context); 5049 5050 #endif 5051 5052 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || (defined(__REACTOS__) && defined(_NTDLLBUILD_)) 5053 /* Put NTSYSAPI back when this will be really exported. Only statically linked for now */ 5054 // NTSYSAPI 5055 VOID 5056 NTAPI 5057 RtlInitializeSRWLock(OUT PRTL_SRWLOCK SRWLock); 5058 5059 // NTSYSAPI 5060 VOID 5061 NTAPI 5062 RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock); 5063 5064 // NTSYSAPI 5065 VOID 5066 NTAPI 5067 RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock); 5068 5069 // NTSYSAPI 5070 VOID 5071 NTAPI 5072 RtlReleaseSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock); 5073 5074 // NTSYSAPI 5075 VOID 5076 NTAPI 5077 RtlReleaseSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock); 5078 5079 #endif /* Win vista or Reactos Ntdll build */ 5080 5081 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) || (defined(__REACTOS__) && defined(_NTDLLBUILD_)) 5082 5083 // NTSYSAPI 5084 BOOLEAN 5085 NTAPI 5086 RtlTryAcquireSRWLockShared(PRTL_SRWLOCK SRWLock); 5087 5088 // NTSYSAPI 5089 BOOLEAN 5090 NTAPI 5091 RtlTryAcquireSRWLockExclusive(PRTL_SRWLOCK SRWLock); 5092 5093 #endif /* Win7 or Reactos Ntdll build */ 5094 5095 #endif // NTOS_MODE_USER 5096 5097 NTSYSAPI 5098 NTSTATUS 5099 NTAPI 5100 RtlFindActivationContextSectionGuid( 5101 ULONG flags, 5102 const GUID *extguid, 5103 ULONG section_kind, 5104 const GUID *guid, 5105 void *ptr 5106 ); 5107 5108 #ifdef __cplusplus 5109 } 5110 #endif 5111 5112 #endif 5113