Metadata-Version: 2.4
Name: trainerbase-injector
Version: 1.0.2
Summary: A tool/library allowing dynamic library injection into running processes (fork)
Keywords: injection,dll,so,library
Author-Email: v01d <v01d@v01d.ru>
License-Expression: MIT
License-File: injector/LICENSE_GPL.txt
License-File: injector/LICENSE_LGPL.txt
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Repository, https://gitlab.com/python-trainers/trainerbase-injector
Project-URL: Upstream, https://github.com/kmaork/pyinjector
Requires-Python: >=3.15
Description-Content-Type: text/markdown

# Trainerbase Injector (forked Pyinjector)

Forked from [kmaork's Pyinjector](https://github.com/kmaork/pyinjector) to support modern Python versions.
The current release requires Python 3.13 or newer.

[![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/trainerbase-injector.svg)](https://pypi.python.org/pypi/trainerbase-injector/)
[![PyPI version](https://badge.fury.io/py/trainerbase-injector.svg)](https://badge.fury.io/py/trainerbase-injector)
[![Downloads](https://pepy.tech/badge/trainerbase-injector)](https://pepy.tech/project/trainerbase-injector)

A cross-platform tool/library allowing dynamic library injection into running processes.
If you are looking for a way to inject _python_ code into a running process, try the [hypno](https://github.com/kmaork/hypno) library.

Trainerbase Injector has no external python dependencies.
It is implemented as a python wrapper for [kubo/injector](https://github.com/kubo/injector).

## Installation

```shell script
uv add trainerbase-injector
```

## Usage

### CLI

```shell script
uv run inject <pid> <path/to/shared/library>
```

### API

```python
from trainerbase_injector import inject

inject(pid, path_to_so_file)
```

## How it works

We build [kubo/injector](https://github.com/kubo/injector) as a CPython C extension.
[kubo/injector](https://github.com/kubo/injector) is an awesome repo allowing to inject shared libraries into running
processes both on Windows (`CreateRemoteThread`), Linux (`ptrace`), and Mac (`task_for_pid`).

## Development

Use Python 3.15, [uv](https://docs.astral.sh/uv/), and a C compiler:
Visual Studio Build Tools with the C++ workload and Windows SDK on Windows,
GCC or Clang on Linux, or Xcode Command Line Tools on macOS.
uv installs Meson and Ninja.

```shell
git submodule update --init --recursive
uv sync --locked
uv run poe run --help
uv run poe lint       # Format, fix lint issues, and check types
uv run poe build      # Build an sdist and a wheel in dist/
uv run poe test       # Prepare the build and run the original tests
```

The default `build` dependency group supplies the tools needed by editable
installs, including with `uv sync --no-dev`.

The original tests use `tests/injection/injection.c` as an injection payload.
`poe test` rebuilds it with Meson and runs pytest from the `test` group.
The payload is never included in the release wheel.

Meson archives the **last committed revision**, including the pinned submodule.
Commit release changes before running `poe build`.
