-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
83 lines (71 loc) · 1.76 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <psp2/kernel/modulemgr.h>
#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/clib.h>
#include <psp2/net/netctl.h>
#include <psp2/power.h>
#include <taihen.h>
static SceUID g_hook, g_hook2;
static tai_hook_ref_t ref_hook0, ref_hook1;
int ret0() {
return 0;
}
int fake_dev_mode(uint8_t *ret) {
*ret = 0;
return 0;
}
void _start() __attribute__ ((weak, alias ("module_start")));
int module_start(SceSize argc, const void *args) {
tai_module_info_t info;
info.size = sizeof(info);
int ret = taiGetModuleInfo("SceShell", &info);
if (ret < 0) {
sceClibPrintf("taiGetModuleInfo error %X\n", ret);
return SCE_KERNEL_START_FAILED;
}
uint32_t offset;
uint32_t offset2;
switch (info.module_nid) {
case 0xEAB89D5C: // PTEL 3.60 SceShell
offset = 0x2c2af8;
offset2 = 0x2ce4d4;
break;
case 0x6CB01295: // PDEL 3.60 SceShell
offset = 0x2be204;
offset2 = 0;
break;
case 0x0552F692: // Retail 3.60 SceShell
offset = 0x2cc088;
offset2 = 0x2d7a64;
break;
case 0x5549BF1F: // Retail 3.65 SceShell
case 0x34B4D82E: // Retail 3.67 SceShell
case 0x12DAC0F3: // Retail 3.68 SceShell
offset = 0x2cc4cc;
offset2 = 0x2d7ea8;
break;
default:
sceClibPrintf("Unsupported firmware\n");
return SCE_KERNEL_START_FAILED;
}
g_hook = taiHookFunctionOffset(&ref_hook0,
info.modid,
0, // segidx
offset, // offset
1, // thumb
ret0);
if (offset2) {
g_hook2 = taiHookFunctionOffset(&ref_hook1,
info.modid,
0, // segidx
offset2, // offset
1, // thumb
fake_dev_mode);
}
return SCE_KERNEL_START_SUCCESS;
}
int module_stop(SceSize argc, const void *args) {
sceClibPrintf("Stopping module\n");
if (g_hook >= 0) taiHookRelease(g_hook, ref_hook0);
if (g_hook2 >= 0) taiHookRelease(g_hook2, ref_hook1);
return SCE_KERNEL_STOP_SUCCESS;
}