Skip to content

Commit

Permalink
Fix 5.05 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sleirsgoevy committed Sep 16, 2021
1 parent 54bf58b commit 9b0ed7d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
3 changes: 0 additions & 3 deletions app/app/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <signal.h>

int jailbreak(void);
int maybe_load_tun(void);
int my_fork(void);
void my_exit(int);
int ldr_main(int argc, const char** argv);
Expand Down Expand Up @@ -83,7 +82,5 @@ int init_daemon(void)
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
if(maybe_load_tun())
return -1;
return 0;
}
16 changes: 16 additions & 0 deletions app/app/getfw.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <orbis/libkernel.h>

int dynlib_get_obj_member(int module_id, int which, void** out);

//obtain the target firmware of libkernel.sprx. should be the same as the current firmware, and bypasses spoofs
uint32_t get_fw_version(void)
{
int libkernel = sceKernelLoadStartModule("libkernel.sprx", 0, 0, 0, 0, 0);
if(libkernel < 0)
return -1;
void* sce_proc_param;
if(dynlib_get_obj_member(libkernel, 8, &sce_proc_param))
return -1;
uint32_t* spp = sce_proc_param;
return spp[4];
}
23 changes: 13 additions & 10 deletions app/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <signal.h>
#include "gui.h"

int maybe_load_tun(void);
int init_daemon(void);
int start_daemon(void);
void daemon_thread(void);
Expand All @@ -31,12 +32,17 @@ char* concat3(const char* s1, const char* s2, const char* s3)
return buf;
}

int is_sw_version_supported(void)
uint32_t get_fw_version(void);

void check_is_sw_version_supported(void)
{
OrbisKernelSwVersion sw_ver;
sceKernelGetSystemSwVersion(&sw_ver);
int ver = sw_ver.i_version >> 16;
return ver == 0x505 || ver == 0x672 || ver == 0x702 || (ver >= 0x750 && ver <= 0x755);
int ver = get_fw_version() >> 16;
if(ver == 0x505 || ver == 0x672 || ver == 0x702 || (ver >= 0x750 && ver <= 0x755))
return;
char errormsg[256];
sprintf(errormsg, "Your firmware version is not supported. Supported versions: 5.05, 6.72, 7.02, 7.5X. Your version: %x.%02x", ver >> 8, ver & 255);
gui_init();
gui_show_error_screen(errormsg);
}

int main(int argc, const char** argv)
Expand All @@ -49,11 +55,8 @@ int main(int argc, const char** argv)
return 0;
}
gui_preinit();
if(!is_sw_version_supported())
{
gui_init();
gui_show_error_screen("Your firmware version is not supported. Supported versions: 6.72, 7.02, 7.5X"); //noreturn
}
check_is_sw_version_supported();
maybe_load_tun();
int d_st = start_daemon();
if(d_st > 0)
{
Expand Down
31 changes: 20 additions & 11 deletions app/app/maybe_tun.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#include <unistd.h>
#include <fcntl.h>
#include "libjbc/utils.h"
#include <errno.h>
#include <orbis/libkernel.h>

void load_tun_tsr(int);
void load_uhack_tsr(int);
int open(const char*, int);
int close(int);

int maybe_load_tun(void)
uint32_t get_fw_version(void);

static void do_maybe_load_tun(void* p_status)
{
int* status = p_status;
*status = 0;
int fd = open("/dev/tun", 0);
if(fd < 0)
{
if(errno == ENOENT)
{
OrbisKernelSwVersion sw_ver;
sceKernelGetSystemSwVersion(&sw_ver);
load_tun_tsr(sw_ver.i_version >> 16);
return 0;
load_tun_tsr(get_fw_version() >> 16);
*status = 0;
}
return -1;
*status = -1;
return;
}
close(fd);
return 0;
return;
}

int maybe_load_tun(void)
{
int status;
jbc_run_as_root(do_maybe_load_tun, &status, CWD_RESET);
return status;
}
2 changes: 1 addition & 1 deletion tun/tunldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void load_start_module(void* td, struct uap* uap)
if(uap->arg == 0x505)
{
// 5.05 offsets
kernel_map = *(unsigned long long*)(kernel_map + 0x1ac60e0);
kernel_map = *(unsigned long long*)(kernel_base + 0x1ac60e0);
kmem_alloc = (void*)(kernel_base + 0xfcc80);
copyin = (void*)(kernel_base + 0x1ea710);
blob = blob_505;
Expand Down

0 comments on commit 9b0ed7d

Please sign in to comment.