Some minor cosmetics and improvements

This commit is contained in:
d0k3 2017-03-13 20:20:20 +01:00
parent 2d0abe2e49
commit fd91427317
7 changed files with 12 additions and 11 deletions

View File

@ -53,7 +53,7 @@ bool FormatSDCard(u64 hidden_mb, u32 cluster_size, const char* label) {
memcpy(mbrdata + 0x18, &emu_sector, 4); memcpy(mbrdata + 0x18, &emu_sector, 4);
memcpy(mbrdata + 0x1C, &emu_size, 4); memcpy(mbrdata + 0x1C, &emu_size, 4);
memcpy(mbr + 0x1BE, mbrdata, 0x42); 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); else memset(mbr + 0x1CE, 0, 0x10);
// one last warning.... // one last warning....

View File

@ -14,7 +14,7 @@
u32 GetOutputPath(char* dest, const char* path, const char* ext) { u32 GetOutputPath(char* dest, const char* path, const char* ext) {
// special handling for input from title directories (somewhat hacky) // 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; u32 tid_high, tid_low, app_id;
char drv; char drv;
if (((sscanf(path, "%c:/title/%08lx/%08lx/content/%08lx", &drv, &tid_high, &tid_low, &app_id) == 4) && if (((sscanf(path, "%c:/title/%08lx/%08lx/content/%08lx", &drv, &tid_high, &tid_low, &app_id) == 4) &&

View File

@ -46,9 +46,10 @@ u32 BuildFakeTmd(TitleMetaData* tmd, u8* title_id, u32 n_contents, u32 save_size
memcpy(tmd->title_id, title_id, 8); memcpy(tmd->title_id, title_id, 8);
tmd->title_type[3] = 0x40; // whatever tmd->title_type[3] = 0x40; // whatever
for (u32 i = 0; i < 4; i++) tmd->save_size[i] = (save_size >> (i*8)) & 0xFF; // little endian? 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) 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) memset(tmd->contentinfo[0].hash, 0xFF, 0x20); // placeholder (hash)
// nothing to do for content list (yet) // nothing to do for content list (yet)

View File

@ -2,7 +2,7 @@
#include "common.h" #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_MIN sizeof(TitleMetaData)
#define TMD_SIZE_MAX (sizeof(TitleMetaData) + (TMD_MAX_CONTENTS*sizeof(TmdContentChunk))) #define TMD_SIZE_MAX (sizeof(TitleMetaData) + (TMD_MAX_CONTENTS*sizeof(TmdContentChunk)))

View File

@ -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) { u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboard) {
const char* optionstr[8]; const char* optionstr[8];
const char* promptstr = "HOME more.. menu.\nSelect action:"; const char* promptstr = "HOME more... menu.\nSelect action:";
u32 n_opt = 0; u32 n_opt = 0;
int sdformat = ++n_opt; int sdformat = ++n_opt;
int bonus = (GetNandUnusedSectors(NAND_SYSNAND) > 0x2000) ? (int) ++n_opt : -1; // 4MB minsize 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; user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, promptstr) : n_opt;
if (user_select > 0) { if (user_select > 0) {
u32 flags = BUILD_PATH | CALC_SHA; u32 flags = BUILD_PATH | CALC_SHA;
ShowPrompt(false, "NAND backup: %s", if (PathCopy(OUTPUT_PATH, (user_select == sys) ? "S:/nand.bin" : "E:/nand.bin", &flags))
(PathCopy(OUTPUT_PATH, (user_select == sys) ? "S:/nand.bin" : "E:/nand.bin", &flags)) ? ShowPrompt(false, "NAND backup written to " OUTPUT_PATH);
"success" : "failed"); else ShowPrompt(false, "NAND backup failed");
GetDirContents(current_dir, current_path); GetDirContents(current_dir, current_path);
return 0; return 0;
} }

View File

@ -325,7 +325,7 @@ bool BuildVGameCiaDir(void) {
for (u32 i = 0; (i < content_count) && (i < TMD_MAX_CONTENTS); i++) { for (u32 i = 0; (i < content_count) && (i < TMD_MAX_CONTENTS); i++) {
u64 size = getbe64(content_list[i].size); u64 size = getbe64(content_list[i].size);
bool is_ncch = false; // is unencrypted NCCH? 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; NcchHeader ncch;
ReadImageBytes((u8*) &ncch, next_offset, sizeof(NcchHeader)); ReadImageBytes((u8*) &ncch, next_offset, sizeof(NcchHeader));
is_ncch = (ValidateNcchHeader(&ncch) == 0); is_ncch = (ValidateNcchHeader(&ncch) == 0);

View File

@ -157,7 +157,7 @@ bool GetVirtualDirContents(DirStruct* contents, char* fpath, int fnsize, const c
bool GetVirtualFilename(char* name, const VirtualFile* vfile, u32 n_chars) { bool GetVirtualFilename(char* name, const VirtualFile* vfile, u32 n_chars) {
if (!(vfile->flags & VFLAG_LV3)) strncpy(name, vfile->name, 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; return true;
} }