Add Cryptopp

This commit is contained in:
wheremyfoodat 2022-10-01 18:53:53 +03:00
parent f6c2e390c1
commit 29241b41ce
8 changed files with 469 additions and 4 deletions

View file

@ -1,4 +1,6 @@
#include <cryptopp/aes.h>
#include "loader/ncch.hpp"
#include "memory.hpp"
bool NCCH::loadFromHeader(u8* header) {
const u8* exheader = &header[0x200]; // Extended NCCH header
@ -16,6 +18,14 @@ bool NCCH::loadFromHeader(u8* header) {
encrypted = (header[0x188 + 7] & 0x4) != 0x4;
compressExeFS = (exheader[0xD] & 1) != 0;
stackSize = *(u32*)&exheader[0x1C];
bssSize = *(u32*)&exheader[0x3C];
printf("Stack size: %08X\nBSS size: %08X\n", stackSize, bssSize);
if (stackSize != VirtualAddrs::DefaultStackSize) {
Helpers::panic("Stack size != 0x4000");
}
if (compressExeFS) {
Helpers::panic("Compressed ExeFS");

View file

@ -26,8 +26,8 @@ void Memory::reset() {
// Map stack pages as R/W
// We have 16KB for the stack, so we allocate the last 16KB of APPLICATION FCRAM for the stack
u32 basePaddrForStack = FCRAM_APPLICATION_SIZE - VirtualAddrs::StackSize;
allocateMemory(VirtualAddrs::StackBottom, basePaddrForStack, VirtualAddrs::StackSize, true);
u32 basePaddrForStack = FCRAM_APPLICATION_SIZE - VirtualAddrs::DefaultStackSize;
allocateMemory(VirtualAddrs::StackBottom, basePaddrForStack, VirtualAddrs::DefaultStackSize, true);
// And map (4 * 32)KB of FCRAM before the stack for the TLS of each thread
u32 basePaddrForTLS = basePaddrForStack;

View file

@ -9,7 +9,7 @@ int main (int argc, char *argv[]) {
emu.initGraphicsContext();
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "SuperMario3DLand.3ds");
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "OoT.3ds");
if (!emu.loadROM(romPath)) {
// For some reason just .c_str() doesn't show the proper path
Helpers::panic("Failed to load ROM file: %s", romPath.string().c_str());