#include "utils.h" uintptr_t utils::scanpattern(uintptr_t base, int size, const char* signature) { static auto patternToByte = [](const char* pattern) { auto bytes = std::vector{}; const auto start = const_cast(pattern); const auto end = const_cast(pattern) + strlen(pattern); for (auto current = start; current < end; ++current) { if (*current == '?') { ++current; if (*current == '?') ++current; bytes.push_back(-1); } else { bytes.push_back(strtoul(current, ¤t, 16)); } } return bytes; }; auto patternBytes = patternToByte(signature); const auto scanBytes = reinterpret_cast(base); const auto s = patternBytes.size(); const auto d = patternBytes.data(); for (auto i = 0ul; i < size - s; ++i) { bool found = true; for (auto j = 0ul; j < s; ++j) { if (scanBytes[i + j] != d[j] && d[j] != -1) { found = false; break; } } if (found) { return reinterpret_cast(&scanBytes[i]); } } return NULL; }