#pragma once #include #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 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 originalBytes; bool hasTrampoline = false; void* trampolineDestination = nullptr; }; static std::unordered_map patches; };