Skip to content

Commit

Permalink
Move hook guards into separate config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Prof9 committed Nov 7, 2023
1 parent ebd1c54 commit 7339e08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions chaudloader/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Config {

// Secret options
pub developer_mode: Option<bool>,
pub enable_hook_guards: Option<bool>, // requires developer_mode
}

const CONFIG_FILE_NAME: &str = "chaudloader.toml";
Expand Down
4 changes: 2 additions & 2 deletions chaudloader/src/hooks/stage0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 7339e08

Please sign in to comment.