Skip to content

Commit

Permalink
Add keystone import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Jan 15, 2022
1 parent a1594a8 commit 69c4d79
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@ $<
Expand Down
Binary file modified appdata/version.dat
Binary file not shown.
4 changes: 2 additions & 2 deletions include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/settings.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 23 additions & 6 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
9 changes: 7 additions & 2 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions source/menu_about.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/menu_cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down
49 changes: 30 additions & 19 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

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

Expand All @@ -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);

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

Expand All @@ -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;

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

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

0 comments on commit 69c4d79

Please sign in to comment.