Can someone explain to me how to use WriteProcessMemory correctly
I definitely have the value of the address right but I don't think I'm passing it correctly because the value is not being written. The code I have is here (and yes it is definitely being called because the calling function is appended to the bottom of an onclick event that grabs the addresses and values it relies on)
Tried it, didn't work... wait just thought of something that I forgot, I should've added the Base Memory address to the address before passing it, I'll give that a go and see if there is any change.
BTW I'm hacking PCSX2 0.9.7+ since it base address is fixed, the game is Final Fantasy 12, I'm just looking for the GIL to change before I worry about Byte Orders.
Edit: Still didn't work, here's my current code, I know HCSet works because I was sending the output to a textctrl before to make sure it was analysing correctly.
Tried it but didn't see any change so I stuck in a bunch of message boxes to see how far it was getting and eventually found the reason, h->use had never been made true so I'm going to fix that and see what happens.
Edit: Didn't write because of handle now (had messagebox in write function), I'm having a look at the code you just posted so it'll be a few minutes before I reply for that one
// Get a handle for the target process.
hProcess = OpenProcess(
PROCESS_QUERY_INFORMATION | // Required by Alpha
PROCESS_CREATE_THREAD | // For CreateRemoteThread
PROCESS_VM_OPERATION | // For VirtualAllocEx/VirtualFreeEx
PROCESS_VM_WRITE, // For WriteProcessMemory
FALSE, dwProcessId);
if (hProcess == NULL) __leave;
// Calculate the number of bytes needed for the DLL's pathname
int cch = 1 + lstrlenW(pszLibFile);
int cb = cch * sizeof(wchar_t);
// Allocate space in the remote process for the pathname
pszLibFileRemote = (PWSTR)
VirtualAllocEx(hProcess, NULL, cb, MEM_COMMIT, PAGE_READWRITE);
if (pszLibFileRemote == NULL) __leave;
// Copy the DLL's pathname to the remote process' address space
if (!WriteProcessMemory(hProcess, pszLibFileRemote,
(PVOID) pszLibFile, cb, NULL)) __leave;
I've tried with both x and a, once I have this function working I should be able to write HCRead on my own
Edit: Finally, Turned out I remembered the start address wrong for the RAM, once I corrected that I was getting the desired result :D At long last my app is starting to behave like the app it was designed to be from the start.
Just got to add the HCRead and fill out the rest of the code abilities. Thank you for your help, the app's source code will be uploaded to http://code.google.com/p/renegade on the 9th (I'm running off a Dongle at the moment so will wait for Broadband to be activated - recently moved)