From 5e208b25ab7dde12fae9e95c9baf309818356396 Mon Sep 17 00:00:00 2001 From: Joel16 Date: Sat, 17 Feb 2018 19:00:07 -0600 Subject: [PATCH] Can now dump original SecureInfo_X + more wipe functions The following options were added to the Advanced wipe menu: - Wipe pending titles. - Wipe demo launch infos. - Cleaned up redundant statements as well. - Data folder is now 3DSRecoveryTool --- include/pp2d/loadbmp.h | 147 ----------------------- source/main.c | 263 ++++++++++++++++++++--------------------- 2 files changed, 125 insertions(+), 285 deletions(-) delete mode 100644 include/pp2d/loadbmp.h diff --git a/include/pp2d/loadbmp.h b/include/pp2d/loadbmp.h deleted file mode 100644 index 00fa1e1..0000000 --- a/include/pp2d/loadbmp.h +++ /dev/null @@ -1,147 +0,0 @@ -// Author: Christian Vallentin -// Website: http://vallentinsource.com -// Repository: https://github.com/MrVallentin/LoadBMP -// -// Date Created: January 03, 2014 -// Last Modified: August 13, 2016 -// -// Version: 1.1.0 - -// Copyright (c) 2014-2016 Christian Vallentin -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. - -// Errors -#define LOADBMP_NO_ERROR 0 -#define LOADBMP_OUT_OF_MEMORY 1 -#define LOADBMP_FILE_NOT_FOUND 2 -#define LOADBMP_FILE_OPERATION 3 -#define LOADBMP_INVALID_FILE_FORMAT 4 -#define LOADBMP_INVALID_SIGNATURE 5 -#define LOADBMP_INVALID_BITS_PER_PIXEL 6 - -# define LOADBMP_API - -LOADBMP_API unsigned int loadbmp_decode_file( - const char *filename, unsigned char **imageData, unsigned int *width, unsigned int *height); - -// Disable Microsoft Visual C++ compiler security warnings for fopen, strcpy, etc being unsafe -#if defined(_MSC_VER) && (_MSC_VER >= 1310) -# pragma warning(disable: 4996) -#endif - -#include /* malloc(), free() */ -#include /* memset(), memcpy() */ -#include /* fopen(), fwrite(), fread(), fclose() */ - -LOADBMP_API unsigned int loadbmp_decode_file( - const char *filename, unsigned char **imageData, unsigned int *width, unsigned int *height) -{ - FILE *f = fopen(filename, "rb"); - - if (!f) - return LOADBMP_FILE_NOT_FOUND; - - unsigned char bmp_file_header[14]; - unsigned char bmp_info_header[40]; - unsigned char bmp_pad[3]; - - unsigned int w, h; - unsigned char *data = NULL; - - unsigned int x, y, i, padding; - - memset(bmp_file_header, 0, sizeof(bmp_file_header)); - memset(bmp_info_header, 0, sizeof(bmp_info_header)); - - if (fread(bmp_file_header, sizeof(bmp_file_header), 1, f) == 0) - { - fclose(f); - return LOADBMP_INVALID_FILE_FORMAT; - } - - if (fread(bmp_info_header, sizeof(bmp_info_header), 1, f) == 0) - { - fclose(f); - return LOADBMP_INVALID_FILE_FORMAT; - } - - if ((bmp_file_header[0] != 'B') || (bmp_file_header[1] != 'M')) - { - fclose(f); - return LOADBMP_INVALID_SIGNATURE; - } - - if ((bmp_info_header[14] != 24) && (bmp_info_header[14] != 32)) - { - fclose(f); - return LOADBMP_INVALID_BITS_PER_PIXEL; - } - - w = (bmp_info_header[4] + (bmp_info_header[5] << 8) + (bmp_info_header[6] << 16) + (bmp_info_header[7] << 24)); - h = (bmp_info_header[8] + (bmp_info_header[9] << 8) + (bmp_info_header[10] << 16) + (bmp_info_header[11] << 24)); - - if ((w > 0) && (h > 0)) - { - data = (unsigned char*)malloc(w * h * 4); - - if (!data) - { - fclose(f); - return LOADBMP_OUT_OF_MEMORY; - } - - for (y = (h - 1); y != -1; y--) - { - for (x = 0; x < w; x++) - { - i = (x + y * w) * 4; - - if (fread(data + i, 3, 1, f) == 0) - { - free(data); - fclose(f); - return LOADBMP_INVALID_FILE_FORMAT; - } - - data[i + 3] = data[i + 2]; - data[i + 2] = data[i + 1]; - data[i + 1] = data[i]; - data[i] = 255; - } - - padding = ((4 - (w * 3) % 4) % 4); - - if (fread(bmp_pad, 1, padding, f) != padding) - { - free(data); - fclose(f); - return LOADBMP_INVALID_FILE_FORMAT; - } - } - } - - (*width) = w; - (*height) = h; - (*imageData) = data; - - fclose(f); - return LOADBMP_NO_ERROR; -} \ No newline at end of file diff --git a/source/main.c b/source/main.c index cf157fe..5ef1334 100644 --- a/source/main.c +++ b/source/main.c @@ -49,10 +49,10 @@ void Init_Services(void) if (Utils_IsN3DS()) osSetSpeedupEnable(true); - FS_RecursiveMakeDir(sdmcArchive, "/3ds/3ds_rec_tool/dumps"); - FS_RecursiveMakeDir(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/ro/sys"); - FS_RecursiveMakeDir(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys"); - FS_RecursiveMakeDir(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/private"); + FS_RecursiveMakeDir(sdmcArchive, "/3ds/3DSRecoveryTool/dumps"); + FS_RecursiveMakeDir(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/ro/sys"); + FS_RecursiveMakeDir(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys"); + FS_RecursiveMakeDir(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/private"); Utils_LoadConfig(); } @@ -94,11 +94,7 @@ void Menu_Main(void); void Menu_Backup(void) { - int selection = 1; - int selector_y = 25; - int selector_image_y = 0; - - int max_items = 5; + int selection = 0, max_items = 4; Result res = 0; @@ -114,13 +110,11 @@ void Menu_Backup(void) pp2d_draw_rectangle(0, 16, 400, 40, RGBA8(39, 50, 56, 255)); pp2d_draw_rectangle(0, 55, 400, 185, darkTheme? BG_COLOUR_DARK : BG_COLOUR_LIGHT); - selector_image_y = selector_y + (DISTANCE_Y * selection); - StatusBar_DisplayBar(); pp2d_draw_text(10, 27, 0.5f, 0.5f, RGBA8(240, 242, 242, 255), "Backup"); - pp2d_draw_rectangle(0, selector_image_y, 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); + pp2d_draw_rectangle(0, 55 + (DISTANCE_Y * selection), 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); pp2d_draw_text(10, 65, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Back"); pp2d_draw_text(10, 95, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Backup NAND LocalFriendCodeSeed"); @@ -150,53 +144,48 @@ void Menu_Backup(void) selection--; if (selection > max_items) - selection = 1; - if (selection < 1) + selection = 0; + if (selection < 0) selection = max_items; if (kDown & KEY_A) { switch(selection) { - case 1: + case 0: Menu_Main(); break; - case 2: + case 1: if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_B")) - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/LocalFriendCodeSeed_B", "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_B"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/LocalFriendCodeSeed_B", "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_B"); else if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_A")) - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/LocalFriendCodeSeed_A", "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_A"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/LocalFriendCodeSeed_A", "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_A"); snprintf(func, 20, "LocalFriendCodeSeed"); - selection = 1; - isSelected = true; break; - case 3: + case 2: if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_C")) - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_C", "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_C"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_C", "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_C"); if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_A")) - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_A", "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_A"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_A", "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_A"); else if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_B")) - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_B", "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_B"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/rw/sys/SecureInfo_B", "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_B"); snprintf(func, 11, "SecureInfo"); - selection = 1; - isSelected = true; + break; + case 3: + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/private/movable.sed", "/3ds/3DSRecoveryTool/backups/nand/private/movable.sed"); + snprintf(func, 12, "movable.sed"); break; case 4: - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/private/movable.sed", "/3ds/3ds_rec_tool/backups/nand/private/movable.sed"); - snprintf(func, 12, "movable.sed"); - selection = 1; - isSelected = true; - break; - case 5: - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/ro/sys/HWCAL0.dat", "/3ds/3ds_rec_tool/backups/nand/ro/sys/HWCAL0.dat"); - res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/ro/sys/HWCAL1.dat", "/3ds/3ds_rec_tool/backups/nand/ro/sys/HWCAL1.dat"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/ro/sys/HWCAL0.dat", "/3ds/3DSRecoveryTool/backups/nand/ro/sys/HWCAL0.dat"); + res = FS_Copy_File(nandArchive, sdmcArchive, ARCHIVE_NAND_CTR_FS, ARCHIVE_SDMC, "/ro/sys/HWCAL1.dat", "/3ds/3DSRecoveryTool/backups/nand/ro/sys/HWCAL1.dat"); snprintf(func, 6, "HWCAL"); - selection = 1; - isSelected = true; break; } + + isSelected = true; + selection = 0; } else if (kDown & KEY_B) @@ -206,11 +195,7 @@ void Menu_Backup(void) void Menu_Restore(void) { - int selection = 1; - int selector_y = 25; - int selector_image_y = 0; - - int max_items = 5; + int selection = 0, max_items = 4; Result res = 0; @@ -226,13 +211,11 @@ void Menu_Restore(void) pp2d_draw_rectangle(0, 16, 400, 40, RGBA8(39, 50, 56, 255)); pp2d_draw_rectangle(0, 55, 400, 185, darkTheme? BG_COLOUR_DARK : BG_COLOUR_LIGHT); - selector_image_y = selector_y + (DISTANCE_Y * selection); - StatusBar_DisplayBar(); pp2d_draw_text(10, 27, 0.5f, 0.5f, RGBA8(240, 242, 242, 255), "Restore"); - pp2d_draw_rectangle(0, selector_image_y, 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); + pp2d_draw_rectangle(0, 55 + (DISTANCE_Y * selection), 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); pp2d_draw_text(10, 65, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Back"); pp2d_draw_text(10, 95, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Restore original LocalFriendCodeSeed"); @@ -262,51 +245,46 @@ void Menu_Restore(void) selection--; if (selection > max_items) - selection = 1; - if (selection < 1) + selection = 0; + if (selection < 0) selection = max_items; if (kDown & KEY_A) { switch(selection) { - case 1: + case 0: Menu_Main(); break; - case 2: + case 1: res = CFGI_RestoreLocalFriendCodeSeed(); snprintf(func, 20, "LocalFriendCodeSeed"); - selection = 1; - isSelected = true; break; - case 3: + case 2: res = CFGI_RestoreSecureInfo(); snprintf(func, 11, "SecureInfo"); - selection = 1; - isSelected = true; - case 4: - if (FS_FileExists(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_B")) - res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_B", "/rw/sys/LocalFriendCodeSeed_B"); - else if (FS_FileExists(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_A")) - res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3ds_rec_tool/backups/nand/rw/sys/LocalFriendCodeSeed_A", "/rw/sys/LocalFriendCodeSeed_A"); + case 3: + if (FS_FileExists(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_B")) + res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_B", "/rw/sys/LocalFriendCodeSeed_B"); + else if (FS_FileExists(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_A")) + res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/LocalFriendCodeSeed_A", "/rw/sys/LocalFriendCodeSeed_A"); snprintf(func, 20, "LocalFriendCodeSeed"); - selection = 1; - isSelected = true; break; - case 5: - if (FS_FileExists(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_C")) - res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_C", "/rw/sys/SecureInfo_C"); - if (FS_FileExists(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_A")) - res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_A", "/rw/sys/SecureInfo_A"); - else if (FS_FileExists(sdmcArchive, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_B")) - res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3ds_rec_tool/backups/nand/rw/sys/SecureInfo_B", "/rw/sys/SecureInfo_B"); + case 4: + if (FS_FileExists(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_C")) + res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_C", "/rw/sys/SecureInfo_C"); + if (FS_FileExists(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_A")) + res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_A", "/rw/sys/SecureInfo_A"); + else if (FS_FileExists(sdmcArchive, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_B")) + res = FS_Copy_File(sdmcArchive, nandArchive, ARCHIVE_SDMC, ARCHIVE_NAND_CTR_FS, "/3ds/3DSRecoveryTool/backups/nand/rw/sys/SecureInfo_B", "/rw/sys/SecureInfo_B"); snprintf(func, 11, "SecureInfo"); - selection = 1; - isSelected = true; break; } + + isSelected = true; + selection = 0; } else if (kDown & KEY_B) @@ -316,8 +294,7 @@ void Menu_Restore(void) void Menu_Advanced_Wipe(void) { - int selection = 0; - int max_items = 8; + int selection = 0, max_items = 10; Result res = 0; @@ -330,6 +307,8 @@ void Menu_Advanced_Wipe(void) "Back", "Wipe all temporary and expired titles", "Wipe all TWL titles", + "Wipe all pending titles", + "Wipe all demo launch infos", "Wipe config", "Wipe parental controls", "Wipe all data (NAND)", @@ -411,8 +390,6 @@ void Menu_Advanced_Wipe(void) res = AM_DeleteAllTemporaryTitles(); res = AM_DeleteAllExpiredTitles(MEDIATYPE_SD); snprintf(func, 27, "temporary & expired titles"); - selection = 1; - isSelected = true; } break; case 2: @@ -420,56 +397,62 @@ void Menu_Advanced_Wipe(void) { res = AM_DeleteAllTwlTitles(); snprintf(func, 11, "TWL titles"); - selection = 1; - isSelected = true; } break; case 3: + if (R_SUCCEEDED(Dialog_Draw("You will lose all pending tiles.", "Do you wish to continue?"))) + { + res = AM_DeleteAllPendingTitles(MEDIATYPE_NAND); + res = AM_DeleteAllPendingTitles(MEDIATYPE_SD); + snprintf(func, 14, "pending tiles"); + } + break; + case 4: + if (R_SUCCEEDED(Dialog_Draw("You will lose all demo launch infos.", "Do you wish to continue?"))) + { + res = AM_DeleteAllDemoLaunchInfos(); + snprintf(func, 18, "demo launch infos"); + } + break; + case 5: if (R_SUCCEEDED(Dialog_Draw("You will lose all data in Settings.", "Do you wish to continue?"))) { res = CFGI_FormatConfig(); snprintf(func, 7, "config"); - selection = 1; - isSelected = true; } break; - case 4: + case 6: if (R_SUCCEEDED(Dialog_Draw("This will disable parental controls.", "Do you wish to continue?"))) { res = CFGI_ClearParentalControls(); snprintf(func, 18, "parental controls"); - selection = 1; - isSelected = true; } break; - case 5: + case 7: if (R_SUCCEEDED(Dialog_Draw("You will lose ALL data.", "Do you wish to continue?"))) { res = FSUSER_DeleteAllExtSaveDataOnNand(); res = FSUSER_InitializeCtrFileSystem(); snprintf(func, 9, "all data"); - selection = 1; - isSelected = true; } break; - case 6: - if (R_SUCCEEDED(Dialog_Draw("You will ALL data in your SD.", "Do you wish to continue?"))) + case 8: + if (R_SUCCEEDED(Dialog_Draw("You will lose ALL data in your SD.", "Do you wish to continue?"))) { res = FSUSER_DeleteSdmcRoot(); snprintf(func, 5, "SDMC"); - selection = 1; - isSelected = true; } break; - case 7: + case 9: if (R_SUCCEEDED(Dialog_Draw("You will lose ALL ext savedata in nand.", "Do you wish to continue?"))) { res = FSUSER_DeleteAllExtSaveDataOnNand(); snprintf(func, 18, "NAND ext savedata"); - selection = 1; - isSelected = true; } } + + isSelected = true; + selection = 0; } else if (kDown & KEY_B) @@ -479,21 +462,19 @@ void Menu_Advanced_Wipe(void) void Menu_Misc(void) { - int selection = 1; - int selector_y = 25; - int selector_image_y = 0; - - int max_items = 5; + int selection = 0, max_items = 5; Result res = 0; char func[33]; bool isSelected = false; - - u8 data[0x110]; - FILE * fp; - CFGI_GetLocalFriendCodeSeedData(data); + + FILE *fp = NULL; + u8 lfcs_data[0x110], sig_data[0x100], secureinfo_data[0x11]; + + CFGI_GetSecureInfoSignature(sig_data); + CFGI_GetSecureInfoData(secureinfo_data); while (aptMainLoop()) { @@ -503,21 +484,20 @@ void Menu_Misc(void) pp2d_draw_rectangle(0, 16, 400, 40, RGBA8(39, 50, 56, 255)); pp2d_draw_rectangle(0, 55, 400, 185, darkTheme? BG_COLOUR_DARK : BG_COLOUR_LIGHT); - selector_image_y = selector_y + (DISTANCE_Y * selection); - StatusBar_DisplayBar(); pp2d_draw_text(10, 27, 0.5f, 0.5f, RGBA8(240, 242, 242, 255), "Miscellaneous"); - pp2d_draw_rectangle(0, selector_image_y, 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); + pp2d_draw_rectangle(0, 55 + (DISTANCE_Y * selection), 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); pp2d_draw_text(10, 65, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Back"); pp2d_draw_text(10, 95, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Dump original LocalFriendCodeSeed data"); - pp2d_draw_text(10, 125, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Verify LocalFriendCodeSeed sig"); - pp2d_draw_text(10, 155, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Verify SecureInfo sig"); - pp2d_draw_text(10, 185, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Dark theme"); + pp2d_draw_text(10, 125, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Dump original SecureInfo data"); + pp2d_draw_text(10, 155, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Verify LocalFriendCodeSeed sig"); + pp2d_draw_text(10, 185, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Verify SecureInfo sig"); + pp2d_draw_text(10, 215, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Dark theme"); - darkTheme? pp2d_draw_texture(TEXTURE_TOGGLE_ON, 350, 175) : pp2d_draw_texture(TEXTURE_TOGGLE_OFF, 350, 175); + darkTheme? pp2d_draw_texture(TEXTURE_TOGGLE_ON, 350, 205) : pp2d_draw_texture(TEXTURE_TOGGLE_OFF, 350, 205); pp2d_end_draw(); @@ -541,45 +521,58 @@ void Menu_Misc(void) selection--; if (selection > max_items) - selection = 1; - if (selection < 1) + selection = 0; + if (selection < 0) selection = max_items; if (kDown & KEY_A) { switch(selection) { - case 1: + case 0: Menu_Main(); break; - case 2: + case 1: + CFGI_GetLocalFriendCodeSeedData(lfcs_data); + if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_B")) - { - fp = fopen ("/3ds/3ds_rec_tool/dumps/LocalFriendCodeSeed_B", "wb"); - res = fwrite(data, 1, 0x110, fp); - fclose(fp); - } + fp = fopen ("/3ds/3DSRecoveryTool/dumps/LocalFriendCodeSeed_B", "wb"); else if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_A")) - { - fp = fopen ("/3ds/3ds_rec_tool/dumps/LocalFriendCodeSeed_A", "wb"); - res = fwrite(data, 1, 0x110, fp); - fclose(fp); - } + fp = fopen ("/3ds/3DSRecoveryTool/dumps/LocalFriendCodeSeed_A", "wb"); + + res = fwrite(lfcs_data, 1, 0x110, fp); + fclose(fp); snprintf(func, 25, "LocalFriendCodeSeed dump"); - selection = 1; + selection = 0; + isSelected = true; + break; + case 2: + if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_C")) + fp = fopen ("/3ds/3DSRecoveryTool/dumps/SecureInfo_C", "wb"); + else if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_A")) + fp = fopen ("/3ds/3DSRecoveryTool/dumps/SecureInfo_A", "wb"); + else if (FS_FileExists(nandArchive, "/rw/sys/SecureInfo_B")) + fp = fopen ("/3ds/3DSRecoveryTool/dumps/SecureInfo_B", "wb"); + + res = fwrite(sig_data, 1, 0x100, fp); + res = fwrite(secureinfo_data, 1, 0x11, fp); + fclose(fp); + + snprintf(func, 25, "SecureInfo dump"); + selection = 0; isSelected = true; break; case 3: res = CFGI_VerifySigLocalFriendCodeSeed(); snprintf(func, 33, "LocalFriendCodeSeed verification"); - selection = 1; + selection = 0; isSelected = true; break; case 4: res = CFGI_VerifySigSecureInfo(); snprintf(func, 24, "SecureInfo verification"); - selection = 1; + selection = 0; isSelected = true; break; case 5: @@ -599,11 +592,7 @@ void Menu_Misc(void) void Menu_Main(void) { - int selection = 1; - int selector_y = 25; - int selector_image_y = 0; - - int max_items = 5; + int selection = 0, max_items = 4; pp2d_set_screen_color(GFX_TOP, 0x000000FF); pp2d_set_screen_color(GFX_BOTTOM, 0x000000FF); @@ -616,13 +605,11 @@ void Menu_Main(void) pp2d_draw_rectangle(0, 16, 400, 40, RGBA8(39, 50, 56, 255)); pp2d_draw_rectangle(0, 55, 400, 185, darkTheme? BG_COLOUR_DARK : BG_COLOUR_LIGHT); - selector_image_y = selector_y + (DISTANCE_Y * selection); - StatusBar_DisplayBar(); pp2d_draw_text(10, 27, 0.5f, 0.5f, RGBA8(240, 242, 242, 255), "3DS Recovery Tool"); - pp2d_draw_rectangle(0, selector_image_y, 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); + pp2d_draw_rectangle(0, 55 + (DISTANCE_Y * selection), 400, 30, darkTheme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); pp2d_draw_text(10, 65, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Back-up"); pp2d_draw_text(10, 95, 0.45f, 0.45f, darkTheme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT, "Restore"); @@ -652,27 +639,27 @@ void Menu_Main(void) selection--; if (selection > max_items) - selection = 1; - if (selection < 1) + selection = 0; + if (selection < 0) selection = max_items; if (kDown & KEY_A) { switch(selection) { - case 1: + case 0: Menu_Backup(); break; - case 2: + case 1: Menu_Restore(); break; - case 3: + case 2: Menu_Advanced_Wipe(); break; - case 4: + case 3: Menu_Misc(); break; - case 5: + case 4: longjmp(exitJmp, 1); break; }