Building a tiny real-life VEH hooking demo!
Building a tiny real-life VEH hooking demo!
I'll show you how to:
-
Set up a VEH handler,
-
Trigger an intentional crash,
-
Catch it and redirect execution to a Hello World function 🚀.
I'll keep it super simple and annotated so you can fully understand.
🛠️ Full VEH Hook Demo (C++)
#include <windows.h> #include <iostream> // This is the "payload" we want to jump to void MyShellcode() { MessageBoxA(NULL, "VEH Hooked Successfully!", "Hello World", MB_OK); } // This is our VEH handler LONG WINAPI MyVEH(EXCEPTION_POINTERS* ExceptionInfo) { // Check if it's the kind of exception we want (Access Violation) if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { // Redirect instruction pointer (EIP for x86, RIP for x64) #ifdef _WIN64 ExceptionInfo->ContextRecord->Rip = (DWORD64)MyShellcode; #else ExceptionInfo->ContextRecord->Eip = (DWORD)MyShellcode;
Comments
Post a Comment