Skip to content

fengjixuchui/RenHook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RenHook

Build status

An open-source x64 hooking library for Windows.

Build instructions

Requirements

Windows

  1. Download and install Visual Studio 2017 Community Edition or a higher version.
  2. Clone this repository.
  3. Extract the content of PREMAKE 5 into Premake directory.
  4. Go to the Premake directory and run GenerateVisualStudioProjects.bat.
  5. Open the solution (RenHook.sln) located in Premake/Projects directory.
  6. Build the projects.

Examples

Basic usage

#include <RenHook/RenHook.hpp>

int IsDebuggerPresentFunction()
{
    return 0;
}

int main()
{
    RenHook::Hook::Create(L"kernel32", L"IsDebuggerPresent", &IsDebuggerPresentFunction);
    std::cout << IsDebuggerPresent() << std::endl;

    return 0;
}

Trampolines

#include <RenHook/RenHook.hpp>

MessageBoxWFunction(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
    auto Hook = RenHook::Hook::Get(L"user32", L"MessageBoxW");

    using MessageBoxW_t = int(*)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
    return Hook->Call<MessageBoxW_t>(hWnd, L"Hello from the hook!", L"Hooked MessageBoxW", MB_OK);
}

int main()
{
    RenHook::Hook::Create(L"user32", L"MessageBoxW", &MessageBoxWFunction);
    MessageBoxW(nullptr, L"Hello", L"MessageBoxW", MB_OK);

    return 0;
}

Trampolines (with std::shared_ptr)

#include <RenHook/RenHook.hpp>

std::shared_ptr<RenHook::Hook> MessageBoxWHook;

int MessageBoxWFunction(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
    using MessageBoxW_t = int(WINAPI*)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
    return MessageBoxWHook->Call<int, MessageBoxW_t>(hWnd, L"Hello from the hook!", L"Hooked MessageBoxW", MB_OK);
}

int main()
{
    MessageBoxWHook = RenHook::Hook::Create(L"user32", L"MessageBoxW", &MessageBoxWFunction);
    MessageBoxW(nullptr, L"Hello", L"MessageBoxW", MB_OK);

    return 0;
}

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.5%
  • Lua 3.4%
  • Batchfile 0.1%