Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jan 30, 2024
1 parent b88cd71 commit 4bf4141
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions kernel_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int pspXploitInitKernelExploit(){
#endif

// figure out address of libctime
u32 libctime_addr = pspXploitFindFunctionFromUsermode("UtilsForUser", 0x27CC57F0, (u32)kram_copy, (u32)kram_copy + KRAM_BACKUP_SIZE);
u32 libctime_addr = pspXploitFindFunctionFromUsermode("UtilsForUser", 0x27CC57F0, kram_copy, KRAM_BACKUP_SIZE);

if (libctime_addr == NULL){
sceKernelFreePartitionMemory(memid);
Expand Down Expand Up @@ -110,6 +110,6 @@ int pspXploitDoKernelExploit()
}

sceKernelTerminateDeleteThread(qwikthread);

return (is_exploited)? 0 : -1;
}
15 changes: 6 additions & 9 deletions libpspexploit.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ int pspXploitCloseP5()
return 1;
}

u32 pspXploitFindFunctionFromUsermode(const char *library, u32 nid, u32 start_addr, u32 end_addr)
u32 pspXploitFindFunctionFromUsermode(const char *library, u32 nid, void* buf, u32 size)
{
u32 addr = start_addr;
u32 addr;
u32 start_addr = (u32)buf;

if (addr) {
u32 maxaddr = end_addr;
for (; addr < maxaddr; addr += 4) {
if (buf) {
u32 maxaddr = start_addr+size;
for (addr=start_addr; addr < maxaddr; addr += 4) {
if (strcmp(library, (const char *)addr) == 0) {

u32 libaddr = (addr-start_addr-4) + 0x88000000; // TODO: is -4 necessary?
Expand Down Expand Up @@ -414,10 +415,6 @@ u32 pspXploitResolveImport(char* lib, u32 nid, u32 version){
return ret;
}

void _flush_cache(){
sceKernelDcacheWritebackAll();
}

int pspXploitIsKernel(){
u32 ra;
__asm__ volatile ("move %0, $ra;" : "=r"(ra));
Expand Down
10 changes: 5 additions & 5 deletions libpspexploit.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ typedef struct KernelFunctions{
#define pspXploitFindFirstJALReverse(addr) pspXploitFindAnyJAL(addr, 1, 0)
#define pspXploitFindJAL(addr, pos) pspXploitFindAnyJAL(addr, 0, pos)
#define pspXploitFindJALReverse(addr, pos) pspXploitFindAnyJAL(addr, 1, pos)
#define pspXploitFindFirstJALForFunction(modname, libname, uid) findFirstJAL(FindFunction(modname, libname, uid))
#define pspXploitFindJALForFunction(modname, libname, uid, pos) findJAL(FindFunction(modname, libname, uid), pos)
#define pspXploitFindFirstJALReverseForFunction(modname, libname, uid) findFirstJALReverse(FindFunction(modname, libname, uid))
#define pspXploitFindJALReverseForFunction(modname, libname, uid, pos) findJALReverse(FindFunction(modname, libname, uid), pos)
#define pspXploitFindFirstJALForFunction(modname, libname, nid) findFirstJAL(FindFunction(modname, libname, nid))
#define pspXploitFindJALForFunction(modname, libname, nid, pos) findJAL(FindFunction(modname, libname, nid), pos)
#define pspXploitFindFirstJALReverseForFunction(modname, libname, nid) findFirstJALReverse(FindFunction(modname, libname, nid))
#define pspXploitFindJALReverseForFunction(modname, libname, nid, pos) findJALReverse(FindFunction(modname, libname, nid), pos)
u32 pspXploitFindAnyJAL(u32 addr, int reversed, int skip);
u32 pspXploitFindFirstBEQ(u32 addr);
u32 pspXploitFindRefInGlobals(char* libname, u32 addr, u32 ptr);
Expand All @@ -181,7 +181,7 @@ u32 pspXploitFindImportVolatileRam(char *libname, u32 nid);
u32 pspXploitFindImportUserRam(char *libname, u32 nid);
int pspXploitOpenP5(int mode);
int pspXploitCloseP5();
u32 pspXploitFindFunctionFromUsermode(const char *library, u32 nid, u32 start_addr, u32 end_addr);
u32 pspXploitFindFunctionFromUsermode(const char *library, u32 nid, void* buf, u32 size);
u32 pspXploitResolveImport(char* lib, u32 nid, u32 version);

// Kernel Utils
Expand Down

0 comments on commit 4bf4141

Please sign in to comment.