Skip to content

Commit

Permalink
Fix USB bulk commands
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
bucanero committed Feb 2, 2022
1 parent f1b9632 commit 7eb915e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 51 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion include/settings.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
74 changes: 33 additions & 41 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7eb915e

Please sign in to comment.