Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C++ Hooking - Write Less Do More

Featured Replies

Posted

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

#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

#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.

Edited by Vic
CrLf

Very practical source codes... :)

  • 9 months later...
On 11/7/2023 at 7:15 AM, Vic said:

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

#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

#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.

Does it possible to restore the api hooked with detour?

 

Thanks 

Edited by TRISTAN Pro

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.