Skip to content

pinonym/DLLInjection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💉 DLL-MessageBox-Hook (x64)

A simple Windows x64 DLL hook demo that intercepts calls to MessageBoxA using inline patching (manual trampoline).
Perfect for understanding DLL injection, function hooking, and runtime behavior modification.


🧩 Features

  • Hooks MessageBoxA via mov rax / jmp rax (12-byte patch, x64-compliant)
  • Displays a custom message (💥 p0wn3d!) when the app calls MessageBoxA
  • Can be injected into any x64 Win32 app calling MessageBoxA
  • Includes a test app with a button that triggers a MessageBox

🛠️ Build

🧪 DLL

Compile the DLL from hook64_msgboxa.c:

cl /LD hook64_msgboxa.c /Fehook64_msgboxa.dll user32.lib

⚠️ Requires Visual Studio + Developer Command Prompt for x64

🧪 Demo App (x64)

Compile simple_app.c:

cl simple_app.c /Fesimple_app.exe user32.lib gdi32.lib

The app shows a window with a button. Clicking it triggers MessageBoxA.


🚀 Usage

  • Start simple_app.exe
  • Use a DLL injector (Python or C) to inject hook64_msgboxa.dll
  • Click the button in the window

✅ You’ll see:

Intercepted
💥 p0wn3d!

🧠 How it works

  • Finds MessageBoxA in user32.dll
  • Saves its first 12 bytes
  • Overwrites it with:
mov rax, HookedFunction
jmp rax
  • Redirects execution to HookedMessageBoxA, which modifies the message
  • Optionally, the hook can be removed before calling the original

🛡️ Notes

  • This only works on x64 processes
  • Hooking x86 requires a different approach (jmp rel32, 5 bytes)
  • Modern apps often use MessageBoxW (Unicode); hook that if needed

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors