help with mbi.BaseAddress loop
if someone can help me with this i would be very greatfull,
i am stuck with figuring out how to loop from baseaddress to regionsize and scan the memory between base address and regionsize ,
Code:
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
using namespace std;
//structs
PROCESSENTRY32 pe32;
MODULEENTRY32 me32;
//handles
HANDLE hProcessSnap;
HANDLE processtokill;
HANDLE modhandle;
HANDLE Process;
//memory
MEMORY_BASIC_INFORMATION mbi;
SYSTEM_INFO si;
//varible
int i = 0;
char data[32];
char buff[32];
//prototype
DWORD GetProcess();
DWORD GetProcess()
{
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap);
return 0;
}
while (Process32Next(hProcessSnap, &pe32))
{
if(strcmpi(pe32.szExeFile , "mirc.exe")==0)
{
return pe32.th32ProcessID;
}
}
}
int main()
{
Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetProcess()); //Got Process Handle
GetSystemInfo(&si);
void *addr = 0;
void *incaddr = 0;
DWORD inc = 0;
DWORD incre = 1;
while (addr < si.lpMaximumApplicationAddress)
{
if (!VirtualQueryEx(Process, addr, &mbi, sizeof(MEMORY_BASIC_INFORMATION)))
{
return 0;
}
else
{
if(mbi.State == MEM_COMMIT)
{
cout << addr << " " << "mbi.BaseAddress" << mbi.BaseAddress << " " << mbi.RegionSize << endl;
// i am stuck here , i cant seem to think how to loop as many times as baseaddress + regionsize
while(1)
{
mbi.BaseAddress = (void*)+1;
Sleep(50);
ReadProcessMemory(Process , (void*)&mbi.BaseAddress ,&buff , sizeof(buff) , NULL);
//mbi.RegionSize = (void*)=1;
}
//MessageBox(NULL,"region covered","",0);
}
}
cout << addr <<endl;
addr = (void*)((unsigned long)mbi.BaseAddress + mbi.RegionSize);
}
return 0;
}