I have a string defined as
std::string str ("This is my Test String");
std::cout << str.c_str() << std::endl;
I want to read the memory location of str, which should contain "This is my Test String" and get back the value of "This is my Test String"
I am attempting to read the string as so.
void WorkerThread::ReadMemorySpecific(void* pAddr, SIZE_T count)
char buff[8192];
ZeroMemory(buff, sizeof(buff));
SIZE_T bytesRead;
HANDLE currentProcess = GetCurrentProcess();
std::ofstream outFile("PATH_TO_FILE\\string.dat", std::ios::out | std::ios::binary);
ReadProcessMemory(currentProcess,(LPVOID)pAddr,&buff,count+1,&bytesRead);
outFile.write(buff,sizeof(buff));
outFile.flush();
outFile.close();
std::cout<< "Possible err: " << GetLastError() << std::endl;
for(int j = 0; j <8192; j++)
printf("%02X\n",buff[j]);
I am in the current process therefore I shouldn't need to enable debug privileges. I can verify the size & the address of the memory location are correct because I call this function as:
WorkerThread wt;
wt.ReadMemorySpecific(&str, str.length());
I can't seem to get my string back as ascii text no matter, what I do, I've tried dumping to a binary file and converting the binary back to ascii, I've tried converting the hex. Any suggestions?