mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Process full media units in ExeFS
This commit is contained in:
parent
fe19600828
commit
96d70aaa01
@ -1,4 +1,5 @@
|
||||
#include "exefs.h"
|
||||
#include "ncch.h"
|
||||
|
||||
u32 ValidateExeFsHeader(ExeFsHeader* exefs, u32 size) {
|
||||
u8 zeroes[32] = { 0 };
|
||||
@ -8,9 +9,10 @@ u32 ValidateExeFsHeader(ExeFsHeader* exefs, u32 size) {
|
||||
ExeFsFileHeader* file = exefs->files + i;
|
||||
u8* hash = exefs->hashes[9 - i];
|
||||
if (file->size == 0) continue;
|
||||
if (file->offset % NCCH_MEDIA_UNIT) return 1; // not aligned to media unit, failed
|
||||
if (file->offset < data_size) return 1; // overlapping data, failed
|
||||
if (memcmp(hash, zeroes, 32) == 0) return 1; // hash not set, failed
|
||||
data_size = file->offset + file->size;
|
||||
data_size = file->offset + align(file->size, NCCH_MEDIA_UNIT);
|
||||
n_files++;
|
||||
}
|
||||
if (size && (data_size > (size - sizeof(ExeFsHeader)))) // exefs header not included in table
|
||||
|
@ -284,7 +284,7 @@ u32 CryptNcch(u8* data, u32 offset, u32 size, NcchHeader* ncch, ExeFsHeader* exe
|
||||
ExeFsFileHeader* file = exefs->files + i;
|
||||
if (CryptNcchSection(data, offset, size,
|
||||
(ncch->offset_exefs * NCCH_MEDIA_UNIT) + 0x200 + file->offset,
|
||||
file->size, 0x200 + file->offset,
|
||||
align(file->size, NCCH_MEDIA_UNIT), 0x200 + file->offset,
|
||||
ncch, 2, crypt_to, EXEFS_KEYID(file->name)) != 0) return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user