Skip to content

Commit d99f8cf

Browse files
committed
make path variables
1 parent b94bb09 commit d99f8cf

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

installer/include/path.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#define BASE_PATH "/data/hen"
4+
#define HEN_INI "hen.ini"
5+
#define HDD_INI_PATH BASE_PATH "/" HEN_INI
6+
#define USB_INI_PATH "/mnt/usb0/" HEN_INI

installer/source/main.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#define VERSION "2.2.0 BETA"
66

7+
#include "path.h"
78
#include "defines.h"
89
#include "offsets.h"
910

@@ -460,7 +461,7 @@ int set_target_id(char *tid) {
460461
snprintf(buffer, buffer_size, "Kratos");
461462
break;
462463
default:
463-
printf_notification("Spoofing: UNKNOWN...\nCheck your `hen.ini` file");
464+
printf_notification("Spoofing: UNKNOWN...\nCheck your `" HEN_INI "` file");
464465
return -1;
465466
}
466467

@@ -485,9 +486,9 @@ static void write_blob(const char* path, const void* blob, const size_t blobsz)
485486
}
486487

487488
static void upload_prx_to_disk(void) {
488-
write_blob("/user/data/hen/plugin_bootloader.prx", plugin_bootloader_prx, plugin_bootloader_prx_len);
489-
write_blob("/user/data/hen/plugin_loader.prx", plugin_loader_prx, plugin_loader_prx_len);
490-
write_blob("/user/data/hen/plugin_server.prx", plugin_server_prx, plugin_server_prx_len);
489+
write_blob("/user/" BASE_PATH "/plugin_bootloader.prx", plugin_bootloader_prx, plugin_bootloader_prx_len);
490+
write_blob("/user/" BASE_PATH "/plugin_loader.prx", plugin_loader_prx, plugin_loader_prx_len);
491+
write_blob("/user/" BASE_PATH "/plugin_server.prx", plugin_server_prx, plugin_server_prx_len);
491492
}
492493

493494
static void kill_proc(const char* proc) {
@@ -505,7 +506,7 @@ static void kill_proc(const char* proc) {
505506

506507

507508
static void upload_ver(void) {
508-
write_blob("/user/data/hen/ps4hen_version.txt", VERSION, sizeof(VERSION) - 1);
509+
write_blob("/user/" BASE_PATH "/ps4hen_version.txt", VERSION, sizeof(VERSION) - 1);
509510
}
510511

511512
int _main(struct thread *td) {
@@ -537,23 +538,23 @@ int _main(struct thread *td) {
537538
memset(&config, '\0', sizeof(config));
538539
config.disable_aslr = DEFAULT_DISABLE_ASLR;
539540
config.nobd_patches = DEFAULT_NOBD_PATCHES;
540-
if (file_exists("/mnt/usb0/hen.ini")) {
541-
if (cfg_parse("/mnt/usb0/hen.ini", config_handler, &config) < 0) {
542-
printf_notification("ERROR: Unable to load `/mnt/usb0/hen.ini`");
541+
if (file_exists(USB_INI_PATH)) {
542+
if (cfg_parse(USB_INI_PATH, config_handler, &config) < 0) {
543+
printf_notification("ERROR: Unable to load `" USB_INI_PATH "`");
543544
// Restore defaults in case one of them changed for some reason...
544545
memset(&config, '\0', sizeof(config));
545546
config.disable_aslr = DEFAULT_DISABLE_ASLR;
546547
config.nobd_patches = DEFAULT_NOBD_PATCHES;
547548
} else {
548-
if (!file_compare("/mnt/usb0/hen/hen.ini", "/data/hen/hen.ini")) {
549-
unlink("/data/hen/hen.ini");
550-
copy_file("/mnt/usb0/hen/hen.ini", "/data/hen/hen.ini");
549+
if (!file_compare(USB_INI_PATH, HDD_INI_PATH)) {
550+
unlink(HDD_INI_PATH);
551+
copy_file(USB_INI_PATH, HDD_INI_PATH);
551552
}
552553
config_loaded = 1;
553554
}
554-
} else if (file_exists("/data/hen/hen.ini")) {
555-
if (cfg_parse("/data/hen/hen.ini", config_handler, &config) < 0) {
556-
printf_notification("ERROR: Unable to load `/data/hen/hen.ini`");
555+
} else if (file_exists(HDD_INI_PATH)) {
556+
if (cfg_parse(HDD_INI_PATH, config_handler, &config) < 0) {
557+
printf_notification("ERROR: Unable to load `" HDD_INI_PATH "`");
557558
// Restore defaults in case one of them changed for some reason...
558559
memset(&config, '\0', sizeof(config));
559560
config.disable_aslr = DEFAULT_DISABLE_ASLR;

kpayload/source/hooks.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "hooks.h"
1717

18+
#include "../../installer/include/path.h"
19+
1820
extern char *(*strstr)(const char *haystack, const char *needle)PAYLOAD_BSS;
1921
extern void *(*memcpy)(void *dst, const void *src, size_t len) PAYLOAD_BSS;
2022
extern void *(*memset)(void *s, int c, size_t n) PAYLOAD_BSS;
@@ -272,7 +274,7 @@ PAYLOAD_CODE int sys_dynlib_load_prx_hook(struct thread *td, struct dynlib_load_
272274
const int handle_out = args->handle_out ? *args->handle_out : 0;
273275
struct dynlib_load_prx_args my_args = {};
274276
int handle = 0;
275-
my_args.prx_path = "/data/hen/plugin_bootloader.prx";
277+
my_args.prx_path = BASE_PATH "/plugin_bootloader.prx";
276278
my_args.handle_out = &handle;
277279
sys_dynlib_load_prx(td, &my_args);
278280
uintptr_t init_env_ptr = 0;
@@ -287,8 +289,7 @@ PAYLOAD_CODE int sys_dynlib_load_prx_hook(struct thread *td, struct dynlib_load_
287289
// dummy process to load server prx into
288290
struct dynlib_load_prx_args my_args = {};
289291
int handle = 0;
290-
// TODO: Upload this file to disk
291-
my_args.prx_path = "/data/hen/plugin_server.prx";
292+
my_args.prx_path = BASE_PATH "/plugin_server.prx";
292293
my_args.handle_out = &handle;
293294
sys_dynlib_load_prx(td, &my_args);
294295
uintptr_t init_env_ptr = 0;

0 commit comments

Comments
 (0)