I have a question
when i do this
inline uintptr_t get_pattern(LPCSTR lpModuleName, LPCSTR lpPattern)
{
uintptr_t moduleAdress = get_module(lpModuleName);
if (!moduleAdress)
return 0;
static auto patternToByte = [](const char* pattern)
{
auto bytes = std::vector<int>{};
const auto start = const_cast<char*>(pattern);
const auto end = const_cast<char*>(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;
};
const auto dosHeader = (PIMAGE_DOS_HEADER)moduleAdress;
const auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)moduleAdress + dosHeader->e_lfanew);
const auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
auto patternBytes = patternToByte(lpPattern);
const auto scanBytes = reinterpret_cast<std::uint8_t*>(moduleAdress);
const auto s = patternBytes.size();
const auto d = patternBytes.data();
for (auto i = 0ul; i < sizeOfImage - 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<uintptr_t>(&scanBytes[i]); }
}
return 0;
}
and i use this to get a pattern my game crash but when i use it without anticheat it will work? and i even tryed to bypass the anticheat pointer thats block the ntHeaders->OptionalHeader.SizeOfImage;