dll-syringe
dll-syringe copied to clipboard
Can't eject DLL in ctrlc handler
Thanks for publishing this library!
I want my injector to eject the DLL when I ctrl+c close the program. However, I cannot use the Syringe or ProcessModule in my ctrlc handler because it uses Rc.
How can I eject the DLL on ctrl c?
Errors:
error[E0277]: `Rc<dll_syringe::process::memory::remote_box::RemoteBoxAllocatorInner>` cannot be sent between threads safely
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| _____------------------_^
| | |
| | required by a bound introduced by this call
44 | | syringe.lock().unwrap().eject(*injected.lock().unwrap());
45 | | });
| |_____^ `Rc<dll_syringe::process::memory::remote_box::RemoteBoxAllocatorInner>` cannot be sent between threads safely
|
= help: within `Syringe`, the trait `Send` is not implemented for `Rc<dll_syringe::process::memory::remote_box::RemoteBoxAllocatorInner>`, which is required by `{closure@src\main.rs:43:24: 43:31}: Send`
note: required because it appears within the type `dll_syringe::process::memory::remote_box::RemoteBoxAllocator`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\process\memory\remote_box.rs:9:12
|
9 | pub struct RemoteBoxAllocator(pub(crate) Rc<RemoteBoxAllocatorInner>);
| ^^^^^^^^^^^^^^^^^^
note: required because it appears within the type `Syringe`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\syringe.rs:97:12
|
97 | pub struct Syringe {
| ^^^^^^^
= note: required for `Mutex<Syringe>` to implement `Sync`
= note: required for `Arc<Mutex<Syringe>>` to implement `Send`
note: required because it's used within this closure
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| ^^^^^^^
note: required by a bound in `set_handler`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ctrlc-3.4.2\src\lib.rs:95:28
|
93 | pub fn set_handler<F>(user_handler: F) -> Result<(), Error>
| ----------- required by a bound in this function
94 | where
95 | F: FnMut() + 'static + Send,
| ^^^^ required by this bound in `set_handler`
error[E0277]: `*mut winapi::shared::minwindef::HINSTANCE__` cannot be sent between threads safely
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| _____------------------_^
| | |
| | required by a bound introduced by this call
44 | | syringe.lock().unwrap().eject(*injected.lock().unwrap());
45 | | });
| |_____^ `*mut winapi::shared::minwindef::HINSTANCE__` cannot be sent between threads safely
|
= help: within `Syringe`, the trait `Send` is not implemented for `*mut winapi::shared::minwindef::HINSTANCE__`, which is required by `{closure@src\main.rs:43:24: 43:31}: Send`
note: required because it appears within the type `PhantomData<*mut winapi::shared::minwindef::HINSTANCE__>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\marker.rs:740:12
|
740 | pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `dll_syringe::process::memory::remote_box::RemoteBox<*mut winapi::shared::minwindef::HINSTANCE__>`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\process\memory\remote_box.rs:123:12
|
123 | pub struct RemoteBox<T: ?Sized> {
| ^^^^^^^^^
note: required because it appears within the type `dll_syringe::syringe::LoadLibraryWStub`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\syringe.rs:380:8
|
380 | struct LoadLibraryWStub {
| ^^^^^^^^^^^^^^^^
note: required because it appears within the type `Option<dll_syringe::syringe::LoadLibraryWStub>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\option.rs:572:10
|
572 | pub enum Option<T> {
| ^^^^^^
note: required because it appears within the type `UnsafeCell<Option<dll_syringe::syringe::LoadLibraryWStub>>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cell.rs:2030:12 |
2030 | pub struct UnsafeCell<T: ?Sized> {
| ^^^^^^^^^^
note: required because it appears within the type `OnceCell<dll_syringe::syringe::LoadLibraryWStub>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cell\once.rs:33:12
|
33 | pub struct OnceCell<T> {
| ^^^^^^^^
note: required because it appears within the type `Syringe`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\syringe.rs:97:12
|
97 | pub struct Syringe {
| ^^^^^^^
= note: required for `Mutex<Syringe>` to implement `Sync`
= note: required for `Arc<Mutex<Syringe>>` to implement `Send`
note: required because it's used within this closure
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| ^^^^^^^
note: required by a bound in `set_handler`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ctrlc-3.4.2\src\lib.rs:95:28
|
93 | pub fn set_handler<F>(user_handler: F) -> Result<(), Error>
| ----------- required by a bound in this function
94 | where
95 | F: FnMut() + 'static + Send,
| ^^^^ required by this bound in `set_handler`
error[E0277]: `*mut winapi::shared::minwindef::__some_function` cannot be sent between threads safely
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| _____------------------_^
| | |
| | required by a bound introduced by this call
44 | | syringe.lock().unwrap().eject(*injected.lock().unwrap());
45 | | });
| |_____^ `*mut winapi::shared::minwindef::__some_function` cannot be sent between threads safely
|
= help: within `Syringe`, the trait `Send` is not implemented for `*mut winapi::shared::minwindef::__some_function`, which is required by `{closure@src\main.rs:43:24: 43:31}: Send`
note: required because it appears within the type `PhantomData<*mut winapi::shared::minwindef::__some_function>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\marker.rs:740:12
|
740 | pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `dll_syringe::process::memory::remote_box::RemoteBox<*mut winapi::shared::minwindef::__some_function>`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\process\memory\remote_box.rs:123:12
|
123 | pub struct RemoteBox<T: ?Sized> {
| ^^^^^^^^^
note: required because it appears within the type `rpc::rpc_core::RemoteProcedureStub<rpc::rpc_core::GetProcAddressParams, *mut winapi::shared::minwindef::__some_function>`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\rpc\rpc_core.rs:180:19
|
180 | pub(crate) struct RemoteProcedureStub<A: ?Sized + Copy, R: Copy> {
| ^^^^^^^^^^^^^^^^^^^
note: required because it appears within the type `Option<RemoteProcedureStub<GetProcAddressParams, *mut __some_function>>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\option.rs:572:10
|
572 | pub enum Option<T> {
| ^^^^^^
note: required because it appears within the type `UnsafeCell<Option<RemoteProcedureStub<GetProcAddressParams, *mut __some_function>>>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cell.rs:2030:12 |
2030 | pub struct UnsafeCell<T: ?Sized> {
| ^^^^^^^^^^
note: required because it appears within the type `OnceCell<RemoteProcedureStub<GetProcAddressParams, *mut __some_function>>`
--> C:\Users\me\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\cell\once.rs:33:12
|
33 | pub struct OnceCell<T> {
| ^^^^^^^^
note: required because it appears within the type `Syringe`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dll-syringe-0.15.2\src\syringe.rs:97:12
|
97 | pub struct Syringe {
| ^^^^^^^
= note: required for `Mutex<Syringe>` to implement `Sync`
= note: required for `Arc<Mutex<Syringe>>` to implement `Send`
note: required because it's used within this closure
--> src\main.rs:43:24
|
43 | ctrlc::set_handler(move || {
| ^^^^^^^
note: required by a bound in `set_handler`
--> C:\Users\me\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ctrlc-3.4.2\src\lib.rs:95:28
|
93 | pub fn set_handler<F>(user_handler: F) -> Result<(), Error>
| ----------- required by a bound in this function
94 | where
95 | F: FnMut() + 'static + Send,
| ^^^^ required by this bound in `set_handler`
For more information about this error, try `rustc --explain E0277`.