From f79749637817f21e799871bca919fbcbe2da3739 Mon Sep 17 00:00:00 2001 From: emiyl Date: Sat, 11 Apr 2020 01:00:46 +0100 Subject: [PATCH] added more file dump options --- src/main.c | 119 +++++++++++++++++++++++++++++------------------- src/sd_dumper.c | 12 +++-- 2 files changed, 78 insertions(+), 53 deletions(-) diff --git a/src/main.c b/src/main.c index ea0a2f4..3b5c072 100644 --- a/src/main.c +++ b/src/main.c @@ -127,6 +127,40 @@ int CheckCancel(void) return 0; } +int dump_func(const char *mount_path, int selectedItem, int fsaFd, int initScreen) +{ + int res = mount_fs("dev", fsaFd, NULL, mount_path); + if(res < 0) + { + console_printf(1, "Mount of %s to %s failed", NULL, mount_path); + } + else + { + char *targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); + if(targetPath) + { + strcpy(targetPath, "dev:/"); + char sdPath[255] = "sd:/dumpling"; + if (selectedItem == 0) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/online_files%s", mount_path); + if (selectedItem == 1) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/friends_list%s", mount_path); + if (selectedItem == 2) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/games"); + if (selectedItem == 3) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/updates"); + if (selectedItem == 4) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/dlc"); + if (selectedItem == 5) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/saves"); + if (selectedItem == 6) snprintf(sdPath, sizeof(sdPath), "sd:/dumpling/nand"); + //snprintf(sdPath, sizeof(sdPath), "sd:/dumpling%s", mount_path); + DumpDir(targetPath, sdPath); + + free(targetPath); + } + unmount_fs("dev"); + if (selectedItem != 1) console_printf(1, "Dump complete"); + } + if (selectedItem != 1) sleep(1); + initScreen = 1; + return initScreen; +} + /* Entry point */ int Menu_Main(void) { @@ -209,36 +243,36 @@ int Menu_Main(void) static const char* paths_output[] = { - "account.dat", - "ccerts", - "scerts", - "Miis", - "Friends List (JP)", - "Friends List (US)", - "Friends List (EU)", + "Online Files", + "Friends List", + "All digital games on MLC01", + "All digital updates on MLC01", + "All digital DLC on MLC01", + "All save data on MLC01", + "Full MLC01 (Very long time!)", }; static const char* selection_paths[] = { - "/vol/storage_mlc01/usr/save/system/act/", - "/vol/storage_mlc01/sys/title/0005001b/10054000/content/ccerts", - "/vol/storage_mlc01/sys/title/0005001b/10054000/content/scerts", - "/vol/storage_mlc01/sys/title/0005001b/10056000/", - "/vol/storage_mlc01/sys/title/00050030/1001500A/", - "/vol/storage_mlc01/sys/title/00050030/1001510A/", - "/vol/storage_mlc01/sys/title/00050030/1001520A/", + NULL, + NULL, + "/vol/storage_mlc01/usr/title/00050000/", + "/vol/storage_mlc01/usr/title/0005000E/", + "/vol/storage_mlc01/usr/title/0005000C/", + "/vol/storage_mlc01/usr/save/00050000/", + "/vol/storage_mlc01/", }; - static const char* selection_paths_description[] = + /*static const char* selection_paths_description[] = { "", "", "", "", - "(JP)", - "(US)", - "(EU)", - }; + "", + "", + "", + };*/ int selectedItem = 0; @@ -271,22 +305,22 @@ int Menu_Main(void) OSScreenClearBufferEx(1, 0); - console_print_pos(0, 1, "-- Dumpling v0.0.1 by emiyl --"); + console_print_pos(0, 1, "-- Dumpling v0.1 by emiyl --"); console_print_pos(0, 2, "Based on FT2SD by Dimok"); console_print_pos(0, 4, "Select what to dump to SD card and press A to start dump."); - console_print_pos(0, 5, "Hold B to cancel dump."); + console_print_pos(0, 5, "Press HOME to exit."); u32 i; for(i = 0; i < (sizeof(selection_paths) / 4); i++) { if(selectedItem == (int)i) { - console_print_pos(0, 7 + i, "--> %s %s", selection_paths[i], selection_paths_description[i]); + console_print_pos(0, 7 + i, "--> %s", paths_output[i]); //, selection_paths_description[i]); } else { - console_print_pos(0, 7 + i, " %s %s", selection_paths[i], selection_paths_description[i]); + console_print_pos(0, 7 + i, " %s", paths_output[i]); //, selection_paths_description[i]); } } // Flip buffers @@ -312,31 +346,20 @@ int Menu_Main(void) if(vpadError == 0 && ((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_A)) { - const char *dev_path = (selectedItem < 0) ? selection_paths[selectedItem] : NULL; - const char *mount_path = (selectedItem >= 0) ? selection_paths[selectedItem] : "/vol/storage_ft_content"; - - int res = mount_fs("dev", fsaFd, dev_path, mount_path); - if(res < 0) - { - console_printf(1, "Mount of %s to %s failed", dev_path, mount_path); - } - else - { - char *targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); - if(targetPath) - { - strcpy(targetPath, "dev:/"); - char sdPath[255]; - snprintf(sdPath, sizeof(sdPath), "sd:/dumpling%s", selection_paths[selectedItem]); - DumpDir(targetPath, sdPath); - - free(targetPath); - } - unmount_fs("dev"); - console_printf(1, "Dump complete"); - } - sleep(3); - initScreen = 1; + if (selectedItem > 2) initScreen = dump_func(selection_paths[selectedItem], selectedItem, fsaFd, initScreen); + else if (selectedItem == 0) { + initScreen = dump_func("/vol/storage_mlc01/usr/save/system/act/" , selectedItem, fsaFd, initScreen); + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/ccerts", selectedItem, fsaFd, initScreen); + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10054000/content/scerts", selectedItem, fsaFd, initScreen); + initScreen = dump_func("/vol/storage_mlc01/sys/title/0005001b/10056000/" , selectedItem, fsaFd, initScreen); + } + else if (selectedItem == 1) { + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001500A/", selectedItem, fsaFd, initScreen); + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001510A/", selectedItem, fsaFd, initScreen); + initScreen = dump_func("/vol/storage_mlc01/sys/title/00050030/1001520A/", selectedItem, fsaFd, initScreen); + console_printf(1, "Dump complete"); + sleep(1); + } } if(vpadError == 0 && ((vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_HOME)) diff --git a/src/sd_dumper.c b/src/sd_dumper.c index e694214..6b85966 100644 --- a/src/sd_dumper.c +++ b/src/sd_dumper.c @@ -14,6 +14,8 @@ void console_printf(int newline, const char *format, ...); int checkCancel(void); +const bool detailed_logs = false; + static int DumpFile(char *pPath, const char * output_path) { char *pSlash = strchr(pPath, '/'); @@ -26,7 +28,7 @@ static int DumpFile(char *pPath, const char * output_path) else pFilename++; - console_printf(1, "0x%X - %s", 0, pSlash); + if (detailed_logs) console_printf(1, "0x%X - %s", 0, pSlash); unsigned char* dataBuf = (unsigned char*)memalign(0x40, BUFFER_SIZE); if(!dataBuf) { @@ -34,14 +36,14 @@ static int DumpFile(char *pPath, const char * output_path) } FILE *pReadFile = fopen(pPath, "rb"); - if(!pReadFile) + if(!pReadFile && detailed_logs) { console_printf(1, "Can't open file %s\n", pPath); return -2; } FILE *pWriteFile = fopen(output_path, "wb"); - if(!pWriteFile) + if(!pWriteFile && detailed_logs) { console_printf(1, "Can't open write file %s\n", output_path); fclose(pReadFile); @@ -77,9 +79,9 @@ int DumpDir(char *pPath, const char * target_path) DIR *dir = NULL; dir = opendir(pPath); - if (dir == NULL) + if (dir == NULL && detailed_logs) { - console_printf(1, "Can't open %s - Ensure you selected the correct region\n", pPath); + console_printf(1, "Can't open %s\n", pPath); return -1; }