testing KernelPm patch

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-05-05 09:09:48 +03:00
parent cf41491adc
commit f0c8a7c96f

View File

@ -751,6 +751,8 @@ VOID LOADER_ENTRY::KernelCPUIDPatch(UINT8* kernelData)
}
}
#define NEW_PM 0
BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData)
{
DBG_RT("Patching kernel power management...\n");
@ -767,7 +769,7 @@ BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData)
const UINT8 patchJmp[] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90};
DBG_RT("==> xcpm_idle at %llx\n", procLocation);
INTN Num = SearchAndReplace(&Kernel[procLocation], 0x400, findJmp, sizeof(findJmp), patchJmp, 0);
DBG_RT("==> found %lld patterns\n", Num);
//2. procedure xcpm_init
// indirect call to _xcpm_core_scope_msrs and _xcpm_SMT_scope_msrs
// 488D3DDA317600 lea rdi, qword [ds:_xcpm_SMT_scope_msrs]
@ -796,7 +798,7 @@ BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData)
UINTN symbol2 = searchProc(Kernel, "_xcpm_SMT_scope_msrs", &procLen);
patchLocation1 = FindRelative32(Kernel, procLocation, 0x200, symbol2);
if (patchLocation1 != 0) {
DBG_RT("=> _xcpm_SMT_scope_msrs found at %llx\n", patchLocation2);
DBG_RT("=> _xcpm_SMT_scope_msrs found at %llx\n", patchLocation1);
if (Kernel[patchLocation1 + 7] == 0xE8) {
DBG_RT("=> patch applied\n");
Kernel[patchLocation1] = 0xEB;