{"id":17317852,"url":"https://github.com/mavenlin/wrap_dll","last_synced_at":"2025-10-16T04:51:24.355Z","repository":{"id":147856526,"uuid":"5323532","full_name":"mavenlin/wrap_dll","owner":"mavenlin","description":"Automatic generate dll wrapper for code injection.","archived":false,"fork":false,"pushed_at":"2021-02-14T10:45:15.000Z","size":641,"stargazers_count":168,"open_issues_count":2,"forks_count":55,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-27T21:39:30.972Z","etag":null,"topics":["api-hooking","code-injection","detour-hook","dll","dll-wrapper","hook","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"Python","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/mavenlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2012-08-07T04:47:46.000Z","updated_at":"2025-05-30T18:34:52.000Z","dependencies_parsed_at":"2023-05-01T03:03:43.782Z","dependency_job_id":null,"html_url":"https://github.com/mavenlin/wrap_dll","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mavenlin/wrap_dll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavenlin%2Fwrap_dll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavenlin%2Fwrap_dll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavenlin%2Fwrap_dll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavenlin%2Fwrap_dll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mavenlin","download_url":"https://codeload.github.com/mavenlin/wrap_dll/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavenlin%2Fwrap_dll/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279156824,"owners_count":26115908,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-hooking","code-injection","detour-hook","dll","dll-wrapper","hook","wrapper-api"],"created_at":"2024-10-15T13:18:01.576Z","updated_at":"2025-10-16T04:51:24.313Z","avatar_url":"https://github.com/mavenlin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wrap DLL\n\nA tool to automatically generate cpp/asm codes for wrapping a dynamic-link library.\n\n## Features\n\n- All the wrapper functions perform a `jmp` instruction that jumps to the real function.\n- A CMake project is generated under the directory with the same name as the DLL.\n- If the signature of any of the functions is known, the user can replace the default implementation with a custom function that performs API hooking / code injection.\n- Both `x64` or `Win32` DLLs are supported.\n- The original real DLL is prefixed with `real_` and copied to the project directory.\n- C++ functions are demangled, a C function name is created in the generated project but it is exported as the original mangled symbol.\n- `__stdcall`, `__fastcall` symbols are undecorated, but exported as the original symbol. The user is responsible to ensure the overriding function has the same calling convention.\n\n## Install\n\nNo installation is necessary, but you need `python\u003e=3.7` to run it, and want to install the dependencies through\n\n```shell\npip install -r requirements.txt\n```\n\ncurrently there's only `jinja2` for rendering the code templates.\n\nMake sure you installed Visual Studio, the script by default assumes the `dumpbin.exe` and `undname.exe` tools are available in the `PATH`. Mine is located at `C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.27.29110\\bin\\Hostx64\\x64\\`, so add it to your path. Otherwise pass the `--dumpbin` and `--undname` arguments.\n\n\n## Example\n\n### x64 DLL\n```shell\npython3 wrap_dll.py C:\\Windows\\System32\\AudioSes.dll\ncd AudioSes\ncmake -f CMakeLists.txt\n```\n\n### x86 DLL\n```shell\npython3 wrap_dll.py C:\\Windows\\SysWOW64\\AudioSes.dll\ncd AudioSes\ncmake -f CMakeLists.txt\n```\n### Override some of the exported functions\nTo override some of the functions, provide a `hook.h` file.\n\nSay if we wrap `abc_dll.dll` with the function `int abc(const char* a, int b, float c)`, override it in the `hook.h` with\n\n```C++\n/*\n * content of file: hook.h\n */\n#include \"hook_macro.h\"\n/*\n * define a variable that is uppercase of the function name that you want to override.\n * which notifies the generated code that a override of the function is provided.\n */\n#define ABC\n/*\n * Arguments of the FAKE macro is (return_type, call_convention, function_name, arg_type1 arg1, arg_type2 arg2, ...).\n */\nFAKE(int, __cdecl, abc, const char* a, int b, float c) { // currently, the parsing code only support __cdecl functions.\n  b = 0; // custom code before calling the real function.\n  int ret = abc_real(a, b, c); // call the real function, FAKE macro prepares abc_real for you, which can be called directly.\n  ret += 1; // custom code after calling the real function.\n  return ret;\n}\n```\n\nNow generate the wrapper with\n\n```shell\npython3 wrap_dll.py --hook hook.h abc_dll.dll\ncd abc_dll\ncmake -f CMakeLists.txt\n```\n\n## PS\n\nThis tool seems to be useful for some people, as I saw a few forks recently.\nTherefore I performed a major refactor to make the code more professional.\n\nChanges:\n- Remove the `dumpbin.exe` included, the user can specify their own `dumpbin.exe` that comes with their visual studio installation. e.g. Mine is located at `C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.27.29110\\bin\\Hostx64\\x64\\dumpbin.exe`. The script by default assumes `dumpbin.exe` is available in the user's `PATH`.\n- Use `cmake` to generate visual studio solution file.\n- Use `jinja2` to separate the `c++/asm` code into independent template files.\n- Support `--dry` flag to perform dry run, which only prints all the files to be generated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavenlin%2Fwrap_dll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmavenlin%2Fwrap_dll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavenlin%2Fwrap_dll/lists"}