Skip to content

Commit

Permalink
Added config dumper (for Citra)
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Nov 10, 2016
1 parent ea16e8c commit 5ab96d2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
46 changes: 46 additions & 0 deletions source/decryptor/nandfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,52 @@ u32 AutoFixCtrnand(u32 param)
return 0;
}

u32 DumpCitraConfig(u32 param)
{
(void) (param); // param is unused here

static const u32 config_offset[2] = { 0x6000, 0x25000 };
static const u32 config_size = 0x8000;
static const u8 magic[] = { 0x41, 0x00, 0xE4, 0x41, 0x00, 0x00, 0x00, 0x00, 0x39, 0x00 };

NandFileInfo* f_info = GetNandFileInfo(F_CONFIGSAVE);
PartitionInfo* p_info = GetPartitionInfo(f_info->partition_id);
u8* buffer = BUFFER_ADDRESS;

u32 p_active = 0;
u32 offset;
u32 size;

// search for config save
if (DebugSeekFileInNand(&offset, &size, f_info->name_l, f_info->path, p_info) != 0)
return 1;

// get active partition from DISA
if (DecryptNandToMem(buffer, offset, 0x200, p_info) != 0)
return 1;
p_active = (getle32(buffer + 0x168)) ? 1 : 0;

Debug("");
for (u32 i = 0; i < 2; i++) {
char filename[64];
u32 p = (i + p_active) % 2; // offset / partition to try;
Debug("Trying offset 0x%06X, partition %u...", config_offset[p], p);
if (DecryptNandToMem(buffer, offset + config_offset[p], 0x200, p_info) != 0)
return 1;
if (memcmp(buffer, magic, sizeof(magic)) != 0) {
Debug("Magic not found!");
continue;
}
if (OutputFileNameSelector(filename, "config", NULL) != 0)
return 1;
if (DecryptNandToFile(filename, offset + config_offset[p], config_size, p_info, NULL) != 0)
return 1;
return 0;
}

return 1; // failed if arriving here
}

u32 UpdateSeedDb(u32 param)
{
(void) (param); // param is unused here
Expand Down
1 change: 1 addition & 0 deletions source/decryptor/nandfat.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ u32 DumpHealthAndSafety(u32 param);
u32 InjectHealthAndSafety(u32 param);
u32 DumpNcchFirms(u32 param);
u32 AutoFixCtrnand(u32 param);
u32 DumpCitraConfig(u32 param);
u32 UpdateSeedDb(u32 param);
6 changes: 4 additions & 2 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,25 @@ MenuInfo menu[] =
}
},
{
"Miscellaneous... (SysNAND)", 7, // ID 16
"Miscellaneous... (SysNAND)", 8, // ID 16
{
{ "Health&Safety Dump", &DumpHealthAndSafety, 0 },
{ "Health&Safety Inject", &InjectHealthAndSafety, N_NANDWRITE },
{ "GBA VC Save Dump", &DumpGbaVcSave, 0 },
{ "GBA VC Save Inject", &InjectGbaVcSave, N_NANDWRITE },
{ "Update SeedDB", &UpdateSeedDb, 0 },
{ "Dump Config (for Citra)", &DumpCitraConfig, 0 },
{ "NCCH FIRMs Dump", &DumpNcchFirms, 0 },
{ "FIRM ARM9 Decryptor", &DecryptFirmArm9File, 0 }
}
},
{
"Miscellaneous... (EmuNAND)", 5, // ID 17
"Miscellaneous... (EmuNAND)", 6, // ID 17
{
{ "Health&Safety Dump", &DumpHealthAndSafety, N_EMUNAND },
{ "Health&Safety Inject", &InjectHealthAndSafety, N_NANDWRITE | N_EMUNAND },
{ "Update SeedDB", &UpdateSeedDb, N_EMUNAND },
{ "Dump Config (for Citra)", &DumpCitraConfig, N_EMUNAND },
{ "NCCH FIRMs Dump", &DumpNcchFirms, N_EMUNAND },
{ "FIRM ARM9 Decryptor", &DecryptFirmArm9File, 0 }
}
Expand Down

0 comments on commit 5ab96d2

Please sign in to comment.