Add initial project files (excluding ignored content)
This commit is contained in:
32
Memory/Memory.hpp
Normal file
32
Memory/Memory.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#define AUTO_ASSEMBLE_TRAMPOLINE(ADDRESS, TRAMPOLINE_LENGTH, INSTRUCTIONS) \
|
||||
do { \
|
||||
auto allocMemory = Memory::AllocateNearbyMemory(ADDRESS, sizeof INSTRUCTIONS + 14); \
|
||||
Memory::CreateTrampoline(ADDRESS, allocMemory, TRAMPOLINE_LENGTH); \
|
||||
Memory::WriteInstructions(allocMemory, INSTRUCTIONS, sizeof INSTRUCTIONS, ADDRESS + TRAMPOLINE_LENGTH); \
|
||||
} while (false)
|
||||
|
||||
|
||||
class Memory
|
||||
{
|
||||
public:
|
||||
static void PatchBytes(void* address, const char* bytes, size_t len);
|
||||
//static void RestoreBytes(uintptr_t address);
|
||||
static void RestoreBytes(void* address);
|
||||
// AOB scan dans le module spécifié (par nom), avec filtrage sur protections (ex: PAGE_EXECUTE_READ) et offset optionnel
|
||||
static uint8_t* aob_scan(const std::string& module_name, const std::string& signature, DWORD protect_flags, std::shared_ptr<spdlog::logger> log = nullptr);
|
||||
static bool wait_for_module(const std::string& module_name, int timeoutMs, int intervalMs);
|
||||
static std::string byteToHexEscaped(const BYTE byte);
|
||||
private:
|
||||
struct PatchInfo {
|
||||
void* address;
|
||||
std::vector<BYTE> originalBytes;
|
||||
bool hasTrampoline = false;
|
||||
void* trampolineDestination = nullptr;
|
||||
};
|
||||
|
||||
static std::unordered_map<void*, PatchInfo> patches;
|
||||
};
|
||||
Reference in New Issue
Block a user