mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-12-26 11:26:05 +00:00
Add system mounting
Also fixed sizes not re rendering when scrolling
This commit is contained in:
parent
f3808edb40
commit
7dc9320b41
6 changed files with 73 additions and 23 deletions
|
@ -30,8 +30,11 @@ extern void sd_unmount();
|
|||
static bool _key_exists(const void *data) { return memcmp(data, zeros, 0x10); };
|
||||
static void _generate_kek(u32 ks, const void *key_source, void *master_key, const void *kek_seed, const void *key_seed);
|
||||
|
||||
int launch_payload(char *path, bool update)
|
||||
{
|
||||
sdmmc_storage_t storage;
|
||||
emmc_part_t *system_part;
|
||||
sdmmc_t sdmmc;
|
||||
|
||||
int launch_payload(char *path, bool update){
|
||||
if (!update) gfx_clear_grey(0x1B);
|
||||
gfx_con_setpos(0, 0);
|
||||
if (!path)
|
||||
|
@ -89,10 +92,8 @@ int launch_payload(char *path, bool update)
|
|||
}
|
||||
|
||||
void dump_biskeys(u8 bis_key[4][32]){
|
||||
tsec_ctxt_t tsec_ctxt;
|
||||
sdmmc_t sdmmc;
|
||||
sdmmc_storage_t storage;
|
||||
u8 temp_key[0x10], device_key[0x10] = {0};
|
||||
tsec_ctxt_t tsec_ctxt;
|
||||
|
||||
int retries = 0;
|
||||
|
||||
|
@ -177,6 +178,46 @@ void dump_biskeys(u8 bis_key[4][32]){
|
|||
se_aes_crypt_block_ecb(8, 0, bis_key[2] + 0x10, bis_key_source[2] + 0x10);
|
||||
memcpy(bis_key[3], bis_key[2], 0x20);
|
||||
}
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
// Parse eMMC GPT.
|
||||
LIST_INIT(gpt);
|
||||
nx_emmc_gpt_parse(&gpt, &storage);
|
||||
|
||||
/*
|
||||
char part_name[37] = "SYSTEM";
|
||||
|
||||
// todo: menu selection for this
|
||||
|
||||
u32 bis_key_index = 0;
|
||||
if (strcmp(part_name, "PRODINFOF") == 0)
|
||||
bis_key_index = 0;
|
||||
else if (strcmp(part_name, "SAFE") == 0)
|
||||
bis_key_index = 1;
|
||||
else if (strcmp(part_name, "SYSTEM") == 0)
|
||||
bis_key_index = 2;
|
||||
else if (strcmp(part_name, "USER") == 0)
|
||||
bis_key_index = 3;
|
||||
else {
|
||||
gfx_printf("Partition name %s unrecognized.", part_name);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
se_aes_key_set(8, bis_key[2] + 0x00, 0x10);
|
||||
se_aes_key_set(9, bis_key[2] + 0x10, 0x10);
|
||||
|
||||
system_part = nx_emmc_part_find(&gpt, "SYSTEM");
|
||||
if (!system_part) {
|
||||
gfx_printf("Failed to locate SYSTEM partition.");
|
||||
return;
|
||||
}
|
||||
|
||||
__attribute__ ((aligned (16))) FATFS emmc_fs;
|
||||
if (f_mount(&emmc_fs, "emmc:", 1)) {
|
||||
gfx_printf("Mount failed.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void _generate_kek(u32 ks, const void *key_source, void *master_key, const void *kek_seed, const void *key_seed) {
|
||||
|
|
|
@ -14,7 +14,7 @@ int _copystring(char *out, const char *in, int copynumb){
|
|||
if (strlength > copynumb + 1) strlength = copynumb;
|
||||
memset(out + strlength, '\0', 1);
|
||||
int ret = copynumb - strlength;
|
||||
return ret;
|
||||
return ret + 4;
|
||||
}
|
||||
|
||||
int messagebox(char *message){
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "../gfx/di.h"
|
||||
#include "../gfx/gfx.h"
|
||||
#include "../utils/btn.h"
|
||||
|
@ -15,19 +16,21 @@
|
|||
extern bool sd_mount();
|
||||
extern void sd_unmount();
|
||||
|
||||
static u8 bis_keys[4][0x20];
|
||||
|
||||
void meme_main(){
|
||||
utils_gfx_init();
|
||||
//dump_keys();
|
||||
|
||||
u8 bis_keys[4][0x20] = {0};
|
||||
dump_biskeys(bis_keys);
|
||||
|
||||
/*
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
|
||||
sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);
|
||||
sdmmc_storage_set_mmc_partition(&storage, 1);
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, 1); */
|
||||
|
||||
dump_biskeys(bis_keys);
|
||||
|
||||
char *options[5];
|
||||
char *itemsinfolder[1000];
|
||||
unsigned int muhbits[1000];
|
||||
|
@ -41,13 +44,13 @@ void meme_main(){
|
|||
addchartoarray("[SD:/] SD card", options, i);
|
||||
i++;
|
||||
}
|
||||
//addchartoarray("[emmc:/] SYSTEM", options, i);
|
||||
addchartoarray("\nTools", options, i);
|
||||
addchartoarray("About", options, i+1);
|
||||
addchartoarray("Exit", options, i+2);
|
||||
addchartoarray("[emmc:/] SYSTEM", options, i);
|
||||
addchartoarray("\nTools", options, i+1);
|
||||
addchartoarray("About", options, i+2);
|
||||
addchartoarray("Exit", options, i+3);
|
||||
|
||||
meme_clearscreen();
|
||||
ret = gfx_menulist(32, options, (i + 3));
|
||||
ret = gfx_menulist(32, options, (i + 4));
|
||||
|
||||
if (strcmp(options[ret - 1], "[SD:/] SD card") == 0){
|
||||
sdexplorer(itemsinfolder, muhbits, "sd:/");
|
||||
|
|
|
@ -65,10 +65,10 @@ void sdexplorer(char *items[], unsigned int *muhbits, char *rootpath){
|
|||
int value = 1;
|
||||
int copymode = -1;
|
||||
int folderamount = 0;
|
||||
char path[PATHSIZE] = "sd:/";
|
||||
char path[PATHSIZE] = "";
|
||||
char clipboard[PATHSIZE] = "";
|
||||
strcpy(path, rootpath);
|
||||
char app[20], rpp[20];
|
||||
char clipboard[PATHSIZE] = "";
|
||||
int temp = -1;
|
||||
strcpy(app, rootpath);
|
||||
strcpy(rpp, app);
|
||||
|
@ -80,6 +80,10 @@ void sdexplorer(char *items[], unsigned int *muhbits, char *rootpath){
|
|||
gfx_con_setpos(0, 0);
|
||||
gfx_box(0, 0, 719, 15, COLOR_WHITE);
|
||||
folderamount = readfolder(items, muhbits, path);
|
||||
if (folderamount == -1){
|
||||
messagebox("\nInvalid path\n\nReturning to main menu");
|
||||
break;
|
||||
}
|
||||
gfx_printf("%k%pTegraExplorer - %s", COLOR_DEFAULT, COLOR_WHITE, app);
|
||||
gfx_con_setpos(39 * 16, 0);
|
||||
gfx_printf("%d\n%k%p", folderamount - 2, COLOR_WHITE, COLOR_DEFAULT);
|
||||
|
@ -91,9 +95,10 @@ void sdexplorer(char *items[], unsigned int *muhbits, char *rootpath){
|
|||
}
|
||||
else if (value == 2) {
|
||||
if (copymode != -1){
|
||||
copywithpath(clipboard, path, copymode);
|
||||
copywithpath(clipboard, path, copymode, app);
|
||||
copymode = -1;
|
||||
}
|
||||
else messagebox("\nThe Clipboard is empty!");
|
||||
}
|
||||
else {
|
||||
if(muhbits[value - 1] & OPTION1) addpartpath(path, items[value - 1], app);
|
||||
|
|
|
@ -87,9 +87,10 @@ int readfolder(char *items[], unsigned int *muhbits, const char *path){
|
|||
_mallocandaddfolderbit(muhbits, 0, true);
|
||||
_mallocandaddfolderbit(muhbits, 1, true);
|
||||
|
||||
|
||||
if (f_opendir(&dir, path)) {
|
||||
gfx_printf("\nFailed to open %s", path);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||
|
@ -158,12 +159,12 @@ int copy(const char *src, const char *dst){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int copywithpath(const char *src, const char *dstpath, int mode){
|
||||
int copywithpath(const char *src, const char *dstpath, int mode, char *app){
|
||||
FILINFO fno;
|
||||
f_stat(src, &fno);
|
||||
char dst[PATHSIZE];
|
||||
strcpy(dst, dstpath);
|
||||
if (strcmp(dstpath, "sd:/") != 0) strcat(dst, "/");
|
||||
if (strcmp(dstpath, app) != 0) strcat(dst, "/");
|
||||
strcat(dst, fno.fname);
|
||||
int ret = -1;
|
||||
if (mode == 0) ret = copy(src, dst);
|
||||
|
|
|
@ -13,6 +13,6 @@ void addpartpath(char *path, char *add, char *root);
|
|||
int readfolder(char *items[], unsigned int *muhbits, const char *path);
|
||||
int copy(const char *src, const char *dst);
|
||||
void addchartoarray(char *add, char *items[], int spot);
|
||||
int copywithpath(const char *src, const char *dstpath, int mode);
|
||||
int copywithpath(const char *src, const char *dstpath, int mode, char *app);
|
||||
void return_readable_byte_amounts(unsigned long int size, char *in);
|
||||
int getfilesize(const char *path);
|
Loading…
Reference in a new issue