injectionforge/src/injector.rs

31 lines
899 B
Rust
Raw Normal View History

#[cfg(all(unix, not(feature = "frida")))]
compile_error!("Only Frida injection is supported for Unix targets");
#[cfg(all(not(feature = "managed_lib"), not(feature = "frida")))]
compile_error!("No injection method is selected - please enable either managed_lib (windows-only) and/or frida feature");
#[cfg(all(not(windows), feature = "managed_lib"))]
compile_error!("Managed library injection is only supported for Windows target");
#[cfg(feature = "frida")]
use crate::frida_handler::attach_pid as frida_attach_pid;
#[no_mangle]
pub extern "C" fn attach(pid: u32) {
#[cfg(feature = "frida")]
{
let frida_code = env!("FRIDA_CODE").to_string();
2023-06-03 18:02:46 +03:00
#[cfg(windows)]
std::thread::spawn(move || frida_attach_pid(frida_code, pid));
2023-06-03 18:02:46 +03:00
#[cfg(not(windows))]
frida_attach_pid(frida_code, pid);
}
}
#[no_mangle]
pub extern "C" fn attach_self() {
println!("[*] Attaching to self");
attach(0);
}