mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
* base for potentially re-encrypting modcrypt, doesn't seem to be required? but can also serve to decrypt it
* revise SD IRQ behavior (fixing potential hang when loading DS games)
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "NDSCart.h"
|
||||
#include "ARM.h"
|
||||
#include "CRC32.h"
|
||||
#include "DSi_AES.h"
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
@ -599,6 +600,15 @@ void Key2_Encrypt(u8* data, u32 len)
|
||||
}
|
||||
|
||||
|
||||
void ApplyModcrypt(u32 addr, u32 len, u8* iv)
|
||||
{return;
|
||||
u8 key[16];
|
||||
|
||||
DSi_AES::GetModcryptKey(&CartROM[0], key);
|
||||
DSi_AES::ApplyModcrypt(&CartROM[addr], len, key, iv);
|
||||
}
|
||||
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if (!NDSCart_SRAM::Init()) return false;
|
||||
@ -980,6 +990,19 @@ bool LoadROM(const char* path, const char* sram, bool direct)
|
||||
CartIsHomebrew = true;
|
||||
}
|
||||
|
||||
// re-encrypt modcrypt areas if needed
|
||||
// TODO: somehow detect whether those are already encrypted
|
||||
if (true)
|
||||
{
|
||||
u32 mod1 = *(u32*)&CartROM[0x220];
|
||||
u32 mod2 = *(u32*)&CartROM[0x228];
|
||||
|
||||
printf("Re-encrypting modcrypt areas: %08X, %08X\n", mod1, mod2);
|
||||
|
||||
if (mod1) ApplyModcrypt(mod1, *(u32*)&CartROM[0x224], &CartROM[0x300]);
|
||||
if (mod2) ApplyModcrypt(mod2, *(u32*)&CartROM[0x22C], &CartROM[0x314]);
|
||||
}
|
||||
|
||||
|
||||
// save
|
||||
printf("Save file: %s\n", sram);
|
||||
|
Reference in New Issue
Block a user