From d26235cf8bd916f9d0991f370d0ece9ad672933c Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 6 Aug 2025 00:05:05 +0300 Subject: [PATCH] More memory fixes --- include/memory.hpp | 2 ++ src/core/loader/ncsd.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/memory.hpp b/include/memory.hpp index 71637517..2eb892a4 100644 --- a/include/memory.hpp +++ b/include/memory.hpp @@ -186,6 +186,8 @@ class Memory { // perms |= Common::MemoryPermission::Execute; } + // If anything is mapped at the place we're trying to map, unmap it. Then, create our mapping. + arena->Unmap(guestVaddr, size, false); arena->Map(guestVaddr, arenaOffset, size, perms, false); } } diff --git a/src/core/loader/ncsd.cpp b/src/core/loader/ncsd.cpp index dd3366af..500b70ce 100644 --- a/src/core/loader/ncsd.cpp +++ b/src/core/loader/ncsd.cpp @@ -40,7 +40,7 @@ bool Memory::mapCXI(NCSD& ncsd, NCCH& cxi) { // Total memory to allocate for loading u32 totalSize = (cxi.text.pageCount + cxi.rodata.pageCount + cxi.data.pageCount) * pageSize + bssSize; - if (code.size() < totalSize) { + if (code.size() + bssSize < totalSize) { Helpers::panic("Total code size as reported by the exheader is larger than the .code file"); return false; }