{"id":13578672,"url":"https://github.com/OpenByteDev/dll-syringe","last_synced_at":"2025-04-05T19:33:26.732Z","repository":{"id":40822638,"uuid":"387948810","full_name":"OpenByteDev/dll-syringe","owner":"OpenByteDev","description":"A windows dll injection library written in rust.","archived":false,"fork":false,"pushed_at":"2024-07-02T16:07:44.000Z","size":315,"stargazers_count":180,"open_issues_count":13,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T20:06:37.432Z","etag":null,"topics":["dll-injection","windows"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenByteDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-21T00:39:53.000Z","updated_at":"2025-04-04T05:33:39.000Z","dependencies_parsed_at":"2024-01-16T20:29:02.112Z","dependency_job_id":"4742aef2-3bf4-4024-b15e-be7e92d9381a","html_url":"https://github.com/OpenByteDev/dll-syringe","commit_stats":{"total_commits":268,"total_committers":2,"mean_commits":134.0,"dds":0.007462686567164201,"last_synced_commit":"0508b0f2e029d52c588bd6c2fbf8658e866fd9a0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenByteDev%2Fdll-syringe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenByteDev%2Fdll-syringe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenByteDev%2Fdll-syringe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenByteDev%2Fdll-syringe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenByteDev","download_url":"https://codeload.github.com/OpenByteDev/dll-syringe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242678,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dll-injection","windows"],"created_at":"2024-08-01T15:01:32.763Z","updated_at":"2025-04-05T19:33:24.799Z","avatar_url":"https://github.com/OpenByteDev.png","language":"Rust","readme":"# dll-syringe\n\n[![CI](https://github.com/OpenByteDev/dll-syringe/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenByteDev/dll-syringe/actions/workflows/ci.yml)\n[![crates.io](https://img.shields.io/crates/v/dll-syringe.svg)](https://crates.io/crates/dll-syringe)\n[![Documentation](https://docs.rs/dll-syringe/badge.svg)](https://docs.rs/dll-syringe)\n[![dependency status](https://deps.rs/repo/github/openbytedev/dll-syringe/status.svg)](https://deps.rs/repo/github/openbytedev/dll-syringe)\n[![MIT](https://img.shields.io/crates/l/dll-syringe.svg)](https://github.com/OpenByteDev/dll-syringe/blob/master/LICENSE)\n\nA windows dll injection library written in Rust.\n\n## Supported scenarios\n| Injector Process | Target Process | Supported?                                 |\n| ---------------- | -------------- | ------------------------------------------ |\n| 32-bit           | 32-bit         | Yes                                        |\n| 32-bit           | 64-bit         | No                                         |\n| 64-bit           | 32-bit         | Yes (requires feature `into-x86-from-x64`) |\n| 64-bit           | 64-bit         | Yes                                        |\n\n## Usage\n### Inject \u0026 Eject\nThis crate allows you to inject and eject a DLL into a target process.\nThe example below will inject and then eject `injection_payload.dll` into the process called \"ExampleProcess\".\n\n```rust no_run\nuse dll_syringe::{Syringe, process::OwnedProcess};\n\n// find target process by name\nlet target_process = OwnedProcess::find_first_by_name(\"ExampleProcess\").unwrap();\n\n// create a new syringe for the target process\nlet syringe = Syringe::for_process(target_process);\n\n// inject the payload into the target process\nlet injected_payload = syringe.inject(\"injection_payload.dll\").unwrap();\n\n// do something else\n\n// eject the payload from the target (optional)\nsyringe.eject(injected_payload).unwrap();\n```\n\n## Remote Procedure Calls (RPC)\nThis crate supports two mechanisms for rpc. Both only work one-way for calling exported functions in the target process and are only intended for one-time initialization usage. For extended communication a dedicated rpc library should be used.\n\n|                                  | `RemotePayloadProcedure`         | `RemoteRawProcedure`                                                   |\n| -------------------------------- | -------------------------------- | ---------------------------------------------------------------------- |\n| Feature                          | `rpc-payload`                    | `rpc-raw`                                                              |\n| Argument and Return Requirements | `Serialize + DeserializeOwned`   | `Copy`, Argument size has to be smaller than `usize` in target process |\n| Function Definition              | Using macro `payload_procedure!` | Any `extern \"system\"` or `extern \"C\"` with `#[no_mangle]`              |\n\n### RemotePayloadProcedure\nA rpc mechanism based on [`bincode`](https://crates.io/crates/bincode).\nThe target procedure must be defined using the `payload_procedure!` macro (requires the `payload-utils` feature).\n\nThe definition of an exported `add` function could look like this:\n```rust\ndll_syringe::payload_procedure! {\n    fn add(a: f64, b: f64) -\u003e f64 {\n        a + b\n    }\n}\n```\n\nThe code of the injector/caller could looks like this:\n```rust no_run\nuse dll_syringe::{Syringe, process::OwnedProcess};\n\n// find target process by name\nlet target_process = OwnedProcess::find_first_by_name(\"ExampleProcess\").unwrap();\n\n// create a new syringe for the target process\nlet syringe = Syringe::for_process(target_process);\n\n// inject the payload into the target process\nlet injected_payload = syringe.inject(\"injection_payload.dll\").unwrap();\n\nlet remote_add = unsafe { syringe.get_payload_procedure::\u003cfn(f64, f64) -\u003e f64\u003e(injected_payload, \"add\") }.unwrap().unwrap();\nlet result = remote_add.call(\u00262.0, \u00264.0).unwrap();\nprintln!(\"{}\", result); // prints 6\n\n// eject the payload from the target (optional)\nsyringe.eject(injected_payload).unwrap();\n```\n\n### RemoteRawProcedure\nThis mechanism is based on dynamically generated assembly code.\nThe target procedure can be any exported function as long as it uses either the `system` or `C` calling convention.\nThis means that even Win32 functions can be called directly.\n\nThe definition of an exported `add` function could look like this:\n```rust\n#[no_mangle]\nextern \"system\" fn add(a: f64, b: f64) -\u003e f64 {\n    a + b\n}\n```\n\nThe code of the injector/caller could looks like this:\n```rust no_run\nuse dll_syringe::{Syringe, process::OwnedProcess};\n\n// find target process by name\nlet target_process = OwnedProcess::find_first_by_name(\"ExampleProcess\").unwrap();\n\n// create a new syringe for the target process\nlet syringe = Syringe::for_process(target_process);\n\n// inject the payload into the target process\nlet injected_payload = syringe.inject(\"injection_payload.dll\").unwrap();\n\nlet remote_add = unsafe { syringe.get_raw_procedure::\u003cextern \"system\" fn(f64, f64) -\u003e f64\u003e(injected_payload, \"add\") }.unwrap().unwrap();\nlet result = remote_add.call(2.0, 4.0).unwrap();\nprintln!(\"{}\", result); // prints 6\n\n// eject the payload from the target (optional)\nsyringe.eject(injected_payload).unwrap();\n```\n\n## License\nLicensed under MIT license ([LICENSE](https://github.com/OpenByteDev/dll-syringe/blob/master/LICENSE) or http://opensource.org/licenses/MIT)\n\n## Instructions for Contributors\n\n### Prerequisites\n\nYou will need the nightly toolchains of Rust and Cargo to build/test this project.\n\n```\nrustup target add x86_64-pc-windows-msvc --toolchain nightly\nrustup target add i686-pc-windows-msvc --toolchain nightly\n```\n\n\u003e [!NOTE]\n\u003e Also applies to developing on Linux, you'll need it for your IDE (i.e. rust-analyzer or RustRover) to work properly.\n\n### Run Tests\n\nRun the `./scripts/test.ps1` script from PowerShell.\n\n### Running Tests on Linux\n\nYou'll need `cargo xwin` to build the MSVC targets on Linux:\n\n```\ncargo install cargo-xwin\n```\n\nAfter that, you can run the tests with `./scripts/test-wine.ps1` PowerShell script.\n(As opposed to `./scripts/test.ps1`)\n\nMake sure you have Wine installed!\n\n## Attribution\nInspired by [Reloaded.Injector](https://github.com/Reloaded-Project/Reloaded.Injector) from [Sewer](https://github.com/Sewer56).\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenByteDev%2Fdll-syringe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOpenByteDev%2Fdll-syringe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenByteDev%2Fdll-syringe/lists"}