Finding memory ranges of self--process

Posts 1–3 of 3 · Page 1 of 1
Finding memory ranges of self--process
I can't think of a way to do this without a windows API providing the information. Does such an API exist?

I am trying to code a function for a hack that will find an address given a pattern of bytes starting at that address -- I know this already exists, but I want to find out how by myself.

Thanks.
For external processes, you need VirtualQuery and ReadProcessMemory. If you are searching for something within your own memory space (same process), you just need VirtualQuery and the rest is possible by casting.
Quote Originally Posted by Fovea View Post
For external processes, you need VirtualQuery and ReadProcessMemory. If you are searching for something within your own memory space (same process), you just need VirtualQuery and the rest is possible by casting.
KK. Using that, I came up with this for the function:

Code:
bool matchPattern(PBYTE address, BYTE bytes)
{
	if(*address == bytes) return true;
	else return false;
}
DWORD* scanAdd(BYTE bytes)
{
	VirtualQuery(NULL, &procMem, sizeof(procMem));
	int n;
	VOID *currentaddress;
	for(n = 0; n < procMem.RegionSize; n++)
	{
		currentaddress = ((PBYTE)procMem.BaseAddress + n);
		if(matchPattern((PBYTE)currentaddress, bytes)) return (DWORD*)currentaddress;
	}
	return 0;
}
Now it's time for me to see if it works.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?