| 568 | } |
| 569 | |
| 570 | BOOLEAN intel_driver::MmSetPageProtection(uint64_t address, uint32_t size, ULONG new_protect) |
| 571 | { |
| 572 | if (!address) |
| 573 | { |
| 574 | Log::Warning("Invalid address passed to MmSetPageProtection", false); |
| 575 | return FALSE; |
| 576 | } |
| 577 | |
| 578 | static uint64_t kernel_MmSetPageProtection = 0; |
| 579 | |
| 580 | if (!kernel_MmSetPageProtection) |
| 581 | { |
| 582 | //Updated, tested from 1803 to 24H2 |
| 583 | // 0F 45 ? ? 8D ? ? ? FF FF E8 |
| 584 | // 0F 45 ? ? 45 8B ? ? ? ? 8D ? ? ? ? ? ? FF FF E8 (Some windows builds have a instruction in the middle) |
| 585 | kernel_MmSetPageProtection = intel_driver::FindPatternInSectionAtKernel("PAGELK", intel_driver::ntoskrnlAddr, |
| 586 | (BYTE*)"\x0F\x45\x00\x00\x8D\x00\x00\x00\xFF\xFF\xE8", |
| 587 | (char*)"xx??x???xxx"); |
| 588 | if (!kernel_MmSetPageProtection) { |
| 589 | |
| 590 | kernel_MmSetPageProtection = intel_driver::FindPatternInSectionAtKernel("PAGELK", intel_driver::ntoskrnlAddr, |
| 591 | (BYTE*)"\x0F\x45\x00\x00\x45\x8B\x00\x00\x00\x00\x8D\x00\x00\x00\x00\x00\x00\xFF\xFF\xE8", |
| 592 | (char*)"xx??xx????x???xxx"); |
| 593 | |
| 594 | if (!kernel_MmSetPageProtection) { |
| 595 | Log::Warning("Failed to find MmSetPageProtection", false); |
| 596 | return FALSE; |
| 597 | } |
| 598 | |
| 599 | kernel_MmSetPageProtection += 13; |
| 600 | } |
| 601 | else { |
| 602 | kernel_MmSetPageProtection += 10; |
| 603 | } |
| 604 | |
| 605 | kernel_MmSetPageProtection = (uint64_t)ResolveRelativeAddress((PVOID)kernel_MmSetPageProtection, 1, 5); |
| 606 | if (!kernel_MmSetPageProtection) { |
| 607 | Log::Warning("Failed to find MmSetPageProtection", false); |
| 608 | return FALSE; |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | BOOLEAN set_prot_status{}; |
| 613 | if (!intel_driver::CallKernelFunction(&set_prot_status, kernel_MmSetPageProtection, address, size, new_protect)) |
| 614 | return FALSE; |
| 615 | |
| 616 | return set_prot_status; |
| 617 | } |
| 618 | |
| 619 | uint64_t intel_driver::AllocatePool(nt::POOL_TYPE pool_type, uint64_t size) { |
| 620 | if (!size) |
nothing calls this directly
no test coverage detected