diff --git a/.cargo/config b/.cargo/config index ccc4a6c..3a249ae 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1,2 @@ [build] -target = "x86_64-pc-windows-msvc" \ No newline at end of file +target = "i686-pc-windows-msvc" \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 79c8103..e11ba31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "injrs" -version = "0.1.1" +version = "0.1.2" description = "DLL injector library and tool written in Rust. Rust 实现的DLL注入工具/库。" authors = ["Zoe "] license = "Apache-2.0" @@ -8,6 +8,9 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[example]] +name = "hellobox" +crate-type = ["cdylib"] [dependencies.winapi] @@ -16,6 +19,7 @@ features = [ "memoryapi", "minwindef", "ntdef", + "winuser", "tlhelp32", "psapi", "securitybaseapi", diff --git a/README.md b/README.md index 6fd9c10..b8f74fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@
+Hello Box Demo + # `injrs` **DLL injector library and tool written in Rust. Rust 实现的DLL注入工具/库** @@ -42,7 +44,24 @@ EXAMPLES: $ injrs 1888 test.dll demo.dll ``` -The code in [example](./example) is a simple message box dll for testing injector. +## DLL Demo + +The code in [examples/hellobox](./examples/hellobox) is a simple message box dll for testing injector. + +You can build with command: +```bash +cargo build --release --example hellobox +``` + +Build target will locate in: +```bash +target/i686-pc-windows-msvc/release/examples/hellobox.dll +``` + +Try to inject the demo dll to your target process: +```bash +injrs PID/PNAME target/i686-pc-windows-msvc/release/examples/hellobox.dll +``` ## Usage as library diff --git a/example/.cargo/config b/example/.cargo/config deleted file mode 100644 index ccc4a6c..0000000 --- a/example/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "x86_64-pc-windows-msvc" \ No newline at end of file diff --git a/example/Cargo.toml b/example/Cargo.toml deleted file mode 100644 index 49a768d..0000000 --- a/example/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "example" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib"] - -[dependencies] -winapi = { version = "0.3.9", features = [ "minwindef", "winnt", "libloaderapi", "winuser" ] } - diff --git a/example/src/lib.rs b/examples/hellobox.rs similarity index 92% rename from example/src/lib.rs rename to examples/hellobox.rs index 6e734a1..569c93a 100644 --- a/example/src/lib.rs +++ b/examples/hellobox.rs @@ -33,7 +33,7 @@ fn show_message_box(caption: &str, text: &str) { // define dllmain to handle the init action #[no_mangle] #[allow(non_snake_case)] -pub extern "stdcall" fn DllMain(hinst: HINSTANCE, reason: DWORD, _reserved: LPVOID) -> BOOL { +unsafe extern "system" fn DllMain(hinst: HINSTANCE, reason: DWORD, _reserved: LPVOID) -> BOOL { match reason { DLL_PROCESS_DETACH => { println!("Remove from main process."); diff --git a/hello-box-demo.png b/hello-box-demo.png new file mode 100644 index 0000000..c478550 Binary files /dev/null and b/hello-box-demo.png differ