Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unloading kernel module exposing syscalls not working on 3.68 #85

Open
MinikPLayer opened this issue Jan 25, 2019 · 1 comment
Open

Comments

@MinikPLayer
Copy link

MinikPLayer commented Jan 25, 2019

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

@Princess-of-Sleeping
Copy link

Princess-of-Sleeping commented Dec 11, 2019

Caused by

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants