Closed dustinrouillard closed 5 years ago
Just tested this and I encountered no problems.
Here was my test application:
// print the value of the string and its memory location
string _string = "robert";
cout << "string\t0x" << hex << (DWORD64)_string.c_str() << dec << "\t" << _string << endl;
// pause, during this pause I use memoryjs to write to the string
// after I've written to the string, reprint the value
getchar();
cout << "string\t0x" << hex << (DWORD64)_string.c_str() << dec << "\t" << _string << endl;
And I used the following code to read the string (ensure the correct address) and then write:
> processObject = memoryjs.openProcess("ConsoleApplication2.exe")
{ dwSize: 304,
th32ProcessID: 6076,
cntThreads: 3,
th32ParentProcessID: 5524,
pcPriClassBase: 8,
szExeFile: 'ConsoleApplication2.exe',
handle: 744,
modBaseAddr: 20774912 }
> memoryjs.readMemory(processObject.handle, 0x4ff940, 'string');
'robert'
> memoryjs.writeMemory(processObject.handle, 0x4ff940, 'rogerd', 'string');
undefined
> memoryjs.readMemory(processObject.handle, 0x4ff940, 'string');
'rogerd'
Alright, so I've tried multiple times to write a string back to memory, the string is the same length just the original text but reversed to make it a noticeable change.
This is the code I'm using to read the address and I know it is working perfectly to get me the value of the address.
I was going through some trouble at first reading until I changed the handle in the readMemory spot to the one from the original process instead of the module.
I've tried writting like this with both handles and none of them seem to have any effect of the memory.
The value never changes, I originally thought this was a permissions issue with windows but even in the Administrator CMD nothing seems to happen. I've also tried using setProtection before the writeMemory on the same address and it still seems to have no effect.
If anyone happens to know what I can do to fix this or if I'm doing anything wrong. I'm able to change all the memory values I'm trying to change with this in other memory editors perfectly fine.
(Note: I would like to add this is a 64-bit process and I'm not sure if this matters or not with how it's done on the C++ side of it.)