-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37812e6
commit cdc5a86
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "mod-tavern-show-all-sailors" | ||
edition = "2021" | ||
version.workspace = true | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
name="tavern_show_all_sailors" | ||
|
||
[dependencies] | ||
p3-api = { path = "../p3-api" } | ||
log = { workspace = true } | ||
win_dbg_logger = { workspace = true } | ||
|
||
[dependencies.windows] | ||
version = "0.48" | ||
features = [ | ||
"Win32_Foundation", | ||
"Win32_System_Memory", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use log::{debug, error}; | ||
use windows::Win32::{ | ||
Foundation::{GetLastError, WIN32_ERROR}, | ||
System::Memory::{VirtualProtect, PAGE_EXECUTE_READWRITE, PAGE_PROTECTION_FLAGS}, | ||
}; | ||
|
||
const PATCH_ADDRESS: u32 = 0x005D4CD6; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn start() -> u32 { | ||
let _ = log::set_logger(&win_dbg_logger::DEBUGGER_LOGGER); | ||
log::set_max_level(log::LevelFilter::Trace); | ||
let patch_ptr: *mut u8 = PATCH_ADDRESS as _; | ||
|
||
let mut old_flags: PAGE_PROTECTION_FLAGS = windows::Win32::System::Memory::PAGE_PROTECTION_FLAGS(0); | ||
if !VirtualProtect(patch_ptr as _, 5, PAGE_EXECUTE_READWRITE, &mut old_flags).as_bool() { | ||
let error: WIN32_ERROR = GetLastError(); | ||
error!("VirtualProtect PAGE_EXECUTE_READWRITE failed: {:?}", error); | ||
return 1; | ||
} | ||
|
||
debug!("Patching comparison at {:#x}", PATCH_ADDRESS); | ||
*patch_ptr = 0x64; | ||
|
||
if !VirtualProtect(patch_ptr as _, 5, old_flags, &mut old_flags).as_bool() { | ||
let error: WIN32_ERROR = GetLastError(); | ||
error!("VirtualProtect restore failed: {:?}", error); | ||
return 2; | ||
} | ||
|
||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub(crate) mod ffi; |