diff --git a/source/fs/fsutil.c b/source/fs/fsutil.c index 092b899..598478d 100644 --- a/source/fs/fsutil.c +++ b/source/fs/fsutil.c @@ -53,7 +53,7 @@ bool FormatSDCard(u64 hidden_mb, u32 cluster_size, const char* label) { memcpy(mbrdata + 0x18, &emu_sector, 4); memcpy(mbrdata + 0x1C, &emu_size, 4); memcpy(mbr + 0x1BE, mbrdata, 0x42); - if (hidden_mb) memcpy(mbr, "GATEWAYNAND", 12); + if (hidden_mb) memcpy(mbr, "GATEWAYNAND", 12); // legacy else memset(mbr + 0x1CE, 0, 0x10); // one last warning.... diff --git a/source/game/gameutil.c b/source/game/gameutil.c index 6b3daa4..fffc543 100644 --- a/source/game/gameutil.c +++ b/source/game/gameutil.c @@ -14,7 +14,7 @@ u32 GetOutputPath(char* dest, const char* path, const char* ext) { // special handling for input from title directories (somewhat hacky) - if ((strspn(path, "AB147") > 0) && (strncmp(path + 1, ":/title/", 8) == 0)) { + if (strncmp(path + 1, ":/title/", 8) == 0) { u32 tid_high, tid_low, app_id; char drv; if (((sscanf(path, "%c:/title/%08lx/%08lx/content/%08lx", &drv, &tid_high, &tid_low, &app_id) == 4) && diff --git a/source/game/tmd.c b/source/game/tmd.c index 10cdf57..963182c 100644 --- a/source/game/tmd.c +++ b/source/game/tmd.c @@ -46,9 +46,10 @@ u32 BuildFakeTmd(TitleMetaData* tmd, u8* title_id, u32 n_contents, u32 save_size memcpy(tmd->title_id, title_id, 8); tmd->title_type[3] = 0x40; // whatever for (u32 i = 0; i < 4; i++) tmd->save_size[i] = (save_size >> (i*8)) & 0xFF; // little endian? - tmd->content_count[1] = (u8) n_contents; + tmd->content_count[0] = (u8) ((n_contents >> 8) & 0xFF); + tmd->content_count[1] = (u8) (n_contents & 0xFF); memset(tmd->contentinfo_hash, 0xFF, 0x20); // placeholder (hash) - tmd->contentinfo[0].cmd_count[1] = (u8) n_contents; + memcpy(tmd->contentinfo[0].cmd_count, tmd->content_count, 2); memset(tmd->contentinfo[0].hash, 0xFF, 0x20); // placeholder (hash) // nothing to do for content list (yet) diff --git a/source/game/tmd.h b/source/game/tmd.h index 8d3f798..8d44d05 100644 --- a/source/game/tmd.h +++ b/source/game/tmd.h @@ -2,7 +2,7 @@ #include "common.h" -#define TMD_MAX_CONTENTS 256 // theme CIAs contain maximum 100 themes + 1 index content +#define TMD_MAX_CONTENTS 255 // theme CIAs contain maximum 100 themes + 1 index content #define TMD_SIZE_MIN sizeof(TitleMetaData) #define TMD_SIZE_MAX (sizeof(TitleMetaData) + (TMD_MAX_CONTENTS*sizeof(TmdContentChunk))) diff --git a/source/godmode.c b/source/godmode.c index 915363c..4db049b 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -1043,7 +1043,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboard) { const char* optionstr[8]; - const char* promptstr = "HOME more.. menu.\nSelect action:"; + const char* promptstr = "HOME more... menu.\nSelect action:"; u32 n_opt = 0; int sdformat = ++n_opt; int bonus = (GetNandUnusedSectors(NAND_SYSNAND) > 0x2000) ? (int) ++n_opt : -1; // 4MB minsize @@ -1111,9 +1111,9 @@ u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboar user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, promptstr) : n_opt; if (user_select > 0) { u32 flags = BUILD_PATH | CALC_SHA; - ShowPrompt(false, "NAND backup: %s", - (PathCopy(OUTPUT_PATH, (user_select == sys) ? "S:/nand.bin" : "E:/nand.bin", &flags)) ? - "success" : "failed"); + if (PathCopy(OUTPUT_PATH, (user_select == sys) ? "S:/nand.bin" : "E:/nand.bin", &flags)) + ShowPrompt(false, "NAND backup written to " OUTPUT_PATH); + else ShowPrompt(false, "NAND backup failed"); GetDirContents(current_dir, current_path); return 0; } diff --git a/source/virtual/vgame.c b/source/virtual/vgame.c index 359d97b..d994464 100644 --- a/source/virtual/vgame.c +++ b/source/virtual/vgame.c @@ -325,7 +325,7 @@ bool BuildVGameCiaDir(void) { for (u32 i = 0; (i < content_count) && (i < TMD_MAX_CONTENTS); i++) { u64 size = getbe64(content_list[i].size); bool is_ncch = false; // is unencrypted NCCH? - if (!(getbe16(content_list[i].type) & 0x1)) { + if (!(getbe16(content_list[i].type) & 0x1) && (size >= sizeof(NcchHeader))) { NcchHeader ncch; ReadImageBytes((u8*) &ncch, next_offset, sizeof(NcchHeader)); is_ncch = (ValidateNcchHeader(&ncch) == 0); diff --git a/source/virtual/virtual.c b/source/virtual/virtual.c index 1ca9720..1bd5ed5 100644 --- a/source/virtual/virtual.c +++ b/source/virtual/virtual.c @@ -157,7 +157,7 @@ bool GetVirtualDirContents(DirStruct* contents, char* fpath, int fnsize, const c bool GetVirtualFilename(char* name, const VirtualFile* vfile, u32 n_chars) { if (!(vfile->flags & VFLAG_LV3)) strncpy(name, vfile->name, n_chars); - else if (!GetVGameLv3Filename(name, vfile, 256)) return false; + else if (!GetVGameLv3Filename(name, vfile, n_chars)) return false; return true; }