A plugin for IDA Pro 9.1 that automatically generates ready-to-use C/C++ code for interacting with analyzed functions. It supports both direct function calling wrappers and detouring/hooking stubs with multiple hooking frameworks: Windows Detours, MinHook, and ByteWeaver.
Making it easier to integrate reverse-engineered code into real projects.
- 🔌 Native IDA Pro 9.1 plugin integration
- 🧩 Generates C/C++ callable wrappers for identified functions
- 🪝 Generates hook/detour templates with multiple framework support:
- Windows Detours - Microsoft's detour framework
- MinHook - Minimal x86/x64 API Hooking Library
- ByteWeaver - Macro-based memory hooking framework
- ⚙️ Auto-save settings that persist across IDA restarts
- 📄 Converts IDA-analyzed functions into reusable project code
- 🧠 Works directly from disassembled function context
- 💡 Speeds up binary integration and runtime patching workflows
- 🔍 Intelligent parameter naming (a1, a2, a3, etc. for unnamed parameters)
- ✨ Support for
__thiscall,__cdecl,__stdcall,__fastcallcalling conventions
When analyzing a binary in IDA, this plugin can:
It produces clean code that allows you to call reverse-engineered functions directly from your own project:
DWORD __cdecl MyFunction(int a1, const char* a2)
{
return ((decltype(&MyFunction))(0x401000))(a1, a2);
}It can generate hook templates for multiple frameworks:
typedef DWORD (__cdecl* OriginalMyFunctionFn_t)(int a1, const char* a2);
OriginalMyFunctionFn_t OriginalMyFunction = NULL;
DWORD __cdecl MyFunctionHk(int a1, const char* a2)
{
// custom logic here
return OriginalMyFunction(a1, a2);
}
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach((PVOID*)&OriginalMyFunction, (PVOID)MyFunctionHk);
DetourTransactionCommit();typedef DWORD (__cdecl* OriginalMyFunctionFn_t)(int a1, const char* a2);
OriginalMyFunctionFn_t OriginalMyFunction = nullptr;
DWORD __cdecl MyFunctionHk(int a1, const char* a2)
{
// custom logic here
return OriginalMyFunction(a1, a2);
}
MH_Initialize();
MH_CreateHook((LPVOID)0x401000, (LPVOID)MyFunctionHk, (LPVOID*)&OriginalMyFunction);
MH_EnableHook((LPVOID)0x401000);DECLARE_HOOK_SIMPLE(MyFunction, DWORD, __cdecl, int a1, const char* a2);
DWORD __cdecl MyFunctionHook(int a1, const char* a2)
{
// custom logic here
return MyFunctionOriginal(a1, a2);
}
INSTALL_HOOK_ADDRESS(MyFunction, 0x401000);- IDA Pro 9.1
- IDAPython enabled
- C/C++ compiler (for integrating generated output)
- Optional: Hooking library based on your choice:
- Windows Detours - Microsoft Detours library
- MinHook - Minimal API Hooking Library
- ByteWeaver - Custom memory hooking framework by @0xKate
- Open your IDA installation directory:
<IDA_INSTALLATION>/plugins/
- Copy:
ida_Code_generator.py
-
Restart IDA Pro
-
The plugin will appear under:
Edit → Plugins → Code Generator
-
Load a binary in IDA Pro
-
Wait for auto-analysis to complete
-
Position cursor in a function
-
Choose your hook framework:
- Windows Detours - For Microsoft Detours library
- MinHook - For Minimal API Hooking
- ByteWeaver - For macro-based hooking
- Configure settings as needed (auto-saves!)
- Click "Generate Detours Hook" or "Generate Calling Function"
- Copy generated code into your project
The plugin includes comprehensive settings that auto-save and persist across IDA restarts:
- Hook Framework - Select between Windows Detours, MinHook, or ByteWeaver
- Include Comments in Generated Code - Add/remove TODO comments
- Include Typedef Declarations - Include function pointer typedefs
- Include Original Signature Comment - Show original IDA signature
- Include Framework Setup Code - Include initialization/hook attachment code
- Auto-Copy Generated Code to Clipboard - Automatically copy to clipboard on generation
The plugin leverages IDAPython APIs to:
- Identify selected or discovered functions
- Extract function signatures (where possible)
- Detect calling conventions and parameters
- Read addresses and type information
- Generate structured C/C++ code templates
- Support multiple hooking frameworks
- Auto-persist settings to IDA database
It bridges the gap between:
🔍 Reverse engineering (IDA analysis) and 🧱 Real-world code integration
ida_code_gen_with_settings.py # Main IDA Pro 9.1 plugin with multi-framework support
README.md # This file
- Reverse engineering software for research or auditing
- Game hacking / modding workflows (where permitted)
- Malware analysis and behavioral redirection
- Binary API reconstruction
- Rapid prototyping of function interfaces
- Runtime hooking and detouring
- Integration of reverse-engineered code into custom tools
| Feature | Windows Detours | MinHook | ByteWeaver |
|---|---|---|---|
| Setup Complexity | Medium | Low | Low |
| Macro-Based | No | No | Yes |
| Microsoft | Yes | No | No |
| Typedef Support | Yes | Yes | Yes |
| x86/x64 | Yes | Yes | Yes |
| Type Safety | High | High | High |
This tool is intended strictly for educational, research, and authorized security testing purposes only.
Do not use this plugin on software you do not own or have explicit permission to analyze.
The author is not responsible for misuse.
Pull requests are welcome.
Ideas for improvement:
- Better type inference from IDA signatures
- Improved calling convention detection
- Additional hooking framework support
- Export formats (JSON, etc.)
- Batch code generation
The MIT License (MIT)
Copyright (c) 2025 Tech Mecca
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This plugin is designed for IDA Pro 9.1, but may be adaptable to other versions with minor API adjustments.
- v2.1.0 - Added auto-save settings, MinHook support, ByteWeaver support
- v2.0.0 - Initial release with Windows Detours support