Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
added more file dump options
Browse files Browse the repository at this point in the history
  • Loading branch information
emiyl committed Apr 11, 2020
1 parent 8b790f0 commit f797496
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 53 deletions.
119 changes: 71 additions & 48 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
12 changes: 7 additions & 5 deletions src/sd_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
Expand All @@ -26,22 +28,22 @@ 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) {
return -1;
}

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

Expand Down

0 comments on commit f797496

Please sign in to comment.