aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-04-28 13:46:24 -0400
committer浅倉麗子2020-04-28 13:46:24 -0400
commit9c13bfd7796f76f6f30d99ddce7d115214192dda (patch)
tree561993ff768e6506a578870e6175d3610f0a2193
parentAdd configuration app (diff)
downloadsharpscale-9c13bfd7796f76f6f30d99ddce7d115214192dda.tar.gz
Add UNHOOK function
-rw-r--r--main.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/main.c b/main.c
index 6d34078..6f589ed 100644
--- a/main.c
+++ b/main.c
@@ -86,6 +86,17 @@ static SceUID hook_offset(int idx, int mod, int ofs, void *func) {
#define HOOK_OFFSET(idx, mod, ofs, func)\
hook_offset(idx, mod, ofs, func##_hook)
+static int UNHOOK(int idx) {
+ int ret = 0;
+ if (hook_id[idx] >= 0) {
+ ret = taiHookReleaseForKernel(hook_id[idx], hook_ref[idx]);
+ LOG("Unhooked %d UID %08X\n", idx, hook_id[idx]);
+ hook_id[idx] = -1;
+ hook_ref[idx] = -1;
+ }
+ return ret;
+}
+
extern int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset, uintptr_t *addr);
#define GET_OFFSET(modid, seg, ofs, addr)\
module_get_offset(KERNEL_PID, modid, seg, ofs, (uintptr_t*)addr)
@@ -205,12 +216,7 @@ static void startup(void) {
}
static void cleanup(void) {
- for (int i = 0; i < N_HOOK; i++) {
- if (hook_id[i] >= 0) {
- taiHookReleaseForKernel(hook_id[i], hook_ref[i]);
- LOG("Unhooked %d UID %08X\n", i, hook_id[i]);
- }
- }
+ for (int i = 0; i < N_HOOK; i++) { UNHOOK(i); }
}
int _start() __attribute__ ((weak, alias("module_start")));