yifanlu / taiHEN

CFW framework for PS Vita
MIT License
302 stars 46 forks source link

Unloading kernel module exposing syscalls not working on 3.68 #85

Open MinikPLayer opened 5 years ago

MinikPLayer commented 5 years ago

As in title if i try to unload the plugin and load it again i get the same errors like in #20 thread. But for me the solution in this thread doesn't work, just the same behaviour without any change.

Code:

include "kmodule.h"

static tai_hook_ref_t unload_allowed_hook; static SceUID unload_allowed_uid;

int ksaveTestFile() { uint32_t state; ENTER_SYSCALL(state);

SceUID fd;
fd = ksceIoOpen("ux0:data/cpuid.txt", SCE_O_WRONLY | SCE_O_CREAT, 0777);
ksceIoWrite(fd, "helloWorld", 11);
ksceIoClose(fd);

EXIT_SYSCALL(state);
return 5;

}

int unload_allowed_patched(void) { int ret; ret = TAI_CONTINUE(int, unload_allowed_hook); return 1; // always allowed }

void log(char * text, int size) { SceUID fdlog = ksceIoOpen("ux0:data/vitaBtLog/log.txt", SCE_O_WRONLY | SCE_O_CREAT, 0777); ksceIoWrite(fdlog, text, size); ksceIoClose(fdlog); }

void _start() attribute((weak, alias("module_start"))); int module_start() { unload_allowed_uid = taiHookFunctionImportForKernel(KERNEL_PID, &unload_allowed_hook, // Output a reference "SceKernelModulemgr", // Name of module being hooked 0x11F9B314, // NID specifying SceSblACMgrForKernel 0xBBA13D9C, // Function NID unload_allowed_patched); // Name of the hook function

log("Module started and function hooked", 35);

return SCE_KERNEL_START_SUCCESS;

}

int module_stop() { taiHookReleaseForKernel(unload_allowed_uid, unload_allowed_hook); return SCE_KERNEL_STOP_SUCCESS; }



Module loaded with taiLoadStartKernelModule() and unloaded with taiStopUnloadKernelModule()

PS VITA PHAT 3.68 H-Encore
Princess-of-Sleeping commented 4 years ago

Caused by

  1. Basically, the module that exposes syscall cannot be unloaded
  2. Nid has been changed in 3.68. 3.60:ksceSblACMgrIsDevelopmentMode2: 0xBBA13D9C