Skip to content

Commit

Permalink
Add missing code
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyX committed Dec 7, 2023
1 parent b51685c commit ba8b87b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ widestring = "1.0.2"
zerocopy = "0.7.29"
paste = "1.0.14"
region = "3.0.0"
pelite = "0.10.0"

[dependencies.windows]
version = "0.52.0"
Expand Down
9 changes: 7 additions & 2 deletions src/dll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::os::windows::fs::FileExt;
use std::{ops::Range, fs::File};
use std::sync::OnceLock;

use crate::{post_udk_init, udk_log};
use sha2::{Digest, Sha256};

use windows::{
Expand All @@ -19,10 +20,14 @@ use windows::{
core::Error,
};

pub fn dll_main(_hinst_dll: HINSTANCE, fdw_reason: u32, _lpv_reserved: usize) -> i32 {
#[no_mangle]
pub extern "stdcall" fn dll_main(_hinst_dll: HINSTANCE, fdw_reason: u32, _lpv_reserved: usize) -> i32 {
match fdw_reason {
DLL_PROCESS_ATTACH => {
dll_attach()
dll_attach();
if let Err(error) = post_udk_init() {
udk_log::log(udk_log::LogType::Error, &format!("An error occurred initializing the library: {}", error))
}
}
DLL_PROCESS_DETACH => {}

Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ mod xaudio27;

mod dll;
mod udk_log;
mod udk_xaudio;
mod udk_xaudio;

pub fn post_udk_init() -> anyhow::Result<()> {
udk_xaudio::init()?;
Ok(())
}
2 changes: 1 addition & 1 deletion src/udk_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum LogType {
//Debug = 0x36c,
//Log = 0x2f8,
Warning = 0x2ff,
//Error = 0x315,
Error = 0x315,
//Critical = 0x2f9,
}

Expand Down
2 changes: 1 addition & 1 deletion src/udk_xaudio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use anyhow::Context;
use retour::static_detour;

use crate::get_udk_ptr;
use crate::dll::get_udk_ptr;
use crate::udk_log::{log, LogType};
use crate::xaudio27::{IXAudio27, XAudio27Wrapper};

Expand Down

0 comments on commit ba8b87b

Please sign in to comment.