Skip to main content

PyDll-Injector

Python DLL injector for Windows. Supports various injection methods.

Features

PyDll-Injector comes with the following features:

  • DLL Injection on app start: Injects DLL(s) into a process when it starts;
  • Env variables support: Enables you to pass environmental variables to the injected DLL;
  • Multiple injection methods: Supports various injection methods;
  • Check if process is running: Checks if a process is running after injection;
  • Graceful process termination: Allows you to terminate the spawned process;
  • Ready to use CLI: Comes with a command line interface for easy usage.

Injection methods

The following injection methods are supported:

  • standard: Classic CreateRemoteThread + LoadLibraryA;
  • apc: QueueUserAPC + LoadLibraryA. Target thread must enter an alertable state;
  • nt: NtCreateThreadEx + LoadLibraryA (stealthier than CreateRemoteThread);
  • hook: SetWindowsHookExA(WH_CBT) injection. DLL must export HookProc.

Usage

You can use PyDll-Injector via the command line interface or as a library in your Python code.

CLI

Install the package on your system:

pip install pydll-injector[cli]

You can now use PyDll-Injector from the command line like this:

pydll-injector --executable-file "A:\Path\To\App.exe" --dll-list "B:\Path\To\Your.dll"

For the list of all available CLI options, run:

pydll-injector --help

This injector also allows you to pass configuration via a toml file. Here is a sample configuration file:

[launcher]
executable_file = "A:\\Path\\To\\App.exe"
cmd_line_args = "-arg1 -arg2"
dll_list = [
    "B:\\Path\\To\\Your.dll",
]
injection_method = "nt"

[environment]
vars = ["FOO=bar", "BAZ=qux"]
use_system_env = true
environment_append = false

Library

First, install the package. For example, using uv:

uv add pydll-injector

You can now import the library and use it in your Python code:

from pydll_injector.process import spawn_process, is_process_running
from pydll_injector.models import Launcher, Environment

def main() -> None:
    launcher = Launcher(
        executable_file= r"A:\Path\To\App.exe",
        cmd_line_args="",
        dll_list=[r"B:\\Path\\To\\Your.dll"],
        injection_method='apc',
    )
    env = Environment(
        vars=["FOO=bar"],
        use_system_env=True,
        environment_append=False
    )

    ctx = spawn_process(launcher, env)
    while is_process_running(ctx):
        pass

    print("Process has exited.")

if __name__ == "__main__":
    main()

License

The project is distributed under the MIT License. See the LICENSE file for details.

Metadata

Release files for pydll_injector 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydll_injector 0.1.2
File Size Uploaded
pydll_injector-0.1.2.tar.gz 22.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydll_injector 0.1.2
File Interpreter ABI Platform
pydll_injector-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / pydll_injector-0.1.2.tar.gz

Download URL pydll_injector-0.1.2.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8d128144837827ba48ef831289656268f093af68a1bdb036665d5ed4fd20c71e
BLAKE2b-256 checksum
How to use checksums
c35f43f5e262c21fbc31711991cb7790804e9c8f5dcd63603f9154edf3b95e26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.3

Release files / pydll_injector-0.1.2-py3-none-any.whl

Download URL pydll_injector-0.1.2-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2187a224059d6931549f7c212b1a4c13ee5218e9f84d2da8892756f022db27e2
BLAKE2b-256 checksum
How to use checksums
7c4649f742f04272c6479249ad810baeaab96010e9a74b9c2c3a8a67600c2119
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page