From 7eb915e4171765ae161d8920800b975dcdeb1c32 Mon Sep 17 00:00:00 2001 From: bucanero Date: Wed, 2 Feb 2022 20:25:04 -0300 Subject: [PATCH] Fix USB bulk commands Fixes #27 --- CHANGELOG.md | 6 ++++ Makefile | 2 +- include/settings.h | 2 +- source/exec_cmd.c | 74 +++++++++++++++++++++------------------------- source/main.c | 5 +--- source/saves.c | 8 ++--- 6 files changed, 46 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69a9d6..9b09310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to the `apollo-ps4` project will be documented in this file. ## [Unreleased]() +## [v1.0.1](https://github.com/bucanero/apollo-ps4/releases/tag/v1.0.1) - 2022-02-02 + +### Fixed + +* Fixed Bulk resign and copy from USB + ## [v1.0.0](https://github.com/bucanero/apollo-ps4/releases/tag/v1.0.0) - 2022-01-30 ### Added diff --git a/Makefile b/Makefile index 43b4d39..18c3cb2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Package metadata. TITLE := Apollo Save Tool -VERSION := 1.00 +VERSION := 1.01 TITLE_ID := APOL00004 CONTENT_ID := IV0000-APOL00004_00-APOLLO0000000PS4 diff --git a/include/settings.h b/include/settings.h index 89c6e7e..2f2aca9 100644 --- a/include/settings.h +++ b/include/settings.h @@ -1,4 +1,4 @@ -#define APOLLO_VERSION "1.0.0" //Apollo PS4 version (about menu) +#define APOLLO_VERSION "1.0.1" //Apollo PS4 version (about menu) #define APOLLO_DATA_VERSION 5 #define MENU_TITLE_OFF 45 //Offset of menu title text from menu mini icon diff --git a/source/exec_cmd.c b/source/exec_cmd.c index 9d6fc95..8cf925f 100644 --- a/source/exec_cmd.c +++ b/source/exec_cmd.c @@ -220,7 +220,7 @@ static void copyAllSavesHDD(const char* path) for (node = list_head(list); (item = list_get(node)); node = list_next(node)) { update_progress_bar(progress++, list_count(list), item->name); - if (item->type == FILE_TYPE_PS4) + if (item->type == FILE_TYPE_PS4 && !(item->flags & SAVE_FLAG_LOCKED)) err_count += ! _copy_save_hdd(item); } @@ -359,7 +359,7 @@ static void dumpAllFingerprints(const char* path) if (!list) { - show_message("Error! Folder is not available:\n%s", APOLLO_PATH); + show_message("Error! Folder is not available:\n%s", path); return; } @@ -369,7 +369,7 @@ static void dumpAllFingerprints(const char* path) for (node = list_head(list); (item = list_get(node)); node = list_next(node)) { update_progress_bar(progress++, list_count(list), item->name); - if (item->type != FILE_TYPE_PS4) + if (item->type != FILE_TYPE_PS4 || (item->flags & SAVE_FLAG_LOCKED)) continue; if (item->flags & SAVE_FLAG_HDD) @@ -389,7 +389,7 @@ static void dumpAllFingerprints(const char* path) end_progress_bar(); UnloadGameList(list); - show_message("All fingerprints dumped to:\n%s", APOLLO_PATH); + show_message("All fingerprints dumped to:\n%sfingerprints.txt", APOLLO_PATH); } static void activateAccount(int user, const char* value) @@ -809,56 +809,48 @@ static void resignSave(sfo_patch_t* patch) static void resignAllSaves(const char* path) { - DIR *d; - struct dirent *dir; char sfoPath[256]; - char titleid[10]; - char message[128] = "Resigning all saves..."; + int err_count = 0; + list_node_t *node; + save_entry_t *item; + uint64_t progress = 0; + list_t *list = ReadUsbList(path); + sfo_patch_t patch = { + .user_id = apollo_config.user_id, + .psid = (u8*) apollo_config.psid, + .account_id = apollo_config.account_id, + }; - if (dir_exists(path) != SUCCESS) + if (!list) { show_message("Error! Folder is not available:\n%s", path); return; } - d = opendir(path); - if (!d) - return; - - init_loading_screen(message); - - sfo_patch_t patch = { - .flags = SFO_PATCH_FLAG_REMOVE_COPY_PROTECTION, - .user_id = apollo_config.user_id, - .psid = (u8*) apollo_config.psid, - .account_id = apollo_config.account_id, - .directory = NULL, - }; + init_progress_bar("Resigning all saves..."); - LOG("Resigning saves from '%s'...", path); - while ((dir = readdir(d)) != NULL) + LOG("Resigning all saves from '%s'...", path); + for (node = list_head(list); (item = list_get(node)); node = list_next(node)) { - if (dir->d_type == DT_DIR && strcmp(dir->d_name, ".") != 0 && strcmp(dir->d_name, "..") != 0) - { - snprintf(sfoPath, sizeof(sfoPath), "%s%s/sce_sys/param.sfo", path, dir->d_name); - if (file_exists(sfoPath) == SUCCESS) - { - LOG("Patching SFO '%s'...", sfoPath); - if (patch_sfo(sfoPath, &patch) != SUCCESS) - continue; + update_progress_bar(progress++, list_count(list), item->name); + if (item->type != FILE_TYPE_PS4 || (item->flags & SAVE_FLAG_LOCKED)) + continue; - snprintf(titleid, sizeof(titleid), "%.9s", dir->d_name); - snprintf(sfoPath, sizeof(sfoPath), "%s%s/", path, dir->d_name); - snprintf(message, sizeof(message), "Resigning %s...", dir->d_name); + snprintf(sfoPath, sizeof(sfoPath), "%s" "sce_sys/param.sfo", item->path); + if (file_exists(sfoPath) != SUCCESS) + continue; - LOG("Resigning save '%s'...", sfoPath); - } - } + LOG("Patching SFO '%s'...", sfoPath); + err_count += patch_sfo(sfoPath, &patch); } - closedir(d); - stop_loading_screen(); - show_message("All saves successfully resigned!"); + end_progress_bar(); + UnloadGameList(list); + + if (err_count) + show_message("Error: %d Saves couldn't be resigned", err_count); + else + show_message("All saves successfully resigned!"); } /* int apply_trophy_account() diff --git a/source/main.c b/source/main.c index d1acd3d..b74eefd 100644 --- a/source/main.c +++ b/source/main.c @@ -1374,7 +1374,7 @@ s32 main(s32 argc, const char* argv[]) // Unpack application data on first run if (appdata_check(APOLLO_DATA_PATH "version.dat")) { - clean_directory(APOLLO_DATA_PATH); +// clean_directory(APOLLO_DATA_PATH); if (extract_zip(APOLLO_APP_PATH "misc/appdata.zip", APOLLO_DATA_PATH)) show_message("Successfully installed local application data"); } @@ -1388,9 +1388,6 @@ s32 main(s32 argc, const char* argv[]) // Load application settings load_app_settings(&apollo_config); -// if (file_exists(APOLLO_PATH OWNER_XML_FILE) == SUCCESS) -// save_xml_owner(APOLLO_PATH OWNER_XML_FILE, NULL); - menu_options[8].options = get_logged_users(); // Setup font diff --git a/source/saves.c b/source/saves.c index 3fcda94..63349ed 100644 --- a/source/saves.c +++ b/source/saves.c @@ -1426,15 +1426,15 @@ list_t * ReadUsbList(const char* userPath) item = _createSaveEntry(SAVE_FLAG_PS4, CHAR_ICON_COPY " Bulk Save Management"); item->type = FILE_TYPE_MENU; item->codes = list_alloc(); - item->path = strdup(pathDec); + item->path = strdup(userPath); - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_SIGN " Resign all Saves", CMD_RESIGN_ALL_SAVES); + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_SIGN " Resign all decrypted Saves", CMD_RESIGN_ALL_SAVES); list_append(item->codes, cmd); - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Copy all Saves to HDD", CMD_COPY_SAVES_HDD); + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Copy all decrypted Saves to HDD", CMD_COPY_SAVES_HDD); list_append(item->codes, cmd); - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Dump all Save Fingerprints", CMD_DUMP_FINGERPRINTS); + cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Dump all decrypted Save Fingerprints", CMD_DUMP_FINGERPRINTS); list_append(item->codes, cmd); list_append(list, item);