Skip to content

Commit

Permalink
feat: injecting on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
fgardt committed Aug 13, 2024
1 parent 096a888 commit 40dc38b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 23 deletions.
54 changes: 33 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ windows = { version = "0.58.0", features = [
] }

[target.'cfg(unix)'.dependencies]
ctor = "0.2.8"
ctor = "0.2"
libloading = "0.8"

[lib]
crate-type = ["cdylib"]
Expand Down
21 changes: 20 additions & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,24 @@ pub fn run() {
}
};

// TODO: load rivets library
unsafe {
let lib = match libloading::Library::new(rivets_lib) {
Ok(lib) => lib,
Err(e) => {
eprintln!("Failed to load rivets library: {e}");
return;
}
};

let entry_point: libloading::Symbol<unsafe extern "C" fn()> =
match lib.get(b"rivets_entry_point") {
Ok(entry_point) => entry_point,
Err(e) => {
eprintln!("Failed to get rivets entry point: {e}");
return;
}
};

entry_point();
}
}

0 comments on commit 40dc38b

Please sign in to comment.