From 761ceb7dbea64e4fd26a65ce11bf29197283822a Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Tue, 17 Mar 2020 00:26:35 +0100 Subject: [PATCH] Misc changes --- source/tegraexplorer/fs.c | 19 ++++++++++++++----- source/tegraexplorer/fs.h | 3 ++- source/tegraexplorer/gfx.c | 12 ++++++++++++ source/tegraexplorer/io.c | 8 ++++++-- source/tegraexplorer/te.c | 1 - 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/source/tegraexplorer/fs.c b/source/tegraexplorer/fs.c index ee7c37a..c629f2a 100644 --- a/source/tegraexplorer/fs.c +++ b/source/tegraexplorer/fs.c @@ -10,6 +10,7 @@ #include "../utils/util.h" #include "io.h" #include "script.h" +#include "te.h" fs_entry *fileobjects; char rootpath[10] = ""; @@ -19,7 +20,7 @@ u8 clipboardhelper = 0; extern const char sizevalues[4][3]; extern int launch_payload(char *path); -menu_item explfilemenu[12] = { +menu_item explfilemenu[13] = { {"-- File Menu --", COLOR_BLUE, -1, 0}, {"FILE", COLOR_GREEN, -1, 0}, {"\nSIZE", COLOR_VIOLET, -1, 0}, @@ -31,7 +32,8 @@ menu_item explfilemenu[12] = { {"Launch Payload", COLOR_ORANGE, PAYLOAD, 1}, {"Launch Script", COLOR_YELLOW, SCRIPT, 1}, {"View Hex", COLOR_GREEN, HEXVIEW, 1}, - {"Extract Bis", COLOR_RED, DUMPBIS, 1} + {"Extract BIS", COLOR_RED, DUMPBIS, 1}, + {"Restore BIS", COLOR_RED, RESTOREBIS, 1} }; menu_item explfoldermenu[6] = { @@ -317,12 +319,16 @@ int filemenu(fs_entry file){ else explfilemenu[9].property = -1; - if (strstr(file.name, ".bis") != NULL) + if (strstr(file.name, ".bis") != NULL){ explfilemenu[11].property = 1; - else + explfilemenu[12].property = 1; + } + else { explfilemenu[11].property = -1; + explfilemenu[12].property = -1; + } - temp = makemenu(explfilemenu, 12); + temp = makemenu(explfilemenu, 13); switch (temp){ case COPY: @@ -348,6 +354,9 @@ int filemenu(fs_entry file){ extract_bis_file(getnextloc(currentpath, file.name), currentpath); btn_wait(); break; + case RESTOREBIS: + message(COLOR_ORANGE, "Stubbed"); + break; } return 0; diff --git a/source/tegraexplorer/fs.h b/source/tegraexplorer/fs.h index fa3b681..c7c7550 100644 --- a/source/tegraexplorer/fs.h +++ b/source/tegraexplorer/fs.h @@ -36,7 +36,8 @@ enum filemenuoptions { PAYLOAD, SCRIPT, HEXVIEW, - DUMPBIS + DUMPBIS, + RESTOREBIS }; enum foldermenuoptions { diff --git a/source/tegraexplorer/gfx.c b/source/tegraexplorer/gfx.c index 1f241e5..73b85d0 100644 --- a/source/tegraexplorer/gfx.c +++ b/source/tegraexplorer/gfx.c @@ -10,6 +10,8 @@ #include "../mem/minerva.h" #include "../power/max17050.h" #include +#include "../storage/emummc.h" +#include "emmc.h" const char fixedoptions[3][50] = { "Folder -> previous folder ", @@ -136,6 +138,16 @@ int makewaitmenunoclear(char *initialmessage, char *hiddenmessage, int timer){ } } +/* +int mmcChoiceMenu(){ + if (emu_cfg.enabled){ + + } + + return SYSMMC; +} +*/ + void gfx_print_length(int size, char *toprint){ char *temp; temp = (char*) malloc (size + 1); diff --git a/source/tegraexplorer/io.c b/source/tegraexplorer/io.c index 2391b29..047cacd 100644 --- a/source/tegraexplorer/io.c +++ b/source/tegraexplorer/io.c @@ -375,6 +375,11 @@ int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part buf = calloc(16384, sizeof(u8)); + if (!buf){ + message(COLOR_RED, "Calloc returned null!"); + return -1; + } + if ((res = f_stat(path, &fno))){ message(COLOR_RED, "f_stat() failed! err: %d", res); return -1; @@ -430,7 +435,7 @@ int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part totalSectors -= num; bytesWritten += num * NX_EMMC_BLOCKSIZE; - pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start); + pct = (u64)((u64)(bytesWritten) * 100u) / (u64)(fno.fsize); gfx_printf("Progress: %d%%\r", pct); } @@ -457,7 +462,6 @@ int restore_emmc_file(char *path, const char *target, u8 partition, u8 mmctype){ restore_emmc_part(path, &storage, &bootPart); } else { - sdmmc_storage_set_mmc_partition(&storage, partition); if (connect_part(target)){ message(COLOR_RED, "Find of partition failed!\nPart: %s", target); return -1; diff --git a/source/tegraexplorer/te.c b/source/tegraexplorer/te.c index b4d9d26..fe39af9 100644 --- a/source/tegraexplorer/te.c +++ b/source/tegraexplorer/te.c @@ -130,7 +130,6 @@ void MainMenu_Tools(){ dump_emmc_parts(PART_BOOT | PART_PKG2, SYSMMC); break; case RESTORE_BOOT: - SWAPCOLOR(COLOR_ORANGE); if (makewaitmenu( "WARNING!\nThis will mess with your switch boot files\nMake a nand backup beforehand!\n\nThis will pull from path:\nsd:/tegraexplorer/boot.bis\n\nVol +/- to cancel\n", "Power to confirm",