Skip to content

Commit

Permalink
Switch to proxy_dll
Browse files Browse the repository at this point in the history
  • Loading branch information
trumank committed Nov 4, 2024
1 parent 2a0e245 commit 8f39d26
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
35 changes: 32 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions hook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ bitflags = "2.6.0"
widestring = "1.1.0"
tokio = { workspace = true, features = ["full"] }
tracing-appender = "0.2.3"
proxy_dll = { git = "https://github.com/trumank/proxy_dll.git", version = "0.1.0" }
45 changes: 5 additions & 40 deletions hook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,13 @@ use fs_err as fs;
use hooks::{FnLoadGameFromMemory, FnSaveGameToMemory};
use mint_lib::mod_info::Meta;
use tracing::{info, warn};
use windows::Win32::{
Foundation::HMODULE,
System::{
SystemServices::*,
Threading::{GetCurrentThread, QueueUserAPC},
},
};

// x3daudio1_7.dll
#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn X3DAudioCalculate() {}
#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn X3DAudioInitialize() {}

// d3d9.dll
#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn D3DPERF_EndEvent() {}
#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn D3DPERF_BeginEvent() {}

#[no_mangle]
#[allow(non_snake_case, unused_variables)]
extern "system" fn DllMain(dll_module: HMODULE, call_reason: u32, _: *mut ()) -> bool {
unsafe {
match call_reason {
DLL_PROCESS_ATTACH => {
QueueUserAPC(Some(init), GetCurrentThread(), 0);
}
DLL_PROCESS_DETACH => (),
_ => (),
}

true
}
}
proxy_dll::proxy_dll!([x3daudio1_7, d3d9], init);

unsafe extern "system" fn init(_: usize) {
patch().ok();
fn init() {
unsafe {
patch().ok();
}
}

static mut GLOBALS: Option<Globals> = None;
Expand Down

0 comments on commit 8f39d26

Please sign in to comment.