Make the injector work on windows - dll proxying still behaving weird

This commit is contained in:
Dimitris Zervas
2023-05-27 16:38:27 +03:00
parent 5902d9bf40
commit d65438091f
6 changed files with 71 additions and 52 deletions

View File

@@ -2,20 +2,10 @@ use std::env;
fn main() {
println!("cargo:rerun-if-env-changed=FRIDA_CODE");
println!("cargo:rerun-if-env-changed=FRIDA_CODE_FILE");
println!("cargo:rerun-if-env-changed=DLL_PROXY");
if let Ok(code_file) = env::var("FRIDA_CODE_FILE") {
env::set_var("FRIDA_CODE", &std::fs::read_to_string(&code_file).unwrap());
println!("cargo:warning=Using code from file: {}", &code_file);
} else if env::var("FRIDA_CODE").is_ok() {
println!("cargo:warning=Using code from environment variable: FRIDA_CODE");
} else {
println!("Please set FRIDA_CODE or FRIDA_CODE_FILE environment variable");
std::process::exit(1);
}
if let Ok(lib_path) = env::var("DLL_PROXY") {
println!("cargo:rerun-if-changed={}", &lib_path);
use goblin::Object::{self, PE};
let path = std::path::Path::new(&lib_path);
@@ -38,9 +28,9 @@ fn main() {
};
for e in exports.iter() {
println!("cargo:warning=Exported function: {}", e);
// println!("cargo:rustc-link-lib=dylib={}-orig", lib_name);
// println!("cargo:warning=Exported function: {} => {}-orig.{}", e, lib_name, e);
println!("cargo:rustc-link-arg=/export:{}={}-orig.{}", e, lib_name, e);
// println!("cargo:rustc-link-lib=dylib={}-orig", lib_name);
}
println!("cargo:warning=Expected library name: {}-orig.dll", lib_name);
}