Add files via upload
This commit is contained in:
44
BattleyePresentCheck/utils.cpp
Normal file
44
BattleyePresentCheck/utils.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#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<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;
|
||||
};
|
||||
auto patternBytes = patternToByte(signature);
|
||||
const auto scanBytes = reinterpret_cast<std::uint8_t*>(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<uintptr_t>(&scanBytes[i]); }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user