taiHEN icon indicating copy to clipboard operation
taiHEN copied to clipboard

Unloading kernel module exposing syscalls not working on 3.68

Open MinikPLayer opened this issue 6 years ago • 1 comments

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:

  • kmodule.c file:
#include <vitasdkkern.h>
#include <taihen.h>

#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

MinikPLayer avatar Jan 25 '19 18:01 MinikPLayer

Caused by

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

Princess-of-Sleeping avatar Dec 11 '19 02:12 Princess-of-Sleeping