View Single Post
  #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)