diff --git a/hook/src/lib.rs b/hook/src/lib.rs index cefdf46d..ea7b740d 100644 --- a/hook/src/lib.rs +++ b/hook/src/lib.rs @@ -87,6 +87,11 @@ unsafe fn patch() -> Result<()> { return Ok(()); } + let log_path = std::env::current_exe().unwrap().parent().unwrap().join("log.txt"); + let mut log = std::fs::OpenOptions::new().create(true).write(true).truncate(true).open(log_path).unwrap(); + use std::io::Write; + writeln!(log, "started")?; + let installation_type = DRGInstallationType::from_exe_path()?; #[derive(Debug, PartialEq)] @@ -138,9 +143,14 @@ unsafe fn patch() -> Result<()> { ), ]; - let scan = patternsleuth::process::internal::read_image()?.scan(&patterns)?; + writeln!(log, "reading image")?; + let image = patternsleuth::process::internal::read_image()?; + writeln!(log, "starting scan")?; + let scan = image.scan(&patterns)?; + writeln!(log, "scan done")?; if let Ok(address) = scan.get_unique_sig_address(Sig::GetServerName) { + writeln!(log, "found GetServerName")?; let address = address as *const c_void; let resize_rip = address.add(53); @@ -158,6 +168,7 @@ unsafe fn patch() -> Result<()> { if matches!(installation_type, DRGInstallationType::Steam) { if let Ok(address) = scan.get_unique_sig_address(Sig::Disable) { + writeln!(log, "found Disable")?; let address = (address as *mut u8).add(29); let patch = [0xB8, 0x01, 0x00, 0x00, 0x00]; @@ -195,6 +206,7 @@ unsafe fn patch() -> Result<()> { ); if let Ok(address) = scan.get_unique_sig_address(Sig::SaveGameToSlot) { + writeln!(log, "found SaveGameToSlot")?; let address = address as *const c_void; let save_rip = address.add(39); @@ -209,6 +221,7 @@ unsafe fn patch() -> Result<()> { } if let Ok(address) = scan.get_unique_sig_address(Sig::LoadGameFromMemory) { + writeln!(log, "found LoadGameFromMemory")?; let address = address as *const c_void; LoadGameFromMemory = Some(std::mem::transmute(address)); @@ -223,6 +236,7 @@ unsafe fn patch() -> Result<()> { } if let Ok(address) = scan.get_unique_sig_address(Sig::DoesSaveGameExist) { + writeln!(log, "found DoesSaveGameExist")?; let address = address as *const c_void; let target: FnDoesSaveGameExist = std::mem::transmute(address);