From 88d3e0de8d049070862e65a26675782b740a2c84 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Wed, 15 Jul 2020 19:43:58 -0400 Subject: [PATCH] Support for the "boot" partition in Terra gamecards. --- source/gamecard.c | 6 +++--- source/gamecard.h | 5 +++-- source/main.c | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/gamecard.c b/source/gamecard.c index b67bfc1..c98a098 100644 --- a/source/gamecard.c +++ b/source/gamecard.c @@ -144,7 +144,7 @@ static GameCardHashFileSystemHeader *gamecardGetHashFileSystemPartitionHeader(u8 NX_INLINE GameCardHashFileSystemEntry *gamecardGetHashFileSystemEntryByIndex(void *header, u32 idx); NX_INLINE char *gamecardGetHashFileSystemNameTable(void *header); NX_INLINE char *gamecardGetHashFileSystemEntryNameByIndex(void *header, u32 idx); -NX_INLINE bool gamecardGetHashFileSystemEntryIndexByName(void *header, const char *name, u32 *out_idx); +static bool gamecardGetHashFileSystemEntryIndexByName(void *header, const char *name, u32 *out_idx); bool gamecardInitialize(void) { @@ -410,7 +410,7 @@ bool gamecardGetEntryInfoFromHashFileSystemPartitionByIndex(u8 hfs_partition_typ { if (hfs_partition_type == GameCardHashFileSystemPartitionType_Root) { - *out_offset = g_gameCardHfsPartitions[idx].offset; /* No need to recalculate what we already have */ + *out_offset = g_gameCardHfsPartitions[idx].offset; /* No need to recalculate what we already have. */ } else { *out_offset = (g_gameCardHfsPartitions[hfs_partition_idx].offset + g_gameCardHfsPartitions[hfs_partition_idx].header_size + fs_entry->offset); } @@ -1108,7 +1108,7 @@ NX_INLINE char *gamecardGetHashFileSystemEntryNameByIndex(void *header, u32 idx) return (name_table + fs_entry->name_offset); } -NX_INLINE bool gamecardGetHashFileSystemEntryIndexByName(void *header, const char *name, u32 *out_idx) +static bool gamecardGetHashFileSystemEntryIndexByName(void *header, const char *name, u32 *out_idx) { size_t name_len = 0; GameCardHashFileSystemEntry *fs_entry = NULL; diff --git a/source/gamecard.h b/source/gamecard.h index 68ddea5..0ba986f 100644 --- a/source/gamecard.h +++ b/source/gamecard.h @@ -34,7 +34,7 @@ #define GAMECARD_HFS_PARTITION_NAME(x) ((x) == GameCardHashFileSystemPartitionType_Root ? "root" : ((x) == GameCardHashFileSystemPartitionType_Update ? "update" : \ ((x) == GameCardHashFileSystemPartitionType_Logo ? "logo" : ((x) == GameCardHashFileSystemPartitionType_Normal ? "normal" : \ - ((x) == GameCardHashFileSystemPartitionType_Secure ? "secure" : "unknown"))))) + ((x) == GameCardHashFileSystemPartitionType_Secure ? "secure" : ((x) == GameCardHashFileSystemPartitionType_Boot ? "boot" : "unknown")))))) /// Plaintext area. Dumped from FS program memory. typedef struct { @@ -182,7 +182,8 @@ typedef enum { GameCardHashFileSystemPartitionType_Update = 1, GameCardHashFileSystemPartitionType_Logo = 2, ///< Only available in GameCardFwVersion_Since400NUP gamecards. GameCardHashFileSystemPartitionType_Normal = 3, - GameCardHashFileSystemPartitionType_Secure = 4 + GameCardHashFileSystemPartitionType_Secure = 4, + GameCardHashFileSystemPartitionType_Boot = 5 ///< Only available in Terra (Tencent) gamecards. } GameCardHashFileSystemPartitionType; /// Initializes data needed to access raw gamecard storage areas. diff --git a/source/main.c b/source/main.c index d71ee05..27fa431 100644 --- a/source/main.c +++ b/source/main.c @@ -484,6 +484,8 @@ out2: bktrFreeContext(&bktr_ctx); + if (serviceIsActive(&(resolver.s))) serviceClose(&(resolver.s)); + lrExit(); if (serviceIsActive(&(ncm_storage_emmc.s))) ncmContentStorageClose(&ncm_storage_emmc);