Personal commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
[build]
|
||||
target = "i686-pc-windows-msvc"
|
||||
|
||||
[alias]
|
||||
runcode = "run -- ../target/i686-unknown-none/release/code.bin"
|
||||
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "codeloader"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
region = { workspace = true }
|
||||
@@ -0,0 +1,20 @@
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + 'static>>;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let file = std::env::args().nth(1).unwrap_or("code.bin".to_string());
|
||||
|
||||
let code = std::fs::read(file)?;
|
||||
|
||||
let code: extern "C" fn() = unsafe {
|
||||
region::protect(
|
||||
code.as_ptr(),
|
||||
code.len(),
|
||||
region::Protection::READ_WRITE_EXECUTE,
|
||||
)?;
|
||||
std::mem::transmute(code.as_ptr())
|
||||
};
|
||||
|
||||
code();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user