2023-05-23 17:21:14 +03:00
|
|
|
|
2023-06-03 01:52:10 +03:00
|
|
|
#[cfg(all(unix, not(feature = "frida")))]
|
|
|
|
compile_error!("Only Frida injection is supported for Unix targets");
|
2023-05-27 16:38:27 +03:00
|
|
|
|
2023-06-03 01:52:10 +03:00
|
|
|
#[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");
|
2023-05-27 16:38:27 +03:00
|
|
|
|
2023-06-03 01:52:10 +03:00
|
|
|
#[cfg(all(not(windows), feature = "managed_lib"))]
|
|
|
|
compile_error!("Managed library injection is only supported for Windows target");
|
2023-05-27 16:38:27 +03:00
|
|
|
|
2023-06-03 01:52:10 +03:00
|
|
|
#[cfg(feature = "frida")]
|
|
|
|
use crate::frida_handler::attach_pid as frida_attach_pid;
|
2023-05-27 16:38:27 +03:00
|
|
|
|
2023-06-03 01:52:10 +03:00
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn attach(pid: u32) {
|
|
|
|
#[cfg(feature = "frida")]
|
|
|
|
{
|
|
|
|
let frida_code = env!("FRIDA_CODE").to_string();
|
|
|
|
std::thread::spawn(move || frida_attach_pid(frida_code, pid));
|
|
|
|
}
|
2023-05-23 17:21:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2023-06-03 01:52:10 +03:00
|
|
|
pub extern "C" fn attach_self() {
|
2023-05-27 16:38:27 +03:00
|
|
|
println!("[*] Attaching to self");
|
|
|
|
attach(0);
|
2023-05-23 17:21:14 +03:00
|
|
|
}
|