Skip to content

Commit

Permalink
Fix ;h replacement breaking mods that start with H
Browse files Browse the repository at this point in the history
  • Loading branch information
trumank committed Dec 18, 2023
1 parent e6d3ebd commit 9f68ffe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ unsafe fn patch() -> Result<()> {
}

if let Ok(server_mods) = resolution.server_mods {
let patch_addr = server_mods.semicolon_h_replace.0 as *mut u8;
patch_mem(patch_addr.add(2), [0xC3])?;
patch_mem(patch_addr.add(7), [0x0F, 0x1F, 0x44, 0x00, 0x00])?;
patch_mem(patch_addr.add(102), [0xEB])?;

let mods_fname = server_mods.mods_fname.0;
let set_fstring = server_mods.set_fstring.0;
USessionHandlingFSDFillSessionSetting
Expand Down Expand Up @@ -263,7 +268,6 @@ static_detour! {
static LoadGameFromSlot: unsafe extern "system" fn(*const FString, i32) -> *const USaveGame;
static DoesSaveGameExist: unsafe extern "system" fn(*const FString, i32) -> bool;
static USessionHandlingFSDFillSessionSetting: unsafe extern "system" fn(*const c_void, *mut c_void, bool);
static FOnlineSessionSettingsSetFString: unsafe extern "system" fn(*const c_void, *const c_void, *const FString, u32);
}

#[allow(non_upper_case_globals)]
Expand Down
9 changes: 9 additions & 0 deletions hook_resolvers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ impl_resolver_singleton!(ModsFName, |ctx| async {
)?))
});

#[derive(Debug)]
pub struct SemicolonHReplace(pub usize);
impl_resolver_singleton!(SemicolonHReplace, |ctx| async {
let patterns = ["48 8B CB 48 8D 55 E0 E8 ?? ?? ?? ?? 4D 63 FE 48 8B F0 45 8D 77 01 44 89 75 B8 45 3B F4 7E 18 41 8B D7 48 8D 4D B0 E8 ?? ?? ?? ?? 44 8B 65 BC 44 8B 75 B8 4C 8B 6D B0 33 D2 49 8B CF 48 C1 E1 04 49 03 CD 48 89 11 48 8B 06 48 89 01 48 89 16 8B 46 08 89 41 08 8B 46 0C 89 41 0C 48 89 56 08 48 8B 4D E0 48 85 C9 74 05 E8"];
let res = join_all(patterns.iter().map(|p| ctx.scan(Pattern::new(p).unwrap()))).await;
Ok(Self(ensure_one(res.into_iter().flatten())?))
});

#[derive(Debug)]
pub struct Disable(pub usize);
impl_resolver_singleton!(Disable, |ctx| async {
Expand Down Expand Up @@ -103,6 +111,7 @@ impl_try_collector! {
pub set_fstring: FOnlineSessionSettingsSetFString,
pub fill_session_setting: USessionHandlingFSDFillSessionSettting,
pub mods_fname: ModsFName,
pub semicolon_h_replace: SemicolonHReplace,
}
}

Expand Down

0 comments on commit 9f68ffe

Please sign in to comment.