Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save secretdataz/b0a48bfe14d93b67c480481decf7ff43 to your computer and use it in GitHub Desktop.
Save secretdataz/b0a48bfe14d93b67c480481decf7ff43 to your computer and use it in GitHub Desktop.
Mem edit
#include <Windows.h>
BOOL WriteBytes(DWORD dwAddress, LPBYTE lpBuffer, DWORD nBytes) {
if (nBytes == 0) {
return FALSE;
}
DWORD dwOldProtect;
if (!VirtualProtect((LPVOID)dwAddress, nBytes, PAGE_EXECUTE_READWRITE, &dwOldProtect)) {
return FALSE;
}
memcpy((LPVOID)dwAddress, lpBuffer, nBytes);
if (!VirtualProtect((LPVOID)dwAddress, nBytes, dwOldProtect, &dwOldProtect)) {
return FALSE;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment