Skip to main content

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:

  1. Intercept function calls
  2. Modify parameters or return values
  3. Log API usage
  4. 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:

  1. Open the generated project in Visual Studio
  2. Edit the function implementations in the source files
  3. 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:

  1. Build the proxy DLL
  2. Rename the original DLL to match your worker DLL path if needed
  3. Place your proxy DLL in the original location
  4. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dllproxy-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dllproxy-1.0.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

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

Hashes for dllproxy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 46470d75a386e53c322c53c278577d928bb9753025c0469353d88318dc0304bb
MD5 1e40c30efa8fe3480a631a67584bf816
BLAKE2b-256 6fec524ca8a0d4154a5fb6c855de58451580868f922b34fd81f196d2ae3accba

See more details on using hashes here.

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

Hashes for dllproxy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e951165e410f8e9ba850641eff5c9196ebe1ec6671e77ce00e4f0c5ecfe9ec
MD5 163f8af16e2e2e33e8046eee6e961c94
BLAKE2b-256 e02617bec39cc6d6110ce22179ca1283d720b44b045ff5671e95a71cbe0ed9aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page