From 3d582c6a6355f81ad77bd6a337dbdf2105d9bb96 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Fri, 27 Feb 2026 22:42:33 +0100 Subject: [PATCH] Add preprocessor log. Add AOB scan by region and base address. --- libs/Memory/Memory.hpp | 56 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/libs/Memory/Memory.hpp b/libs/Memory/Memory.hpp index 801aab7..8dc2016 100644 --- a/libs/Memory/Memory.hpp +++ b/libs/Memory/Memory.hpp @@ -11,6 +11,15 @@ Memory::CreateTrampoline(ADDRESS, allocMemory, TRAMPOLINE_LENGTH); \ Memory::WriteInstructions(allocMemory, INSTRUCTIONS, sizeof INSTRUCTIONS, ADDRESS + TRAMPOLINE_LENGTH); \ } while (false) +// Rich verbose for internal release only +#ifdef MY_VERBOSE_LOGS +#define LOG_SIGNATURE_FOUND(name, addr) \ + logger->info("{} signature found at address: 0x{:X}.",name, addr) +#else +#define LOG_SIGNATURE_FOUND(name, addr) \ + logger->info("{} signature found", name) +#endif + namespace UT { // Typedef used by Unreal Engine typedef int8_t int8; typedef int16_t int16; @@ -41,6 +50,10 @@ namespace AOBScan { } } +//namespace Memory { + +//} + enum class OffsetCalcType { None, @@ -79,7 +92,26 @@ namespace OffsetScan { class Memory { public: - + /** + * Scan a memory range for an obfuscated AOB signature. + * + * @tparam ObfStr Must provide decrypt() returning a std::string with wildcards as '?'. + * @param baseAddress Start of memory to scan. + * @param name Name for logging. + * @param range Number of bytes to scan. + * @param signature Obfuscated signature object. + * @param protect_flags Memory protection flags (default PAGE_EXECUTE_READWRITE). + * @param log Optional logger. + * @return Pointer to matching byte or nullptr if not found. + */ + template + static uint8_t* AOBScanRange(uint8_t* baseAddress, const char* name, size_t range, + ObfStr& signature, + DWORD protect_flags = PAGE_EXECUTE_READWRITE, + std::shared_ptr log = nullptr) { + auto patternStr = signature.decrypt(); + return Memory::AOBScanInternal(baseAddress, name, range, patternStr, protect_flags, log); + }; /** * Get offset from opcode. * @@ -139,6 +171,27 @@ class Memory */ static uint8_t* AOBScan(const std::string& module_name, const std::string& signature, DWORD protect_flags, std::shared_ptr log = nullptr); + /** + * Scan a memory range for a specific Array of Bytes (AOB) signature. + * + * @param base The starting address of the memory range to scan. + * @param label A descriptive label for logging purposes. + * @param size The size (in bytes) of the memory range to scan. + * @param signature The byte pattern to search for, represented as a string (e.g., "F3 0F ?? ?? F2"). + * Wildcards can be represented by '?'. + * @param protect_flags Optional. Memory protection flags to consider during the scan + * (default: PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE). + * @param log Optional. Logger instance to report progress, hits, or warnings. + * + * @return uint8_t* Pointer to the first byte matching the signature within the specified memory range, + * or nullptr if no match is found. + * + * @note This function assumes the memory range is accessible. It will skip pages that are + * guarded or have no access. + */ + static uint8_t* AOBScanInternal(uint8_t* base, const char* label, size_t size, const std::string& signature, DWORD protect_flags = PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE, + std::shared_ptr log = nullptr); + /** * Achieve an AOB scan in memory by batch. * @@ -147,6 +200,7 @@ class Memory */ static void AOBScanBatch(const std::vector& entries, std::shared_ptr logger); + /** * Achieve an unreal offsets scan by batch. *