forked from SKGleba/modoru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.c
37 lines (30 loc) · 1.24 KB
/
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
/* patch.c -- allow kernel module unloading
*
* Copyright (C) 2019 TheFloW
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include <psp2kern/kernel/modulemgr.h>
#include <taihen.h>
static tai_hook_ref_t ksceSblACMgrIsDevelopmentModeRef;
static SceUID hookid = -1;
static int ksceSblACMgrIsDevelopmentModePatched(void) {
TAI_CONTINUE(int, ksceSblACMgrIsDevelopmentModeRef);
return 1;
}
void _start() __attribute__ ((weak, alias ("module_start")));
int module_start(SceSize args, void *argp) {
hookid = taiHookFunctionImportForKernel(KERNEL_PID, &ksceSblACMgrIsDevelopmentModeRef, "SceKernelModulemgr",
TAI_ANY_LIBRARY, 0xBBA13D9C, ksceSblACMgrIsDevelopmentModePatched);
if (hookid < 0) {
hookid = taiHookFunctionImportForKernel(KERNEL_PID, &ksceSblACMgrIsDevelopmentModeRef, "SceKernelModulemgr",
TAI_ANY_LIBRARY, 0xE87D1777, ksceSblACMgrIsDevelopmentModePatched);
}
return SCE_KERNEL_START_SUCCESS;
}
int module_stop(SceSize args, void *argp) {
if (hookid >= 0)
taiHookReleaseForKernel(hookid, ksceSblACMgrIsDevelopmentModeRef);
return SCE_KERNEL_STOP_SUCCESS;
}