mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-03 00:39:14 +00:00
Always assume exheader is 1024 bytes long (#70)
* always assume exheader is 1024 bytes long * oops
This commit is contained in:
+10
-4
@@ -416,6 +416,12 @@ void ncch_process(ncch_context* ctx, u32 actions)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getle32(ctx->header.extendedheadersize) != 0x400)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "Error, exheader is 0x%02x bytes long, expected 0x0400\n", getle32(ctx->header.extendedheadersize));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ncch_determine_key(ctx, actions);
|
ncch_determine_key(ctx, actions);
|
||||||
|
|
||||||
ncch_get_counter(ctx, exheadercounter, NCCHTYPE_EXHEADER);
|
ncch_get_counter(ctx, exheadercounter, NCCHTYPE_EXHEADER);
|
||||||
@@ -619,9 +625,9 @@ void ncch_determine_key(ncch_context* ctx, u32 actions)
|
|||||||
// Check if the NCCH is already decrypted, by checking if the exheader hash matches
|
// Check if the NCCH is already decrypted, by checking if the exheader hash matches
|
||||||
// Otherwise, use determination rules
|
// Otherwise, use determination rules
|
||||||
fseeko64(ctx->file, ncch_get_exheader_offset(ctx), SEEK_SET);
|
fseeko64(ctx->file, ncch_get_exheader_offset(ctx), SEEK_SET);
|
||||||
memset(exheader_buffer, 0, getle32(header->extendedheadersize));
|
memset(exheader_buffer, 0, 0x400);
|
||||||
fread(exheader_buffer, 1, getle32(header->extendedheadersize), ctx->file);
|
fread(exheader_buffer, 1, 0x400, ctx->file);
|
||||||
ctr_sha_256(exheader_buffer, getle32(header->extendedheadersize), hash);
|
ctr_sha_256(exheader_buffer, 0x400, hash);
|
||||||
if (!memcmp(hash, header->extendedheaderhash, 32))
|
if (!memcmp(hash, header->extendedheaderhash, 32))
|
||||||
{
|
{
|
||||||
// exheader hash matches, so probably decrypted
|
// exheader hash matches, so probably decrypted
|
||||||
@@ -825,7 +831,7 @@ void ncch_print(ncch_context* ctx)
|
|||||||
else
|
else
|
||||||
memdump(stdout, "Logo hash (FAIL): ", header->logohash, 0x20);
|
memdump(stdout, "Logo hash (FAIL): ", header->logohash, 0x20);
|
||||||
fprintf(stdout, "Product code: %.16s\n", header->productcode);
|
fprintf(stdout, "Product code: %.16s\n", header->productcode);
|
||||||
fprintf(stdout, "Exheader size: %08x\n", getle32(header->extendedheadersize));
|
fprintf(stdout, "Exheader size: 00000400\n"); //this is always the same
|
||||||
if (ctx->exheaderhashcheck == Unchecked)
|
if (ctx->exheaderhashcheck == Unchecked)
|
||||||
memdump(stdout, "Exheader hash: ", header->extendedheaderhash, 0x20);
|
memdump(stdout, "Exheader hash: ", header->extendedheaderhash, 0x20);
|
||||||
else if (ctx->exheaderhashcheck == Good)
|
else if (ctx->exheaderhashcheck == Good)
|
||||||
|
|||||||
Reference in New Issue
Block a user