From ad04c7966950f4f7dbc96790712311b74a6c90d6 Mon Sep 17 00:00:00 2001 From: CTurt Date: Sun, 24 Apr 2016 08:29:59 +0100 Subject: [PATCH] Improve libk handling --- libPS4/include/kernel.h | 2 ++ libPS4/source/jit.c | 9 +++---- libPS4/source/kernel.c | 65 +++++++++++++++++++++++++------------------------ libPS4/source/pthread.c | 29 ++++++++++------------ 4 files changed, 51 insertions(+), 54 deletions(-) diff --git a/libPS4/include/kernel.h b/libPS4/include/kernel.h index ed33090..a00becf 100644 --- a/libPS4/include/kernel.h +++ b/libPS4/include/kernel.h @@ -5,6 +5,8 @@ typedef struct timeval SceKernelTimeval; typedef uint64_t SceKernelEqueue; +extern int libKernelHandle; + extern int (*sceKernelLoadStartModule)(const char *name, size_t argc, const void *argv, unsigned int flags, int, int); extern int (*sceKernelAllocateDirectMemory)(off_t searchStart, off_t searchEnd, size_t length, size_t alignment, int type, off_t *physicalAddressDestination); diff --git a/libPS4/source/jit.c b/libPS4/source/jit.c index f94c130..4c19d9d 100644 --- a/libPS4/source/jit.c +++ b/libPS4/source/jit.c @@ -9,12 +9,9 @@ int (*sceKernelJitCreateAliasOfSharedMemory)(int handle, int protection, int *de int (*sceKernelJitMapSharedMemory)(int handle, int protection, void **destination); void initJIT(void) { - int libkernel; - loadModule("libkernel.sprx", &libkernel); - - RESOLVE(libkernel, sceKernelJitCreateSharedMemory); - RESOLVE(libkernel, sceKernelJitCreateAliasOfSharedMemory); - RESOLVE(libkernel, sceKernelJitMapSharedMemory); + RESOLVE(libKernelHandle, sceKernelJitCreateSharedMemory); + RESOLVE(libKernelHandle, sceKernelJitCreateAliasOfSharedMemory); + RESOLVE(libKernelHandle, sceKernelJitMapSharedMemory); } void allocateJIT(size_t size, void **executableAddress, void **writableAddress) { diff --git a/libPS4/source/kernel.c b/libPS4/source/kernel.c index a74f029..5fc8841 100644 --- a/libPS4/source/kernel.c +++ b/libPS4/source/kernel.c @@ -3,6 +3,8 @@ #include "kernel.h" +int libKernelHandle; + int (*sceKernelLoadStartModule)(const char *name, size_t argc, const void *argv, unsigned int flags, int, int); int (*sceKernelAllocateDirectMemory)(off_t searchStart, off_t searchEnd, size_t length, size_t alignment, int type, off_t *physicalAddressDestination); @@ -41,39 +43,38 @@ SYSCALL(kill, 37); SYSCALL(ioctl, 54); void initKernel(void) { - int libkernel; - loadModule("libkernel.sprx", &libkernel); + loadModule("libkernel.sprx", &libKernelHandle); - RESOLVE(libkernel, sceKernelLoadStartModule); + RESOLVE(libKernelHandle, sceKernelLoadStartModule); - RESOLVE(libkernel, sceKernelAllocateDirectMemory); - RESOLVE(libkernel, sceKernelMapDirectMemory); + RESOLVE(libKernelHandle, sceKernelAllocateDirectMemory); + RESOLVE(libKernelHandle, sceKernelMapDirectMemory); - RESOLVE(libkernel, sceKernelSleep); - RESOLVE(libkernel, sceKernelUsleep); - RESOLVE(libkernel, sceKernelGettimeofday); - RESOLVE(libkernel, sceKernelGetProcessTime); - RESOLVE(libkernel, sceKernelGetCurrentCpu); - - RESOLVE(libkernel, sysctl); - RESOLVE(libkernel, sysctlbyname); - RESOLVE(libkernel, sysarch); - RESOLVE(libkernel, execve); - - RESOLVE(libkernel, pthread_self); - RESOLVE(libkernel, pthread_setaffinity_np); - - RESOLVE(libkernel, sceKernelCreateEqueue); - RESOLVE(libkernel, sceKernelDeleteEqueue); - RESOLVE(libkernel, sceKernelAddUserEvent); - RESOLVE(libkernel, sceKernelAddReadEvent); - - RESOLVE(libkernel, getuid); - RESOLVE(libkernel, getgid); - RESOLVE(libkernel, getpid); - - RESOLVE(libkernel, setuid); - RESOLVE(libkernel, setgid); - RESOLVE(libkernel, setreuid); - RESOLVE(libkernel, setregid); + RESOLVE(libKernelHandle, sceKernelSleep); + RESOLVE(libKernelHandle, sceKernelUsleep); + RESOLVE(libKernelHandle, sceKernelGettimeofday); + RESOLVE(libKernelHandle, sceKernelGetProcessTime); + RESOLVE(libKernelHandle, sceKernelGetCurrentCpu); + + RESOLVE(libKernelHandle, sysctl); + RESOLVE(libKernelHandle, sysctlbyname); + RESOLVE(libKernelHandle, sysarch); + RESOLVE(libKernelHandle, execve); + + RESOLVE(libKernelHandle, pthread_self); + RESOLVE(libKernelHandle, pthread_setaffinity_np); + + RESOLVE(libKernelHandle, sceKernelCreateEqueue); + RESOLVE(libKernelHandle, sceKernelDeleteEqueue); + RESOLVE(libKernelHandle, sceKernelAddUserEvent); + RESOLVE(libKernelHandle, sceKernelAddReadEvent); + + RESOLVE(libKernelHandle, getuid); + RESOLVE(libKernelHandle, getgid); + RESOLVE(libKernelHandle, getpid); + + RESOLVE(libKernelHandle, setuid); + RESOLVE(libKernelHandle, setgid); + RESOLVE(libKernelHandle, setreuid); + RESOLVE(libKernelHandle, setregid); } diff --git a/libPS4/source/pthread.c b/libPS4/source/pthread.c index c525dcf..69917f2 100644 --- a/libPS4/source/pthread.c +++ b/libPS4/source/pthread.c @@ -19,21 +19,18 @@ int (*scePthreadMutexTimedlock)(ScePthreadMutex *mutex, SceKernelUseconds usec); int (*scePthreadMutexUnlock)(ScePthreadMutex *mutex); void initPthread(void) { - int libkernel; - loadModule("libkernel.sprx", &libkernel); + RESOLVE(libKernelHandle, scePthreadCreate); + RESOLVE(libKernelHandle, scePthreadExit); + RESOLVE(libKernelHandle, scePthreadDetach); + RESOLVE(libKernelHandle, scePthreadJoin); + RESOLVE(libKernelHandle, scePthreadYield); + RESOLVE(libKernelHandle, scePthreadSelf); + RESOLVE(libKernelHandle, scePthreadCancel); - RESOLVE(libkernel, scePthreadCreate); - RESOLVE(libkernel, scePthreadExit); - RESOLVE(libkernel, scePthreadDetach); - RESOLVE(libkernel, scePthreadJoin); - RESOLVE(libkernel, scePthreadYield); - RESOLVE(libkernel, scePthreadSelf); - RESOLVE(libkernel, scePthreadCancel); - - RESOLVE(libkernel, scePthreadMutexInit); - RESOLVE(libkernel, scePthreadMutexDestroy); - RESOLVE(libkernel, scePthreadMutexLock); - RESOLVE(libkernel, scePthreadMutexTrylock); - RESOLVE(libkernel, scePthreadMutexTimedlock); - RESOLVE(libkernel, scePthreadMutexUnlock); + RESOLVE(libKernelHandle, scePthreadMutexInit); + RESOLVE(libKernelHandle, scePthreadMutexDestroy); + RESOLVE(libKernelHandle, scePthreadMutexLock); + RESOLVE(libKernelHandle, scePthreadMutexTrylock); + RESOLVE(libKernelHandle, scePthreadMutexTimedlock); + RESOLVE(libKernelHandle, scePthreadMutexUnlock); } -- 2.11.4.GIT