programme-zero How do I cheat?
Reputation: 0
Joined: 05 May 2014 Posts: 1
|
Posted: Mon May 05, 2014 4:17 pm Post subject: Memory scan |
|
|
Hi everyone,
Cheat Engine is detected by all the anti cheat in the world so i'm writing my own memory scanner but I get some problems...
My memory scanner don't found my variable in my test application and I don't understand why (but it found correct variable that I can find with cheat engine).
My code :
| Code: | #include <windows.h>
#include <stdio.h>
#include <iostream>
int founded = 0;
int total = 0;
// Below are helper functions
BOOL DoRtlAdjustPrivilege()
{
#define SE_DEBUG_PRIVILEGE 20L
#define AdjustCurrentProcess 0
BOOL bPrev = FALSE;
LONG (WINAPI *RtlAdjustPrivilege)(DWORD, BOOL, INT, PBOOL);
*(FARPROC *)&RtlAdjustPrivilege = GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlAdjustPrivilege");
if(!RtlAdjustPrivilege) return FALSE;
RtlAdjustPrivilege(SE_DEBUG_PRIVILEGE, TRUE, AdjustCurrentProcess, &bPrev);
return TRUE;
}
typedef BOOL (CALLBACK *LPENUMADDRESSES)(LPBYTE lpAddress, DWORD dwSize, DWORD dwState, DWORD dwType, DWORD dwProtect);
BOOL EnumProcessAddresses(HANDLE hProcess, LPENUMADDRESSES lpCallback)
{
MEMORY_BASIC_INFORMATION mbi;
SYSTEM_INFO msi;
ZeroMemory(&mbi, sizeof(mbi));
GetSystemInfo(&msi);
for(LPBYTE lpAddress = (LPBYTE)msi.lpMinimumApplicationAddress;
lpAddress <= (LPBYTE)msi.lpMaximumApplicationAddress;
lpAddress += mbi.RegionSize){
if(VirtualQueryEx(hProcess, lpAddress, &mbi, sizeof(mbi))){
if(lpCallback && !lpCallback((LPBYTE)mbi.BaseAddress, mbi.RegionSize,
mbi.State, mbi.Type, mbi.Protect)) return FALSE;
} else break;
}
return TRUE;
}
// Below is actual code --
BOOL CALLBACK DoSomethingForAddress(LPBYTE lpAddress, DWORD dwSize, DWORD dwState, DWORD dwType, DWORD dwProtect)
{
int value = 0;
HWND hWnd = FindWindow(0, "Sandbox 2");
DWORD proccess_ID;
GetWindowThreadProcessId(hWnd, &proccess_ID);
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,proccess_ID);
ReadProcessMemory(phandle,(void*)lpAddress,&value,sizeof(value),0);
printf("0x%08X - 0x%08X (0x%08X) : ", lpAddress, (lpAddress + dwSize), dwSize);
printf("(%d)", value);
if (value == 5462)
{
founded += 1;
printf(" FOUND !");
}
total += 1;
printf("\n");
return TRUE;
}
int main(int argc, char **argv)
{
if(!DoRtlAdjustPrivilege()) return 1;// Error 1
HWND hWnd = FindWindow(0, "Sandbox 2");
DWORD proccess_ID;
GetWindowThreadProcessId(hWnd, &proccess_ID);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, proccess_ID);
if(hProcess == NULL) return 2; // Error 2
printf("=====SCAN BEGIN===== \n");
EnumProcessAddresses(hProcess, DoSomethingForAddress);
CloseHandle(hProcess);
printf("=====END OF THE SCAN===== \n");
printf("Found : %d\n", founded);
printf("Total : %d", total);
return 0;
} | [/code]
|
|