I hate errors
Hello, I'm trying to scan memory here but I keep getting an error. Here's the code.
It compiles and it does what it's suposed to, but when I add:
To check if any of the bytes are equal to 10 I just get an error. Here's the full code.
It tells me i'm getting an unhandled win32 exception.
Thanks.
Code:
#include <windows.h>
#include <conio.h>
#include <iostream>
using namespace std;
DWORD pid;
HWND hwnd;
HANDLE handle;
DWORD base = 0x0000000;
DWORD end = 0x7FFFFFFF;
DWORD bSize = 0x5D1745D;
LPBYTE buffer = new byte[bSize];
int value = 10;
int main()
{
hwnd = FindWindow(0,"Minesweeper");
if(!hwnd)
{
cout <<"Window not found!";
getch();
return 0;
}
GetWindowThreadProcessId(hwnd,&pid);
handle = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
if(!handle)
{
cout <<"Could not get window handle!";
getch();
return 0;
}
while ( base != end)
{
ReadProcessMemory(handle,(LPVOID)base,buffer,bSize,0);
if( (end-base) > bSize)
{
base += bSize;
} else if( (end-base) < bSize)
{
base += (end-base);
}
delete[] buffer;
}
cout <<"Done";
getch();
}
Code:
for(int i = 0; i < bSize; i++ )
{
if(buffer[i] == 10)
{
cout << hex << base + i << endl;
}
}
Code:
#include <windows.h>
#include <conio.h>
#include <iostream>
using namespace std;
DWORD pid;
HWND hwnd;
HANDLE handle;
DWORD base = 0x0000000;
DWORD end = 0x7FFFFFFF;
DWORD bSize = 0x5D1745D;
LPBYTE buffer = new byte[bSize];
int value = 10;
int main()
{
hwnd = FindWindow(0,"Minesweeper");
if(!hwnd)
{
cout <<"Window not found!";
getch();
return 0;
}
GetWindowThreadProcessId(hwnd,&pid);
handle = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
if(!handle)
{
cout <<"Could not get window handle!";
getch();
return 0;
}
while ( base != end)
{
ReadProcessMemory(handle,(LPVOID)base,buffer,bSize,0);
for(int i = 0; i < bSize; i++ )
{
if(buffer[i] == value)
{
cout << hex << base + i << endl;
}
}
if( (end-base) > bSize)
{
base += bSize;
} else if( (end-base) < bSize)
{
base += (end-base);
}
delete[] buffer;
}
cout <<"Done";
getch();
}
Thanks.


)