Personal commit

This commit is contained in:
2024-08-21 19:01:00 -07:00
parent ba567d1bba
commit bdaa48defd
14 changed files with 424 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
[build]
target = "i686-pc-windows-msvc"
[alias]
runcode = "run -- ../target/i686-unknown-none/release/code.bin"
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "codeloader"
version = "0.1.0"
edition = "2021"
[dependencies]
region = { workspace = true }
+20
View File
@@ -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(())
}