Skip to content

Commit 98685bb

Browse files
authored
Added dev/testkit support
1 parent 71f35dd commit 98685bb

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

ps5-kstuff/main.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@
77
#include <stdarg.h>
88
#include <unistd.h>
99
#include <fcntl.h>
10+
#include <sys/stat.h>
11+
#include <stdbool.h>
1012
#include "../prosper0gdb/r0gdb.h"
1113
#include "../prosper0gdb/offsets.h"
1214
#include "../gdb_stub/dbg.h"
1315
#include "uelf/structs.h"
1416
#include "uelf/parasite_desc.h"
1517

18+
bool if_exists(const char *path) {
19+
struct stat buffer;
20+
return stat(path, &buffer) == 0;
21+
}
22+
23+
bool sceKernelIsTestKit() {
24+
return if_exists("/system/priv/lib/libSceDeci5Ttyp.sprx");
25+
}
26+
1627
void* dlsym(void*, const char*);
1728

1829
void notify(const char* s)
@@ -2118,7 +2129,8 @@ int main(void* ds, int a, int b, uintptr_t c, uintptr_t d)
21182129
copyout(&q, offsets.security_flags, 4);
21192130
q |= 0x14;
21202131
copyin(offsets.security_flags, &q, 4);
2121-
copyin(offsets.targetid, "\x82", 1);
2132+
if(!sceKernelIsTestKit())
2133+
copyin(offsets.targetid, "\x82", 1);
21222134
copyout(&q, offsets.qa_flags, 4);
21232135
q |= 0x1030300;
21242136
copyin(offsets.qa_flags, &q, 4);
@@ -2136,7 +2148,8 @@ int main(void* ds, int a, int b, uintptr_t c, uintptr_t d)
21362148
#endif
21372149
copyin(IDT+16*9+5, "\x8e", 1);
21382150
copyin(IDT+16*179+5, "\x8e", 1);
2139-
patch_shellcore(shellcore_patches, n_shellcore_patches, shellcore_eh_frame_offset);
2151+
if(!sceKernelIsTestKit())
2152+
patch_shellcore(shellcore_patches, n_shellcore_patches, shellcore_eh_frame_offset);
21402153
gdb_remote_syscall("write", 3, 0, (uintptr_t)1, (uintptr_t)"done\npatching app.db... ", (uintptr_t)24);
21412154
#ifndef FIRMWARE_PORTING
21422155
//patch_app_db();
@@ -2149,3 +2162,4 @@ int main(void* ds, int a, int b, uintptr_t c, uintptr_t d)
21492162
asm volatile("ud2");
21502163
return 0;
21512164
}
2165+

0 commit comments

Comments
 (0)