This commit is contained in:
CrazyBloo 2024-08-23 02:45:52 -04:00
parent 90f1d2c08f
commit 0c1c3d7a83
3 changed files with 8 additions and 6 deletions

View File

@ -13,16 +13,17 @@ void AddPatchToQueue(patchInfo patchToAdd) {
void ApplyPendingPatches() { void ApplyPendingPatches() {
for (size_t i = 0; i < pending_patches.size(); ++i) { for (size_t i = 0; i < pending_patches.size(); ++i) {
patchInfo currentPatch = pending_patches[i]; patchInfo currentPatch = pending_patches[i];
PatchMemory(currentPatch.modNameStr, currentPatch.offsetStr, currentPatch.valueStr, PatchMemory(currentPatch.modNameStr, currentPatch.offsetStr, currentPatch.valueStr,
currentPatch.isOffset); currentPatch.isOffset);
} }
pending_patches.clear(); pending_patches.clear();
} }
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr, bool isOffset) { void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr,
bool isOffset) {
// Send a request to modify the process memory. // Send a request to modify the process memory.
void* cheatAddress = nullptr; void* cheatAddress = nullptr;
@ -44,7 +45,7 @@ void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valu
std::memcpy(cheatAddress, bytePatch.data(), bytePatch.size()); std::memcpy(cheatAddress, bytePatch.data(), bytePatch.size());
LOG_INFO(Loader, "Applied patch:{}, Offset:{}, Value:{}", modNameStr, (uintptr_t)cheatAddress, LOG_INFO(Loader, "Applied patch:{}, Offset:{}, Value:{}", modNameStr, (uintptr_t)cheatAddress,
valueStr); valueStr);
} }
} // namespace MemoryPatcher } // namespace MemoryPatcher

View File

@ -19,6 +19,7 @@ extern std::vector<patchInfo> pending_patches;
void AddPatchToQueue(patchInfo patchToAdd); void AddPatchToQueue(patchInfo patchToAdd);
void ApplyPendingPatches(); void ApplyPendingPatches();
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr, bool isOffset); void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr,
bool isOffset);
} // namespace MemoryPatcher } // namespace MemoryPatcher

View File

@ -26,9 +26,9 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <common/logging/log.h> #include <common/logging/log.h>
#include "cheats_patches.h" #include "cheats_patches.h"
#include "common/memory_patcher.h"
#include "common/path_util.h" #include "common/path_util.h"
#include "core/module.h" #include "core/module.h"
#include "common/memory_patcher.h"
using namespace Common::FS; using namespace Common::FS;