Currently the Windows process crashes as soon as I write to the chunk of memory with 'invalid page fault' (Wine doesn't seem to complain or interfere), and the Linux application keeps running just fine.
This is what I'm supposed to do on Windows:
Code: Select all
DWORD tmp;
if (!VirtualProtectEx(processHandle, dataAdress, dataSize, PAGE_EXECUTE_READWRITE, &tmp)) {
printf("error changing memory protection\n");
return false;
}
if (!WriteProcessMemory(processHandle, dataAdress, &newData, dataSize, NULL)) {
printf("error writing memory\n");
return false;
}
Code: Select all
// open process memory
char path[80];
snprintf(path, 80, "/proc/%d/mem", pid);
int fd_procmem = open(path, O_RDWR);
if (fd_procmem == -1) {
printf("could not open \"%s\" (%i): %s\n", path, errno, strerror(errno) );
return false;
}
// write data
long int addr = 0x98FCC500;
lseek(fd_procmem, addr, SEEK_SET);
int r = write(fd_procmem, data, dataSize);
if (r != 64) {
printf("error while writing\n");
return false;
}