Skip to content

Instantly share code, notes, and snippets.

@WheretIB
Created September 5, 2019 18:35
Show Gist options
  • Save WheretIB/4b719bba2dbac8062cc9db5103ad309d to your computer and use it in GitHub Desktop.
Save WheretIB/4b719bba2dbac8062cc9db5103ad309d to your computer and use it in GitHub Desktop.
__declspec(naked) void* self()
{
__asm mov eax, [esp]
__asm ret
}
int test()
{
DWORD unused = 0;
VirtualProtect(self(), 4096, PAGE_EXECUTE_READWRITE, &unused);
__asm
{
call $+10
jmp $+6
ret
mov eax, [esp-4]
mov[eax+18], 0xcd
mov[eax+19], 0x03
// Continue after breakpoint here and crash on incorrect instruction sequence
xor eax, eax
}
}
int main()
{
return test();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment