From 69c4d7927bfdfcb50bed92e021b976be80534188 Mon Sep 17 00:00:00 2001 From: bucanero Date: Sat, 15 Jan 2022 19:33:49 -0300 Subject: [PATCH] Add keystone import/export --- Makefile | 2 +- appdata/version.dat | Bin 4 -> 4 bytes include/saves.h | 4 ++-- include/settings.h | 4 ++-- source/exec_cmd.c | 29 +++++++++++++++++++------ source/http.c | 2 +- source/main.c | 9 ++++++-- source/menu_about.c | 7 ++++--- source/menu_cheats.c | 2 +- source/saves.c | 49 ++++++++++++++++++++++++++----------------- 10 files changed, 71 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 661427b..492efc4 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ sce_sys/param.sfo: Makefile eboot.bin: $(INTDIR) $(OBJS) $(LD) $(INTDIR)/*.o -o $(INTDIR)/$(PROJDIR).elf $(LDFLAGS) - $(TOOLCHAIN)/bin/$(CDIR)/create-eboot -in=$(INTDIR)/$(PROJDIR).elf -out=$(INTDIR)/$(PROJDIR).oelf --paid 0x3800000000000011 --authinfo 000000000000000000000000001C004000FF000000000080000000000000000000000000000000000000008000400040000000000000008000000000000000080040FFFF000000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + $(TOOLCHAIN)/bin/$(CDIR)/create-fself -in=$(INTDIR)/$(PROJDIR).elf -out=$(INTDIR)/$(PROJDIR).oelf --eboot "eboot.bin" --paid 0x3800000000000011 --authinfo 000000000000000000000000001C004000FF000000000080000000000000000000000000000000000000008000400040000000000000008000000000000000080040FFFF000000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $(INTDIR)/%.o: $(PROJDIR)/%.c $(CC) $(CFLAGS) -o $@ $< diff --git a/appdata/version.dat b/appdata/version.dat index 59c36c64b0847e574e2d118e7365f446a8f54bf2..86906d2f2176b77221aa6575cf6b92b619fd637d 100644 GIT binary patch literal 4 LcmZQ!U|;|M02BZP literal 4 LcmZQ(U|;|M01yBK diff --git a/include/saves.h b/include/saves.h index 52133c0..b5a0e39 100644 --- a/include/saves.h +++ b/include/saves.h @@ -92,14 +92,14 @@ enum cmd_code_enum CMD_DUMP_FINGERPRINTS, // Export commands - CMD_EXP_EXDATA_USB, + CMD_EXP_KEYSTONE, CMD_EXP_LICS_RAPS, CMD_EXP_FLASH2_USB, CMD_EXP_PSV_MCS, CMD_EXP_PSV_PSU, // Import commands - CMD_IMP_EXDATA_USB, + CMD_IMP_KEYSTONE, CMD_CREATE_ACT_DAT, // SFO patches diff --git a/include/settings.h b/include/settings.h index 71bfc3d..fcb53fd 100644 --- a/include/settings.h +++ b/include/settings.h @@ -1,5 +1,5 @@ -#define APOLLO_VERSION "0.7.0" //Apollo PS4 version (about menu) -#define APOLLO_DATA_VERSION 3 +#define APOLLO_VERSION "0.8.0" //Apollo PS4 version (about menu) +#define APOLLO_DATA_VERSION 4 #define MENU_TITLE_OFF 45 //Offset of menu title text from menu mini icon #define MENU_ICON_OFF 105 //X Offset to start printing menu mini icon diff --git a/source/exec_cmd.c b/source/exec_cmd.c index dcefe5b..ffa6987 100644 --- a/source/exec_cmd.c +++ b/source/exec_cmd.c @@ -920,6 +920,23 @@ static int _copy_save_file(const char* src_path, const char* dst_path, const cha return (copy_file(src, dst) == SUCCESS); } +static void copyKeystone(int import) +{ + char path_data[256]; + char path_save[256]; + + snprintf(path_save, sizeof(path_save), "%ssce_sys/", selected_entry->path); + snprintf(path_data, sizeof(path_data), APOLLO_USER_PATH "%s/", apollo_config.user_id, selected_entry->title_id); + mkdirs(path_data); + + LOG("Copy '%skeystone' <-> '%s'...", path_save, path_data); + + if (_copy_save_file(import ? path_data : path_save, import ? path_save : path_data, "keystone")) + show_message("Keystone successfully copied to:\n%skeystone", import ? path_save : path_data); + else + show_message("Error! Keystone couldn't be copied"); +} + static void decryptSaveFile(const char* filename) { char path[256]; @@ -1007,17 +1024,17 @@ void execCodeCommand(code_entry_t* code, const char* codecmd) copySaveHDD(selected_entry); code->activated = 0; break; -/* - case CMD_EXP_EXDATA_USB: - exportLicensesZip(codecmd[1] ? EXPORT_PATH_USB1 : EXPORT_PATH_USB0); + + case CMD_EXP_KEYSTONE: + copyKeystone(0); code->activated = 0; break; - case CMD_EXP_LICS_RAPS: - exportLicensesRap(code->file, codecmd[1]); + case CMD_IMP_KEYSTONE: + copyKeystone(1); code->activated = 0; break; -*/ + case CMD_CREATE_ACT_DAT: activateAccount(code->file[0]); code->activated = 0; diff --git a/source/http.c b/source/http.c index 5a68b1c..51dcd8b 100644 --- a/source/http.c +++ b/source/http.c @@ -137,7 +137,7 @@ int http_download(const char* url, const char* filename, const char* local_dst, goto close_http; } - uint8_t dl_buf[8 * 1024]; + uint8_t dl_buf[64 * 1024]; uint64_t total_read = 0; FILE* fd = fopen(local_dst, "wb"); diff --git a/source/main.c b/source/main.c index 1422d6d..2df0c1b 100644 --- a/source/main.c +++ b/source/main.c @@ -74,6 +74,7 @@ pad_input_t pad_data; OrbisPadData padA[MAX_PADS]; +void drawScene(); void update_usb_path(char *p); void update_hdd_path(char *p); void update_trophy_path(char *p); @@ -470,8 +471,8 @@ int LoadSounds(void* data) /* Output audio */ sceAudioOutOutput(audio, NULL); // NULL: wait for completion - if (sceAudioOutOutput(audio, pSampleData + sOffs) < 0) { - + if (sceAudioOutOutput(audio, pSampleData + sOffs) < 0) + { LOG("Failed to output audio"); return -1; } @@ -850,7 +851,11 @@ void doMainMenu() move_selection_fwd(MENU_CREDITS, 1); else if (pad_check_button(ORBIS_PAD_BUTTON_CROSS)) + { SetMenu(menu_sel+1); + drawScene(); + return; + } else if(pad_check_button(ORBIS_PAD_BUTTON_CIRCLE) && show_dialog(1, "Exit to XMB?")) close_app = 1; diff --git a/source/menu_about.c b/source/menu_about.c index 507dd90..8010d24 100644 --- a/source/menu_about.c +++ b/source/menu_about.c @@ -9,9 +9,10 @@ static void _draw_AboutMenu(u8 alpha) { int cnt = 0; + u8 alp2 = ((alpha*2) > 0xFF) ? 0xFF : (alpha * 2); //------------- About Menu Contents - DrawTextureCenteredX(&menu_textures[logo_text_png_index], SCREEN_WIDTH/2, 110, 0, menu_textures[logo_text_png_index].width * 3/2, menu_textures[logo_text_png_index].height * 3/2, 0xFFFFFF00 | alpha); + DrawTextureCenteredX(&menu_textures[logo_text_png_index], SCREEN_WIDTH/2, 110, 0, menu_textures[logo_text_png_index].width * 3/2, menu_textures[logo_text_png_index].height * 3/2, 0xFFFFFF00 | alp2); SetFontAlign(FONT_ALIGN_SCREEN_CENTER); SetCurrentFont(font_adonais_regular); @@ -28,7 +29,7 @@ static void _draw_AboutMenu(u8 alpha) DrawStringMono((SCREEN_WIDTH / 2) + 20, 280 + (cnt * 20), menu_about_strings[cnt + 1]); } - DrawTexture(&menu_textures[help_png_index], help_png_x, 300 + (cnt * 22), 0, help_png_w, 220, 0xFFFFFF00 | alpha); + DrawTexture(&menu_textures[help_png_index], help_png_x, 300 + (cnt * 22), 0, help_png_w, 220, 0xFFFFFF00 | alp2); SetFontAlign(FONT_ALIGN_SCREEN_CENTER); SetFontColor(APP_FONT_COLOR | alpha, 0); @@ -48,7 +49,7 @@ static void _draw_AboutMenu(u8 alpha) SetFontAlign(FONT_ALIGN_SCREEN_CENTER); SetCurrentFont(font_adonais_regular); - SetFontColor(APP_FONT_MENU_COLOR | 0xFF, 0); + SetFontColor(APP_FONT_MENU_COLOR | alp2, 0); SetFontSize(APP_FONT_SIZE_JARS); DrawStringMono(0, 890, "www.bucanero.com.ar"); SetFontAlign(FONT_ALIGN_LEFT); diff --git a/source/menu_cheats.c b/source/menu_cheats.c index fd3dd64..cd23c57 100644 --- a/source/menu_cheats.c +++ b/source/menu_cheats.c @@ -201,7 +201,7 @@ int DrawCodes(code_entry_t* code, u8 alpha, int y_inc, int xOff, int selIndex) //SetCurrentFont(font_comfortaa_regular); if (code->file && (code->type == PATCH_BSD || code->type == PATCH_GAMEGENIE)) - DrawFormatString(xOff + MENU_ICON_OFF + 20, 585, "Target File: %s", code->file); + DrawFormatString(xOff + MENU_ICON_OFF + 20, 880, "Target File: %s", code->file); for (c = startDrawX; c < max; c++) { diff --git a/source/saves.c b/source/saves.c index 025c03b..434151d 100644 --- a/source/saves.c +++ b/source/saves.c @@ -30,7 +30,7 @@ const void* sqlite3_get_sqlite3Apis(); int sqlite3_memvfs_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi); -sqlite3* open_sqlite_db(const char* db_path) +static sqlite3* open_sqlite_db(const char* db_path) { uint8_t* db_buf; size_t db_size; @@ -193,7 +193,7 @@ int orbis_UpdateSaveParams(const char* mountPath, const char* title, const char* * b: Potential end * Return: pointer if true, NULL if false */ -char* endsWith(const char * a, const char * b) +static char* endsWith(const char * a, const char * b) { int al = strlen(a), bl = strlen(b); @@ -241,7 +241,7 @@ char * readTextFile(const char * path, long* size) return string; } -code_entry_t* _createCmdCode(uint8_t type, const char* name, char code) +static code_entry_t* _createCmdCode(uint8_t type, const char* name, char code) { code_entry_t* entry = (code_entry_t *)calloc(1, sizeof(code_entry_t)); entry->type = type; @@ -251,7 +251,7 @@ code_entry_t* _createCmdCode(uint8_t type, const char* name, char code) return entry; } -option_entry_t* _initOptions(int count) +static option_entry_t* _initOptions(int count) { option_entry_t* options = (option_entry_t*)malloc(sizeof(option_entry_t)); @@ -265,7 +265,7 @@ option_entry_t* _initOptions(int count) return options; } -option_entry_t* _createOptions(int count, const char* name, char value) +static option_entry_t* _createOptions(int count, const char* name, char value) { option_entry_t* options = _initOptions(count); @@ -277,7 +277,7 @@ option_entry_t* _createOptions(int count, const char* name, char value) return options; } -save_entry_t* _createSaveEntry(uint16_t flag, const char* name) +static save_entry_t* _createSaveEntry(uint16_t flag, const char* name) { save_entry_t* entry = (save_entry_t *)calloc(1, sizeof(save_entry_t)); entry->flags = flag; @@ -286,7 +286,7 @@ save_entry_t* _createSaveEntry(uint16_t flag, const char* name) return entry; } -option_entry_t* _getFileOptions(const char* save_path, const char* mask, uint8_t is_cmd) +static option_entry_t* _getFileOptions(const char* save_path, const char* mask, uint8_t is_cmd) { DIR *d; struct dirent *dir; @@ -338,7 +338,7 @@ option_entry_t* _getFileOptions(const char* save_path, const char* mask, uint8_t return opt; } -void _addBackupCommands(save_entry_t* item) +static void _addBackupCommands(save_entry_t* item) { code_entry_t* cmd; @@ -365,9 +365,6 @@ void _addBackupCommands(save_entry_t* item) asprintf(&cmd->options->value[2], "%c", CMD_EXPORT_ZIP_HDD); list_append(item->codes, cmd); - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Dump save Fingerprint", CMD_EXP_FINGERPRINT); - list_append(item->codes, cmd); - if(!(item->flags & SAVE_FLAG_HDD)) return; @@ -382,7 +379,7 @@ void _addBackupCommands(save_entry_t* item) list_append(item->codes, cmd); } -option_entry_t* _getSaveTitleIDs(const char* title_id) +static option_entry_t* _getSaveTitleIDs(const char* title_id) { int count = 1; option_entry_t* opt; @@ -419,10 +416,24 @@ option_entry_t* _getSaveTitleIDs(const char* title_id) return opt; } -void _addSfoCommands(save_entry_t* save) +static void _addSfoCommands(save_entry_t* save) { code_entry_t* cmd; + cmd = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " Keystone Backup " UTF8_CHAR_STAR " -----", CMD_CODE_NULL); + list_append(save->codes, cmd); + + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Export Keystone", CMD_EXP_KEYSTONE); + list_append(save->codes, cmd); + + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Import Keystone", CMD_IMP_KEYSTONE); + list_append(save->codes, cmd); + + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Dump save Fingerprint", CMD_EXP_FINGERPRINT); + list_append(save->codes, cmd); + + return; + cmd = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " SFO Patches " UTF8_CHAR_STAR " -----", CMD_CODE_NULL); list_append(save->codes, cmd); @@ -570,7 +581,7 @@ int ReadCodes(save_entry_t * save) } _addBackupCommands(save); -// _addSfoCommands(save); + _addSfoCommands(save); snprintf(filePath, sizeof(filePath), APOLLO_DATA_PATH "%s.savepatch", save->title_id); if (file_exists(filePath) != SUCCESS) @@ -884,7 +895,7 @@ int ReadBackupCodes(save_entry_t * bup) bup->codes = list_alloc(); LOG("Loading %s files from '%s'...", fext, bup->path); - +/* if (bup->type == FILE_TYPE_RIF) { cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_ZIP " Backup All Licenses to .Zip", CMD_CODE_NULL); @@ -940,7 +951,7 @@ int ReadBackupCodes(save_entry_t * bup) } closedir(d); } - +*/ LOG("%d items loaded", list_count(bup->codes)); return list_count(bup->codes); @@ -1048,7 +1059,7 @@ int sortSaveList_Compare(const void* a, const void* b) return strcasecmp(((save_entry_t*) a)->name, ((save_entry_t*) b)->name); } -void read_usb_savegames(const char* userPath, list_t *list, uint32_t flag) +static void read_usb_savegames(const char* userPath, list_t *list, uint32_t flag) { DIR *d; struct dirent *dir; @@ -1108,7 +1119,7 @@ void read_usb_savegames(const char* userPath, list_t *list, uint32_t flag) closedir(d); } -void read_hdd_savegames(const char* userPath, list_t *list, uint32_t flag) +static void read_hdd_savegames(const char* userPath, list_t *list, uint32_t flag) { save_entry_t *item; sqlite3_stmt *res; @@ -1367,7 +1378,7 @@ list_t * ReadUserList(const char* userPath) * gmc: Set as the number of games read * Return: Pointer to array of game_entry, null if failed */ -void _ReadOnlineListEx(const char* urlPath, uint16_t flag, list_t *list) +static void _ReadOnlineListEx(const char* urlPath, uint16_t flag, list_t *list) { save_entry_t *item; char path[256];