This commit is contained in:
CrazyBloo 2024-08-22 20:11:53 -04:00
parent 06f6082bc1
commit fbe7f6d388
3 changed files with 20 additions and 24 deletions

View file

@ -1,8 +1,7 @@
#include "memory_patcher.h"
#include "common/logging/log.h"
#include "memory_patcher.h"
namespace MemoryPatcher
{
namespace MemoryPatcher {
uintptr_t g_eboot_address;
@ -25,8 +24,7 @@ void ApplyPendingPatches() {
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr) {
// Send a request to modify the process memory.
void* cheatAddress =
reinterpret_cast<void*>(g_eboot_address + std::stoi(offsetStr, 0, 16));
void* cheatAddress = reinterpret_cast<void*>(g_eboot_address + std::stoi(offsetStr, 0, 16));
std::vector<unsigned char> bytePatch;
@ -38,7 +36,8 @@ void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valu
}
std::memcpy(cheatAddress, bytePatch.data(), bytePatch.size());
LOG_INFO(Loader, "Applied patch:{}, Offset:{}, Value:{}", modNameStr, (uintptr_t)cheatAddress, valueStr);
LOG_INFO(Loader, "Applied patch:{}, Offset:{}, Value:{}", modNameStr, (uintptr_t)cheatAddress,
valueStr);
}
}
} // namespace MemoryPatcher

View file

@ -1,24 +1,23 @@
#pragma once
#include <cstring>
#include <vector>
#include <string>
#include <vector>
namespace MemoryPatcher
{
extern uintptr_t g_eboot_address;
namespace MemoryPatcher {
struct patchInfo {
std::string modNameStr;
std::string offsetStr;
std::string valueStr;
};
extern uintptr_t g_eboot_address;
extern std::vector<patchInfo> pending_patches;
struct patchInfo {
std::string modNameStr;
std::string offsetStr;
std::string valueStr;
};
void AddPatchToQueue(patchInfo patchToAdd);
void ApplyPendingPatches();
extern std::vector<patchInfo> pending_patches;
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr);
void AddPatchToQueue(patchInfo patchToAdd);
void ApplyPendingPatches();
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr);
}
} // namespace MemoryPatcher

View file

@ -5,13 +5,13 @@
#include "common/alignment.h"
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/memory_patcher.h"
#include "common/string_util.h"
#include "core/aerolib/aerolib.h"
#include "core/cpu_patches.h"
#include "core/loader/dwarf.h"
#include "core/memory.h"
#include "core/module.h"
#include "common/memory_patcher.h"
namespace Core {
@ -197,11 +197,9 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
if (MemoryPatcher::g_eboot_address == 0) {
if (name == "eboot") {
MemoryPatcher::g_eboot_address = base_virtual_addr;
MemoryPatcher::ApplyPendingPatches();
}
}
}
void Module::LoadDynamicInfo() {