Exetools  

Go Back   Exetools > General > Source Code

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-07-2023, 12:12
vic4key's Avatar
vic4key vic4key is offline
Family
 
Join Date: Apr 2010
Posts: 62
Rept. Given: 5
Rept. Rcvd 24 Times in 10 Posts
Thanks Given: 63
Thanks Rcvd at 98 Times in 23 Posts
vic4key Reputation: 24
Talking C++ Hooking - Write Less Do More

With this library, you can set up function hooking easily and write less code.
It supports both Inline hooking & IAT hooking on both 32-bit & 64-bit.

Eg. To hook/un-hook a function with the Inline Hooking technique, you only need to write codes as the following
Code:
#include "cpp-hooking/hooking.h"

// Define the hooking function
int WINAPI hkMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
  lpText = L"INL Hooked";
  return INLHookingManager::instance().invoke<int>(MessageBoxW, hWnd, lpText, lpCaption, uType);
}

// Perform hooking
INLHookingManager::instance().hook(MessageBoxW, hkMessageBoxW);

// Perform un-hooking
INLHookingManager::instance().unhook(MessageBoxW);
Eg. To hook/un-hook a function with the IAT Hooking technique, you only need to write codes as the following
Code:
#include "cpp-hooking/hooking.h"

// Define the hooking entry
#define Entry_MessageBoxW { "cpp-hooking.exe"s, "user32.dll"s, "MessageBoxW"s }

// Define the hooking function
int WINAPI hkMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
  lpText = L"IAT Hooked";
  return IATHookingManager::instance().invoke<int>(Entry_MessageBoxW, hWnd, lpText, lpCaption, uType);
}

// Perform hooking
IATHookingManager::instance().hook(Entry_MessageBoxW, hkMessageBoxW);

// Perform un-hooking
IATHookingManager::instance().unhook(Entry_MessageBoxW);
The repository @ https://github.com/vic4key/cpp-hooking.git

Follow me on GitHub @ https://github.com/vic4key

Regards,
Vic P.

Last edited by vic4key; 11-07-2023 at 15:26. Reason: forum auto remove unexpected chars when submitting the post
Reply With Quote
The Following 4 Users Gave Reputation+1 to vic4key For This Useful Post:
ahmadmansoor (11-07-2023), blue_devil (11-07-2023), chants (11-12-2023), MarcElBichon (11-07-2023)
The Following 13 Users Say Thank You to vic4key For This Useful Post:
ahmadmansoor (11-07-2023), astroid (11-09-2023), besoeso (11-08-2023), blue_devil (11-07-2023), canopus (01-12-2024), chants (11-12-2023), darkBLACK (11-09-2023), Dr.FarFar (04-14-2024), NoneForce (11-07-2023), pnta (11-12-2023), WillyTerra (11-19-2023), wilson bibe (11-07-2023), zhongtiany (11-07-2023)
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Hooking - Write Less Do More vic4key Source Code 2 12-29-2023 10:06
Write Access on Win9x nikola General Discussion 2 04-27-2005 20:23
How to write a dubug like OllDbg? rivenhuang General Discussion 3 02-27-2004 15:06
For those who write tutorials. Nilrem General Discussion 4 02-03-2004 00:21


All times are GMT +8. The time now is 03:28.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2025 )