Created
September 5, 2019 18:35
-
-
Save WheretIB/4b719bba2dbac8062cc9db5103ad309d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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