Fix some small issues and experiment with C#

This commit is contained in:
Dimitris Zervas
2024-02-27 03:01:29 +02:00
parent 62e98de539
commit a89850d410
16 changed files with 287 additions and 37 deletions

View File

@ -1,13 +1,15 @@
pub mod injector;
#[cfg(feature = "frida")]
pub mod frida_handler;
// #[cfg(feature = "dotnet")]
// pub mod cs;
pub use injector::{attach, attach_self};
pub use injector::attach_self;
#[cfg(all(unix, not(test)))]
#[cfg(all(unix, not(test), not(feature = "dotnet")))]
use ctor::ctor;
#[cfg(all(unix, not(test)))]
#[cfg(all(unix, not(test), not(feature = "dotnet")))]
#[ctor]
fn _start() {
println!("[+] frida-deepfreeze-rs library injected");
@ -16,27 +18,24 @@ fn _start() {
// For some reason ctor doesn't work on Windows - it hangs the process
// during DeviceManager::obtain. DllMain works fine though.
#[cfg(all(windows, not(test)))]
#[cfg(all(any(windows, feature = "dotenv"), not(test)))]
use std::ffi::c_void;
#[cfg(all(windows, not(test)))]
#[cfg(all(any(windows, feature = "dotenv"), not(test)))]
use winapi::um::winnt::DLL_PROCESS_ATTACH;
#[cfg(all(windows, feature = "dll_proxy", not(test)))]
#[cfg(all(any(windows, feature = "dotenv"), not(test)))]
use winapi::um::libloaderapi::LoadLibraryA;
#[cfg(all(windows, not(test)))]
#[cfg(all(any(windows, feature = "dotenv"), not(test)))]
#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn DllMain(dll_module: *mut c_void, call_reason: u32, _: *mut ()) -> bool {
pub extern "system" fn DllMain(dll_module: *mut c_void, call_reason: u32, _: *mut ()) -> bool {
match call_reason {
DLL_PROCESS_ATTACH => {
println!("[+] frida-deepfreeze-rs DLL injected");
#[cfg(feature = "dll_proxy")]
{
unsafe { LoadLibraryA(env!("LIB_NAME").as_ptr() as *const i8); }
println!("[+] Original DLL {} loaded", env!("LIB_NAME"));
}
unsafe { LoadLibraryA(env!("LIB_NAME").as_ptr() as *const i8); }
println!("[+] Original DLL {} loaded", env!("LIB_NAME"));
attach_self();
}