I have been trying to get this function working for some time now with no luck.
def write_memory(self, address, data):
PROCESS_ALL_ACCESS = 0x001F0FFF
count = c_ulong(0)
length = len(data)
c_data = c_char_p(data[count.value:])
null = c_int(0)
windll.kernel32.SetLastError(10000)
if not windll.kernel32.WriteProcessMemory(self.h_process, address, c_data, length, byref(count)):
print "Failed to write memory."
print "Error Code: ", windll.kernel32.GetLastError()
else:
return True
GetLastError() returns 87 (0x57), which is ERROR_INVALID_PARAMETER. For this function I copied it straight from Gray Hat Python by Justin Seitz. Not sure what I'm doing wrong, ReadProcessMemory() works great and returns the appropriate value.
For address I'm picking a random location at the moment, 0x00050000, and passing data like "\x61" reading the location before and after with no change.
I have the feeling It's a simple error, Thanks in advance for the help. Nav.