1 /****************************************************************************** 2 * Runtime Library Functions * 3 ******************************************************************************/ 4 5 $if (_WDMDDK_) 6 #define FAST_FAIL_LEGACY_GS_VIOLATION 0 7 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1 8 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2 9 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3 10 #define FAST_FAIL_INCORRECT_STACK 4 11 #define FAST_FAIL_INVALID_ARG 5 12 #define FAST_FAIL_GS_COOKIE_INIT 6 13 #define FAST_FAIL_FATAL_APP_EXIT 7 14 #define FAST_FAIL_RANGE_CHECK_FAILURE 8 15 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9 16 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10 17 #define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11 18 #define FAST_FAIL_INVALID_FIBER_SWITCH 12 19 #define FAST_FAIL_INVALID_SET_OF_CONTEXT 13 20 #define FAST_FAIL_INVALID_REFERENCE_COUNT 14 21 #define FAST_FAIL_INVALID_JUMP_BUFFER 18 22 #define FAST_FAIL_MRDATA_MODIFIED 19 23 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF 24 25 DECLSPEC_NORETURN 26 FORCEINLINE 27 VOID 28 RtlFailFast( 29 _In_ ULONG Code) 30 { 31 __fastfail(Code); 32 } 33 34 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && (defined(_M_CEE_PURE) || defined(_M_CEE_SAFE)) 35 #define NO_KERNEL_LIST_ENTRY_CHECKS 36 #endif 37 38 #if !defined(EXTRA_KERNEL_LIST_ENTRY_CHECKS) && defined(__REACTOS__) 39 #define EXTRA_KERNEL_LIST_ENTRY_CHECKS 40 #endif 41 42 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS) 43 44 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } 45 46 FORCEINLINE 47 VOID 48 InitializeListHead( 49 _Out_ PLIST_ENTRY ListHead) 50 { 51 ListHead->Flink = ListHead->Blink = ListHead; 52 } 53 54 _Must_inspect_result_ 55 FORCEINLINE 56 BOOLEAN 57 IsListEmpty( 58 _In_ const LIST_ENTRY * ListHead) 59 { 60 return (BOOLEAN)(ListHead->Flink == ListHead); 61 } 62 63 FORCEINLINE 64 BOOLEAN 65 RemoveEntryListUnsafe( 66 _In_ PLIST_ENTRY Entry) 67 { 68 PLIST_ENTRY OldFlink; 69 PLIST_ENTRY OldBlink; 70 71 OldFlink = Entry->Flink; 72 OldBlink = Entry->Blink; 73 OldFlink->Blink = OldBlink; 74 OldBlink->Flink = OldFlink; 75 return (BOOLEAN)(OldFlink == OldBlink); 76 } 77 78 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 79 FORCEINLINE 80 VOID 81 FatalListEntryError( 82 _In_ PVOID P1, 83 _In_ PVOID P2, 84 _In_ PVOID P3) 85 { 86 UNREFERENCED_PARAMETER(P1); 87 UNREFERENCED_PARAMETER(P2); 88 UNREFERENCED_PARAMETER(P3); 89 90 RtlFailFast(FAST_FAIL_CORRUPT_LIST_ENTRY); 91 } 92 93 FORCEINLINE 94 VOID 95 RtlpCheckListEntry( 96 _In_ PLIST_ENTRY Entry) 97 { 98 if (Entry->Flink->Blink != Entry || Entry->Blink->Flink != Entry) 99 FatalListEntryError(Entry->Blink, Entry, Entry->Flink); 100 } 101 #endif 102 103 FORCEINLINE 104 BOOLEAN 105 RemoveEntryList( 106 _In_ PLIST_ENTRY Entry) 107 { 108 PLIST_ENTRY OldFlink; 109 PLIST_ENTRY OldBlink; 110 111 OldFlink = Entry->Flink; 112 OldBlink = Entry->Blink; 113 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 114 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS 115 if (OldFlink == Entry || OldBlink == Entry) 116 FatalListEntryError(OldBlink, Entry, OldFlink); 117 #endif 118 if (OldFlink->Blink != Entry || OldBlink->Flink != Entry) 119 FatalListEntryError(OldBlink, Entry, OldFlink); 120 #endif 121 OldFlink->Blink = OldBlink; 122 OldBlink->Flink = OldFlink; 123 return (BOOLEAN)(OldFlink == OldBlink); 124 } 125 126 FORCEINLINE 127 PLIST_ENTRY 128 RemoveHeadList( 129 _Inout_ PLIST_ENTRY ListHead) 130 { 131 PLIST_ENTRY Flink; 132 PLIST_ENTRY Entry; 133 134 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG 135 RtlpCheckListEntry(ListHead); 136 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS 137 if (ListHead->Flink == ListHead || ListHead->Blink == ListHead) 138 FatalListEntryError(ListHead->Blink, ListHead, ListHead->Flink); 139 #endif 140 #endif 141 Entry = ListHead->Flink; 142 Flink = Entry->Flink; 143 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 144 if (Entry->Blink != ListHead || Flink->Blink != Entry) 145 FatalListEntryError(ListHead, Entry, Flink); 146 #endif 147 ListHead->Flink = Flink; 148 Flink->Blink = ListHead; 149 return Entry; 150 } 151 152 FORCEINLINE 153 PLIST_ENTRY 154 RemoveTailList( 155 _Inout_ PLIST_ENTRY ListHead) 156 { 157 PLIST_ENTRY Blink; 158 PLIST_ENTRY Entry; 159 160 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG 161 RtlpCheckListEntry(ListHead); 162 #ifdef EXTRA_KERNEL_LIST_ENTRY_CHECKS 163 if (ListHead->Flink == ListHead || ListHead->Blink == ListHead) 164 FatalListEntryError(ListHead->Blink, ListHead, ListHead->Flink); 165 #endif 166 #endif 167 Entry = ListHead->Blink; 168 Blink = Entry->Blink; 169 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 170 if (Blink->Flink != Entry || Entry->Flink != ListHead) 171 FatalListEntryError(Blink, Entry, ListHead); 172 #endif 173 ListHead->Blink = Blink; 174 Blink->Flink = ListHead; 175 return Entry; 176 } 177 178 FORCEINLINE 179 VOID 180 InsertTailList( 181 _Inout_ PLIST_ENTRY ListHead, 182 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry) 183 { 184 PLIST_ENTRY OldBlink; 185 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG 186 RtlpCheckListEntry(ListHead); 187 #endif 188 OldBlink = ListHead->Blink; 189 Entry->Flink = ListHead; 190 Entry->Blink = OldBlink; 191 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 192 if (OldBlink->Flink != ListHead) 193 FatalListEntryError(OldBlink->Blink, OldBlink, ListHead); 194 #endif 195 OldBlink->Flink = Entry; 196 ListHead->Blink = Entry; 197 } 198 199 FORCEINLINE 200 VOID 201 InsertHeadList( 202 _Inout_ PLIST_ENTRY ListHead, 203 _Inout_ __drv_aliasesMem PLIST_ENTRY Entry) 204 { 205 PLIST_ENTRY OldFlink; 206 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) && DBG 207 RtlpCheckListEntry(ListHead); 208 #endif 209 OldFlink = ListHead->Flink; 210 Entry->Flink = OldFlink; 211 Entry->Blink = ListHead; 212 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 213 if (OldFlink->Blink != ListHead) 214 FatalListEntryError(ListHead, OldFlink, OldFlink->Flink); 215 #endif 216 OldFlink->Blink = Entry; 217 ListHead->Flink = Entry; 218 } 219 220 FORCEINLINE 221 VOID 222 AppendTailList( 223 _Inout_ PLIST_ENTRY ListHead, 224 _Inout_ PLIST_ENTRY ListToAppend) 225 { 226 PLIST_ENTRY ListEnd = ListHead->Blink; 227 228 #if !defined(NO_KERNEL_LIST_ENTRY_CHECKS) 229 RtlpCheckListEntry(ListHead); 230 RtlpCheckListEntry(ListToAppend); 231 #endif 232 ListHead->Blink->Flink = ListToAppend; 233 ListHead->Blink = ListToAppend->Blink; 234 ListToAppend->Blink->Flink = ListHead; 235 ListToAppend->Blink = ListEnd; 236 } 237 238 FORCEINLINE 239 PSINGLE_LIST_ENTRY 240 PopEntryList( 241 _Inout_ PSINGLE_LIST_ENTRY ListHead) 242 { 243 PSINGLE_LIST_ENTRY FirstEntry; 244 FirstEntry = ListHead->Next; 245 if (FirstEntry != NULL) { 246 ListHead->Next = FirstEntry->Next; 247 } 248 return FirstEntry; 249 } 250 251 FORCEINLINE 252 VOID 253 PushEntryList( 254 _Inout_ PSINGLE_LIST_ENTRY ListHead, 255 _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry) 256 { 257 Entry->Next = ListHead->Next; 258 ListHead->Next = Entry; 259 } 260 261 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ 262 263 __analysis_noreturn 264 NTSYSAPI 265 VOID 266 NTAPI 267 RtlAssert( 268 _In_ PVOID FailedAssertion, 269 _In_ PVOID FileName, 270 _In_ ULONG LineNumber, 271 _In_opt_z_ PSTR Message); 272 273 /* VOID 274 * RtlCopyMemory( 275 * IN VOID UNALIGNED *Destination, 276 * IN CONST VOID UNALIGNED *Source, 277 * IN SIZE_T Length) 278 */ 279 #define RtlCopyMemory(Destination, Source, Length) \ 280 memcpy(Destination, Source, Length) 281 282 #define RtlCopyBytes RtlCopyMemory 283 284 #if defined(_M_AMD64) 285 NTSYSAPI 286 VOID 287 NTAPI 288 RtlCopyMemoryNonTemporal( 289 _Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination, 290 _In_reads_bytes_(Length) const VOID UNALIGNED *Source, 291 _In_ SIZE_T Length); 292 #else 293 #define RtlCopyMemoryNonTemporal RtlCopyMemory 294 #endif 295 296 /* BOOLEAN 297 * RtlEqualLuid( 298 * IN PLUID Luid1, 299 * IN PLUID Luid2) 300 */ 301 #define RtlEqualLuid(Luid1, Luid2) \ 302 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart)) 303 304 /* LOGICAL 305 * RtlEqualMemory( 306 * IN VOID UNALIGNED *Destination, 307 * IN CONST VOID UNALIGNED *Source, 308 * IN SIZE_T Length) 309 */ 310 #define RtlEqualMemory(Destination, Source, Length) \ 311 (!memcmp(Destination, Source, Length)) 312 313 /* VOID 314 * RtlFillMemory( 315 * IN VOID UNALIGNED *Destination, 316 * IN SIZE_T Length, 317 * IN UCHAR Fill) 318 */ 319 #define RtlFillMemory(Destination, Length, Fill) \ 320 memset(Destination, Fill, Length) 321 322 #define RtlFillBytes RtlFillMemory 323 324 _IRQL_requires_max_(PASSIVE_LEVEL) 325 NTSYSAPI 326 VOID 327 NTAPI 328 RtlFreeUnicodeString( 329 _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem)) 330 PUNICODE_STRING UnicodeString); 331 332 _IRQL_requires_max_(PASSIVE_LEVEL) 333 _Must_inspect_result_ 334 NTSYSAPI 335 NTSTATUS 336 NTAPI 337 RtlGUIDFromString( 338 _In_ PUNICODE_STRING GuidString, 339 _Out_ GUID *Guid); 340 341 _IRQL_requires_max_(DISPATCH_LEVEL) 342 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString)) 343 _When_(SourceString != NULL, 344 _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR))) 345 _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR)))) 346 _When_(SourceString == NULL, 347 _At_(DestinationString->Length, _Post_equal_to_(0)) 348 _At_(DestinationString->MaximumLength, _Post_equal_to_(0))) 349 NTSYSAPI 350 VOID 351 NTAPI 352 RtlInitUnicodeString( 353 _Out_ PUNICODE_STRING DestinationString, 354 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString); 355 356 /* VOID 357 * RtlMoveMemory( 358 * IN VOID UNALIGNED *Destination, 359 * IN CONST VOID UNALIGNED *Source, 360 * IN SIZE_T Length) 361 */ 362 #define RtlMoveMemory(Destination, Source, Length) \ 363 memmove(Destination, Source, Length) 364 365 _IRQL_requires_max_(PASSIVE_LEVEL) 366 _Must_inspect_result_ 367 NTSYSAPI 368 NTSTATUS 369 NTAPI 370 RtlStringFromGUID( 371 _In_ REFGUID Guid, 372 _Out_ _At_(GuidString->Buffer, __drv_allocatesMem(Mem)) 373 PUNICODE_STRING GuidString); 374 375 /* VOID 376 * RtlZeroMemory( 377 * IN VOID UNALIGNED *Destination, 378 * IN SIZE_T Length) 379 */ 380 #define RtlZeroMemory(Destination, Length) \ 381 memset(Destination, 0, Length) 382 383 #define RtlZeroBytes RtlZeroMemory 384 $endif (_WDMDDK_) 385 386 #if (NTDDI_VERSION >= NTDDI_WIN2K) 387 388 $if (_WDMDDK_) 389 _Must_inspect_result_ 390 NTSYSAPI 391 BOOLEAN 392 NTAPI 393 RtlAreBitsClear( 394 _In_ PRTL_BITMAP BitMapHeader, 395 _In_ ULONG StartingIndex, 396 _In_ ULONG Length); 397 398 _Must_inspect_result_ 399 NTSYSAPI 400 BOOLEAN 401 NTAPI 402 RtlAreBitsSet( 403 _In_ PRTL_BITMAP BitMapHeader, 404 _In_ ULONG StartingIndex, 405 _In_ ULONG Length); 406 407 _IRQL_requires_max_(PASSIVE_LEVEL) 408 _Must_inspect_result_ 409 NTSYSAPI 410 NTSTATUS 411 NTAPI 412 RtlAnsiStringToUnicodeString( 413 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 414 _When_(!AllocateDestinationString, _Inout_) 415 PUNICODE_STRING DestinationString, 416 _In_ PANSI_STRING SourceString, 417 _In_ BOOLEAN AllocateDestinationString); 418 419 _IRQL_requires_max_(PASSIVE_LEVEL) 420 NTSYSAPI 421 ULONG 422 NTAPI 423 RtlxAnsiStringToUnicodeSize( 424 _In_ PCANSI_STRING AnsiString); 425 426 #define RtlAnsiStringToUnicodeSize(String) ( \ 427 NLS_MB_CODE_PAGE_TAG ? \ 428 RtlxAnsiStringToUnicodeSize(String) : \ 429 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ 430 ) 431 432 _Success_(1) 433 _Unchanged_(Destination->MaximumLength) 434 _Unchanged_(Destination->Buffer) 435 _When_(_Old_(Destination->Length) + Source->Length <= Destination->MaximumLength, 436 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + Source->Length)) 437 _At_(return, _Out_range_(==, 0))) 438 _When_(_Old_(Destination->Length) + Source->Length > Destination->MaximumLength, 439 _Unchanged_(Destination->Length) 440 _At_(return, _Out_range_(<, 0))) 441 NTSYSAPI 442 NTSTATUS 443 NTAPI 444 RtlAppendUnicodeStringToString( 445 _Inout_ PUNICODE_STRING Destination, 446 _In_ PCUNICODE_STRING Source); 447 448 _Success_(1) 449 _Unchanged_(Destination->MaximumLength) 450 _Unchanged_(Destination->Buffer) 451 /* _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) <= Destination->MaximumLength, 452 _At_(Destination->Length, _Post_equal_to_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR))) 453 _At_(return, _Out_range_(==, 0))) 454 _When_(_Old_(Destination->Length) + _String_length_(Source) * sizeof(WCHAR) > Destination->MaximumLength, 455 _Unchanged_(Destination->Length) 456 _At_(return, _Out_range_(<, 0))) */ 457 NTSYSAPI 458 NTSTATUS 459 NTAPI 460 RtlAppendUnicodeToString( 461 _Inout_ PUNICODE_STRING Destination, 462 _In_opt_z_ PCWSTR Source); 463 464 _IRQL_requires_max_(PASSIVE_LEVEL) 465 _Must_inspect_result_ 466 NTSYSAPI 467 NTSTATUS 468 NTAPI 469 RtlCheckRegistryKey( 470 _In_ ULONG RelativeTo, 471 _In_ PWSTR Path); 472 473 NTSYSAPI 474 VOID 475 NTAPI 476 RtlClearAllBits( 477 _In_ PRTL_BITMAP BitMapHeader); 478 479 NTSYSAPI 480 VOID 481 NTAPI 482 RtlClearBits( 483 _In_ PRTL_BITMAP BitMapHeader, 484 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, 485 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear); 486 487 _Must_inspect_result_ 488 NTSYSAPI 489 SIZE_T 490 NTAPI 491 RtlCompareMemory( 492 _In_ const VOID *Source1, 493 _In_ const VOID *Source2, 494 _In_ SIZE_T Length); 495 496 _IRQL_requires_max_(PASSIVE_LEVEL) 497 _Must_inspect_result_ 498 NTSYSAPI 499 LONG 500 NTAPI 501 RtlCompareUnicodeString( 502 _In_ PCUNICODE_STRING String1, 503 _In_ PCUNICODE_STRING String2, 504 _In_ BOOLEAN CaseInSensitive); 505 506 _IRQL_requires_max_(PASSIVE_LEVEL) 507 _Must_inspect_result_ 508 NTSYSAPI 509 LONG 510 NTAPI 511 RtlCompareUnicodeStrings( 512 _In_reads_(String1Length) PCWCH String1, 513 _In_ SIZE_T String1Length, 514 _In_reads_(String2Length) PCWCH String2, 515 _In_ SIZE_T String2Length, 516 _In_ BOOLEAN CaseInSensitive); 517 518 _Unchanged_(DestinationString->Buffer) 519 _Unchanged_(DestinationString->MaximumLength) 520 _At_(DestinationString->Length, 521 _When_(SourceString->Length > DestinationString->MaximumLength, 522 _Post_equal_to_(DestinationString->MaximumLength)) 523 _When_(SourceString->Length <= DestinationString->MaximumLength, 524 _Post_equal_to_(SourceString->Length))) 525 NTSYSAPI 526 VOID 527 NTAPI 528 RtlCopyUnicodeString( 529 _Inout_ PUNICODE_STRING DestinationString, 530 _In_opt_ PCUNICODE_STRING SourceString); 531 532 _IRQL_requires_max_(PASSIVE_LEVEL) 533 NTSYSAPI 534 NTSTATUS 535 NTAPI 536 RtlCreateRegistryKey( 537 _In_ ULONG RelativeTo, 538 _In_ PWSTR Path); 539 540 _IRQL_requires_max_(APC_LEVEL) 541 NTSYSAPI 542 NTSTATUS 543 NTAPI 544 RtlCreateSecurityDescriptor( 545 _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, 546 _In_ ULONG Revision); 547 548 _IRQL_requires_max_(PASSIVE_LEVEL) 549 NTSYSAPI 550 NTSTATUS 551 NTAPI 552 RtlDeleteRegistryValue( 553 _In_ ULONG RelativeTo, 554 _In_ PCWSTR Path, 555 _In_z_ PCWSTR ValueName); 556 557 _IRQL_requires_max_(PASSIVE_LEVEL) 558 _Must_inspect_result_ 559 NTSYSAPI 560 BOOLEAN 561 NTAPI 562 RtlEqualUnicodeString( 563 _In_ CONST UNICODE_STRING *String1, 564 _In_ CONST UNICODE_STRING *String2, 565 _In_ BOOLEAN CaseInSensitive); 566 567 #if !defined(_AMD64_) && !defined(_IA64_) 568 NTSYSAPI 569 LARGE_INTEGER 570 NTAPI 571 RtlExtendedIntegerMultiply( 572 _In_ LARGE_INTEGER Multiplicand, 573 _In_ LONG Multiplier); 574 575 NTSYSAPI 576 LARGE_INTEGER 577 NTAPI 578 RtlExtendedLargeIntegerDivide( 579 _In_ LARGE_INTEGER Dividend, 580 _In_ ULONG Divisor, 581 _Out_opt_ PULONG Remainder); 582 #endif 583 584 #if defined(_X86_) || defined(_IA64_) 585 NTSYSAPI 586 LARGE_INTEGER 587 NTAPI 588 RtlExtendedMagicDivide( 589 _In_ LARGE_INTEGER Dividend, 590 _In_ LARGE_INTEGER MagicDivisor, 591 _In_ CCHAR ShiftCount); 592 #endif 593 594 _IRQL_requires_max_(PASSIVE_LEVEL) 595 NTSYSAPI 596 VOID 597 NTAPI 598 RtlFreeAnsiString( 599 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem)) 600 PANSI_STRING AnsiString); 601 602 _Success_(return != -1) 603 _Must_inspect_result_ 604 NTSYSAPI 605 ULONG 606 NTAPI 607 RtlFindClearBits( 608 _In_ PRTL_BITMAP BitMapHeader, 609 _In_ ULONG NumberToFind, 610 _In_ ULONG HintIndex); 611 612 _Success_(return != -1) 613 NTSYSAPI 614 ULONG 615 NTAPI 616 RtlFindClearBitsAndSet( 617 _In_ PRTL_BITMAP BitMapHeader, 618 _In_ ULONG NumberToFind, 619 _In_ ULONG HintIndex); 620 621 NTSYSAPI 622 ULONG 623 NTAPI 624 RtlFindFirstRunClear( 625 _In_ PRTL_BITMAP BitMapHeader, 626 _Out_ PULONG StartingIndex); 627 628 NTSYSAPI 629 ULONG 630 NTAPI 631 RtlFindClearRuns( 632 _In_ PRTL_BITMAP BitMapHeader, 633 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray, 634 _In_range_(>, 0) ULONG SizeOfRunArray, 635 _In_ BOOLEAN LocateLongestRuns); 636 637 NTSYSAPI 638 ULONG 639 NTAPI 640 RtlFindLastBackwardRunClear( 641 _In_ PRTL_BITMAP BitMapHeader, 642 _In_ ULONG FromIndex, 643 _Out_ PULONG StartingRunIndex); 644 645 _Success_(return != -1) 646 _Must_inspect_result_ 647 NTSYSAPI 648 CCHAR 649 NTAPI 650 RtlFindLeastSignificantBit( 651 _In_ ULONGLONG Set); 652 653 NTSYSAPI 654 ULONG 655 NTAPI 656 RtlFindLongestRunClear( 657 _In_ PRTL_BITMAP BitMapHeader, 658 _Out_ PULONG StartingIndex); 659 660 _Success_(return != -1) 661 _Must_inspect_result_ 662 NTSYSAPI 663 CCHAR 664 NTAPI 665 RtlFindMostSignificantBit( 666 _In_ ULONGLONG Set); 667 668 NTSYSAPI 669 ULONG 670 NTAPI 671 RtlFindNextForwardRunClear( 672 _In_ PRTL_BITMAP BitMapHeader, 673 _In_ ULONG FromIndex, 674 _Out_ PULONG StartingRunIndex); 675 676 NTSYSAPI 677 ULONG 678 NTAPI 679 RtlFindNextForwardRunSet( 680 _In_ PRTL_BITMAP BitMapHeader, 681 _In_ ULONG FromIndex, 682 _Out_ PULONG StartingRunIndex); 683 684 _Success_(return != -1) 685 _Must_inspect_result_ 686 NTSYSAPI 687 ULONG 688 NTAPI 689 RtlFindSetBits( 690 _In_ PRTL_BITMAP BitMapHeader, 691 _In_ ULONG NumberToFind, 692 _In_ ULONG HintIndex); 693 694 _Success_(return != -1) 695 NTSYSAPI 696 ULONG 697 NTAPI 698 RtlFindSetBitsAndClear( 699 _In_ PRTL_BITMAP BitMapHeader, 700 _In_ ULONG NumberToFind, 701 _In_ ULONG HintIndex); 702 703 _IRQL_requires_max_(DISPATCH_LEVEL) 704 NTSYSAPI 705 VOID 706 NTAPI 707 RtlInitAnsiString( 708 _Out_ PANSI_STRING DestinationString, 709 _In_opt_z_ __drv_aliasesMem PCSZ SourceString); 710 711 _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap)) 712 _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer)) 713 NTSYSAPI 714 VOID 715 NTAPI 716 RtlInitializeBitMap( 717 _Out_ PRTL_BITMAP BitMapHeader, 718 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer, 719 _In_opt_ ULONG SizeOfBitMap); 720 721 _IRQL_requires_max_(DISPATCH_LEVEL) 722 NTSYSAPI 723 VOID 724 NTAPI 725 RtlInitString( 726 _Out_ PSTRING DestinationString, 727 _In_opt_z_ __drv_aliasesMem PCSZ SourceString); 728 729 _IRQL_requires_max_(PASSIVE_LEVEL) 730 _At_(String->MaximumLength, _Const_) 731 NTSYSAPI 732 NTSTATUS 733 NTAPI 734 RtlIntegerToUnicodeString( 735 _In_ ULONG Value, 736 _In_opt_ ULONG Base, 737 _Inout_ PUNICODE_STRING String); 738 739 _IRQL_requires_max_(PASSIVE_LEVEL) 740 _At_(String->MaximumLength, _Const_) 741 NTSYSAPI 742 NTSTATUS 743 NTAPI 744 RtlInt64ToUnicodeString( 745 _In_ ULONGLONG Value, 746 _In_opt_ ULONG Base, 747 _Inout_ PUNICODE_STRING String); 748 749 #ifdef _WIN64 750 #define RtlIntPtrToUnicodeString(Value, Base, String) \ 751 RtlInt64ToUnicodeString(Value, Base, String) 752 #else 753 #define RtlIntPtrToUnicodeString(Value, Base, String) \ 754 RtlIntegerToUnicodeString(Value, Base, String) 755 #endif 756 757 /* BOOLEAN 758 * RtlIsZeroLuid( 759 * IN PLUID L1); 760 */ 761 #define RtlIsZeroLuid(_L1) \ 762 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart))) 763 764 _IRQL_requires_max_(APC_LEVEL) 765 NTSYSAPI 766 ULONG 767 NTAPI 768 RtlLengthSecurityDescriptor( 769 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor); 770 771 NTSYSAPI 772 ULONG 773 NTAPI 774 RtlNumberOfClearBits( 775 _In_ PRTL_BITMAP BitMapHeader); 776 777 NTSYSAPI 778 ULONG 779 NTAPI 780 RtlNumberOfSetBits( 781 _In_ PRTL_BITMAP BitMapHeader); 782 783 _IRQL_requires_max_(PASSIVE_LEVEL) 784 NTSYSAPI 785 NTSTATUS 786 NTAPI 787 RtlQueryRegistryValues( 788 _In_ ULONG RelativeTo, 789 _In_ PCWSTR Path, 790 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_) 791 PRTL_QUERY_REGISTRY_TABLE QueryTable, 792 _In_opt_ PVOID Context, 793 _In_opt_ PVOID Environment); 794 795 #define SHORT_SIZE (sizeof(USHORT)) 796 #define SHORT_MASK (SHORT_SIZE - 1) 797 #define LONG_SIZE (sizeof(LONG)) 798 #define LONGLONG_SIZE (sizeof(LONGLONG)) 799 #define LONG_MASK (LONG_SIZE - 1) 800 #define LONGLONG_MASK (LONGLONG_SIZE - 1) 801 #define LOWBYTE_MASK 0x00FF 802 803 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) 804 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) 805 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) 806 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) 807 808 NTSYSAPI 809 VOID 810 NTAPI 811 RtlSetAllBits( 812 _In_ PRTL_BITMAP BitMapHeader); 813 814 NTSYSAPI 815 VOID 816 NTAPI 817 RtlSetBits( 818 _In_ PRTL_BITMAP BitMapHeader, 819 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, 820 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet); 821 822 _IRQL_requires_max_(APC_LEVEL) 823 NTSYSAPI 824 NTSTATUS 825 NTAPI 826 RtlSetDaclSecurityDescriptor( 827 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 828 _In_ BOOLEAN DaclPresent, 829 _In_opt_ PACL Dacl, 830 _In_opt_ BOOLEAN DaclDefaulted); 831 832 // 833 // These functions are really bad and shouldn't be used. 834 // They have no type checking and can easily overwrite the target 835 // variable or only set half of it. 836 // Use Read/WriteUnalignedU16/U32/U64 from reactos/unaligned.h instead. 837 // 838 #if defined(_AMD64_) || defined(_M_AMD64) || defined(_X86) || defined(_M_IX86) 839 840 /* VOID 841 * RtlStoreUlong( 842 * IN PULONG Address, 843 * IN ULONG Value); 844 */ 845 #define RtlStoreUlong(Address,Value) \ 846 *(ULONG UNALIGNED *)(Address) = (Value) 847 848 /* VOID 849 * RtlStoreUlonglong( 850 * IN OUT PULONGLONG Address, 851 * ULONGLONG Value); 852 */ 853 #define RtlStoreUlonglong(Address,Value) \ 854 *(ULONGLONG UNALIGNED *)(Address) = (Value) 855 856 /* VOID 857 * RtlStoreUshort( 858 * IN PUSHORT Address, 859 * IN USHORT Value); 860 */ 861 #define RtlStoreUshort(Address,Value) \ 862 *(USHORT UNALIGNED *)(Address) = (Value) 863 864 /* VOID 865 * RtlRetrieveUshort( 866 * PUSHORT DestinationAddress, 867 * PUSHORT SourceAddress); 868 */ 869 #define RtlRetrieveUshort(DestAddress,SrcAddress) \ 870 *(USHORT*)(DestAddress) = *(USHORT UNALIGNED *)(SrcAddress) 871 872 /* VOID 873 * RtlRetrieveUlong( 874 * PULONG DestinationAddress, 875 * PULONG SourceAddress); 876 */ 877 #define RtlRetrieveUlong(DestAddress,SrcAddress) \ 878 *(ULONG*)(DestAddress) = *(ULONG UNALIGNED *)(SrcAddress) 879 880 #else 881 882 #define RtlStoreUlong(Address,Value) \ 883 if ((ULONG_PTR)(Address) & LONG_MASK) { \ 884 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ 885 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ 886 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ 887 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ 888 } \ 889 else { \ 890 *((PULONG)(Address)) = (ULONG) (Value); \ 891 } 892 893 #define RtlStoreUlonglong(Address,Value) \ 894 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ 895 RtlStoreUlong((ULONG_PTR)(Address), \ 896 (ULONGLONG)(Value) & 0xFFFFFFFF); \ 897 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ 898 (ULONGLONG)(Value) >> 32); \ 899 } else { \ 900 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ 901 } 902 903 #define RtlStoreUshort(Address,Value) \ 904 if ((ULONG_PTR)(Address) & SHORT_MASK) { \ 905 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ 906 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ 907 } \ 908 else { \ 909 *((PUSHORT) (Address)) = (USHORT)Value; \ 910 } 911 912 #define RtlRetrieveUshort(DestAddress,SrcAddress) \ 913 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ 914 { \ 915 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ 916 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ 917 } \ 918 else \ 919 { \ 920 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ 921 } 922 923 #define RtlRetrieveUlong(DestAddress,SrcAddress) \ 924 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ 925 { \ 926 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ 927 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ 928 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \ 929 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \ 930 } \ 931 else \ 932 { \ 933 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ 934 } 935 936 #endif /* defined(_AMD64_) || defined(_M_AMD64) || defined(_X86) || defined(_M_IX86) */ 937 938 #ifdef _WIN64 939 /* VOID 940 * RtlStoreUlongPtr( 941 * IN OUT PULONG_PTR Address, 942 * IN ULONG_PTR Value); 943 */ 944 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) 945 #else 946 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) 947 #endif /* _WIN64 */ 948 949 _Success_(return != FALSE) 950 NTSYSAPI 951 BOOLEAN 952 NTAPI 953 RtlTimeFieldsToTime( 954 _In_ PTIME_FIELDS TimeFields, 955 _Out_ PLARGE_INTEGER Time); 956 957 NTSYSAPI 958 VOID 959 NTAPI 960 RtlTimeToTimeFields( 961 _In_ PLARGE_INTEGER Time, 962 _Out_ PTIME_FIELDS TimeFields); 963 964 NTSYSAPI 965 USHORT 966 FASTCALL 967 RtlUshortByteSwap( 968 _In_ USHORT Source); 969 970 NTSYSAPI 971 ULONG 972 FASTCALL 973 RtlUlongByteSwap( 974 _In_ ULONG Source); 975 976 NTSYSAPI 977 ULONGLONG 978 FASTCALL 979 RtlUlonglongByteSwap( 980 _In_ ULONGLONG Source); 981 982 _When_(AllocateDestinationString, 983 _At_(DestinationString->MaximumLength, 984 _Out_range_(<=, (SourceString->MaximumLength / sizeof(WCHAR))))) 985 _When_(!AllocateDestinationString, 986 _At_(DestinationString->Buffer, _Const_) 987 _At_(DestinationString->MaximumLength, _Const_)) 988 _IRQL_requires_max_(PASSIVE_LEVEL) 989 _When_(AllocateDestinationString, _Must_inspect_result_) 990 NTSYSAPI 991 NTSTATUS 992 NTAPI 993 RtlUnicodeStringToAnsiString( 994 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 995 _When_(!AllocateDestinationString, _Inout_) 996 PANSI_STRING DestinationString, 997 _In_ PCUNICODE_STRING SourceString, 998 _In_ BOOLEAN AllocateDestinationString); 999 1000 _IRQL_requires_max_(PASSIVE_LEVEL) 1001 _Must_inspect_result_ 1002 NTSYSAPI 1003 NTSTATUS 1004 NTAPI 1005 RtlUpcaseUnicodeStringToAnsiString( 1006 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1007 _When_(!AllocateDestinationString, _Inout_) 1008 PANSI_STRING DestinationString, 1009 _In_ PCUNICODE_STRING SourceString, 1010 _In_ BOOLEAN AllocateDestinationString); 1011 1012 _IRQL_requires_max_(PASSIVE_LEVEL) 1013 NTSYSAPI 1014 ULONG 1015 NTAPI 1016 RtlxUnicodeStringToAnsiSize( 1017 _In_ PCUNICODE_STRING UnicodeString); 1018 1019 #define RtlUnicodeStringToAnsiSize(String) ( \ 1020 NLS_MB_CODE_PAGE_TAG ? \ 1021 RtlxUnicodeStringToAnsiSize(String) : \ 1022 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ 1023 ) 1024 1025 _IRQL_requires_max_(PASSIVE_LEVEL) 1026 NTSYSAPI 1027 NTSTATUS 1028 NTAPI 1029 RtlUnicodeStringToInteger( 1030 _In_ PCUNICODE_STRING String, 1031 _In_opt_ ULONG Base, 1032 _Out_ PULONG Value); 1033 1034 _IRQL_requires_max_(PASSIVE_LEVEL) 1035 NTSYSAPI 1036 WCHAR 1037 NTAPI 1038 RtlUpcaseUnicodeChar( 1039 _In_ WCHAR SourceCharacter); 1040 1041 _IRQL_requires_max_(APC_LEVEL) 1042 _Must_inspect_result_ 1043 NTSYSAPI 1044 BOOLEAN 1045 NTAPI 1046 RtlValidRelativeSecurityDescriptor( 1047 _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput, 1048 _In_ ULONG SecurityDescriptorLength, 1049 _In_ SECURITY_INFORMATION RequiredInformation); 1050 1051 _IRQL_requires_max_(APC_LEVEL) 1052 _Must_inspect_result_ 1053 NTSYSAPI 1054 BOOLEAN 1055 NTAPI 1056 RtlValidSecurityDescriptor( 1057 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor); 1058 1059 _IRQL_requires_max_(PASSIVE_LEVEL) 1060 NTSYSAPI 1061 NTSTATUS 1062 NTAPI 1063 RtlGetVersion( 1064 _Out_ 1065 _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_) 1066 _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW), 1067 _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_)) 1068 PRTL_OSVERSIONINFOW lpVersionInformation); 1069 1070 _IRQL_requires_max_(PASSIVE_LEVEL) 1071 _Must_inspect_result_ 1072 NTSYSAPI 1073 NTSTATUS 1074 NTAPI 1075 RtlVerifyVersionInfo( 1076 _In_ PRTL_OSVERSIONINFOEXW VersionInfo, 1077 _In_ ULONG TypeMask, 1078 _In_ ULONGLONG ConditionMask); 1079 1080 _IRQL_requires_max_(PASSIVE_LEVEL) 1081 NTSYSAPI 1082 NTSTATUS 1083 NTAPI 1084 RtlWriteRegistryValue( 1085 _In_ ULONG RelativeTo, 1086 _In_ PCWSTR Path, 1087 _In_z_ PCWSTR ValueName, 1088 _In_ ULONG ValueType, 1089 _In_reads_bytes_opt_(ValueLength) PVOID ValueData, 1090 _In_ ULONG ValueLength); 1091 1092 $endif (_WDMDDK_) 1093 $if (_NTDDK_) 1094 1095 #ifndef RTL_USE_AVL_TABLES 1096 1097 NTSYSAPI 1098 VOID 1099 NTAPI 1100 RtlInitializeGenericTable( 1101 _Out_ PRTL_GENERIC_TABLE Table, 1102 _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, 1103 _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, 1104 _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine, 1105 _In_opt_ PVOID TableContext); 1106 1107 NTSYSAPI 1108 PVOID 1109 NTAPI 1110 RtlInsertElementGenericTable( 1111 _In_ PRTL_GENERIC_TABLE Table, 1112 _In_reads_bytes_(BufferSize) PVOID Buffer, 1113 _In_ CLONG BufferSize, 1114 _Out_opt_ PBOOLEAN NewElement); 1115 1116 NTSYSAPI 1117 PVOID 1118 NTAPI 1119 RtlInsertElementGenericTableFull( 1120 _In_ PRTL_GENERIC_TABLE Table, 1121 _In_reads_bytes_(BufferSize) PVOID Buffer, 1122 _In_ CLONG BufferSize, 1123 _Out_opt_ PBOOLEAN NewElement, 1124 _In_ PVOID NodeOrParent, 1125 _In_ TABLE_SEARCH_RESULT SearchResult); 1126 1127 NTSYSAPI 1128 BOOLEAN 1129 NTAPI 1130 RtlDeleteElementGenericTable( 1131 _In_ PRTL_GENERIC_TABLE Table, 1132 _In_ PVOID Buffer); 1133 1134 _Must_inspect_result_ 1135 NTSYSAPI 1136 PVOID 1137 NTAPI 1138 RtlLookupElementGenericTable( 1139 _In_ PRTL_GENERIC_TABLE Table, 1140 _In_ PVOID Buffer); 1141 1142 NTSYSAPI 1143 PVOID 1144 NTAPI 1145 RtlLookupElementGenericTableFull( 1146 _In_ PRTL_GENERIC_TABLE Table, 1147 _In_ PVOID Buffer, 1148 _Out_ PVOID *NodeOrParent, 1149 _Out_ TABLE_SEARCH_RESULT *SearchResult); 1150 1151 _Must_inspect_result_ 1152 NTSYSAPI 1153 PVOID 1154 NTAPI 1155 RtlEnumerateGenericTable( 1156 _In_ PRTL_GENERIC_TABLE Table, 1157 _In_ BOOLEAN Restart); 1158 1159 _Must_inspect_result_ 1160 NTSYSAPI 1161 PVOID 1162 NTAPI 1163 RtlEnumerateGenericTableWithoutSplaying( 1164 _In_ PRTL_GENERIC_TABLE Table, 1165 _Inout_ PVOID *RestartKey); 1166 1167 _Must_inspect_result_ 1168 NTSYSAPI 1169 PVOID 1170 NTAPI 1171 RtlGetElementGenericTable( 1172 _In_ PRTL_GENERIC_TABLE Table, 1173 _In_ ULONG I); 1174 1175 NTSYSAPI 1176 ULONG 1177 NTAPI 1178 RtlNumberGenericTableElements( 1179 _In_ PRTL_GENERIC_TABLE Table); 1180 1181 _Must_inspect_result_ 1182 NTSYSAPI 1183 BOOLEAN 1184 NTAPI 1185 RtlIsGenericTableEmpty( 1186 _In_ PRTL_GENERIC_TABLE Table); 1187 1188 #endif /* !RTL_USE_AVL_TABLES */ 1189 1190 #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 1191 1192 NTSYSAPI 1193 PRTL_SPLAY_LINKS 1194 NTAPI 1195 RtlSplay( 1196 _Inout_ PRTL_SPLAY_LINKS Links); 1197 1198 NTSYSAPI 1199 PRTL_SPLAY_LINKS 1200 NTAPI 1201 RtlDelete( 1202 _In_ PRTL_SPLAY_LINKS Links); 1203 1204 NTSYSAPI 1205 VOID 1206 NTAPI 1207 RtlDeleteNoSplay( 1208 _In_ PRTL_SPLAY_LINKS Links, 1209 _Inout_ PRTL_SPLAY_LINKS *Root); 1210 1211 _Must_inspect_result_ 1212 NTSYSAPI 1213 PRTL_SPLAY_LINKS 1214 NTAPI 1215 RtlSubtreeSuccessor( 1216 _In_ PRTL_SPLAY_LINKS Links); 1217 1218 _Must_inspect_result_ 1219 NTSYSAPI 1220 PRTL_SPLAY_LINKS 1221 NTAPI 1222 RtlSubtreePredecessor( 1223 _In_ PRTL_SPLAY_LINKS Links); 1224 1225 _Must_inspect_result_ 1226 NTSYSAPI 1227 PRTL_SPLAY_LINKS 1228 NTAPI 1229 RtlRealSuccessor( 1230 _In_ PRTL_SPLAY_LINKS Links); 1231 1232 _Must_inspect_result_ 1233 NTSYSAPI 1234 PRTL_SPLAY_LINKS 1235 NTAPI 1236 RtlRealPredecessor( 1237 _In_ PRTL_SPLAY_LINKS Links); 1238 1239 _IRQL_requires_max_(PASSIVE_LEVEL) 1240 _Must_inspect_result_ 1241 NTSYSAPI 1242 BOOLEAN 1243 NTAPI 1244 RtlPrefixUnicodeString( 1245 _In_ PCUNICODE_STRING String1, 1246 _In_ PCUNICODE_STRING String2, 1247 _In_ BOOLEAN CaseInSensitive); 1248 1249 _IRQL_requires_max_(PASSIVE_LEVEL) 1250 NTSYSAPI 1251 VOID 1252 NTAPI 1253 RtlUpperString( 1254 _Inout_ PSTRING DestinationString, 1255 _In_ const STRING *SourceString); 1256 1257 _IRQL_requires_max_(PASSIVE_LEVEL) 1258 _When_(AllocateDestinationString, _Must_inspect_result_) 1259 NTSYSAPI 1260 NTSTATUS 1261 NTAPI 1262 RtlUpcaseUnicodeString( 1263 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1264 _When_(!AllocateDestinationString, _Inout_) 1265 PUNICODE_STRING DestinationString, 1266 _In_ PCUNICODE_STRING SourceString, 1267 _In_ BOOLEAN AllocateDestinationString); 1268 1269 _IRQL_requires_max_(APC_LEVEL) 1270 NTSYSAPI 1271 VOID 1272 NTAPI 1273 RtlMapGenericMask( 1274 _Inout_ PACCESS_MASK AccessMask, 1275 _In_ PGENERIC_MAPPING GenericMapping); 1276 1277 _IRQL_requires_max_(PASSIVE_LEVEL) 1278 NTSYSAPI 1279 NTSTATUS 1280 NTAPI 1281 RtlVolumeDeviceToDosName( 1282 _In_ PVOID VolumeDeviceObject, 1283 _Out_ PUNICODE_STRING DosName); 1284 1285 _IRQL_requires_max_(PASSIVE_LEVEL) 1286 _Must_inspect_result_ 1287 NTSYSAPI 1288 LONG 1289 NTAPI 1290 RtlCompareString( 1291 _In_ const STRING *String1, 1292 _In_ const STRING *String2, 1293 _In_ BOOLEAN CaseInSensitive); 1294 1295 NTSYSAPI 1296 VOID 1297 NTAPI 1298 RtlCopyString( 1299 _Out_ PSTRING DestinationString, 1300 _In_opt_ const STRING *SourceString); 1301 1302 _IRQL_requires_max_(PASSIVE_LEVEL) 1303 _Must_inspect_result_ 1304 NTSYSAPI 1305 BOOLEAN 1306 NTAPI 1307 RtlEqualString( 1308 _In_ const STRING *String1, 1309 _In_ const STRING *String2, 1310 _In_ BOOLEAN CaseInSensitive); 1311 1312 _IRQL_requires_max_(PASSIVE_LEVEL) 1313 NTSYSAPI 1314 NTSTATUS 1315 NTAPI 1316 RtlCharToInteger( 1317 _In_z_ PCSZ String, 1318 _In_opt_ ULONG Base, 1319 _Out_ PULONG Value); 1320 1321 _IRQL_requires_max_(PASSIVE_LEVEL) 1322 NTSYSAPI 1323 CHAR 1324 NTAPI 1325 RtlUpperChar( 1326 _In_ CHAR Character); 1327 1328 NTSYSAPI 1329 ULONG 1330 NTAPI 1331 RtlWalkFrameChain( 1332 _Out_writes_(Count - (Flags >> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT)) 1333 PVOID *Callers, 1334 _In_ ULONG Count, 1335 _In_ ULONG Flags); 1336 1337 $endif (_NTDDK_) 1338 $if (_NTIFS_) 1339 1340 _Must_inspect_result_ 1341 _Ret_maybenull_ 1342 _Post_writable_byte_size_(Size) 1343 NTSYSAPI 1344 PVOID 1345 NTAPI 1346 RtlAllocateHeap( 1347 _In_ HANDLE HeapHandle, 1348 _In_opt_ ULONG Flags, 1349 _In_ SIZE_T Size); 1350 1351 _Success_(return != 0) 1352 NTSYSAPI 1353 BOOLEAN 1354 NTAPI 1355 RtlFreeHeap( 1356 _In_ PVOID HeapHandle, 1357 _In_opt_ ULONG Flags, 1358 _In_ _Post_invalid_ PVOID BaseAddress); 1359 1360 NTSYSAPI 1361 VOID 1362 NTAPI 1363 RtlCaptureContext( 1364 _Out_ PCONTEXT ContextRecord); 1365 1366 _Ret_range_(<, MAXLONG) 1367 NTSYSAPI 1368 ULONG 1369 NTAPI 1370 RtlRandom( 1371 _Inout_ PULONG Seed); 1372 1373 _IRQL_requires_max_(APC_LEVEL) 1374 _Success_(return != 0) 1375 _Must_inspect_result_ 1376 NTSYSAPI 1377 BOOLEAN 1378 NTAPI 1379 RtlCreateUnicodeString( 1380 _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)) 1381 PUNICODE_STRING DestinationString, 1382 _In_z_ PCWSTR SourceString); 1383 1384 _IRQL_requires_max_(PASSIVE_LEVEL) 1385 _Must_inspect_result_ 1386 NTSYSAPI 1387 BOOLEAN 1388 NTAPI 1389 RtlPrefixString( 1390 _In_ const STRING *String1, 1391 _In_ const STRING *String2, 1392 _In_ BOOLEAN CaseInsensitive); 1393 1394 _IRQL_requires_max_(APC_LEVEL) 1395 NTSYSAPI 1396 NTSTATUS 1397 NTAPI 1398 RtlAppendStringToString( 1399 _Inout_ PSTRING Destination, 1400 _In_ const STRING *Source); 1401 1402 _IRQL_requires_max_(PASSIVE_LEVEL) 1403 _Must_inspect_result_ 1404 NTSYSAPI 1405 NTSTATUS 1406 NTAPI 1407 RtlOemStringToUnicodeString( 1408 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1409 _When_(!AllocateDestinationString, _Inout_) 1410 PUNICODE_STRING DestinationString, 1411 _In_ PCOEM_STRING SourceString, 1412 _In_ BOOLEAN AllocateDestinationString); 1413 1414 _IRQL_requires_max_(PASSIVE_LEVEL) 1415 _Must_inspect_result_ 1416 NTSYSAPI 1417 NTSTATUS 1418 NTAPI 1419 RtlUnicodeStringToOemString( 1420 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1421 _When_(!AllocateDestinationString, _Inout_) 1422 POEM_STRING DestinationString, 1423 _In_ PCUNICODE_STRING SourceString, 1424 _In_ BOOLEAN AllocateDestinationString); 1425 1426 _IRQL_requires_max_(PASSIVE_LEVEL) 1427 _Must_inspect_result_ 1428 NTSYSAPI 1429 NTSTATUS 1430 NTAPI 1431 RtlUpcaseUnicodeStringToOemString( 1432 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1433 _When_(!AllocateDestinationString, _Inout_) 1434 POEM_STRING DestinationString, 1435 _In_ PCUNICODE_STRING SourceString, 1436 _In_ BOOLEAN AllocateDestinationString); 1437 1438 _IRQL_requires_max_(PASSIVE_LEVEL) 1439 _Must_inspect_result_ 1440 NTSYSAPI 1441 NTSTATUS 1442 NTAPI 1443 RtlOemStringToCountedUnicodeString( 1444 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1445 _When_(!AllocateDestinationString, _Inout_) 1446 PUNICODE_STRING DestinationString, 1447 _In_ PCOEM_STRING SourceString, 1448 _In_ BOOLEAN AllocateDestinationString); 1449 1450 _IRQL_requires_max_(PASSIVE_LEVEL) 1451 _Must_inspect_result_ 1452 NTSYSAPI 1453 NTSTATUS 1454 NTAPI 1455 RtlUnicodeStringToCountedOemString( 1456 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1457 _When_(!AllocateDestinationString, _Inout_) 1458 POEM_STRING DestinationString, 1459 _In_ PCUNICODE_STRING SourceString, 1460 _In_ BOOLEAN AllocateDestinationString); 1461 1462 _IRQL_requires_max_(PASSIVE_LEVEL) 1463 _Must_inspect_result_ 1464 NTSYSAPI 1465 NTSTATUS 1466 NTAPI 1467 RtlUpcaseUnicodeStringToCountedOemString( 1468 _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem))) 1469 _When_(!AllocateDestinationString, _Inout_) 1470 POEM_STRING DestinationString, 1471 _In_ PCUNICODE_STRING SourceString, 1472 _In_ BOOLEAN AllocateDestinationString); 1473 1474 _IRQL_requires_max_(PASSIVE_LEVEL) 1475 _When_(AllocateDestinationString, _Must_inspect_result_) 1476 NTSYSAPI 1477 NTSTATUS 1478 NTAPI 1479 RtlDowncaseUnicodeString( 1480 _When_(AllocateDestinationString, _Out_ _At_(UniDest->Buffer, __drv_allocatesMem(Mem))) 1481 _When_(!AllocateDestinationString, _Inout_) 1482 PUNICODE_STRING UniDest, 1483 _In_ PCUNICODE_STRING UniSource, 1484 _In_ BOOLEAN AllocateDestinationString); 1485 1486 _IRQL_requires_max_(PASSIVE_LEVEL) 1487 NTSYSAPI 1488 VOID 1489 NTAPI 1490 RtlFreeOemString( 1491 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem)) POEM_STRING OemString); 1492 1493 _IRQL_requires_max_(PASSIVE_LEVEL) 1494 NTSYSAPI 1495 ULONG 1496 NTAPI 1497 RtlxUnicodeStringToOemSize( 1498 _In_ PCUNICODE_STRING UnicodeString); 1499 1500 _IRQL_requires_max_(PASSIVE_LEVEL) 1501 NTSYSAPI 1502 ULONG 1503 NTAPI 1504 RtlxOemStringToUnicodeSize( 1505 _In_ PCOEM_STRING OemString); 1506 1507 _IRQL_requires_max_(PASSIVE_LEVEL) 1508 NTSYSAPI 1509 NTSTATUS 1510 NTAPI 1511 RtlMultiByteToUnicodeN( 1512 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, 1513 _In_ ULONG MaxBytesInUnicodeString, 1514 _Out_opt_ PULONG BytesInUnicodeString, 1515 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString, 1516 _In_ ULONG BytesInMultiByteString); 1517 1518 _IRQL_requires_max_(PASSIVE_LEVEL) 1519 NTSYSAPI 1520 NTSTATUS 1521 NTAPI 1522 RtlMultiByteToUnicodeSize( 1523 _Out_ PULONG BytesInUnicodeString, 1524 _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString, 1525 _In_ ULONG BytesInMultiByteString); 1526 1527 _IRQL_requires_max_(PASSIVE_LEVEL) 1528 NTSYSAPI 1529 NTSTATUS 1530 NTAPI 1531 RtlUnicodeToMultiByteSize( 1532 _Out_ PULONG BytesInMultiByteString, 1533 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString, 1534 _In_ ULONG BytesInUnicodeString); 1535 1536 _IRQL_requires_max_(PASSIVE_LEVEL) 1537 NTSYSAPI 1538 NTSTATUS 1539 NTAPI 1540 RtlUnicodeToMultiByteN( 1541 _Out_writes_bytes_to_(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, 1542 _In_ ULONG MaxBytesInMultiByteString, 1543 _Out_opt_ PULONG BytesInMultiByteString, 1544 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString, 1545 _In_ ULONG BytesInUnicodeString); 1546 1547 _IRQL_requires_max_(PASSIVE_LEVEL) 1548 NTSYSAPI 1549 NTSTATUS 1550 NTAPI 1551 RtlUpcaseUnicodeToMultiByteN( 1552 _Out_writes_bytes_to_(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, 1553 _In_ ULONG MaxBytesInMultiByteString, 1554 _Out_opt_ PULONG BytesInMultiByteString, 1555 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString, 1556 _In_ ULONG BytesInUnicodeString); 1557 1558 _IRQL_requires_max_(PASSIVE_LEVEL) 1559 NTSYSAPI 1560 NTSTATUS 1561 NTAPI 1562 RtlOemToUnicodeN( 1563 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWSTR UnicodeString, 1564 _In_ ULONG MaxBytesInUnicodeString, 1565 _Out_opt_ PULONG BytesInUnicodeString, 1566 _In_reads_bytes_(BytesInOemString) PCCH OemString, 1567 _In_ ULONG BytesInOemString); 1568 1569 _IRQL_requires_max_(PASSIVE_LEVEL) 1570 NTSYSAPI 1571 NTSTATUS 1572 NTAPI 1573 RtlUnicodeToOemN( 1574 _Out_writes_bytes_to_(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, 1575 _In_ ULONG MaxBytesInOemString, 1576 _Out_opt_ PULONG BytesInOemString, 1577 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString, 1578 _In_ ULONG BytesInUnicodeString); 1579 1580 _IRQL_requires_max_(PASSIVE_LEVEL) 1581 NTSYSAPI 1582 NTSTATUS 1583 NTAPI 1584 RtlUpcaseUnicodeToOemN( 1585 _Out_writes_bytes_to_(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, 1586 _In_ ULONG MaxBytesInOemString, 1587 _Out_opt_ PULONG BytesInOemString, 1588 _In_reads_bytes_(BytesInUnicodeString) PCWCH UnicodeString, 1589 _In_ ULONG BytesInUnicodeString); 1590 1591 #if (NTDDI_VERSION >= NTDDI_VISTASP1) 1592 _IRQL_requires_max_(PASSIVE_LEVEL) 1593 NTSYSAPI 1594 NTSTATUS 1595 NTAPI 1596 RtlGenerate8dot3Name( 1597 _In_ PCUNICODE_STRING Name, 1598 _In_ BOOLEAN AllowExtendedCharacters, 1599 _Inout_ PGENERATE_NAME_CONTEXT Context, 1600 _Inout_ PUNICODE_STRING Name8dot3); 1601 #else 1602 _IRQL_requires_max_(PASSIVE_LEVEL) 1603 NTSYSAPI 1604 VOID 1605 NTAPI 1606 RtlGenerate8dot3Name( 1607 _In_ PCUNICODE_STRING Name, 1608 _In_ BOOLEAN AllowExtendedCharacters, 1609 _Inout_ PGENERATE_NAME_CONTEXT Context, 1610 _Inout_ PUNICODE_STRING Name8dot3); 1611 #endif 1612 1613 _IRQL_requires_max_(PASSIVE_LEVEL) 1614 _Must_inspect_result_ 1615 NTSYSAPI 1616 BOOLEAN 1617 NTAPI 1618 RtlIsNameLegalDOS8Dot3( 1619 _In_ PCUNICODE_STRING Name, 1620 _Inout_opt_ POEM_STRING OemName, 1621 _Out_opt_ PBOOLEAN NameContainsSpaces); 1622 1623 _IRQL_requires_max_(PASSIVE_LEVEL) 1624 _Must_inspect_result_ 1625 NTSYSAPI 1626 BOOLEAN 1627 NTAPI 1628 RtlIsValidOemCharacter( 1629 _Inout_ PWCHAR Char); 1630 1631 _IRQL_requires_max_(PASSIVE_LEVEL) 1632 NTSYSAPI 1633 VOID 1634 NTAPI 1635 PfxInitialize( 1636 _Out_ PPREFIX_TABLE PrefixTable); 1637 1638 _IRQL_requires_max_(PASSIVE_LEVEL) 1639 NTSYSAPI 1640 BOOLEAN 1641 NTAPI 1642 PfxInsertPrefix( 1643 _In_ PPREFIX_TABLE PrefixTable, 1644 _In_ __drv_aliasesMem PSTRING Prefix, 1645 _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry); 1646 1647 _IRQL_requires_max_(PASSIVE_LEVEL) 1648 NTSYSAPI 1649 VOID 1650 NTAPI 1651 PfxRemovePrefix( 1652 _In_ PPREFIX_TABLE PrefixTable, 1653 _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry); 1654 1655 _IRQL_requires_max_(PASSIVE_LEVEL) 1656 _Must_inspect_result_ 1657 NTSYSAPI 1658 PPREFIX_TABLE_ENTRY 1659 NTAPI 1660 PfxFindPrefix( 1661 _In_ PPREFIX_TABLE PrefixTable, 1662 _In_ PSTRING FullName); 1663 1664 _IRQL_requires_max_(PASSIVE_LEVEL) 1665 NTSYSAPI 1666 VOID 1667 NTAPI 1668 RtlInitializeUnicodePrefix( 1669 _Out_ PUNICODE_PREFIX_TABLE PrefixTable); 1670 1671 _IRQL_requires_max_(PASSIVE_LEVEL) 1672 NTSYSAPI 1673 BOOLEAN 1674 NTAPI 1675 RtlInsertUnicodePrefix( 1676 _In_ PUNICODE_PREFIX_TABLE PrefixTable, 1677 _In_ __drv_aliasesMem PUNICODE_STRING Prefix, 1678 _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry); 1679 1680 _IRQL_requires_max_(PASSIVE_LEVEL) 1681 NTSYSAPI 1682 VOID 1683 NTAPI 1684 RtlRemoveUnicodePrefix( 1685 _In_ PUNICODE_PREFIX_TABLE PrefixTable, 1686 _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry); 1687 1688 _IRQL_requires_max_(PASSIVE_LEVEL) 1689 _Must_inspect_result_ 1690 NTSYSAPI 1691 PUNICODE_PREFIX_TABLE_ENTRY 1692 NTAPI 1693 RtlFindUnicodePrefix( 1694 _In_ PUNICODE_PREFIX_TABLE PrefixTable, 1695 _In_ PUNICODE_STRING FullName, 1696 _In_ ULONG CaseInsensitiveIndex); 1697 1698 _IRQL_requires_max_(PASSIVE_LEVEL) 1699 _Must_inspect_result_ 1700 NTSYSAPI 1701 PUNICODE_PREFIX_TABLE_ENTRY 1702 NTAPI 1703 RtlNextUnicodePrefix( 1704 _In_ PUNICODE_PREFIX_TABLE PrefixTable, 1705 _In_ BOOLEAN Restart); 1706 1707 _Must_inspect_result_ 1708 NTSYSAPI 1709 SIZE_T 1710 NTAPI 1711 RtlCompareMemoryUlong( 1712 _In_reads_bytes_(Length) PVOID Source, 1713 _In_ SIZE_T Length, 1714 _In_ ULONG Pattern); 1715 1716 _Success_(return != 0) 1717 NTSYSAPI 1718 BOOLEAN 1719 NTAPI 1720 RtlTimeToSecondsSince1980( 1721 _In_ PLARGE_INTEGER Time, 1722 _Out_ PULONG ElapsedSeconds); 1723 1724 NTSYSAPI 1725 VOID 1726 NTAPI 1727 RtlSecondsSince1980ToTime( 1728 _In_ ULONG ElapsedSeconds, 1729 _Out_ PLARGE_INTEGER Time); 1730 1731 _Success_(return != 0) 1732 NTSYSAPI 1733 BOOLEAN 1734 NTAPI 1735 RtlTimeToSecondsSince1970( 1736 _In_ PLARGE_INTEGER Time, 1737 _Out_ PULONG ElapsedSeconds); 1738 1739 NTSYSAPI 1740 VOID 1741 NTAPI 1742 RtlSecondsSince1970ToTime( 1743 _In_ ULONG ElapsedSeconds, 1744 _Out_ PLARGE_INTEGER Time); 1745 1746 _IRQL_requires_max_(APC_LEVEL) 1747 _Must_inspect_result_ 1748 NTSYSAPI 1749 BOOLEAN 1750 NTAPI 1751 RtlValidSid( 1752 _In_ PSID Sid); 1753 1754 _Must_inspect_result_ 1755 NTSYSAPI 1756 BOOLEAN 1757 NTAPI 1758 RtlEqualSid( 1759 _In_ PSID Sid1, 1760 _In_ PSID Sid2); 1761 1762 _IRQL_requires_max_(APC_LEVEL) 1763 _Must_inspect_result_ 1764 NTSYSAPI 1765 BOOLEAN 1766 NTAPI 1767 RtlEqualPrefixSid( 1768 _In_ PSID Sid1, 1769 _In_ PSID Sid2); 1770 1771 _IRQL_requires_max_(APC_LEVEL) 1772 NTSYSAPI 1773 ULONG 1774 NTAPI 1775 RtlLengthRequiredSid( 1776 _In_ ULONG SubAuthorityCount); 1777 1778 NTSYSAPI 1779 PVOID 1780 NTAPI 1781 RtlFreeSid( 1782 _In_ _Post_invalid_ PSID Sid); 1783 1784 _Must_inspect_result_ 1785 NTSYSAPI 1786 NTSTATUS 1787 NTAPI 1788 RtlAllocateAndInitializeSid( 1789 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, 1790 _In_ UCHAR SubAuthorityCount, 1791 _In_ ULONG SubAuthority0, 1792 _In_ ULONG SubAuthority1, 1793 _In_ ULONG SubAuthority2, 1794 _In_ ULONG SubAuthority3, 1795 _In_ ULONG SubAuthority4, 1796 _In_ ULONG SubAuthority5, 1797 _In_ ULONG SubAuthority6, 1798 _In_ ULONG SubAuthority7, 1799 _Outptr_ PSID *Sid); 1800 1801 _IRQL_requires_max_(APC_LEVEL) 1802 NTSYSAPI 1803 NTSTATUS 1804 NTAPI 1805 RtlInitializeSid( 1806 _Out_ PSID Sid, 1807 _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, 1808 _In_ UCHAR SubAuthorityCount); 1809 1810 NTSYSAPI 1811 PULONG 1812 NTAPI 1813 RtlSubAuthoritySid( 1814 _In_ PSID Sid, 1815 _In_ ULONG SubAuthority); 1816 1817 _Post_satisfies_(return >= 8 && return <= SECURITY_MAX_SID_SIZE) 1818 NTSYSAPI 1819 ULONG 1820 NTAPI 1821 RtlLengthSid( 1822 _In_ PSID Sid); 1823 1824 _IRQL_requires_max_(APC_LEVEL) 1825 NTSYSAPI 1826 NTSTATUS 1827 NTAPI 1828 RtlCopySid( 1829 _In_ ULONG DestinationSidLength, 1830 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid, 1831 _In_ PSID SourceSid); 1832 1833 _IRQL_requires_max_(APC_LEVEL) 1834 NTSYSAPI 1835 NTSTATUS 1836 NTAPI 1837 RtlConvertSidToUnicodeString( 1838 _Inout_ PUNICODE_STRING UnicodeString, 1839 _In_ PSID Sid, 1840 _In_ BOOLEAN AllocateDestinationString); 1841 1842 _IRQL_requires_max_(APC_LEVEL) 1843 NTSYSAPI 1844 VOID 1845 NTAPI 1846 RtlCopyLuid( 1847 _Out_ PLUID DestinationLuid, 1848 _In_ PLUID SourceLuid); 1849 1850 _IRQL_requires_max_(APC_LEVEL) 1851 NTSYSAPI 1852 NTSTATUS 1853 NTAPI 1854 RtlCreateAcl( 1855 _Out_writes_bytes_(AclLength) PACL Acl, 1856 _In_ ULONG AclLength, 1857 _In_ ULONG AclRevision); 1858 1859 _IRQL_requires_max_(APC_LEVEL) 1860 NTSYSAPI 1861 NTSTATUS 1862 NTAPI 1863 RtlAddAce( 1864 _Inout_ PACL Acl, 1865 _In_ ULONG AceRevision, 1866 _In_ ULONG StartingAceIndex, 1867 _In_reads_bytes_(AceListLength) PVOID AceList, 1868 _In_ ULONG AceListLength); 1869 1870 _IRQL_requires_max_(APC_LEVEL) 1871 NTSYSAPI 1872 NTSTATUS 1873 NTAPI 1874 RtlDeleteAce( 1875 _Inout_ PACL Acl, 1876 _In_ ULONG AceIndex); 1877 1878 NTSYSAPI 1879 NTSTATUS 1880 NTAPI 1881 RtlGetAce( 1882 _In_ PACL Acl, 1883 _In_ ULONG AceIndex, 1884 _Outptr_ PVOID *Ace); 1885 1886 _IRQL_requires_max_(APC_LEVEL) 1887 NTSYSAPI 1888 NTSTATUS 1889 NTAPI 1890 RtlAddAccessAllowedAce( 1891 _Inout_ PACL Acl, 1892 _In_ ULONG AceRevision, 1893 _In_ ACCESS_MASK AccessMask, 1894 _In_ PSID Sid); 1895 1896 _IRQL_requires_max_(APC_LEVEL) 1897 NTSYSAPI 1898 NTSTATUS 1899 NTAPI 1900 RtlAddAccessAllowedAceEx( 1901 _Inout_ PACL Acl, 1902 _In_ ULONG AceRevision, 1903 _In_ ULONG AceFlags, 1904 _In_ ACCESS_MASK AccessMask, 1905 _In_ PSID Sid); 1906 1907 _IRQL_requires_max_(APC_LEVEL) 1908 NTSYSAPI 1909 NTSTATUS 1910 NTAPI 1911 RtlCreateSecurityDescriptorRelative( 1912 _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor, 1913 _In_ ULONG Revision); 1914 1915 NTSYSAPI 1916 NTSTATUS 1917 NTAPI 1918 RtlGetDaclSecurityDescriptor( 1919 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1920 _Out_ PBOOLEAN DaclPresent, 1921 _Out_ PACL *Dacl, 1922 _Out_ PBOOLEAN DaclDefaulted); 1923 1924 _IRQL_requires_max_(APC_LEVEL) 1925 NTSYSAPI 1926 NTSTATUS 1927 NTAPI 1928 RtlSetOwnerSecurityDescriptor( 1929 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1930 _In_opt_ PSID Owner, 1931 _In_opt_ BOOLEAN OwnerDefaulted); 1932 1933 _IRQL_requires_max_(APC_LEVEL) 1934 NTSYSAPI 1935 NTSTATUS 1936 NTAPI 1937 RtlGetOwnerSecurityDescriptor( 1938 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 1939 _Out_ PSID *Owner, 1940 _Out_ PBOOLEAN OwnerDefaulted); 1941 1942 _IRQL_requires_max_(APC_LEVEL) 1943 _When_(Status < 0, _Out_range_(>, 0)) 1944 _When_(Status >= 0, _Out_range_(==, 0)) 1945 NTSYSAPI 1946 ULONG 1947 NTAPI 1948 RtlNtStatusToDosError( 1949 _In_ NTSTATUS Status); 1950 1951 _IRQL_requires_max_(PASSIVE_LEVEL) 1952 NTSYSAPI 1953 NTSTATUS 1954 NTAPI 1955 RtlCustomCPToUnicodeN( 1956 _In_ PCPTABLEINFO CustomCP, 1957 _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, 1958 _In_ ULONG MaxBytesInUnicodeString, 1959 _Out_opt_ PULONG BytesInUnicodeString, 1960 _In_reads_bytes_(BytesInCustomCPString) PCH CustomCPString, 1961 _In_ ULONG BytesInCustomCPString); 1962 1963 _IRQL_requires_max_(PASSIVE_LEVEL) 1964 NTSYSAPI 1965 NTSTATUS 1966 NTAPI 1967 RtlUnicodeToCustomCPN( 1968 _In_ PCPTABLEINFO CustomCP, 1969 _Out_writes_bytes_to_(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, 1970 _In_ ULONG MaxBytesInCustomCPString, 1971 _Out_opt_ PULONG BytesInCustomCPString, 1972 _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, 1973 _In_ ULONG BytesInUnicodeString); 1974 1975 _IRQL_requires_max_(PASSIVE_LEVEL) 1976 NTSYSAPI 1977 NTSTATUS 1978 NTAPI 1979 RtlUpcaseUnicodeToCustomCPN( 1980 _In_ PCPTABLEINFO CustomCP, 1981 _Out_writes_bytes_to_(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, 1982 _In_ ULONG MaxBytesInCustomCPString, 1983 _Out_opt_ PULONG BytesInCustomCPString, 1984 _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, 1985 _In_ ULONG BytesInUnicodeString); 1986 1987 _IRQL_requires_max_(PASSIVE_LEVEL) 1988 NTSYSAPI 1989 VOID 1990 NTAPI 1991 RtlInitCodePageTable( 1992 _In_ PUSHORT TableBase, 1993 _Out_ PCPTABLEINFO CodePageTable); 1994 1995 $endif (_NTIFS_) 1996 1997 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 1998 1999 $if (_WDMDDK_) 2000 2001 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) 2002 NTSYSAPI 2003 VOID 2004 FASTCALL 2005 RtlPrefetchMemoryNonTemporal( 2006 _In_ PVOID Source, 2007 _In_ SIZE_T Length); 2008 #endif 2009 2010 $endif (_WDMDDK_) 2011 2012 #if (NTDDI_VERSION >= NTDDI_WINXP) 2013 2014 $if (_WDMDDK_) 2015 2016 NTSYSAPI 2017 VOID 2018 NTAPI 2019 RtlClearBit( 2020 _In_ PRTL_BITMAP BitMapHeader, 2021 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber); 2022 2023 _IRQL_requires_max_(PASSIVE_LEVEL) 2024 NTSYSAPI 2025 WCHAR 2026 NTAPI 2027 RtlDowncaseUnicodeChar( 2028 _In_ WCHAR SourceCharacter); 2029 2030 NTSYSAPI 2031 VOID 2032 NTAPI 2033 RtlSetBit( 2034 _In_ PRTL_BITMAP BitMapHeader, 2035 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber); 2036 2037 _Must_inspect_result_ 2038 NTSYSAPI 2039 BOOLEAN 2040 NTAPI 2041 RtlTestBit( 2042 _In_ PRTL_BITMAP BitMapHeader, 2043 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber); 2044 2045 _IRQL_requires_max_(PASSIVE_LEVEL) 2046 NTSYSAPI 2047 NTSTATUS 2048 NTAPI 2049 RtlHashUnicodeString( 2050 _In_ CONST UNICODE_STRING *String, 2051 _In_ BOOLEAN CaseInSensitive, 2052 _In_ ULONG HashAlgorithm, 2053 _Out_ PULONG HashValue); 2054 2055 $endif (_WDMDDK_) 2056 2057 $if (_NTDDK_) 2058 2059 NTSYSAPI 2060 VOID 2061 NTAPI 2062 RtlInitializeGenericTableAvl( 2063 _Out_ PRTL_AVL_TABLE Table, 2064 _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine, 2065 _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, 2066 _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine, 2067 _In_opt_ PVOID TableContext); 2068 2069 NTSYSAPI 2070 PVOID 2071 NTAPI 2072 RtlInsertElementGenericTableAvl( 2073 _In_ PRTL_AVL_TABLE Table, 2074 _In_reads_bytes_(BufferSize) PVOID Buffer, 2075 _In_ CLONG BufferSize, 2076 _Out_opt_ PBOOLEAN NewElement); 2077 2078 NTSYSAPI 2079 PVOID 2080 NTAPI 2081 RtlInsertElementGenericTableFullAvl( 2082 _In_ PRTL_AVL_TABLE Table, 2083 _In_reads_bytes_(BufferSize) PVOID Buffer, 2084 _In_ CLONG BufferSize, 2085 _Out_opt_ PBOOLEAN NewElement, 2086 _In_ PVOID NodeOrParent, 2087 _In_ TABLE_SEARCH_RESULT SearchResult); 2088 2089 NTSYSAPI 2090 BOOLEAN 2091 NTAPI 2092 RtlDeleteElementGenericTableAvl( 2093 _In_ PRTL_AVL_TABLE Table, 2094 _In_ PVOID Buffer); 2095 2096 _Must_inspect_result_ 2097 NTSYSAPI 2098 PVOID 2099 NTAPI 2100 RtlLookupElementGenericTableAvl( 2101 _In_ PRTL_AVL_TABLE Table, 2102 _In_ PVOID Buffer); 2103 2104 NTSYSAPI 2105 PVOID 2106 NTAPI 2107 RtlLookupElementGenericTableFullAvl( 2108 _In_ PRTL_AVL_TABLE Table, 2109 _In_ PVOID Buffer, 2110 _Out_ PVOID *NodeOrParent, 2111 _Out_ TABLE_SEARCH_RESULT *SearchResult); 2112 2113 _Must_inspect_result_ 2114 NTSYSAPI 2115 PVOID 2116 NTAPI 2117 RtlEnumerateGenericTableAvl( 2118 _In_ PRTL_AVL_TABLE Table, 2119 _In_ BOOLEAN Restart); 2120 2121 _Must_inspect_result_ 2122 NTSYSAPI 2123 PVOID 2124 NTAPI 2125 RtlEnumerateGenericTableWithoutSplayingAvl( 2126 _In_ PRTL_AVL_TABLE Table, 2127 _Inout_ PVOID *RestartKey); 2128 2129 _Must_inspect_result_ 2130 NTSYSAPI 2131 PVOID 2132 NTAPI 2133 RtlLookupFirstMatchingElementGenericTableAvl( 2134 _In_ PRTL_AVL_TABLE Table, 2135 _In_ PVOID Buffer, 2136 _Out_ PVOID *RestartKey); 2137 2138 _Must_inspect_result_ 2139 NTSYSAPI 2140 PVOID 2141 NTAPI 2142 RtlEnumerateGenericTableLikeADirectory( 2143 _In_ PRTL_AVL_TABLE Table, 2144 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction, 2145 _In_opt_ PVOID MatchData, 2146 _In_ ULONG NextFlag, 2147 _Inout_ PVOID *RestartKey, 2148 _Inout_ PULONG DeleteCount, 2149 _In_ PVOID Buffer); 2150 2151 _Must_inspect_result_ 2152 NTSYSAPI 2153 PVOID 2154 NTAPI 2155 RtlGetElementGenericTableAvl( 2156 _In_ PRTL_AVL_TABLE Table, 2157 _In_ ULONG I); 2158 2159 NTSYSAPI 2160 ULONG 2161 NTAPI 2162 RtlNumberGenericTableElementsAvl( 2163 _In_ PRTL_AVL_TABLE Table); 2164 2165 _Must_inspect_result_ 2166 NTSYSAPI 2167 BOOLEAN 2168 NTAPI 2169 RtlIsGenericTableEmptyAvl( 2170 _In_ PRTL_AVL_TABLE Table); 2171 2172 $endif (_NTDDK_) 2173 $if (_NTIFS_) 2174 2175 _Must_inspect_result_ 2176 NTSYSAPI 2177 PVOID 2178 NTAPI 2179 RtlCreateHeap( 2180 _In_ ULONG Flags, 2181 _In_opt_ PVOID HeapBase, 2182 _In_opt_ SIZE_T ReserveSize, 2183 _In_opt_ SIZE_T CommitSize, 2184 _In_opt_ PVOID Lock, 2185 _In_opt_ PRTL_HEAP_PARAMETERS Parameters); 2186 2187 NTSYSAPI 2188 PVOID 2189 NTAPI 2190 RtlDestroyHeap( 2191 _In_ _Post_invalid_ PVOID HeapHandle); 2192 2193 NTSYSAPI 2194 USHORT 2195 NTAPI 2196 RtlCaptureStackBackTrace( 2197 _In_ ULONG FramesToSkip, 2198 _In_ ULONG FramesToCapture, 2199 _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace, 2200 _Out_opt_ PULONG BackTraceHash); 2201 2202 _Ret_range_(<, MAXLONG) 2203 NTSYSAPI 2204 ULONG 2205 NTAPI 2206 RtlRandomEx( 2207 _Inout_ PULONG Seed); 2208 2209 _IRQL_requires_max_(DISPATCH_LEVEL) 2210 NTSYSAPI 2211 NTSTATUS 2212 NTAPI 2213 RtlInitUnicodeStringEx( 2214 _Out_ PUNICODE_STRING DestinationString, 2215 _In_opt_z_ __drv_aliasesMem PCWSTR SourceString); 2216 2217 _Must_inspect_result_ 2218 NTSYSAPI 2219 NTSTATUS 2220 NTAPI 2221 RtlValidateUnicodeString( 2222 _In_ ULONG Flags, 2223 _In_ PCUNICODE_STRING String); 2224 2225 _IRQL_requires_max_(PASSIVE_LEVEL) 2226 _Must_inspect_result_ 2227 NTSYSAPI 2228 NTSTATUS 2229 NTAPI 2230 RtlDuplicateUnicodeString( 2231 _In_ ULONG Flags, 2232 _In_ PCUNICODE_STRING SourceString, 2233 _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)) PUNICODE_STRING DestinationString); 2234 2235 NTSYSAPI 2236 NTSTATUS 2237 NTAPI 2238 RtlGetCompressionWorkSpaceSize( 2239 _In_ USHORT CompressionFormatAndEngine, 2240 _Out_ PULONG CompressBufferWorkSpaceSize, 2241 _Out_ PULONG CompressFragmentWorkSpaceSize); 2242 2243 NTSYSAPI 2244 NTSTATUS 2245 NTAPI 2246 RtlCompressBuffer( 2247 _In_ USHORT CompressionFormatAndEngine, 2248 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, 2249 _In_ ULONG UncompressedBufferSize, 2250 _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer, 2251 _In_ ULONG CompressedBufferSize, 2252 _In_ ULONG UncompressedChunkSize, 2253 _Out_ PULONG FinalCompressedSize, 2254 _In_ PVOID WorkSpace); 2255 2256 _IRQL_requires_max_(APC_LEVEL) 2257 NTSYSAPI 2258 NTSTATUS 2259 NTAPI 2260 RtlDecompressBuffer( 2261 _In_ USHORT CompressionFormat, 2262 _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, 2263 _In_ ULONG UncompressedBufferSize, 2264 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, 2265 _In_ ULONG CompressedBufferSize, 2266 _Out_ PULONG FinalUncompressedSize); 2267 2268 _IRQL_requires_max_(APC_LEVEL) 2269 NTSYSAPI 2270 NTSTATUS 2271 NTAPI 2272 RtlDecompressFragment( 2273 _In_ USHORT CompressionFormat, 2274 _Out_writes_bytes_to_(UncompressedFragmentSize, *FinalUncompressedSize) PUCHAR UncompressedFragment, 2275 _In_ ULONG UncompressedFragmentSize, 2276 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, 2277 _In_ ULONG CompressedBufferSize, 2278 _In_range_(<, CompressedBufferSize) ULONG FragmentOffset, 2279 _Out_ PULONG FinalUncompressedSize, 2280 _In_ PVOID WorkSpace); 2281 2282 _IRQL_requires_max_(APC_LEVEL) 2283 NTSYSAPI 2284 NTSTATUS 2285 NTAPI 2286 RtlDescribeChunk( 2287 _In_ USHORT CompressionFormat, 2288 _Inout_ PUCHAR *CompressedBuffer, 2289 _In_ PUCHAR EndOfCompressedBufferPlus1, 2290 _Out_ PUCHAR *ChunkBuffer, 2291 _Out_ PULONG ChunkSize); 2292 2293 _IRQL_requires_max_(APC_LEVEL) 2294 NTSYSAPI 2295 NTSTATUS 2296 NTAPI 2297 RtlReserveChunk( 2298 _In_ USHORT CompressionFormat, 2299 _Inout_ PUCHAR *CompressedBuffer, 2300 _In_ PUCHAR EndOfCompressedBufferPlus1, 2301 _Out_ PUCHAR *ChunkBuffer, 2302 _In_ ULONG ChunkSize); 2303 2304 _IRQL_requires_max_(APC_LEVEL) 2305 NTSYSAPI 2306 NTSTATUS 2307 NTAPI 2308 RtlDecompressChunks( 2309 _Out_writes_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, 2310 _In_ ULONG UncompressedBufferSize, 2311 _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, 2312 _In_ ULONG CompressedBufferSize, 2313 _In_reads_bytes_(CompressedTailSize) PUCHAR CompressedTail, 2314 _In_ ULONG CompressedTailSize, 2315 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo); 2316 2317 _IRQL_requires_max_(APC_LEVEL) 2318 NTSYSAPI 2319 NTSTATUS 2320 NTAPI 2321 RtlCompressChunks( 2322 _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, 2323 _In_ ULONG UncompressedBufferSize, 2324 _Out_writes_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, 2325 _In_range_(>=, (UncompressedBufferSize - (UncompressedBufferSize / 16))) ULONG CompressedBufferSize, 2326 _Inout_updates_bytes_(CompressedDataInfoLength) PCOMPRESSED_DATA_INFO CompressedDataInfo, 2327 _In_range_(>, sizeof(COMPRESSED_DATA_INFO)) ULONG CompressedDataInfoLength, 2328 _In_ PVOID WorkSpace); 2329 2330 _IRQL_requires_max_(APC_LEVEL) 2331 NTSYSAPI 2332 PSID_IDENTIFIER_AUTHORITY 2333 NTAPI 2334 RtlIdentifierAuthoritySid( 2335 _In_ PSID Sid); 2336 2337 NTSYSAPI 2338 PUCHAR 2339 NTAPI 2340 RtlSubAuthorityCountSid( 2341 _In_ PSID Sid); 2342 2343 _When_(Status < 0, _Out_range_(>, 0)) 2344 _When_(Status >= 0, _Out_range_(==, 0)) 2345 NTSYSAPI 2346 ULONG 2347 NTAPI 2348 RtlNtStatusToDosErrorNoTeb( 2349 _In_ NTSTATUS Status); 2350 2351 _IRQL_requires_max_(PASSIVE_LEVEL) 2352 NTSYSAPI 2353 NTSTATUS 2354 NTAPI 2355 RtlCreateSystemVolumeInformationFolder( 2356 _In_ PCUNICODE_STRING VolumeRootPath); 2357 2358 #if defined(_M_AMD64) 2359 2360 FORCEINLINE 2361 VOID 2362 RtlFillMemoryUlong( 2363 _Out_writes_bytes_all_(Length) PVOID Destination, 2364 _In_ SIZE_T Length, 2365 _In_ ULONG Pattern) 2366 { 2367 PULONG Address = (PULONG)Destination; 2368 if ((Length /= 4) != 0) { 2369 if (((ULONG64)Address & 4) != 0) { 2370 *Address = Pattern; 2371 if ((Length -= 1) == 0) { 2372 return; 2373 } 2374 Address += 1; 2375 } 2376 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2); 2377 if ((Length & 1) != 0) Address[Length - 1] = Pattern; 2378 } 2379 return; 2380 } 2381 2382 #define RtlFillMemoryUlonglong(Destination, Length, Pattern) \ 2383 __stosq((PULONG64)(Destination), Pattern, (Length) / 8) 2384 2385 #else 2386 2387 NTSYSAPI 2388 VOID 2389 NTAPI 2390 RtlFillMemoryUlong( 2391 _Out_writes_bytes_all_(Length) PVOID Destination, 2392 _In_ SIZE_T Length, 2393 _In_ ULONG Pattern); 2394 2395 NTSYSAPI 2396 VOID 2397 NTAPI 2398 RtlFillMemoryUlonglong( 2399 _Out_writes_bytes_all_(Length) PVOID Destination, 2400 _In_ SIZE_T Length, 2401 _In_ ULONGLONG Pattern); 2402 2403 #endif /* defined(_M_AMD64) */ 2404 $endif (_NTIFS_) 2405 2406 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 2407 2408 $if (_NTIFS_) 2409 #if (NTDDI_VERSION >= NTDDI_WS03) 2410 _IRQL_requires_max_(DISPATCH_LEVEL) 2411 NTSYSAPI 2412 NTSTATUS 2413 NTAPI 2414 RtlInitAnsiStringEx( 2415 _Out_ PANSI_STRING DestinationString, 2416 _In_opt_z_ __drv_aliasesMem PCSZ SourceString); 2417 #endif 2418 2419 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 2420 2421 _IRQL_requires_max_(APC_LEVEL) 2422 NTSYSAPI 2423 NTSTATUS 2424 NTAPI 2425 RtlGetSaclSecurityDescriptor( 2426 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 2427 _Out_ PBOOLEAN SaclPresent, 2428 _Out_ PACL *Sacl, 2429 _Out_ PBOOLEAN SaclDefaulted); 2430 2431 _IRQL_requires_max_(APC_LEVEL) 2432 NTSYSAPI 2433 NTSTATUS 2434 NTAPI 2435 RtlSetGroupSecurityDescriptor( 2436 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 2437 _In_opt_ PSID Group, 2438 _In_opt_ BOOLEAN GroupDefaulted); 2439 2440 _IRQL_requires_max_(APC_LEVEL) 2441 NTSYSAPI 2442 NTSTATUS 2443 NTAPI 2444 RtlGetGroupSecurityDescriptor( 2445 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, 2446 _Out_ PSID *Group, 2447 _Out_ PBOOLEAN GroupDefaulted); 2448 2449 _IRQL_requires_max_(APC_LEVEL) 2450 NTSYSAPI 2451 NTSTATUS 2452 NTAPI 2453 RtlAbsoluteToSelfRelativeSD( 2454 _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, 2455 _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, 2456 _Inout_ PULONG BufferLength); 2457 2458 _IRQL_requires_max_(APC_LEVEL) 2459 NTSYSAPI 2460 NTSTATUS 2461 NTAPI 2462 RtlSelfRelativeToAbsoluteSD( 2463 _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, 2464 _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, 2465 _Inout_ PULONG AbsoluteSecurityDescriptorSize, 2466 _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl, 2467 _Inout_ PULONG DaclSize, 2468 _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl, 2469 _Inout_ PULONG SaclSize, 2470 _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner, 2471 _Inout_ PULONG OwnerSize, 2472 _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup, 2473 _Inout_ PULONG PrimaryGroupSize); 2474 2475 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ 2476 $endif (_NTIFS_) 2477 2478 #if (NTDDI_VERSION >= NTDDI_VISTA) 2479 2480 $if (_WDMDDK_) 2481 NTSYSAPI 2482 ULONG 2483 NTAPI 2484 RtlNumberOfSetBitsUlongPtr( 2485 _In_ ULONG_PTR Target); 2486 2487 NTSYSAPI 2488 ULONGLONG 2489 NTAPI 2490 RtlIoDecodeMemIoResource( 2491 _In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor, 2492 _Out_opt_ PULONGLONG Alignment, 2493 _Out_opt_ PULONGLONG MinimumAddress, 2494 _Out_opt_ PULONGLONG MaximumAddress); 2495 2496 NTSYSAPI 2497 NTSTATUS 2498 NTAPI 2499 RtlIoEncodeMemIoResource( 2500 _In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor, 2501 _In_ UCHAR Type, 2502 _In_ ULONGLONG Length, 2503 _In_ ULONGLONG Alignment, 2504 _In_ ULONGLONG MinimumAddress, 2505 _In_ ULONGLONG MaximumAddress); 2506 2507 NTSYSAPI 2508 ULONGLONG 2509 NTAPI 2510 RtlCmDecodeMemIoResource( 2511 _In_ struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, 2512 _Out_opt_ PULONGLONG Start); 2513 2514 NTSYSAPI 2515 NTSTATUS 2516 NTAPI 2517 RtlFindClosestEncodableLength( 2518 _In_ ULONGLONG SourceLength, 2519 _Out_ PULONGLONG TargetLength); 2520 2521 NTSYSAPI 2522 NTSTATUS 2523 NTAPI 2524 RtlCmEncodeMemIoResource( 2525 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, 2526 _In_ UCHAR Type, 2527 _In_ ULONGLONG Length, 2528 _In_ ULONGLONG Start); 2529 2530 $endif (_WDMDDK_) 2531 $if (_NTDDK_) 2532 2533 _IRQL_requires_max_(APC_LEVEL) 2534 NTSYSAPI 2535 VOID 2536 NTAPI 2537 RtlRunOnceInitialize( 2538 _Out_ PRTL_RUN_ONCE RunOnce); 2539 2540 _IRQL_requires_max_(APC_LEVEL) 2541 _Maybe_raises_SEH_exception_ 2542 NTSYSAPI 2543 NTSTATUS 2544 NTAPI 2545 RtlRunOnceExecuteOnce( 2546 _Inout_ PRTL_RUN_ONCE RunOnce, 2547 _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn, 2548 _Inout_opt_ PVOID Parameter, 2549 _Outptr_opt_result_maybenull_ PVOID *Context); 2550 2551 _IRQL_requires_max_(APC_LEVEL) 2552 _Must_inspect_result_ 2553 NTSYSAPI 2554 NTSTATUS 2555 NTAPI 2556 RtlRunOnceBeginInitialize( 2557 _Inout_ PRTL_RUN_ONCE RunOnce, 2558 _In_ ULONG Flags, 2559 _Outptr_opt_result_maybenull_ PVOID *Context); 2560 2561 _IRQL_requires_max_(APC_LEVEL) 2562 NTSYSAPI 2563 NTSTATUS 2564 NTAPI 2565 RtlRunOnceComplete( 2566 _Inout_ PRTL_RUN_ONCE RunOnce, 2567 _In_ ULONG Flags, 2568 _In_opt_ PVOID Context); 2569 2570 NTSYSAPI 2571 BOOLEAN 2572 NTAPI 2573 RtlGetProductInfo( 2574 _In_ ULONG OSMajorVersion, 2575 _In_ ULONG OSMinorVersion, 2576 _In_ ULONG SpMajorVersion, 2577 _In_ ULONG SpMinorVersion, 2578 _Out_ PULONG ReturnedProductType); 2579 2580 $endif (_NTDDK_) 2581 $if (_NTIFS_) 2582 NTSYSAPI 2583 NTSTATUS 2584 NTAPI 2585 RtlNormalizeString( 2586 _In_ ULONG NormForm, 2587 _In_ PCWSTR SourceString, 2588 _In_ LONG SourceStringLength, 2589 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString, 2590 _Inout_ PLONG DestinationStringLength); 2591 2592 NTSYSAPI 2593 NTSTATUS 2594 NTAPI 2595 RtlIsNormalizedString( 2596 _In_ ULONG NormForm, 2597 _In_ PCWSTR SourceString, 2598 _In_ LONG SourceStringLength, 2599 _Out_ PBOOLEAN Normalized); 2600 2601 NTSYSAPI 2602 NTSTATUS 2603 NTAPI 2604 RtlIdnToAscii( 2605 _In_ ULONG Flags, 2606 _In_ PCWSTR SourceString, 2607 _In_ LONG SourceStringLength, 2608 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString, 2609 _Inout_ PLONG DestinationStringLength); 2610 2611 NTSYSAPI 2612 NTSTATUS 2613 NTAPI 2614 RtlIdnToUnicode( 2615 IN ULONG Flags, 2616 IN PCWSTR SourceString, 2617 IN LONG SourceStringLength, 2618 OUT PWSTR DestinationString, 2619 IN OUT PLONG DestinationStringLength); 2620 2621 NTSYSAPI 2622 NTSTATUS 2623 NTAPI 2624 RtlIdnToNameprepUnicode( 2625 _In_ ULONG Flags, 2626 _In_ PCWSTR SourceString, 2627 _In_ LONG SourceStringLength, 2628 _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString, 2629 _Inout_ PLONG DestinationStringLength); 2630 2631 NTSYSAPI 2632 NTSTATUS 2633 NTAPI 2634 RtlCreateServiceSid( 2635 _In_ PUNICODE_STRING ServiceName, 2636 _Out_writes_bytes_opt_(*ServiceSidLength) PSID ServiceSid, 2637 _Inout_ PULONG ServiceSidLength); 2638 2639 NTSYSAPI 2640 LONG 2641 NTAPI 2642 RtlCompareAltitudes( 2643 _In_ PCUNICODE_STRING Altitude1, 2644 _In_ PCUNICODE_STRING Altitude2); 2645 2646 $endif (_NTIFS_) 2647 2648 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 2649 2650 #if (NTDDI_VERSION >= NTDDI_WIN7) 2651 2652 $if (_WDMDDK_) 2653 _IRQL_requires_max_(PASSIVE_LEVEL) 2654 _Must_inspect_result_ 2655 NTSYSAPI 2656 NTSTATUS 2657 NTAPI 2658 RtlUnicodeToUTF8N( 2659 _Out_writes_bytes_to_(UTF8StringMaxByteCount, *UTF8StringActualByteCount) 2660 PCHAR UTF8StringDestination, 2661 _In_ ULONG UTF8StringMaxByteCount, 2662 _Out_ PULONG UTF8StringActualByteCount, 2663 _In_reads_bytes_(UnicodeStringByteCount) PCWCH UnicodeStringSource, 2664 _In_ ULONG UnicodeStringByteCount); 2665 2666 _IRQL_requires_max_(PASSIVE_LEVEL) 2667 _Must_inspect_result_ 2668 NTSYSAPI 2669 NTSTATUS 2670 NTAPI 2671 RtlUTF8ToUnicodeN( 2672 _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) 2673 PWSTR UnicodeStringDestination, 2674 _In_ ULONG UnicodeStringMaxByteCount, 2675 _Out_ PULONG UnicodeStringActualByteCount, 2676 _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource, 2677 _In_ ULONG UTF8StringByteCount); 2678 2679 NTSYSAPI 2680 ULONG64 2681 NTAPI 2682 RtlGetEnabledExtendedFeatures( 2683 IN ULONG64 FeatureMask); 2684 2685 $endif (_WDMDDK_) 2686 $if (_NTDDK_) 2687 2688 _Must_inspect_result_ 2689 NTSYSAPI 2690 BOOLEAN 2691 NTAPI 2692 RtlCreateHashTable( 2693 _Inout_ _When_(NULL == *HashTable, __drv_allocatesMem(Mem)) 2694 PRTL_DYNAMIC_HASH_TABLE *HashTable, 2695 _In_ ULONG Shift, 2696 _In_ _Reserved_ ULONG Flags); 2697 2698 NTSYSAPI 2699 VOID 2700 NTAPI 2701 RtlDeleteHashTable( 2702 _In_ _When_((HashTable->Flags & RTL_HASH_ALLOCATED_HEADER), __drv_freesMem(Mem) _Post_invalid_) 2703 PRTL_DYNAMIC_HASH_TABLE HashTable); 2704 2705 NTSYSAPI 2706 BOOLEAN 2707 NTAPI 2708 RtlInsertEntryHashTable( 2709 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2710 _In_ __drv_aliasesMem PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, 2711 _In_ ULONG_PTR Signature, 2712 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); 2713 2714 NTSYSAPI 2715 BOOLEAN 2716 NTAPI 2717 RtlRemoveEntryHashTable( 2718 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2719 _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, 2720 _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); 2721 2722 _Must_inspect_result_ 2723 NTSYSAPI 2724 PRTL_DYNAMIC_HASH_TABLE_ENTRY 2725 NTAPI 2726 RtlLookupEntryHashTable( 2727 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2728 _In_ ULONG_PTR Signature, 2729 _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); 2730 2731 _Must_inspect_result_ 2732 NTSYSAPI 2733 PRTL_DYNAMIC_HASH_TABLE_ENTRY 2734 NTAPI 2735 RtlGetNextEntryHashTable( 2736 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2737 _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); 2738 2739 NTSYSAPI 2740 BOOLEAN 2741 NTAPI 2742 RtlInitEnumerationHashTable( 2743 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2744 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2745 2746 _Must_inspect_result_ 2747 NTSYSAPI 2748 PRTL_DYNAMIC_HASH_TABLE_ENTRY 2749 NTAPI 2750 RtlEnumerateEntryHashTable( 2751 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2752 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2753 2754 NTSYSAPI 2755 VOID 2756 NTAPI 2757 RtlEndEnumerationHashTable( 2758 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2759 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2760 2761 NTSYSAPI 2762 BOOLEAN 2763 NTAPI 2764 RtlInitWeakEnumerationHashTable( 2765 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2766 _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2767 2768 _Must_inspect_result_ 2769 NTSYSAPI 2770 PRTL_DYNAMIC_HASH_TABLE_ENTRY 2771 NTAPI 2772 RtlWeaklyEnumerateEntryHashTable( 2773 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2774 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2775 2776 NTSYSAPI 2777 VOID 2778 NTAPI 2779 RtlEndWeakEnumerationHashTable( 2780 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, 2781 _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); 2782 2783 NTSYSAPI 2784 BOOLEAN 2785 NTAPI 2786 RtlExpandHashTable( 2787 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable); 2788 2789 NTSYSAPI 2790 BOOLEAN 2791 NTAPI 2792 RtlContractHashTable( 2793 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable); 2794 2795 $endif (_NTDDK_) 2796 $if (_NTIFS_) 2797 _IRQL_requires_max_(PASSIVE_LEVEL) 2798 _Must_inspect_result_ 2799 NTSYSAPI 2800 NTSTATUS 2801 NTAPI 2802 RtlUnicodeToUTF8N( 2803 _Out_writes_bytes_to_(UTF8StringMaxByteCount, *UTF8StringActualByteCount) PCHAR UTF8StringDestination, 2804 _In_ ULONG UTF8StringMaxByteCount, 2805 _Out_ PULONG UTF8StringActualByteCount, 2806 _In_reads_bytes_(UnicodeStringByteCount) PCWCH UnicodeStringSource, 2807 _In_ ULONG UnicodeStringByteCount); 2808 2809 _IRQL_requires_max_(PASSIVE_LEVEL) 2810 _Must_inspect_result_ 2811 NTSYSAPI 2812 NTSTATUS 2813 NTAPI 2814 RtlUTF8ToUnicodeN( 2815 _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) PWSTR UnicodeStringDestination, 2816 _In_ ULONG UnicodeStringMaxByteCount, 2817 _Out_ PULONG UnicodeStringActualByteCount, 2818 _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource, 2819 _In_ ULONG UTF8StringByteCount); 2820 2821 _IRQL_requires_max_(APC_LEVEL) 2822 NTSYSAPI 2823 NTSTATUS 2824 NTAPI 2825 RtlReplaceSidInSd( 2826 _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, 2827 _In_ PSID OldSid, 2828 _In_ PSID NewSid, 2829 _Out_ ULONG *NumChanges); 2830 2831 NTSYSAPI 2832 NTSTATUS 2833 NTAPI 2834 RtlCreateVirtualAccountSid( 2835 _In_ PCUNICODE_STRING Name, 2836 _In_ ULONG BaseSubAuthority, 2837 _Out_writes_bytes_(*SidLength) PSID Sid, 2838 _Inout_ PULONG SidLength); 2839 $endif (_NTIFS_) 2840 2841 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 2842 2843 $if (_WDMDDK_) 2844 2845 #if !defined(MIDL_PASS) 2846 /* inline funftions */ 2847 //DECLSPEC_DEPRECATED_DDK_WINXP 2848 static __inline 2849 LARGE_INTEGER 2850 NTAPI_INLINE 2851 RtlConvertLongToLargeInteger( 2852 _In_ LONG SignedInteger) 2853 { 2854 LARGE_INTEGER ret; 2855 ret.QuadPart = SignedInteger; 2856 return ret; 2857 } 2858 2859 //DECLSPEC_DEPRECATED_DDK_WINXP 2860 static __inline 2861 LARGE_INTEGER 2862 NTAPI_INLINE 2863 RtlConvertUlongToLargeInteger( 2864 _In_ ULONG UnsignedInteger) 2865 { 2866 LARGE_INTEGER ret; 2867 ret.QuadPart = UnsignedInteger; 2868 return ret; 2869 } 2870 2871 //DECLSPEC_DEPRECATED_DDK_WINXP 2872 static __inline 2873 LARGE_INTEGER 2874 NTAPI_INLINE 2875 RtlLargeIntegerShiftLeft( 2876 _In_ LARGE_INTEGER LargeInteger, 2877 _In_ CCHAR ShiftCount) 2878 { 2879 LARGE_INTEGER Result; 2880 2881 Result.QuadPart = LargeInteger.QuadPart << ShiftCount; 2882 return Result; 2883 } 2884 2885 //DECLSPEC_DEPRECATED_DDK_WINXP 2886 static __inline 2887 LARGE_INTEGER 2888 NTAPI_INLINE 2889 RtlLargeIntegerShiftRight( 2890 _In_ LARGE_INTEGER LargeInteger, 2891 _In_ CCHAR ShiftCount) 2892 { 2893 LARGE_INTEGER Result; 2894 2895 Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; 2896 return Result; 2897 } 2898 2899 //DECLSPEC_DEPRECATED_DDK 2900 static __inline 2901 ULONG 2902 NTAPI_INLINE 2903 RtlEnlargedUnsignedDivide( 2904 _In_ ULARGE_INTEGER Dividend, 2905 _In_ ULONG Divisor, 2906 _Out_opt_ PULONG Remainder) 2907 { 2908 if (Remainder) 2909 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 2910 return (ULONG)(Dividend.QuadPart / Divisor); 2911 } 2912 2913 //DECLSPEC_DEPRECATED_DDK 2914 static __inline 2915 LARGE_INTEGER 2916 NTAPI_INLINE 2917 RtlLargeIntegerNegate( 2918 _In_ LARGE_INTEGER Subtrahend) 2919 { 2920 LARGE_INTEGER Difference; 2921 2922 Difference.QuadPart = -Subtrahend.QuadPart; 2923 return Difference; 2924 } 2925 2926 //DECLSPEC_DEPRECATED_DDK 2927 static __inline 2928 LARGE_INTEGER 2929 NTAPI_INLINE 2930 RtlLargeIntegerSubtract( 2931 _In_ LARGE_INTEGER Minuend, 2932 _In_ LARGE_INTEGER Subtrahend) 2933 { 2934 LARGE_INTEGER Difference; 2935 2936 Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; 2937 return Difference; 2938 } 2939 2940 //DECLSPEC_DEPRECATED_DDK 2941 static __inline 2942 LARGE_INTEGER 2943 NTAPI_INLINE 2944 RtlEnlargedUnsignedMultiply( 2945 _In_ ULONG Multiplicand, 2946 _In_ ULONG Multiplier) 2947 { 2948 LARGE_INTEGER ret; 2949 ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; 2950 return ret; 2951 } 2952 2953 //DECLSPEC_DEPRECATED_DDK 2954 static __inline 2955 LARGE_INTEGER 2956 NTAPI_INLINE 2957 RtlEnlargedIntegerMultiply( 2958 _In_ LONG Multiplicand, 2959 _In_ LONG Multiplier) 2960 { 2961 LARGE_INTEGER ret; 2962 ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; 2963 return ret; 2964 } 2965 2966 _At_(AnsiString->Buffer, _Post_equal_to_(Buffer)) 2967 _At_(AnsiString->Length, _Post_equal_to_(0)) 2968 _At_(AnsiString->MaximumLength, _Post_equal_to_(BufferSize)) 2969 FORCEINLINE 2970 VOID 2971 RtlInitEmptyAnsiString( 2972 _Out_ PANSI_STRING AnsiString, 2973 _Pre_maybenull_ _Pre_readable_size_(BufferSize) __drv_aliasesMem PCHAR Buffer, 2974 _In_ USHORT BufferSize) 2975 { 2976 AnsiString->Length = 0; 2977 AnsiString->MaximumLength = BufferSize; 2978 AnsiString->Buffer = Buffer; 2979 } 2980 2981 _At_(UnicodeString->Buffer, _Post_equal_to_(Buffer)) 2982 _At_(UnicodeString->Length, _Post_equal_to_(0)) 2983 _At_(UnicodeString->MaximumLength, _Post_equal_to_(BufferSize)) 2984 FORCEINLINE 2985 VOID 2986 RtlInitEmptyUnicodeString( 2987 _Out_ PUNICODE_STRING UnicodeString, 2988 _Writable_bytes_(BufferSize) 2989 _When_(BufferSize != 0, _Notnull_) 2990 __drv_aliasesMem PWSTR Buffer, 2991 _In_ USHORT BufferSize) 2992 { 2993 UnicodeString->Length = 0; 2994 UnicodeString->MaximumLength = BufferSize; 2995 UnicodeString->Buffer = Buffer; 2996 } 2997 $endif (_WDMDDK_) 2998 2999 #if defined(_AMD64_) || defined(_IA64_) 3000 3001 $if (_WDMDDK_) 3002 3003 static __inline 3004 LARGE_INTEGER 3005 NTAPI_INLINE 3006 RtlExtendedIntegerMultiply( 3007 _In_ LARGE_INTEGER Multiplicand, 3008 _In_ LONG Multiplier) 3009 { 3010 LARGE_INTEGER ret; 3011 ret.QuadPart = Multiplicand.QuadPart * Multiplier; 3012 return ret; 3013 } 3014 3015 static __inline 3016 LARGE_INTEGER 3017 NTAPI_INLINE 3018 RtlExtendedLargeIntegerDivide( 3019 _In_ LARGE_INTEGER Dividend, 3020 _In_ ULONG Divisor, 3021 _Out_opt_ PULONG Remainder) 3022 { 3023 LARGE_INTEGER ret; 3024 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; 3025 if (Remainder) 3026 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 3027 return ret; 3028 } 3029 3030 $endif (_WDMDDK_) 3031 3032 $if (_NTDDK_) 3033 3034 //DECLSPEC_DEPRECATED_DDK_WINXP 3035 FORCEINLINE 3036 LARGE_INTEGER 3037 NTAPI_INLINE 3038 RtlLargeIntegerDivide( 3039 _In_ LARGE_INTEGER Dividend, 3040 _In_ LARGE_INTEGER Divisor, 3041 _Out_opt_ PLARGE_INTEGER Remainder) 3042 { 3043 LARGE_INTEGER ret; 3044 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; 3045 if (Remainder) 3046 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; 3047 return ret; 3048 } 3049 3050 #else 3051 3052 #if (NTDDI_VERSION >= NTDDI_WIN2K) 3053 NTSYSAPI 3054 LARGE_INTEGER 3055 NTAPI 3056 RtlLargeIntegerDivide( 3057 _In_ LARGE_INTEGER Dividend, 3058 _In_ LARGE_INTEGER Divisor, 3059 _Out_opt_ PLARGE_INTEGER Remainder); 3060 #endif 3061 3062 $endif (_NTDDK_) 3063 3064 #endif /* defined(_AMD64_) || defined(_IA64_) */ 3065 3066 $if (_WDMDDK_) 3067 3068 #if defined(_AMD64_) 3069 3070 #define MultiplyHigh __mulh 3071 #define UnsignedMultiplyHigh __umulh 3072 3073 //DECLSPEC_DEPRECATED_DDK 3074 static __inline 3075 LARGE_INTEGER 3076 NTAPI_INLINE 3077 RtlExtendedMagicDivide( 3078 _In_ LARGE_INTEGER Dividend, 3079 _In_ LARGE_INTEGER MagicDivisor, 3080 _In_ CCHAR ShiftCount) 3081 { 3082 LARGE_INTEGER ret; 3083 ULONG64 ret64; 3084 BOOLEAN Pos; 3085 Pos = (Dividend.QuadPart >= 0); 3086 ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, 3087 MagicDivisor.QuadPart); 3088 ret64 >>= ShiftCount; 3089 ret.QuadPart = Pos ? ret64 : -(LONG64)ret64; 3090 return ret; 3091 } 3092 #endif 3093 3094 //DECLSPEC_DEPRECATED_DDK 3095 static __inline 3096 LARGE_INTEGER 3097 NTAPI_INLINE 3098 RtlLargeIntegerAdd( 3099 _In_ LARGE_INTEGER Addend1, 3100 _In_ LARGE_INTEGER Addend2) 3101 { 3102 LARGE_INTEGER ret; 3103 ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; 3104 return ret; 3105 } 3106 3107 /* VOID 3108 * RtlLargeIntegerAnd( 3109 * IN OUT LARGE_INTEGER Result, 3110 * IN LARGE_INTEGER Source, 3111 * IN LARGE_INTEGER Mask); 3112 */ 3113 #define RtlLargeIntegerAnd(Result, Source, Mask) \ 3114 Result.QuadPart = Source.QuadPart & Mask.QuadPart 3115 3116 //DECLSPEC_DEPRECATED_DDK 3117 static __inline 3118 LARGE_INTEGER 3119 NTAPI_INLINE 3120 RtlLargeIntegerArithmeticShift( 3121 _In_ LARGE_INTEGER LargeInteger, 3122 _In_ CCHAR ShiftCount) 3123 { 3124 LARGE_INTEGER ret; 3125 ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; 3126 return ret; 3127 } 3128 3129 /* BOOLEAN 3130 * RtlLargeIntegerEqualTo( 3131 * IN LARGE_INTEGER Operand1, 3132 * IN LARGE_INTEGER Operand2); 3133 */ 3134 #define RtlLargeIntegerEqualTo(X,Y) \ 3135 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart))) 3136 3137 FORCEINLINE 3138 PVOID 3139 RtlSecureZeroMemory( 3140 _Out_writes_bytes_all_(Size) PVOID Pointer, 3141 _In_ SIZE_T Size) 3142 { 3143 volatile char* vptr = (volatile char*)Pointer; 3144 #if defined(_M_AMD64) 3145 __stosb((PUCHAR)vptr, 0, Size); 3146 #else 3147 char * endptr = (char *)vptr + Size; 3148 while (vptr < endptr) { 3149 *vptr = 0; vptr++; 3150 } 3151 #endif 3152 return Pointer; 3153 } 3154 3155 #if defined(_M_AMD64) 3156 _Must_inspect_result_ 3157 FORCEINLINE 3158 BOOLEAN 3159 RtlCheckBit( 3160 _In_ PRTL_BITMAP BitMapHeader, 3161 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition) 3162 { 3163 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); 3164 } 3165 #else 3166 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) 3167 #endif /* defined(_M_AMD64) */ 3168 3169 #define RtlLargeIntegerGreaterThan(X,Y) ( \ 3170 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ 3171 ((X).HighPart > (Y).HighPart) \ 3172 ) 3173 3174 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ 3175 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ 3176 ((X).HighPart > (Y).HighPart) \ 3177 ) 3178 3179 #define RtlLargeIntegerNotEqualTo(X,Y) ( \ 3180 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ 3181 ) 3182 3183 #define RtlLargeIntegerLessThan(X,Y) ( \ 3184 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ 3185 ((X).HighPart < (Y).HighPart) \ 3186 ) 3187 3188 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ 3189 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ 3190 ((X).HighPart < (Y).HighPart) \ 3191 ) 3192 3193 #define RtlLargeIntegerGreaterThanZero(X) ( \ 3194 (((X).HighPart == 0) && ((X).LowPart > 0)) || \ 3195 ((X).HighPart > 0 ) \ 3196 ) 3197 3198 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) 3199 3200 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) 3201 3202 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) 3203 3204 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) 3205 3206 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) 3207 3208 #endif /* !defined(MIDL_PASS) */ 3209 3210 /* Byte Swap Functions */ 3211 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x)) 3212 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) 3213 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x)) 3214 3215 #if defined(_MSC_VER) && !defined(__clang__) 3216 # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg) 3217 # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg) 3218 #else 3219 # define __assert_annotationA(msg) \ 3220 DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg) 3221 # define __assert_annotationW(msg) \ 3222 DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg) 3223 #endif 3224 3225 #ifdef _PREFAST_ 3226 # define NT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp) 3227 #elif DBG 3228 # define NT_ANALYSIS_ASSUME(_exp) ((void)0) 3229 #else 3230 # define NT_ANALYSIS_ASSUME(_exp) __noop(_exp) 3231 #endif 3232 3233 #define NT_ASSERT_ACTION(exp) \ 3234 (NT_ANALYSIS_ASSUME(exp), \ 3235 ((!(exp)) ? \ 3236 (__assert_annotationA(#exp), \ 3237 DbgRaiseAssertionFailure(), FALSE) : TRUE)) 3238 3239 #define NT_ASSERTMSG_ACTION(msg, exp) \ 3240 (NT_ANALYSIS_ASSUME(exp), \ 3241 ((!(exp)) ? \ 3242 (__assert_annotationA(msg), \ 3243 DbgRaiseAssertionFailure(), FALSE) : TRUE)) 3244 3245 #define NT_ASSERTMSGW_ACTION(msg, exp) \ 3246 (NT_ANALYSIS_ASSUME(exp), \ 3247 ((!(exp)) ? \ 3248 (__assert_annotationW(msg), \ 3249 DbgRaiseAssertionFailure(), FALSE) : TRUE)) 3250 3251 #if DBG 3252 3253 #define RTL_VERIFY(exp) \ 3254 ((!(exp)) ? \ 3255 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) 3256 3257 #define RTL_VERIFYMSG(msg, exp) \ 3258 ((!(exp)) ? \ 3259 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE) 3260 3261 #define RTL_SOFT_VERIFY(exp) \ 3262 ((!(exp)) ? \ 3263 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE) 3264 3265 #define RTL_SOFT_VERIFYMSG(msg, exp) \ 3266 ((!(exp)) ? \ 3267 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE) 3268 3269 /* The ASSERTs must be cast to void to avoid warnings about unused results. */ 3270 #define ASSERT (void)RTL_VERIFY 3271 #define ASSERTMSG (void)RTL_VERIFYMSG 3272 #define RTL_SOFT_ASSERT (void)RTL_SOFT_VERIFY 3273 #define RTL_SOFT_ASSERTMSG (void)RTL_SOFT_VERIFYMSG 3274 3275 #define NT_VERIFY NT_ASSERT_ACTION 3276 #define NT_VERIFYMSG NT_ASSERTMSG_ACTION 3277 #define NT_VERIFYMSGW NT_ASSERTMSGW_ACTION 3278 3279 #define NT_ASSERT_ASSUME (void)NT_ASSERT_ACTION 3280 #define NT_ASSERTMSG_ASSUME (void)NT_ASSERTMSG_ACTION 3281 #define NT_ASSERTMSGW_ASSUME (void)NT_ASSERTMSGW_ACTION 3282 3283 #define NT_ASSERT_NOASSUME (void)NT_ASSERT_ACTION 3284 #define NT_ASSERTMSG_NOASSUME (void)NT_ASSERTMSG_ACTION 3285 #define NT_ASSERTMSGW_NOASSUME (void)NT_ASSERTMSGW_ACTION 3286 3287 #else /* !DBG */ 3288 3289 #define ASSERT(exp) ((void)0) 3290 #define ASSERTMSG(msg, exp) ((void)0) 3291 3292 #define RTL_SOFT_ASSERT(exp) ((void)0) 3293 #define RTL_SOFT_ASSERTMSG(msg, exp) ((void)0) 3294 3295 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE) 3296 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) 3297 3298 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) 3299 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) 3300 3301 #define NT_VERIFY(exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE)) 3302 #define NT_VERIFYMSG(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE)) 3303 #define NT_VERIFYMSGW(msg, exp) (NT_ANALYSIS_ASSUME(exp), ((exp) ? TRUE : FALSE)) 3304 3305 #define NT_ASSERT_ASSUME(exp) (NT_ANALYSIS_ASSUME(exp), (void)0) 3306 #define NT_ASSERTMSG_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0) 3307 #define NT_ASSERTMSGW_ASSUME(msg, exp) (NT_ANALYSIS_ASSUME(exp), (void)0) 3308 3309 #define NT_ASSERT_NOASSUME(exp) ((void)0) 3310 #define NT_ASSERTMSG_NOASSUME(msg, exp) ((void)0) 3311 #define NT_ASSERTMSGW_NOASSUME(msg, exp) ((void)0) 3312 3313 #endif /* DBG */ 3314 3315 #define NT_FRE_ASSERT (void)NT_ASSERT_ACTION 3316 #define NT_FRE_ASSERTMSG (void)NT_ASSERTMSG_ACTION 3317 #define NT_FRE_ASSERTMSGW (void)NT_ASSERTMSGW_ACTION 3318 3319 #ifdef NT_ASSERT_ALWAYS_ASSUMES 3320 # define NT_ASSERT NT_ASSERT_ASSUME 3321 # define NT_ASSERTMSG NT_ASSERTMSG_ASSUME 3322 # define NT_ASSERTMSGW NT_ASSERTMSGW_ASSUME 3323 #else 3324 # define NT_ASSERT NT_ASSERT_NOASSUME 3325 # define NT_ASSERTMSG NT_ASSERTMSG_NOASSUME 3326 # define NT_ASSERTMSGW NT_ASSERTMSGW_NOASSUME 3327 #endif /* NT_ASSERT_ALWAYS_ASSUMES */ 3328 3329 #if defined(_MSC_VER) && (defined(__REACTOS__) || defined(ASSERT_ALWAYS_NT_ASSERT)) && !defined(_BLDR_) 3330 #undef ASSERT 3331 #define ASSERT NT_ASSERT 3332 #undef ASSERTMSG 3333 #define ASSERTMSG NT_ASSERTMSG 3334 #undef ASSERTMSGW 3335 #define ASSERTMSGW NT_ASSERTMSGW 3336 #undef RTL_VERIFY 3337 #define RTL_VERIFY NT_VERIFY 3338 #endif 3339 3340 #define InitializeListHead32(ListHead) (\ 3341 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) 3342 3343 #if !defined(_WINBASE_) 3344 3345 #if defined(_WIN64) && !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || !defined(_NTOSP_)) 3346 3347 NTKERNELAPI 3348 VOID 3349 InitializeSListHead( 3350 _Out_ PSLIST_HEADER SListHead); 3351 3352 #else /* defined(_WIN64) && ... */ 3353 3354 /* HACK */ 3355 _IRQL_requires_max_(APC_LEVEL) 3356 NTKERNELAPI 3357 DECLSPEC_NORETURN 3358 VOID 3359 NTAPI 3360 ExRaiseStatus( 3361 _In_ NTSTATUS Status); 3362 3363 FORCEINLINE 3364 VOID 3365 InitializeSListHead( 3366 _Out_ PSLIST_HEADER SListHead) 3367 { 3368 #if defined(_WIN64) 3369 if (((ULONG_PTR)SListHead & 0xf) != 0) { 3370 ExRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); 3371 } 3372 #if defined(_IA64_) 3373 SListHead->Region = (ULONG_PTR)SListHead & VRN_MASK; 3374 #else 3375 SListHead->Region = 0; 3376 #endif /* _IA64_ */ 3377 #endif /* _WIN64 */ 3378 SListHead->Alignment = 0; 3379 } 3380 3381 #endif /* defined(_WIN64) && ... */ 3382 3383 #ifdef _X86_ 3384 3385 NTKERNELAPI 3386 PSLIST_ENTRY 3387 FASTCALL 3388 InterlockedPushEntrySList( 3389 _Inout_ PSLIST_HEADER SListHead, 3390 _Inout_ __drv_aliasesMem PSLIST_ENTRY SListEntry); 3391 3392 NTKERNELAPI 3393 PSLIST_ENTRY 3394 FASTCALL 3395 InterlockedPopEntrySList( 3396 _Inout_ PSLIST_HEADER SListHead); 3397 3398 #define InterlockedFlushSList(SListHead) \ 3399 ExInterlockedFlushSList(SListHead) 3400 3401 #else /* !_X86_ */ 3402 3403 #define InterlockedPushEntrySList(SListHead, SListEntry) \ 3404 ExpInterlockedPushEntrySList(SListHead, SListEntry) 3405 3406 #define InterlockedPopEntrySList(SListHead) \ 3407 ExpInterlockedPopEntrySList(SListHead) 3408 3409 #define InterlockedFlushSList(SListHead) \ 3410 ExpInterlockedFlushSList(SListHead) 3411 3412 #endif /* _X86_ */ 3413 3414 #define QueryDepthSList(SListHead) \ 3415 ExQueryDepthSList(SListHead) 3416 3417 #endif /* !defined(_WINBASE_) */ 3418 3419 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) 3420 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) 3421 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ 3422 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) 3423 #define RTL_CONTEXT_OFFSET(Context, Chunk) \ 3424 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) 3425 #define RTL_CONTEXT_LENGTH(Context, Chunk) \ 3426 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) 3427 #define RTL_CONTEXT_CHUNK(Context, Chunk) \ 3428 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ 3429 (PCONTEXT_EX)(Context + 1), \ 3430 Chunk) 3431 3432 BOOLEAN 3433 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( 3434 _In_ ULONG Version); 3435 3436 BOOLEAN 3437 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( 3438 _In_ ULONG Version); 3439 3440 #ifndef RtlIsNtDdiVersionAvailable 3441 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable 3442 #endif 3443 3444 #ifndef RtlIsServicePackVersionInstalled 3445 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled 3446 #endif 3447 3448 #define RtlInterlockedSetBits(Flags, Flag) \ 3449 InterlockedOr((PLONG)(Flags), Flag) 3450 3451 #define RtlInterlockedAndBits(Flags, Flag) \ 3452 InterlockedAnd((PLONG)(Flags), Flag) 3453 3454 #define RtlInterlockedClearBits(Flags, Flag) \ 3455 RtlInterlockedAndBits(Flags, ~(Flag)) 3456 3457 #define RtlInterlockedXorBits(Flags, Flag) \ 3458 InterlockedXor(Flags, Flag) 3459 3460 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ 3461 (VOID) RtlInterlockedSetBits(Flags, Flag) 3462 3463 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ 3464 (VOID) RtlInterlockedAndBits(Flags, Flag) 3465 3466 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ 3467 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) 3468 3469 $endif (_WDMDDK_) 3470 3471 $if (_NTDDK_) 3472 3473 #ifdef RTL_USE_AVL_TABLES 3474 3475 #define RtlInitializeGenericTable RtlInitializeGenericTableAvl 3476 #define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl 3477 #define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl 3478 #define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl 3479 #define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl 3480 #define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl 3481 #define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl 3482 #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl 3483 #define RtlGetElementGenericTable RtlGetElementGenericTableAvl 3484 #define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl 3485 #define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl 3486 3487 #endif /* RTL_USE_AVL_TABLES */ 3488 3489 #define RtlInitializeSplayLinks(Links) { \ 3490 PRTL_SPLAY_LINKS _SplayLinks; \ 3491 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ 3492 _SplayLinks->Parent = _SplayLinks; \ 3493 _SplayLinks->LeftChild = NULL; \ 3494 _SplayLinks->RightChild = NULL; \ 3495 } 3496 3497 #define RtlIsLeftChild(Links) \ 3498 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) 3499 3500 #define RtlIsRightChild(Links) \ 3501 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) 3502 3503 #define RtlRightChild(Links) \ 3504 ((PRTL_SPLAY_LINKS)(Links))->RightChild 3505 3506 #define RtlIsRoot(Links) \ 3507 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) 3508 3509 #define RtlLeftChild(Links) \ 3510 ((PRTL_SPLAY_LINKS)(Links))->LeftChild 3511 3512 #define RtlParent(Links) \ 3513 ((PRTL_SPLAY_LINKS)(Links))->Parent 3514 3515 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ 3516 { \ 3517 PRTL_SPLAY_LINKS _SplayParent; \ 3518 PRTL_SPLAY_LINKS _SplayChild; \ 3519 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ 3520 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ 3521 _SplayParent->LeftChild = _SplayChild; \ 3522 _SplayChild->Parent = _SplayParent; \ 3523 } 3524 3525 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ 3526 { \ 3527 PRTL_SPLAY_LINKS _SplayParent; \ 3528 PRTL_SPLAY_LINKS _SplayChild; \ 3529 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ 3530 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ 3531 _SplayParent->RightChild = _SplayChild; \ 3532 _SplayChild->Parent = _SplayParent; \ 3533 } 3534 3535 #if !defined(MIDL_PASS) 3536 3537 FORCEINLINE 3538 LUID 3539 NTAPI_INLINE 3540 RtlConvertLongToLuid( 3541 _In_ LONG Val) 3542 { 3543 LUID Luid; 3544 LARGE_INTEGER Temp; 3545 3546 Temp.QuadPart = Val; 3547 Luid.LowPart = Temp.u.LowPart; 3548 Luid.HighPart = Temp.u.HighPart; 3549 return Luid; 3550 } 3551 3552 FORCEINLINE 3553 LUID 3554 NTAPI_INLINE 3555 RtlConvertUlongToLuid( 3556 _In_ ULONG Val) 3557 { 3558 LUID Luid; 3559 3560 Luid.LowPart = Val; 3561 Luid.HighPart = 0; 3562 return Luid; 3563 } 3564 3565 #endif /* !defined(MIDL_PASS) */ 3566 3567 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) 3568 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \ 3569 *CallersAddress = (PVOID)_ReturnAddress(); \ 3570 *CallersCaller = NULL; 3571 #else 3572 #if (NTDDI_VERSION >= NTDDI_WIN2K) 3573 NTSYSAPI 3574 VOID 3575 NTAPI 3576 RtlGetCallersAddress( 3577 _Out_ PVOID *CallersAddress, 3578 _Out_ PVOID *CallersCaller); 3579 #endif 3580 #endif 3581 3582 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS) 3583 3584 #if (NTDDI_VERSION >= NTDDI_WIN7) 3585 3586 FORCEINLINE 3587 VOID 3588 NTAPI 3589 RtlInitHashTableContext( 3590 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) 3591 { 3592 Context->ChainHead = NULL; 3593 Context->PrevLinkage = NULL; 3594 } 3595 3596 FORCEINLINE 3597 VOID 3598 NTAPI 3599 RtlInitHashTableContextFromEnumerator( 3600 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, 3601 _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) 3602 { 3603 Context->ChainHead = Enumerator->ChainHead; 3604 Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; 3605 } 3606 3607 FORCEINLINE 3608 VOID 3609 NTAPI 3610 RtlReleaseHashTableContext( 3611 _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) 3612 { 3613 UNREFERENCED_PARAMETER(Context); 3614 return; 3615 } 3616 3617 FORCEINLINE 3618 ULONG 3619 NTAPI 3620 RtlTotalBucketsHashTable( 3621 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable) 3622 { 3623 return HashTable->TableSize; 3624 } 3625 3626 FORCEINLINE 3627 ULONG 3628 NTAPI 3629 RtlNonEmptyBucketsHashTable( 3630 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable) 3631 { 3632 return HashTable->NonEmptyBuckets; 3633 } 3634 3635 FORCEINLINE 3636 ULONG 3637 NTAPI 3638 RtlEmptyBucketsHashTable( 3639 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable) 3640 { 3641 return HashTable->TableSize - HashTable->NonEmptyBuckets; 3642 } 3643 3644 FORCEINLINE 3645 ULONG 3646 NTAPI 3647 RtlTotalEntriesHashTable( 3648 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable) 3649 { 3650 return HashTable->NumEntries; 3651 } 3652 3653 FORCEINLINE 3654 ULONG 3655 NTAPI 3656 RtlActiveEnumeratorsHashTable( 3657 _In_ PRTL_DYNAMIC_HASH_TABLE HashTable) 3658 { 3659 return HashTable->NumEnumerators; 3660 } 3661 3662 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 3663 3664 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ 3665 3666 $endif (_NTDDK_) 3667 $if (_NTIFS_) 3668 3669 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1 3670 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2 3671 3672 #define RtlUnicodeStringToOemSize(STRING) (NLS_MB_OEM_CODE_PAGE_TAG ? \ 3673 RtlxUnicodeStringToOemSize(STRING) : \ 3674 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ 3675 ) 3676 3677 #define RtlOemStringToUnicodeSize(STRING) ( \ 3678 NLS_MB_OEM_CODE_PAGE_TAG ? \ 3679 RtlxOemStringToUnicodeSize(STRING) : \ 3680 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ 3681 ) 3682 3683 #define RtlOemStringToCountedUnicodeSize(STRING) ( \ 3684 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \ 3685 ) 3686 3687 #define RtlOffsetToPointer(B,O) ((PCHAR)(((PCHAR)(B)) + ((ULONG_PTR)(O)))) 3688 #define RtlPointerToOffset(B,P) ((ULONG)(((PCHAR)(P)) - ((PCHAR)(B)))) 3689 $endif (_NTIFS_) 3690