My problem is resolved. It was that the memory I was writing to was protected.
Code:
[DllImport("kernel32.dll")]
public static extern bool VirtualProtectEx(
IntPtr hProcess,
uint dwAddress,
int nSize,
uint flNewProtect,
out uint lpflOldProtect);
public enum Protection : uint
{
PAGE_NOACCESS = 0x01,
PAGE_READONLY = 0x02,
PAGE_READWRITE = 0x04,
PAGE_WRITECOPY = 0x08,
PAGE_EXECUTE = 0x10,
PAGE_EXECUTE_READ = 0x20,
PAGE_EXECUTE_READWRITE = 0x40,
PAGE_EXECUTE_WRITECOPY = 0x80,
PAGE_GUARD = 0x100,
PAGE_NOCACHE = 0x200,
PAGE_WRITECOMBINE = 0x400
}
Example:
Code:
wow.VirtualProtectEx((wow.BaseAddress + (uint)Offset.Jump), 256, (uint)Imports.Protection.PAGE_READWRITE, (uint)Imports.Protection.PAGE_READONLY);
Not the best example but you should get the idea!