Try to relocate r3 exe

This commit is contained in:
2025-05-30 03:23:12 +08:00
parent 2c104648cd
commit 556f8339c0
2 changed files with 13 additions and 3 deletions

View File

@@ -15,9 +15,18 @@ struct R3Bin {
auto &config = getDefaultConfig();
std::string path = config.gameRootDir + "/Rayman3.exe";
module = LoadLibraryA(path.c_str());
if (!module)
throw std::runtime_error("Failed to load original binary");
// Reserve 4MB at the original base address
module = (HINSTANCE)VirtualAlloc((LPVOID)GH_BASE_ADDR, 4 * 1024 * 1024, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!module) {
// Get the error code
DWORD error = GetLastError();
throw std::runtime_error("Failed to allocate memory at original base address: " + std::to_string(error));
}
// module = LoadLibraryA(path.c_str());
// if (!module)
// throw std::runtime_error("Failed to load original binary");
fixupImports(module);