From 7339e08ee64e70b1446a751ff33ce3b0c4c3eb8a Mon Sep 17 00:00:00 2001 From: "Prof. 9" Date: Tue, 7 Nov 2023 02:23:48 +0100 Subject: [PATCH] Move hook guards into separate config option --- README.md | 9 +++++++++ chaudloader/src/config.rs | 1 + chaudloader/src/hooks/stage0.rs | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 086bad6..13d5cff 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,15 @@ Mods consists of the following files in a directory inside the `mods` folder: - `init.lua`: The Lua script to run on mod load. Please consult [API.md](API.md) for the API documentation. +### Developer mode + +chaudloader has some development options which can be enabled to aid with mod development. These options have to be manually set in `chaudloader.toml`. + +**These options are purely for development purposes. For users it is strongly recommended not to enable them.** + +- `developer_mode` (type: boolean, default: `false`): Enables developer mode. Required to be `true` in order to use any of the other development options. +- `enable_hook_guards` (type: boolean, default: `false`): Enables hook guards. + ## For developers ### First time diff --git a/chaudloader/src/config.rs b/chaudloader/src/config.rs index 7fafd40..dda9e76 100644 --- a/chaudloader/src/config.rs +++ b/chaudloader/src/config.rs @@ -14,6 +14,7 @@ pub struct Config { // Secret options pub developer_mode: Option, + pub enable_hook_guards: Option, // requires developer_mode } const CONFIG_FILE_NAME: &str = "chaudloader.toml"; diff --git a/chaudloader/src/hooks/stage0.rs b/chaudloader/src/hooks/stage0.rs index 4df156b..25c8ec2 100644 --- a/chaudloader/src/hooks/stage0.rs +++ b/chaudloader/src/hooks/stage0.rs @@ -21,7 +21,7 @@ static_detour! { static GetProcAddressForCaller: unsafe extern "system" fn( /* h_module: */ winapi::shared::minwindef::HMODULE, /* lp_proc_name: */ winapi::shared::ntdef::LPCSTR, - /* lp_caller */ winapi::shared::minwindef::LPVOID + /* lp_caller: */ winapi::shared::minwindef::LPVOID ) -> winapi::shared::minwindef::FARPROC; } @@ -246,7 +246,7 @@ pub unsafe fn install() -> Result<(), anyhow::Error> { std::ffi::CStr::from_ptr(lp_proc_name).to_str().unwrap_or("") } else { "" }; - if config.developer_mode == Some(true) { + if config.developer_mode == Some(true) && config.enable_hook_guards == Some(true) { // disclaimer: ultra mega jank, likely will break in the future match &HIDE_STATE { HideState::INACTIVE => {