Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CompareData(const char* Data, const char* Pattern, const char* Mask) {
- while (*Mask) {
- if (*Mask != '?') {
- if (*Data != *Pattern) {
- return false;
- };
- };
- ++Mask;
- ++Data;
- ++Pattern;
- };
- return true;
- };
- struct AOBType {
- string name;
- const char* first;
- const char* second;
- };
- /*
- AOB Scanning
- */
- namespace AOB {
- bool Check(const BYTE* pd, const BYTE* aob, const char* mask)
- {
- for (; *mask; ++mask, ++pd, ++aob)
- if (*mask != '?' && *pd != *aob)
- return false;
- return (*mask) == NULL;
- }
- DWORD FindPattern(const char* aob, const char* mask)
- {
- for (DWORD ind = (DWORD)GetModuleHandle(0); ind <= 0xFFFFFFF; ++ind) {
- if (Check((BYTE*)ind, (BYTE*)aob, mask))
- return ind;
- }
- return 0x00000000;
- }
- }
- namespace Memory {
- void write(void* address, void* instructions, size_t size) {
- DWORD tbuf;
- VirtualProtect(address, 1, PAGE_EXECUTE_READWRITE, &tbuf);
- memcpy(address, instructions, size);
- VirtualProtect(address, 1, tbuf, &tbuf);
- }
- bool compare(BYTE* address, BYTE* pattern, BYTE* mask) {
- for (; *mask; address++, pattern++, mask++) {
- if (*mask == 'x' && *address != *pattern) {
- return false;
- }
- }
- return true;
- }
- DWORD scan(BYTE* aob, BYTE* mask, BYTE prot = (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) {
- MEMORY_BASIC_INFORMATION mbi;
- DWORD j = (DWORD)GetModuleHandle(NULL);
- while (j < 0x7FFFFFFF && VirtualQuery((void*)j, &mbi, sizeof(mbi))) {
- if (!(mbi.Protect & PAGE_GUARD) && (mbi.State & MEM_COMMIT) && (mbi.Protect & prot)) {
- for (DWORD k = (DWORD)mbi.BaseAddress; k < ((DWORD)mbi.BaseAddress + mbi.RegionSize); ++k) {
- if (compare((BYTE*)k, (BYTE*)aob, (BYTE*)mask)) {
- return k;
- }
- }
- }
- j += mbi.RegionSize;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement