mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Replace Tabs -> Spaces
This commit is contained in:
parent
ab4316fd4e
commit
2f61722aa4
@ -9,28 +9,28 @@
|
||||
|
||||
// this structure is 0x80 bytes, thanks @luigoalma
|
||||
typedef struct {
|
||||
char magic[4]; // "PREP" for prepurchase install. NIM excepts "PREP" to do seed downloads on the background.
|
||||
// playable date parameters
|
||||
// 2000-01-01 is a safe bet for a stub entry
|
||||
s32 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
u16 country_code; // enum list of values, this will affect seed downloading, just requires at least one valid enum value. 1 == Japan, it's enough.
|
||||
// everything after this point can be 0 padded
|
||||
u32 seed_status; // 0 == not tried, 1 == last attempt failed, 2 == seed downloaded successfully
|
||||
s32 seed_result; // result related to last download attempt
|
||||
s32 seed_support_error_code; // support code derived from the result code
|
||||
// after this point, all is unused or padding. NIM wont use or access this at all.
|
||||
// It's memset to 0 by NIM
|
||||
u8 unknown[0x68];
|
||||
char magic[4]; // "PREP" for prepurchase install. NIM excepts "PREP" to do seed downloads on the background.
|
||||
// playable date parameters
|
||||
// 2000-01-01 is a safe bet for a stub entry
|
||||
s32 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
u16 country_code; // enum list of values, this will affect seed downloading, just requires at least one valid enum value. 1 == Japan, it's enough.
|
||||
// everything after this point can be 0 padded
|
||||
u32 seed_status; // 0 == not tried, 1 == last attempt failed, 2 == seed downloaded successfully
|
||||
s32 seed_result; // result related to last download attempt
|
||||
s32 seed_support_error_code; // support code derived from the result code
|
||||
// after this point, all is unused or padding. NIM wont use or access this at all.
|
||||
// It's memset to 0 by NIM
|
||||
u8 unknown[0x68];
|
||||
} PACKED_STRUCT TitleTagEntry;
|
||||
|
||||
typedef struct {
|
||||
u32 unknown0;
|
||||
u32 n_entries;
|
||||
u8 unknown1[0x1000 - 0x8];
|
||||
u64 titleId[TITLETAG_MAX_ENTRIES];
|
||||
TitleTagEntry tag[TITLETAG_MAX_ENTRIES];
|
||||
u32 unknown0;
|
||||
u32 n_entries;
|
||||
u8 unknown1[0x1000 - 0x8];
|
||||
u64 titleId[TITLETAG_MAX_ENTRIES];
|
||||
TitleTagEntry tag[TITLETAG_MAX_ENTRIES];
|
||||
} PACKED_STRUCT TitleTag;
|
||||
|
||||
u32 GetSeedPath(char* path, const char* drv) {
|
||||
@ -82,7 +82,7 @@ u32 FindSeed(u8* seed, u64 titleId, u32 hash_seed) {
|
||||
// read SEEDDB from file
|
||||
if (GetSeedPath(path, nand_drv[i]) != 0) continue;
|
||||
if ((ReadDisaDiffIvfcLvl4(path, NULL, SEEDSAVE_AREA_OFFSET, sizeof(SeedDb), seeddb) != sizeof(SeedDb)) ||
|
||||
(seeddb->n_entries > SEEDSAVE_MAX_ENTRIES))
|
||||
(seeddb->n_entries > SEEDSAVE_MAX_ENTRIES))
|
||||
continue;
|
||||
|
||||
// search for the seed
|
||||
@ -97,8 +97,8 @@ u32 FindSeed(u8* seed, u64 titleId, u32 hash_seed) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found -> try seeddb.bin
|
||||
|
||||
// not found -> try seeddb.bin
|
||||
SeedInfo* seeddb = (SeedInfo*) (void*) buffer;
|
||||
size_t len = LoadSupportFile(SEEDINFO_NAME, seeddb, STD_BUFFER_SIZE);
|
||||
if (len && (seeddb->n_entries <= (len - 16) / 32)) { // check filesize / seeddb size
|
||||
@ -169,49 +169,49 @@ u32 InstallSeedDbToSystem(SeedInfo* seed_info, bool to_emunand) {
|
||||
}
|
||||
|
||||
u32 SetupSeedPrePurchase(u64 titleId, bool to_emunand) {
|
||||
// here, we ask the system to install the seed for us
|
||||
TitleTag* titletag = (TitleTag*) malloc(sizeof(TitleTag));
|
||||
if (!titletag) return 1;
|
||||
|
||||
char path[128];
|
||||
if ((GetSeedPath(path, to_emunand ? "4:" : "1:") != 0) ||
|
||||
// here, we ask the system to install the seed for us
|
||||
TitleTag* titletag = (TitleTag*) malloc(sizeof(TitleTag));
|
||||
if (!titletag) return 1;
|
||||
|
||||
char path[128];
|
||||
if ((GetSeedPath(path, to_emunand ? "4:" : "1:") != 0) ||
|
||||
(ReadDisaDiffIvfcLvl4(path, NULL, TITLETAG_AREA_OFFSET, sizeof(TitleTag), titletag) != sizeof(TitleTag)) ||
|
||||
(titletag->n_entries >= TITLETAG_MAX_ENTRIES)) {
|
||||
free (titletag);
|
||||
free (titletag);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pointers for TITLETAG title IDs and seeds
|
||||
// find a free slot, insert titletag
|
||||
u32 slot = 0;
|
||||
for (; slot < titletag->n_entries; slot++)
|
||||
if (titletag->titleId[slot] == titleId) break;
|
||||
if (slot >= titletag->n_entries)
|
||||
titletag->n_entries = slot + 1;
|
||||
|
||||
TitleTagEntry* ttag = &(titletag->tag[slot]);
|
||||
titletag->titleId[slot] = titleId;
|
||||
memset(ttag, 0, sizeof(TitleTagEntry));
|
||||
memcpy(ttag->magic, "PREP", 4);
|
||||
ttag->year = 2000;
|
||||
ttag->month = 1;
|
||||
ttag->day = 1;
|
||||
ttag->country_code = 1;
|
||||
// find a free slot, insert titletag
|
||||
u32 slot = 0;
|
||||
for (; slot < titletag->n_entries; slot++)
|
||||
if (titletag->titleId[slot] == titleId) break;
|
||||
if (slot >= titletag->n_entries)
|
||||
titletag->n_entries = slot + 1;
|
||||
|
||||
TitleTagEntry* ttag = &(titletag->tag[slot]);
|
||||
titletag->titleId[slot] = titleId;
|
||||
memset(ttag, 0, sizeof(TitleTagEntry));
|
||||
memcpy(ttag->magic, "PREP", 4);
|
||||
ttag->year = 2000;
|
||||
ttag->month = 1;
|
||||
ttag->day = 1;
|
||||
ttag->country_code = 1;
|
||||
|
||||
// write back to system (warning: no write protection checks here)
|
||||
u32 size = WriteDisaDiffIvfcLvl4(path, NULL, TITLETAG_AREA_OFFSET, sizeof(TitleTag), titletag);
|
||||
FixFileCmac(path, false);
|
||||
|
||||
free(titletag);
|
||||
return (size == sizeof(TitleTag)) ? 0 : 1;
|
||||
u32 size = WriteDisaDiffIvfcLvl4(path, NULL, TITLETAG_AREA_OFFSET, sizeof(TitleTag), titletag);
|
||||
FixFileCmac(path, false);
|
||||
|
||||
free(titletag);
|
||||
return (size == sizeof(TitleTag)) ? 0 : 1;
|
||||
}
|
||||
|
||||
u32 SetupSeedSystemCrypto(u64 titleId, u32 hash_seed, bool to_emunand) {
|
||||
// attempt to find the seed inside the seeddb.bin support file
|
||||
SeedInfo* seeddb = (SeedInfo*) malloc(STD_BUFFER_SIZE);
|
||||
if (!seeddb) return 1;
|
||||
// attempt to find the seed inside the seeddb.bin support file
|
||||
SeedInfo* seeddb = (SeedInfo*) malloc(STD_BUFFER_SIZE);
|
||||
if (!seeddb) return 1;
|
||||
|
||||
size_t len = LoadSupportFile(SEEDINFO_NAME, seeddb, STD_BUFFER_SIZE);
|
||||
size_t len = LoadSupportFile(SEEDINFO_NAME, seeddb, STD_BUFFER_SIZE);
|
||||
if (len && (seeddb->n_entries <= (len - 16) / 32)) { // check filesize / seeddb size
|
||||
for (u32 s = 0; s < seeddb->n_entries; s++) {
|
||||
if (titleId != seeddb->entries[s].titleId)
|
||||
@ -224,7 +224,7 @@ u32 SetupSeedSystemCrypto(u64 titleId, u32 hash_seed, bool to_emunand) {
|
||||
sha_quick(sha256sum, lseed, 16 + 8, SHA256_MODE);
|
||||
u32 res = 0; // assuming the installed seed to be correct
|
||||
if (hash_seed == sha256sum[0]) {
|
||||
// found, install it
|
||||
// found, install it
|
||||
seeddb->n_entries = 1;
|
||||
seeddb->entries[0].titleId = titleId;
|
||||
memcpy(&(seeddb->entries[0].seed), lseed, sizeof(Seed));
|
||||
@ -236,5 +236,5 @@ u32 SetupSeedSystemCrypto(u64 titleId, u32 hash_seed, bool to_emunand) {
|
||||
}
|
||||
|
||||
free(seeddb);
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define SEEDSAVE_AREA_OFFSET 0x3000
|
||||
|
||||
typedef struct {
|
||||
u8 byte[16];
|
||||
u8 byte[16];
|
||||
} PACKED_STRUCT Seed;
|
||||
|
||||
typedef struct {
|
||||
@ -26,11 +26,11 @@ typedef struct {
|
||||
} PACKED_STRUCT SeedInfo;
|
||||
|
||||
typedef struct {
|
||||
u32 unknown0;
|
||||
u32 n_entries;
|
||||
u8 unknown1[0x1000 - 0x8];
|
||||
u64 titleId[SEEDSAVE_MAX_ENTRIES];
|
||||
Seed seed[SEEDSAVE_MAX_ENTRIES];
|
||||
u32 unknown0;
|
||||
u32 n_entries;
|
||||
u8 unknown1[0x1000 - 0x8];
|
||||
u64 titleId[SEEDSAVE_MAX_ENTRIES];
|
||||
Seed seed[SEEDSAVE_MAX_ENTRIES];
|
||||
} PACKED_STRUCT SeedDb;
|
||||
|
||||
u32 GetSeedPath(char* path, const char* drv);
|
||||
|
@ -63,13 +63,13 @@ u32 GetCartName(char* name, CartData* cdata) {
|
||||
}
|
||||
|
||||
u32 GetCartInfoString(char* info, CartData* cdata) {
|
||||
if (cdata->cart_type & CART_CTR) {
|
||||
if (cdata->cart_type & CART_CTR) {
|
||||
CartDataCtr* cdata_i = (CartDataCtr*)cdata;
|
||||
NcsdHeader* ncsd = &(cdata_i->ncsd);
|
||||
NcchHeader* ncch = &(cdata_i->ncch);
|
||||
snprintf(info, 256, "Title ID : %016llX\nProduct Code : %.10s\nRevision : %lu\nCart ID : %08lX\nPlatform : %s\nTimestamp : 20%02X-%02X-%02X %02X:%02X:%02X\nGM9 Version : %s\n",
|
||||
ncsd->mediaId, ncch->productcode, cdata_i->rom_version, cdata_i->cart_id,
|
||||
(ncch->flags[4] == 0x2) ? "N3DS" : "O3DS",
|
||||
ncsd->mediaId, ncch->productcode, cdata_i->rom_version, cdata_i->cart_id,
|
||||
(ncch->flags[4] == 0x2) ? "N3DS" : "O3DS",
|
||||
init_time.bcd_Y, init_time.bcd_M, init_time.bcd_D,
|
||||
init_time.bcd_h, init_time.bcd_m, init_time.bcd_s,
|
||||
VERSION);
|
||||
@ -77,8 +77,8 @@ u32 GetCartInfoString(char* info, CartData* cdata) {
|
||||
CartDataNtrTwl* cdata_i = (CartDataNtrTwl*)cdata;
|
||||
TwlHeader* nds = &(cdata_i->ntr_header);
|
||||
snprintf(info, 256, "Title String : %.12s\nProduct Code : %.6s\nRevision : %u\nCart ID : %08lX\nPlatform : %s\nTimestamp : 20%02X-%02X-%02X %02X:%02X:%02X\nGM9 Version : %s\n",
|
||||
nds->game_title, nds->game_code, nds->rom_version, cdata_i->cart_id,
|
||||
(nds->unit_code == 0x2) ? "DSi Enhanced" : (nds->unit_code == 0x3) ? "DSi Exclusive" : "DS",
|
||||
nds->game_title, nds->game_code, nds->rom_version, cdata_i->cart_id,
|
||||
(nds->unit_code == 0x2) ? "DSi Enhanced" : (nds->unit_code == 0x3) ? "DSi Exclusive" : "DS",
|
||||
init_time.bcd_Y, init_time.bcd_M, init_time.bcd_D,
|
||||
init_time.bcd_h, init_time.bcd_m, init_time.bcd_s,
|
||||
VERSION);
|
||||
@ -320,15 +320,15 @@ u32 ReadCartPrivateHeader(void* buffer, u64 offset, u64 count, CartData* cdata)
|
||||
}
|
||||
|
||||
u32 ReadCartInfo(u8* buffer, u64 offset, u64 count, CartData* cdata) {
|
||||
char info[256];
|
||||
u32 len;
|
||||
|
||||
GetCartInfoString(info, cdata);
|
||||
len = strnlen(info, 255);
|
||||
char info[256];
|
||||
u32 len;
|
||||
|
||||
GetCartInfoString(info, cdata);
|
||||
len = strnlen(info, 255);
|
||||
|
||||
if (offset >= len) return 0;
|
||||
if (offset + count > len) count = len - offset;
|
||||
memcpy(buffer, info + offset, count);
|
||||
if (offset >= len) return 0;
|
||||
if (offset + count > len) count = len - offset;
|
||||
memcpy(buffer, info + offset, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user