There is a byte array that contains the program. How do run it in a new process from Rust code?
Kind of like this:
const PROGRAM: &[u8] = include_bytes!("proxy.exe");
fn main() {
CreateNewProccess(PROGRAM);
}
There is a byte array that contains the program. How do run it in a new process from Rust code?
Kind of like this:
const PROGRAM: &[u8] = include_bytes!("proxy.exe");
fn main() {
CreateNewProccess(PROGRAM);
}
The most intuitive way to run the embedded executable is to write it to disk, even if temporarily, and only then run it. Here is how one would do this in Rust.
let program = {
let mut p = std::env::current_dir()?;
p.push("proxy.exe");
p
};
std::fs::write(&program, PROGRAM)?;
let child = std::process::Command::new(program)
.spawn()?;
Depending on your use case, it might not be worth it to store executables inside the main program like that.
See also: