diff --git a/crates/loader/src/lib.rs b/crates/loader/src/lib.rs index dbb0343..d7f1ed4 100644 --- a/crates/loader/src/lib.rs +++ b/crates/loader/src/lib.rs @@ -109,9 +109,7 @@ unsafe extern "system-unwind" fn Init(data: &ThreadData) -> u32 { setup_logging(&data.log).context("failed to setup logging")?; // blocking call which waits for all plugins to finish DllMain/Init - unsafe { - load_plugins()?; - } + load_plugins()?; Ok::<_, Error>(()) }); diff --git a/crates/loader/src/loader.rs b/crates/loader/src/loader.rs index be04fbd..031525c 100644 --- a/crates/loader/src/loader.rs +++ b/crates/loader/src/loader.rs @@ -16,10 +16,12 @@ use windows::{ use crate::{utils::ThreadManager, Plugin, LOADED_PLUGINS}; -/// # Safety -/// Any spawned threads MUST be joined. This is taken care of by ThreadManager, -/// but it is still an unsafe requirement that could be circumvented -pub unsafe fn load_plugins() -> Result<()> { +pub fn load_plugins() -> Result<()> { + // # Safety + // Any spawned threads MUST be joined. This is taken care of by ThreadManager, + // but it is still an unsafe requirement that could be circumvented. + // This function is safe because we upheld this requirement + let plugins_dir = get_bg3_plugins_dir()?; let config = get_config()?;