mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-10-17 16:30:34 +02:00
GraphicPack: Allocate the full code cave of a patch group
The address relocator was basically fine with addresses up to 8MB within a code cave, but the size was capped to 1MB. So you could overwrite the next group's code cave if it was too big.
This commit is contained in:
1 parent
4a26a3e7ea
commit
b044641111
3 files changed
+11
-3
No files matched your search
@@ -225,6 +225,8 @@ class PatchGroup
|
||||
friend class GraphicPack2;
|
||||
|
||||
public:
|
||||
static constexpr uint32 CODECAVE_MAX_OFFSET = 8 * 1024 * 1024;
|
||||
|
||||
PatchGroup(class GraphicPack2* gp, const char* nameStr, sint32 nameLength) : graphicPack(gp)
|
||||
{
|
||||
name = std::string(nameStr, nameLength);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
bool _relocateAddress(PatchGroup* group, PatchContext_t* ctx, uint32 addr, uint32& relocatedAddress)
|
||||
{
|
||||
if (addr >= 0 && addr <= 1024 * 1024 * 8)
|
||||
if (addr <= PatchGroup::CODECAVE_MAX_OFFSET)
|
||||
{
|
||||
// codecave address
|
||||
relocatedAddress = group->getCodeCaveBase() + addr;
|
||||
@@ -574,6 +574,12 @@ void GraphicPack2::ApplyPatchGroups(std::vector<PatchGroup*>& groups, const RPLM
|
||||
if (patchGroup->codeCaveSize > 0)
|
||||
{
|
||||
auto codeCaveMem = RPLLoader_AllocateCodeCaveMem(256, patchGroup->codeCaveSize);
|
||||
if (!codeCaveMem)
|
||||
{
|
||||
patchContext.errorHandler.printError(patchGroup, -1, fmt::format("Not enough code cave memory for {} bytes, the code caves of all graphic packs share {} bytes", patchGroup->codeCaveSize, MEMORY_CODECAVEAREA_SIZE));
|
||||
patchContext.errorHandler.showStageErrorMessageBox();
|
||||
return;
|
||||
}
|
||||
cemuLog_log(LogType::Force, "Applying patch group \'{}\' (Codecave: {:08x}-{:08x})", patchGroup->name, codeCaveMem.GetMPTR(), codeCaveMem.GetMPTR() + patchGroup->codeCaveSize);
|
||||
patchGroup->codeCaveMem = codeCaveMem;
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ void GraphicPack2::AddPatchGroup(PatchGroup* group)
|
||||
if (patchData)
|
||||
{
|
||||
uint32 patchAddr = patchData->getAddr();
|
||||
if (patchAddr < 0x00100000)
|
||||
if (patchAddr < PatchGroup::CODECAVE_MAX_OFFSET)
|
||||
{
|
||||
// everything in low 1MB of memory we consider part of the code cave
|
||||
// everything that gets relocated relative to the code cave needs to be part of it
|
||||
codeCaveMaxAddr = std::max(codeCaveMaxAddr, patchAddr + patchData->getSize());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user