Added a workaround for the requirement of calling DllMain in pcileech to initialize mutexes

pull/7/head
ko1N 4 years ago
parent ca12f4b602
commit 02b5c95eaa

@ -8,6 +8,9 @@ license-file = "../LICENSE"
links = "leechcore"
[dependencies]
ctor = "0.1"
[build-dependencies]
cc = "1.0.62"
bindgen = "0.55"

@ -43,6 +43,7 @@ fn build_leechcore(target: &str) {
.collect::<Vec<_>>(),
)
.flag(&format!("-D{}", os_define()));
// EXPORTED_FUNCTION= to not export any symbols
if !target.contains("windows") {
// setup additional flags

@ -8,3 +8,28 @@
//#![allow(clippy::cognitive_complexity)]
include!(concat!(env!("OUT_DIR"), "/leechcore.rs"));
#[cfg(target_os = "windows")]
extern "C" {
pub fn DllMain(_: *const u8, _: u32, _: *const u8) -> u32;
}
use ctor::{ctor, dtor};
#[ctor]
#[cfg(target_os = "windows")]
fn leechcore_attach() {
// DLL_PROCESS_ATTACH
unsafe {
DllMain(std::ptr::null_mut(), 1, std::ptr::null_mut());
}
}
#[dtor]
#[cfg(target_os = "windows")]
fn leechcore_detach() {
// DLL_PROCESS_DETACH
unsafe {
DllMain(std::ptr::null_mut(), 0, std::ptr::null_mut());
}
}

Loading…
Cancel
Save