Generate And Build a Windows DLL Proxy For Any DLL
Project description
dllproxy
A tool for generating Windows DLL proxies with automatic export forwarding.
Now available as a PyPI package!
Overview
The DLL Proxy Generator creates fully functional Visual Studio C++ projects that can intercept calls to any Windows DLL. This enables various scenarios including:
- Function call interception and monitoring
- API hooking and modification
- DLL replacement without changing application code
- Debugging and reverse engineering
How It Works
DLL proxying works by creating a DLL with the same name and exports as the original, but which forwards calls to the actual implementation DLL (renamed or relocated). The proxy sits between the application and the real DLL, allowing you to:
- Intercept function calls
- Modify parameters or return values
- Log API usage
- Forward calls to the original implementation
Requirements
- Windows operating system
- Python 3.7+
- Visual Studio (for building the generated projects)
Installation
Install directly from PyPI:
pip install dllproxy
Alternatively, clone the source:
# Clone the repository
git clone https://github.com/gilgoolon/dllproxy.git
cd dllproxy
# Install the package
pip install -e .
Usage
CLI Usage
Once installed, you can use the dllproxy-generate command-line tool:
dllproxy-generate -s <source_dll> -d <worker_dll> -o <output_directory>
Where:
<source_dll>is the path to the DLL you want to proxy<worker_dll>is the path where the original DLL will be relocated<output_directory>is where the proxy project will be generated
If you don't need the source or simply want to build, use:
dllproxy-generate -s <source_dll> -d <worker_dll> -b
Example
# Generate a proxy for kernel32.dll
dll-proxy-generator -s C:\Windows\System32\kernel32.dll -d C:\Windows\System32\malicious_dll.dll -o .\KernelProxy
Command Line Options
| Option | Description |
|---|---|
-s, --source-dll |
Path to the DLL to proxy (required) |
-d, --worker-dll |
Path to the actual implementation DLL (required) |
-o, --output |
Output directory for the generated project |
-b, --build |
Build the project after generation |
-p, --platform |
Target platform (x86 or x64, default: x64) |
Proxy Features
Forever Retries
The DLL keeps a worker thread alive forever - trying to start the destination DLL.
Mutex Synchornization
A system-wide mutex (with a constant GUID) is used to make sure the destination dll only has One instance loaded at a time.
Library Name
Source.def decalres the name of the source DLL name.
Protections
Protections are used to catch exceptions from the worker dll to make the proxy safe.
Customizing the Proxy
You can modify the generated proxy to add custom logic:
- Open the generated project in Visual Studio
- Edit the function implementations in the source files
- Add your custom code before/after forwarding calls to the original DLL
Advanced Usage
Logging Function Calls
The template includes hooks for adding logging to all function calls:
// Example of adding logging to a proxied function
BOOL WINAPI CreateProcessW_Proxy(/* parameters */) {
// Log the call
LogFunctionCall("CreateProcessW", /* parameters */);
// Forward to original implementation
return Original_CreateProcessW(/* parameters */);
}
Deployment
To deploy your proxy:
- Build the proxy DLL
- Rename the original DLL to match your worker DLL path if needed
- Place your proxy DLL in the original location
- The application will now load your proxy instead
Troubleshooting
- Missing exports: Ensure the proxy exports all functions from the original DLL
- DLL loading issues: Check that the worker DLL path is correct and accessible
- Build errors: Verify Visual Studio and required components are installed
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgements
- pefile for PE file parsing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dllproxy-1.0.0.tar.gz.
File metadata
- Download URL: dllproxy-1.0.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46470d75a386e53c322c53c278577d928bb9753025c0469353d88318dc0304bb
|
|
| MD5 |
1e40c30efa8fe3480a631a67584bf816
|
|
| BLAKE2b-256 |
6fec524ca8a0d4154a5fb6c855de58451580868f922b34fd81f196d2ae3accba
|
File details
Details for the file dllproxy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dllproxy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9e951165e410f8e9ba850641eff5c9196ebe1ec6671e77ce00e4f0c5ecfe9ec
|
|
| MD5 |
163f8af16e2e2e33e8046eee6e961c94
|
|
| BLAKE2b-256 |
e02617bec39cc6d6110ce22179ca1283d720b44b045ff5671e95a71cbe0ed9aa
|