All Projects → apriorit → mhook

apriorit / mhook

Licence: MIT license
A Windows API hooking library

Projects that are alternatives of or similar to mhook

hookwin10calc
Reverse engineered Windows 10 Calculator.exe (UWP application) hacker. 한글/漢文을 배운 윈도우 계산기 패치.
Stars: ✭ 19 (-88.62%)
Mutual labels:  hooking, api-hook
Advanced Video
Stars: ✭ 240 (+43.71%)
Mutual labels:  hooking
Gamemaniptutorial
A tutorial for manipulating the rendering of a game (generally to increase its quality) if you only have a binary available
Stars: ✭ 119 (-28.74%)
Mutual labels:  hooking
Frida Ios Hook
A script that helps you trace classes, functions, and modify the return values of methods on iOS platform
Stars: ✭ 151 (-9.58%)
Mutual labels:  hooking
Khook
Linux Kernel hooking engine (x86)
Stars: ✭ 144 (-13.77%)
Mutual labels:  hooking
Iat patcher
Persistent IAT hooking application - based on bearparser
Stars: ✭ 170 (+1.8%)
Mutual labels:  hooking
Amongus Mumble
Mumble VoIP Plugin and mod for the popular game "Among Us" to enable Proximity Voice Chat.
Stars: ✭ 105 (-37.13%)
Mutual labels:  hooking
Open.WinKeyboardHook
A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.
Stars: ✭ 20 (-88.02%)
Mutual labels:  hooking
Anticuckoo
A tool to detect and crash Cuckoo Sandbox
Stars: ✭ 233 (+39.52%)
Mutual labels:  hooking
Distormx
The ultimate hooking library
Stars: ✭ 146 (-12.57%)
Mutual labels:  hooking
Awesome Frida
Awesome Frida - A curated list of Frida resources http://www.frida.re/ (https://github.com/frida/frida)
Stars: ✭ 2,025 (+1112.57%)
Mutual labels:  hooking
Cfb
Canadian Furious Beaver is a tool for hijacking IRPs handler in Windows drivers, and facilitating the process of analyzing Windows drivers for vulnerabilities
Stars: ✭ 146 (-12.57%)
Mutual labels:  hooking
Pine
Dynamic java method hook framework on ART.
Stars: ✭ 171 (+2.4%)
Mutual labels:  hooking
Orbit
C/C++ Performance Profiler
Stars: ✭ 2,291 (+1271.86%)
Mutual labels:  hooking
Funchook
Hook function calls by inserting jump instructions at runtime
Stars: ✭ 253 (+51.5%)
Mutual labels:  hooking
Pe Sieve
Scans a given process. Recognizes and dumps a variety of potentially malicious implants (replaced/injected PEs, shellcodes, hooks, in-memory patches).
Stars: ✭ 1,783 (+967.66%)
Mutual labels:  hooking
Dbgchild
Debug Child Process Tool (auto attach)
Stars: ✭ 145 (-13.17%)
Mutual labels:  hooking
Pwn Mbr
A simple MBR hijack demonstration
Stars: ✭ 153 (-8.38%)
Mutual labels:  hooking
FindTheStupidWindow
Windows API hooking project to log all the windows / UIs with the exact timestamp when they are opened.
Stars: ✭ 13 (-92.22%)
Mutual labels:  hooking
DbgChild
Debug Child Process Tool (auto attach)
Stars: ✭ 221 (+32.34%)
Mutual labels:  hooking

Mhook - a Windows API hooking library Build status

Introduction

This library was created as a free alternative to Microsoft Detours. It is originally developed by Marton Anka and currently is supported and developed by Apriorit.

How to use

// Include a header
#include <mhook-lib/mhook.h>

// Save the original function
typedef ULONG (WINAPI* _NtClose)(IN HANDLE Handle);
_NtClose TrueNtClose = (_NtClose)GetProcAddress(GetModuleHandle(L"ntdll"), "NtClose");

// Declare your function that will be handle a hook:
ULONG WINAPI HookNtClose(HANDLE hHandle) 
{
    printf("***** Call to NtClose(0x%p)\n", hHandle);
    return TrueNtClose(hHandle);
}

//...

// Set the hook 
BOOL isHookSet = Mhook_SetHook((PVOID*)&TrueNtClose, HookNtClose);

//...

// After finishing using the hook – remove it
Mhook_Unhook((PVOID*)&TrueNtClose);

You can also set a bunch of hooks in one call:

HOOK_INFO hooks[] =
{
    { (PVOID*)&TrueNtOpenProcess, HookNtOpenProcess },
    { (PVOID*)&TrueSelectObject, HookSelectobject },
    { (PVOID*)&Truegetaddrinfo, Hookgetaddrinfo },
    { (PVOID*)&TrueHeapAlloc, HookHeapAlloc },
    { (PVOID*)&TrueNtClose, HookNtClose }
};

int numberOfSetHooks = Mhook_SetHookEx(hooks, 5);
    
//...

// Removing hooks
int numberOfRemovedHooks = Mhook_UnhookEx(hooks, 5);

That way of setting multiple hooks is also much better in performance.

License

Mhook is freely distributed under an MIT license.

Version history

Version 2.5.1 (30 March 2018)

  • Fix #1: VirtualAlloc hooking reports anomaly
  • New #2: Add integration to vcpkg package
  • New #3: Add AppVeyor CI
  • Fix #4: Add ability to hook functions with call in first 5 bytes

Version 2.5 (20 Oct 2017)

  • 10x performance boost
  • CMake build system
  • Change tabs to spaces
  • Ability to hook functions with je/jne in the first 5 bytes
  • Fix hook recursion
  • Other fixes

Version 2.4 (05 Mar 2014, the last from the original author)

  • A number of improvements: hot patch location (mov edi, edi) handling, support for REX-prefixed EIP-relative jumps on x64, removal of compile-time limit on the number of hooks

Version 2.3 (15 Jan 2012)

  • A bugfix that allows hooking more API functions

Version 2.2 (27 Jun 2008)

  • Support for instructions using IP-relative addressing

Version 2.1 (15 Oct 2007)

  • Fixes

Version 2.0 (08 Jul 2007)

  • Built-in disassembler

Version 1.0 (24 Jun 2007)

  • Original release

Acknowledgements

Mhook contains a disassembler that is a stripped-down version of the excellent tDisasm package by Matt Conover. Thank you Matt! tDisasm comes with a BSD-style license and re-releasig a derivative of it under the MIT license has been confirmed to be OK by its author.

Alexandr Filenkov submitted bugfixes in Sept-2007. Michael Syrovatsky submitted fixes for IP-relative addressing in Jun-2008. Andrey Kubyshev submitted a bugfix in Jul-2011 and Jan-2013. John McDonald enabled unlimited hooks. Kasper Brandt provided a fix for hot patch function prologues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].