-
Notifications
You must be signed in to change notification settings - Fork 2
/
xcpm_patch.c
59 lines (50 loc) · 1.12 KB
/
xcpm_patch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <kernel_patcher.h>
#include <modules.h>
#define HEADER
typedef struct {
UInt32 msr;
UInt32 unk0;
UInt32 unk1;
UInt32 unk2;
UInt32 unk3;
UInt32 unk4;
UInt32 data;
UInt32 unk5;
UInt32 unk6;
UInt32 unk7;
UInt32 unk8;
UInt32 unk9;
} msr_t;
void patch_xcpm_msr(void* kernelData)
{
int i = 0;
UInt8* bytes = (UInt8*)kernelData;
// Location section containing symbol
section_t* data = lookup_section("__DATA","__data");
if(!data)
{
printf(HEADER "Unable to locate __DATA,__data\n");
return;
}
// Locate symbol needing patch:
symbolList_t* symbol = lookup_kernel_symbol("_xcpm_core_scope_msrs");
if(!symbol || !symbol->addr)
{
printf(HEADER "Unable to locate _xcpm_scope_msrs");
return;
}
UInt32 addr = data->address;
UInt32 offset = data->offset;
msr_t* msrs = (void*)((UInt32)&bytes[(UInt32)(symbol->addr - data->address + data->offset)]);
// TODO: chose better end condiont (such as end of variable)
for(i = 0; i < 10; i++)
{
//printf("msr[%d] = 0x%X (0x%X)\n", i, msrs[i].msr, msrs[i].data);
if(msrs[i].msr == 0xe2)
{
msrs[i].msr = 0;
msrs[i].unk0 = 0;
}
}
//pause();
}