#1
|
||||
|
||||
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); 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); 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 |
The Following 4 Users Gave Reputation+1 to vic4key For This Useful Post: | ||
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) |
#2
|
|||
|
|||
Hello, is it possible for someone publish the compiled version of this tool? Thanks in advance
|
#3
|
||||
|
||||
Hello vic4key, you have an awesome repo. Once, I have created a thread for sharing our socials (not only twitter&instagram but github&gitlab or other similar accounts)
Socials If you want you can share your socials on this thread. Regards |
The Following User Says Thank You to blue_devil For This Useful Post: | ||
vic4key (11-07-2023) |
#4
|
||||
|
||||
But @wilson, this repo is only contains header files. You create a project and add this header files to you solution; and then start hooking-unhooking! You do not need a compiled version of it! Am I right @vic4key?
|
The Following User Says Thank You to blue_devil For This Useful Post: | ||
vic4key (11-07-2023) |
#5
|
||||
|
||||
Quote:
And install Vutils library is very easy and quick, just checkout/download and double-click to run 2 batch file .cmd inside `Vutils\tools` folder to complete. Refer to https://github.com/vic4key/Vutils#installation |
The Following User Says Thank You to vic4key For This Useful Post: | ||
ahmadmansoor (11-08-2023) |
#6
|
|||
|
|||
batch files have got some hardcoded pathes
in my case VS is installed into other path, is it possible to deduce it from the env the real install pathes? SET VU_VSDEV=%ProgramFiles(x86)%\Microsoft Visual Studio\%VU_VSVER%\%%L\Common7\Tools\VsDevCmd.bat |
The Following User Says Thank You to sendersu For This Useful Post: | ||
vic4key (11-07-2023) |
#7
|
||||
|
||||
Can you gimme the path in your case?
Thanks for feedback. I will check and update the script to make it more common. |
#9
|
|||
|
|||
Yes and VS2022 is no longer x86 with an x64 IDE. One reason I like CMake is not just it's portability but that it has all the strategies to detect all different compilers even on Windows to build with. Providing a CMakeLists.txt in projects is very convenient to make it easy for anyone to configure and build.
|
#10
|
||||
|
||||
Quote:
I targeted only using for Win32/x64/MinGW. So, I wrote a batch file to build all at once (x86, x64, MT/MTd, MD/MDd). And then, just one-click to finish. I believe it much easier and simpler than CMake. BTW, I will update the batch file to fix the bug when I get free time. |
#11
|
|||
|
|||
Yes if you are targetting a specific set of architectures and compilers would not argue it is more efficient to use simpler build methods.
But if you want to write something with library quality usefulness then being independent of these things is important. Different configurations should require different builds if being totally generic. You are likely locked into the Microsoft ecosystem. But at this day and age that is rather niche. Professional programmers can go cross architecture and cross platform and cross compiler quite readily. Getting off topic though, for this project which is very Windows specific, of course CMake is overkill. But there are still several of C compilers on Windows, MSVC isn't the only possibility. The main point is these batch file type issues are completely solved by modern build tools. Whereas making a project that can be shared and built without any issues isn't so easy with custom build processes. |
#12
|
|||
|
|||
so how to instruct cmake to use clang/gcc and not msvc?
in this specific case |
#13
|
|||
|
|||
I mean I suppose using Ninja is best in this case and something along the lines of:
Quote:
|
The Following User Says Thank You to chants For This Useful Post: | ||
sendersu (11-15-2023) |
#14
|
||||
|
||||
Quote:
Quote:
|
#15
|
|||
|
|||
maybe minhook is more useful for unknow functions?
|
Thread Tools | |
Display Modes | |
|
|