From a093a1fbba1d5cfa3d74e09fc32002472c4fda61 Mon Sep 17 00:00:00 2001 From: Damien Zhao Date: Sun, 2 Apr 2023 16:37:24 +0800 Subject: [PATCH] min update Signed-off-by: Damien Zhao --- source/fs/fsutils.c | 1 + source/fs/menus/explorer.c | 2 ++ source/fs/menus/explorer.h | 5 ++++- source/hos/pkg1.c | 13 ++++++++++++- source/keys/keys.c | 12 +++++++----- source/main.c | 2 +- source/tegraexplorer/tools.c | 3 +-- 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/source/fs/fsutils.c b/source/fs/fsutils.c index 8217e73..6efa3aa 100644 --- a/source/fs/fsutils.c +++ b/source/fs/fsutils.c @@ -47,6 +47,7 @@ char *GetFileAttribs(FSEntry_t entry){ return ret; } +// Returns 1 if a file exists, 0 if it does not bool FileExists(const char* path){ FRESULT fr; FILINFO fno; diff --git a/source/fs/menus/explorer.c b/source/fs/menus/explorer.c index efe4631..f06679f 100644 --- a/source/fs/menus/explorer.c +++ b/source/fs/menus/explorer.c @@ -74,6 +74,7 @@ void FileExplorer(char *path){ res = 0; res = newMenu(&entries, res, 60, 42, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count); + vecFree(entries); char *oldPath = storedPath; @@ -125,6 +126,7 @@ void FileExplorer(char *path){ else if (res < ARR_LEN(topEntries)) { if (!strcmp(storedPath, path)){ clearFileVector(&fileVec); + free(storedPath); return; } diff --git a/source/fs/menus/explorer.h b/source/fs/menus/explorer.h index 840f4d8..cda9e09 100644 --- a/source/fs/menus/explorer.h +++ b/source/fs/menus/explorer.h @@ -1,4 +1,7 @@ #pragma once #include "../../utils/vector.h" +#include "../../gfx/menu.h" +#include "../fstypes.h" -void FileExplorer(char *path); \ No newline at end of file +void FileExplorer(char *path); +MenuEntry_t MakeMenuOutFSEntry(FSEntry_t entry); \ No newline at end of file diff --git a/source/hos/pkg1.c b/source/hos/pkg1.c index 0028a0a..a632cbd 100644 --- a/source/hos/pkg1.c +++ b/source/hos/pkg1.c @@ -50,10 +50,21 @@ static const pkg1_id_t _pkg1_ids[] = { { NULL } //End. }; +#define KB_FIRMWARE_VERSION_MAX 11 + const pkg1_id_t *pkg1_identify(u8 *pkg1) { for (u32 i = 0; _pkg1_ids[i].id; i++) if (!memcmp(pkg1 + 0x10, _pkg1_ids[i].id, 8)) return &_pkg1_ids[i]; - return NULL; + + char build_date[15]; + memcpy(build_date, (char *)(pkg1 + 0x10), 14); + build_date[14] = 0; + + if (*(pkg1 + 0xE) != KB_FIRMWARE_VERSION_MAX + 1) { + return NULL; + } + + return &_pkg1_ids[ARRAY_SIZE(_pkg1_ids)-1]; } diff --git a/source/keys/keys.c b/source/keys/keys.c index 8af89b6..a00ebda 100644 --- a/source/keys/keys.c +++ b/source/keys/keys.c @@ -259,9 +259,9 @@ static ALWAYS_INLINE u8 *_read_pkg1(const pkg1_id_t **pkg1_id) { *pkg1_id = pkg1_identify(pkg1 + pk1_offset); if (!*pkg1_id) { DPRINTF("Unknown pkg1 version.\n Make sure you have the latest Lockpick_RCM.\n If a new firmware version just came out,\n Lockpick_RCM must be updated.\n Check Github for new release."); - //gfx_hexdump(0, pkg1, 0x20); + //gfx_hexdump(0, pkg1 + pk1_offset, 0x20); char pkg1txt[16] = {0}; - memcpy(pkg1txt, pkg1 + pk1_offset + 0x10, 15); + memcpy(pkg1txt, pkg1 + pk1_offset + 0x10, 14); gfx_printf("Unknown pkg1 version\nMake sure you have the latest version of TegraExplorer\n\nPKG1: '%s'\n", pkg1txt); return NULL; } @@ -272,9 +272,6 @@ static ALWAYS_INLINE u8 *_read_pkg1(const pkg1_id_t **pkg1_id) { key_derivation_ctx_t __attribute__((aligned(4))) dumpedKeys = {0}; int DumpKeys(){ - if (h_cfg.t210b01) // i'm not even attempting to dump on mariko - return 2; - const pkg1_id_t *pkg1_id; u8 *pkg1 = _read_pkg1(&pkg1_id); if (!pkg1) { @@ -284,6 +281,11 @@ int DumpKeys(){ TConf.pkg1ID = pkg1_id->id; TConf.pkg1ver = (u8)pkg1_id->kb; + if (h_cfg.t210b01) {// i'm not even attempting to dump on mariko + free(pkg1); + return 2; + } + bool res = true; tsec_ctxt_t tsec_ctxt; diff --git a/source/main.c b/source/main.c index d9712a2..6b67554 100644 --- a/source/main.c +++ b/source/main.c @@ -32,7 +32,7 @@ #include #include #include "storage/emummc.h" -#include "storage/emmc.h" +#include #include #include #include diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c index caa82d6..5b08864 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/tools.c @@ -120,7 +120,6 @@ void DumpSysFw(){ } extern sdmmc_storage_t sd_storage; -extern bool is_sd_inited; MenuEntry_t FatAndEmu[] = { {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Back to main menu"}, @@ -135,7 +134,7 @@ void FormatSD(){ bool emummc = 0; int res; - if (!is_sd_inited || sd_get_card_removed()) + if (!sd_get_card_initialized() || sd_get_card_removed()) return; gfx_printf("\nDo you want to partition for an emummc?\n");