From 05c989a1ce39397ae3228ef0e9898b95d87b10f6 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 20 Sep 2021 11:41:48 +0300 Subject: [PATCH] emummc: correct id size and also set id if emupath is used This corrects a truncation that was happening and also if `emupath` key is used to change emuMMC on the fly, it now uses the path as id instead of 0. --- bootloader/storage/emummc.c | 9 ++++++++- bootloader/storage/emummc.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bootloader/storage/emummc.c b/bootloader/storage/emummc.c index 52a748e..62e3578 100644 --- a/bootloader/storage/emummc.c +++ b/bootloader/storage/emummc.c @@ -109,7 +109,14 @@ bool emummc_set_path(char *path) if (found) { emu_cfg.enabled = 1; - emu_cfg.id = 0; + + // Get ID from path. + u32 id_from_path = 0; + u32 path_size = strlen(path); + if (path_size >= 4) + memcpy(&id_from_path, path + path_size - 4, 4); + emu_cfg.id = id_from_path; + strcpy(emu_cfg.nintendo_path, path); strcat(emu_cfg.nintendo_path, "/Nintendo"); } diff --git a/bootloader/storage/emummc.h b/bootloader/storage/emummc.h index e8b1d32..7e162fd 100644 --- a/bootloader/storage/emummc.h +++ b/bootloader/storage/emummc.h @@ -37,7 +37,7 @@ typedef struct _emummc_cfg_t { int enabled; u64 sector; - u16 id; + u32 id; char *path; char *nintendo_path; // Internal.