Add preprocessor log. Add AOB scan by region and base address.

This commit is contained in:
2026-02-27 22:42:33 +01:00
parent ba13f13c11
commit 3d582c6a63

View File

@@ -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<typename ObfStr>
static uint8_t* AOBScanRange(uint8_t* baseAddress, const char* name, size_t range,
ObfStr& signature,
DWORD protect_flags = PAGE_EXECUTE_READWRITE,
std::shared_ptr<spdlog::logger> 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<spdlog::logger> 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<spdlog::logger> log = nullptr);
/**
* Achieve an AOB scan in memory by batch.
*
@@ -147,6 +200,7 @@ class Memory
*/
static void AOBScanBatch(const std::vector<AOBScanEntry>& entries, std::shared_ptr<spdlog::logger> logger);
/**
* Achieve an unreal offsets scan by batch.
*