diff --git a/source/crypto/keydb.c b/source/crypto/keydb.c index 1e3f7ee..f8be615 100644 --- a/source/crypto/keydb.c +++ b/source/crypto/keydb.c @@ -160,7 +160,7 @@ u32 CheckKeySlot(u32 keyslot, char type) u32 LoadKeyFromFile(u8* key, u32 keyslot, char type, char* id) { const char* base[] = { INPUT_PATHS }; - u8 keystore[16] = {0}; + u8 keystore[16] __attribute__((aligned(32))) = {0}; bool found = false; // use keystore if key == NULL diff --git a/source/filetype.c b/source/filetype.c index 16bdcee..12052df 100644 --- a/source/filetype.c +++ b/source/filetype.c @@ -4,7 +4,7 @@ #include "ff.h" u32 IdentifyFileType(const char* path) { - u8 __attribute__((aligned(16))) header[0x200]; // minimum required size + u8 header[0x200] __attribute__((aligned(32))); // minimum required size FIL file; if (fx_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK) return 0; @@ -32,18 +32,18 @@ u32 IdentifyFileType(const char* path) { (header[0x1BE + 0x4] == 0xB) || (header[0x1BE + 0x4] == 0xC) || (header[0x1BE + 0x4] == 0xE))) { return IMG_FAT; // this might be an MBR -> give it the benefit of doubt } - } else if (ValidateCiaHeader((CiaHeader*) header) == 0) { + } else if (ValidateCiaHeader((CiaHeader*) (void*) header) == 0) { // this only works because these functions ignore CIA content index CiaInfo info; GetCiaInfo(&info, (CiaHeader*) header); if (fsize >= info.size_cia) return GAME_CIA; // CIA file - } else if (ValidateNcsdHeader((NcsdHeader*) header) == 0) { - NcsdHeader* ncsd = (NcsdHeader*) header; + } else if (ValidateNcsdHeader((NcsdHeader*) (void*) header) == 0) { + NcsdHeader* ncsd = (NcsdHeader*) (void*) header; if (fsize >= (ncsd->size * NCSD_MEDIA_UNIT)) return GAME_NCSD; // NCSD (".3DS") file - } else if (ValidateNcchHeader((NcchHeader*) header) == 0) { - NcchHeader* ncch = (NcchHeader*) header; + } else if (ValidateNcchHeader((NcchHeader*) (void*) header) == 0) { + NcchHeader* ncch = (NcchHeader*) (void*) header; if (fsize >= (ncch->size * NCCH_MEDIA_UNIT)) return GAME_NCCH; // NCSD (".3DS") file } diff --git a/source/game/ncch.c b/source/game/ncch.c index c842073..4eeb280 100644 --- a/source/game/ncch.c +++ b/source/game/ncch.c @@ -172,7 +172,7 @@ u32 SetNcchKey(NcchHeader* ncch, u32 keyid) { // key Y for seed and non seed if (keyid && (ncch->flags[7] & 0x20)) { // seed crypto - static u8 seedkeyY[16+16] = { 0 }; + static u8 seedkeyY[16+16] __attribute__((aligned(32))) = { 0 }; static u8 lsignature[16] = { 0 }; static u64 ltitleId = 0; if ((memcmp(lsignature, ncch->signature, 16) != 0) || (ltitleId != ncch->programId)) { diff --git a/source/game/ncch.h b/source/game/ncch.h index 1dba4bb..d570cee 100644 --- a/source/game/ncch.h +++ b/source/game/ncch.h @@ -57,7 +57,7 @@ typedef struct { u8 reserved3[0x4]; u8 hash_exefs[0x20]; u8 hash_romfs[0x20]; -} __attribute__((packed)) NcchHeader; +} __attribute__((packed, aligned(16))) NcchHeader; u32 ValidateNcchHeader(NcchHeader* header); u32 SetupNcchCrypto(NcchHeader* ncch); diff --git a/source/nand/nand.c b/source/nand/nand.c index 43f0990..50eb208 100644 --- a/source/nand/nand.c +++ b/source/nand/nand.c @@ -74,8 +74,8 @@ bool InitNandCrypto(void) // see: https://www.3dbrew.org/wiki/Memory_layout#ARM9_ITCM if (CheckA9lh()) { // only for a9lh u32* TwlCustId = (u32*) (0x01FFB808); - u8 TwlKeyX[16]; - u8 TwlKeyY[16]; + u8 TwlKeyX[16] __attribute__((aligned(32))); + u8 TwlKeyY[16] __attribute__((aligned(32))); // thanks b1l1s & Normmatt // see source from https://gbatemp.net/threads/release-twltool-dsi-downgrading-save-injection-etc-multitool.393488/ diff --git a/source/virtual/vgame.c b/source/virtual/vgame.c index 4ba96ff..ef624f1 100644 --- a/source/virtual/vgame.c +++ b/source/virtual/vgame.c @@ -61,10 +61,10 @@ static u64 offset_romfs = (u64) -1; static u64 offset_lv3 = (u64) -1; static u64 offset_lv3fd = (u64) -1; -static CiaStub* cia = (CiaStub*) (VGAME_BUFFER + 0x10000); // 62.5kB reserved - should be enough by far -static NcsdHeader* ncsd = (NcsdHeader*) (VGAME_BUFFER + 0x1FA00); // 512 byte reserved -static NcchHeader* ncch = (NcchHeader*) (VGAME_BUFFER + 0x1FC00); // 512 byte reserved -static ExeFsHeader* exefs = (ExeFsHeader*) (VGAME_BUFFER + 0x1FE00); // 512 byte reserved +static CiaStub* cia = (CiaStub*) (void*) (VGAME_BUFFER + 0x10000); // 62.5kB reserved - should be enough by far +static NcsdHeader* ncsd = (NcsdHeader*) (void*) (VGAME_BUFFER + 0x1FA00); // 512 byte reserved +static NcchHeader* ncch = (NcchHeader*) (void*) (VGAME_BUFFER + 0x1FC00); // 512 byte reserved +static ExeFsHeader* exefs = (ExeFsHeader*) (void*) (VGAME_BUFFER + 0x1FE00); // 512 byte reserved static u8* romfslv3 = (u8*) (VGAME_BUFFER + 0x20000); // 1920kB reserved static RomFsLv3Index lv3idx;