{"id":18001137,"url":"https://github.com/wopss/renhook","last_synced_at":"2025-03-23T04:06:40.629Z","repository":{"id":45751967,"uuid":"94196687","full_name":"wopss/RenHook","owner":"wopss","description":"An open-source x86 / x86-64 hooking library for Windows.","archived":false,"fork":false,"pushed_at":"2024-09-20T16:27:17.000Z","size":241,"stargazers_count":90,"open_issues_count":0,"forks_count":26,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-15T04:04:57.067Z","etag":null,"topics":["cpp11","hooking","windows","x86","x86-64"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wopss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-13T09:41:12.000Z","updated_at":"2024-12-14T09:23:33.000Z","dependencies_parsed_at":"2024-10-29T23:47:50.828Z","dependency_job_id":null,"html_url":"https://github.com/wopss/RenHook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wopss%2FRenHook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wopss%2FRenHook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wopss%2FRenHook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wopss%2FRenHook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wopss","download_url":"https://codeload.github.com/wopss/RenHook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052673,"owners_count":20553172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp11","hooking","windows","x86","x86-64"],"created_at":"2024-10-29T23:16:17.328Z","updated_at":"2025-03-23T04:06:40.602Z","avatar_url":"https://github.com/wopss.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RenHook\n\n[![Build Status](https://github.com/WopsS/RenHook/actions/workflows/build.yml/badge.svg)](https://github.com/WopsS/RenHook/actions/workflows/build.yml)\n\nAn open-source **x86 / x86-64** hooking library for **Windows**.\n\n## Features\n\n* Supports x86 and x86-64 (uses [Zydis](https://github.com/zyantific/zydis) as diassembler)\n* Completely written in C++11\n* Safe and easy to use\n* Hooking methods\n  * **Inline hook** - Patches the prologue of a function to redirect its code flow, also allocates a trampoline to that can be used to execute the original function.\n\n## Quick examples\n\n### Hooking by address\n\n```cpp\n#include \u003cWindows.h\u003e\n#include \u003crenhook/renhook.hpp\u003e\n\nvoid func_detour();\n\nusing func_t = void(*)();\nrenhook::inline_hook\u003cfunc_t\u003e func_hook(0x14000000, \u0026func_detour);\n\nvoid func_detour()\n{\n    OutputDebugStringA(\"Hello from the hook!\\n\");\n    func_hook();\n}\n\nint APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)\n{\n    func_hook.attach();\n    func_hook();\n    func_hook.detach();\n\n    func_hook();\n    return 0;\n}\n```\n\n### Hooking by pattern\n\n```cpp\n#include \u003cWindows.h\u003e\n#include \u003crenhook/renhook.hpp\u003e\n\nvoid func_detour();\n\nusing func_t = void(*)();\nrenhook::inline_hook\u003cfunc_t\u003e func_hook({ 0x89, 0x79, 0xF8, 0xE8, 0xCC, 0xCC, 0xCC, 0xCC, 0x8B, 0x0D, 0xCC, 0xCC, 0xCC, 0xCC }, \u0026func_detour, 0xCC, 3);\n\nvoid func_detour()\n{\n    OutputDebugStringA(\"Hello from the hook!\\n\");\n    func_hook();\n}\n\nint APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)\n{\n    func_hook.attach();\n    func_hook();\n    func_hook.detach();\n\n    func_hook();\n    return 0;\n}\n```\n\n### Hooking a function from a module\n\n```cpp\n#include \u003cWindows.h\u003e\n#include \u003crenhook/renhook.hpp\u003e\n\nint WINAPI msgbox_detour(HWND wnd, LPCWSTR text, LPCWSTR caption, UINT type);\n\nusing MessageBoxW_t = int(WINAPI*)(HWND, LPCWSTR, LPCWSTR, UINT);\nrenhook::inline_hook\u003cMessageBoxW_t\u003e msgbox_hook(\"user32\", \"MessageBoxW\", \u0026msgbox_detour);\n\nint WINAPI msgbox_detour(HWND wnd, LPCWSTR text, LPCWSTR caption, UINT type)\n{\n    return msgbox_hook(wnd, L\"Hello from the hook!\", L\"RenHook\", MB_OK | MB_ICONINFORMATION);\n}\n\nint APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)\n{\n    msgbox_hook.attach();\n    MessageBoxW(nullptr, L\"Hello\", L\"Message\", MB_OK);\n    msgbox_hook.detach();\n\n    MessageBoxW(nullptr, L\"Hello\", L\"Message\", MB_OK);\n    return 0;\n}\n```\n\n## Build instructions\n\n### Requirements\n\n* **[CMake 3.8+](https://cmake.org/)**.\n\n### Windows\n\n1. Download and install **[Visual Studio 2019 Community Edition](https://www.visualstudio.com/)** or a higher version.\n2. Download and install the **[Requirements](#requirements)**.\n3. Clone this repository.\n4. Clone the dependencies (`git submodule update --init --recursive`).\n5. Create a directory named `build` and run **[CMake](https://cmake.org/)** in it.\n6. Open the solution (**RenHook.sln**) located in **build** directory.\n7. Build the projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwopss%2Frenhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwopss%2Frenhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwopss%2Frenhook/lists"}