Hey, I am trying to use the ReadProcessMemory function but every time I call it I get the error code 299 from the function GetLastError() that means: "Only part of a ReadProcessMemory or WriteProcessMemory request was completed.".

OS: Windows Vista.
Code from the "reader":
Code:
handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, getPid());

SIZE_T bytesRead;
std::string buffer(8, '\0');
unsigned long address = 0x001cf834;

if (ReadProcessMemory(handle, &address, &buffer[0], 8, &bytesRead))
{
	return true;
}
else
{
	cout << GetLastError() << '\n';
	return false;
}
Remark: the process ID is correct, I assure you .

Code from the "readed":
Code:
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
	char t[] = "my pattern" ;

	cout << "addr: " << &t << '\n';

	cin.get();
}
1) The address chosen to be the parameter of ReadProcessMemory is the address printed in the readed program, is that right?

2) By the way, always when i restart the readed program the address of char t changes, why? If I am allocating it statically shouldn't it have always the same address?

3) How can i search a program's memory like a debugger? I have tought of scanning its memory trough ReadProcessMemory respecting the maximum and minimum base addresses provided by the function GetSystemInfo(), is it the correct way of doing that?

4) If the last question is true, how much should be the buffer size of the ReadProcessMemory because I imagine that a call to this function should take a lot of time so implementing a buffer would help?

Thank You