{"id":13418320,"url":"https://github.com/stevemk14ebr/PolyHook","last_synced_at":"2025-03-15T03:31:08.599Z","repository":{"id":35869600,"uuid":"40154748","full_name":"stevemk14ebr/PolyHook","owner":"stevemk14ebr","description":"x86/x64 C++ Hooking Library","archived":true,"fork":false,"pushed_at":"2020-06-25T13:45:45.000Z","size":25327,"stargazers_count":877,"open_issues_count":6,"forks_count":171,"subscribers_count":60,"default_branch":"master","last_synced_at":"2024-07-31T22:42:24.125Z","etag":null,"topics":[],"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/stevemk14ebr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["stevemk14ebr"]}},"created_at":"2015-08-04T00:34:34.000Z","updated_at":"2024-07-15T23:00:08.000Z","dependencies_parsed_at":"2022-08-17T22:55:45.196Z","dependency_job_id":null,"html_url":"https://github.com/stevemk14ebr/PolyHook","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/stevemk14ebr%2FPolyHook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemk14ebr%2FPolyHook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemk14ebr%2FPolyHook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemk14ebr%2FPolyHook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevemk14ebr","download_url":"https://codeload.github.com/stevemk14ebr/PolyHook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681024,"owners_count":20330152,"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":[],"created_at":"2024-07-30T22:01:01.012Z","updated_at":"2025-03-15T03:31:03.588Z","avatar_url":"https://github.com/stevemk14ebr.png","language":"C++","funding_links":["https://github.com/sponsors/stevemk14ebr"],"categories":["TODO scan for Android support in followings","Miscellaneous","C++"],"sub_categories":[],"readme":"# PolyHook - x86/x64 Hooking Library\n**Provides abstract C++ 11 interface  for various hooking methods**\n\nTechnical Writeup: https://www.codeproject.com/articles/1100579/polyhook-the-cplusplus-x-x-hooking-library\n\n# OUTDATED\nPlease use V2: https://github.com/stevemk14ebr/PolyHook_2_0. Consider sponsoring my development by clicking sponsor up in the top right!\n\n# Hooking Methods*:\n\n1. **_Detour_**\n  * Description: Modifies opcode to jmp to hook and allocates a trampoline for jmp back\n  * Length Disassembler Support (Capstone)\n  * Supports Code Relocation, including EIP/RIP relative instructions\n\n2. **_Virtual Function Detour_** : \n  * Description: Detours the function pointed to by the Vtable\n\n3. **_Virtual Function Pointer Swap_** \n  * Description: Swaps the pointer in the Vtable to your hook\n  \n4. **_Virtual Table Pointer Swap_**\n  * Description: Swaps the Vtable pointer after copying pointers in source Vtable, \n  then swaps virtual function pointer in the new copy\n\n5. **Import Address Table**\n  * Description: Swaps pointer in the import address table to the hook\n\n6. **VEH**\n  * Description: Intercepts an exception generated on purpose, sets instruction pointer to handler, then resets exception generating mechanism\n  * Methods to generate exception: INT3 Breakpoints, Guard Page violations.\n  * **Note**: it is important to call the GetProtectionObject function INSIDE of your callback as per my example for all VEH hooks\n  * Other exception generation methods are in development\n\n* All methods support x86 and x64\n* Relies on modified capstone branch https://github.com/stevemk14ebr/capstone\n* More Information can be found at the wiki to the right\n\nCredits to DarthTon, evolution536, Dogmatt\n\n# Samples:\nThe file Tests.cpp provides examples for every type of hooking method. Accompanied with these examples is unit testing code provided by the fantastic library Catch (https://github.com/philsquared/Catch/blob/master/docs/tutorial.md). With the addition of this code the example may look a little complex, the general interface is extremely simple, all hook types expose setup, hook, and unhook methods:\n\n```C++\nstd::shared_ptr\u003cPLH::Detour\u003e Detour_Ex(new PLH::Detour);\nDetour_Ex-\u003eSetupHook((BYTE*)\u0026MessageBoxA,(BYTE*) \u0026hkMessageBoxA); //can cast to byte* to\nDetour_Ex-\u003eHook();\noMessageBoxA = Detour_Ex-\u003eGetOriginal\u003ctMessageBoxA\u003e();\nDetour_Ex-\u003eUnHook();\n```\n\n# LICENSE:\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemk14ebr%2FPolyHook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevemk14ebr%2FPolyHook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemk14ebr%2FPolyHook/lists"}