From af2fbb0527dd23b4fe4ab9ccdfd7e8c483fbd518 Mon Sep 17 00:00:00 2001 From: xavo95 Date: Tue, 1 Oct 2024 19:28:57 +0200 Subject: [PATCH] Launcher changes incoming --- Cargo.lock | 32 ++++++++++++++++---------------- src/interceptor.rs | 10 +++++----- src/lib.rs | 43 ++++++++++++++++++++++++++----------------- src/offsets.rs | 4 ++++ 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff650f5..8195bb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,9 +49,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "memchr" @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "shorekeeper-patch" @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -127,18 +127,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "windows" diff --git a/src/interceptor.rs b/src/interceptor.rs index c255748..81209e7 100644 --- a/src/interceptor.rs +++ b/src/interceptor.rs @@ -1,5 +1,5 @@ use ilhook::x64::{ - CallbackOption, HookFlags, HookPoint, HookType, Hooker, JmpBackRoutine, RetnRoutine, + CallbackOption, Hooker, HookFlags, HookPoint, HookType, JmpBackRoutine, RetnRoutine, }; pub struct Interceptor { @@ -12,7 +12,7 @@ impl Interceptor { } #[allow(dead_code)] - pub unsafe fn attach( + pub fn attach( &mut self, addr: usize, routine: JmpBackRoutine, @@ -25,12 +25,12 @@ impl Interceptor { HookFlags::empty(), ); - let hook_point = hooker.hook()?; + let hook_point = unsafe { hooker.hook() }?; self.hooks.push(hook_point); Ok(()) } - pub unsafe fn replace( + pub fn replace( &mut self, addr: usize, routine: RetnRoutine, @@ -43,7 +43,7 @@ impl Interceptor { HookFlags::empty(), ); - let hook_point = hooker.hook()?; + let hook_point = unsafe { hooker.hook() }?; self.hooks.push(hook_point); Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index 95536d1..cf19b1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,39 +2,48 @@ use std::thread; use std::time::Duration; use ilhook::x64::Registers; -use interceptor::Interceptor; -use windows::core::{w, PCSTR, PCWSTR}; +use windows::core::{PCSTR, PCWSTR, w}; +use windows::Win32::Foundation::HINSTANCE; use windows::Win32::System::Console; +use windows::Win32::System::LibraryLoader::GetModuleHandleA; use windows::Win32::System::SystemServices::DLL_PROCESS_ATTACH; -use windows::Win32::{Foundation::HINSTANCE, System::LibraryLoader::GetModuleHandleA}; + +use interceptor::Interceptor; +use offsets::CONFIG; mod interceptor; mod offsets; -use offsets::CONFIG; - -unsafe fn thread_func() { - Console::AllocConsole().unwrap(); - println!("Wuthering Waves signature check bypass"); +fn thread_func() { + unsafe { Console::AllocConsole() }.unwrap(); + println!("Wuthering Waves essential binary patcher"); println!("Don't forget to visit https://discord.gg/reversedrooms"); - let module = GetModuleHandleA(PCSTR::null()).unwrap(); - println!("Base: {:X}", module.0 as usize); + println!("Waiting for ACE init"); + let module = unsafe { GetModuleHandleA(PCSTR::null()) }.unwrap(); + let pak_file_offset = ((module.0 as usize) + CONFIG.f_pak_file_check) as *const u128; + loop { + if unsafe { std::ptr::read(pak_file_offset) } == CONFIG.f_pak_file_check_preamble { + println!("ACE Initialization finished"); + break; + } + thread::sleep(Duration::from_millis(1)) + } let mut interceptor = Interceptor::new(); interceptor - .replace( - (module.0 as usize) + CONFIG.f_pak_file_check, - fpakfile_check_replacement, - ) + .replace((module.0 as usize) + CONFIG.f_pak_file_check, fpakfile_check_replacement) .unwrap(); + let module = unsafe { GetModuleHandleA(PCSTR::null()) }.unwrap(); + println!("Game base: {:X}", module.0 as usize); + interceptor .attach((module.0 as usize) + CONFIG.kuro_http_get, on_kurohttp_get) .unwrap(); let krsdk_ex = loop { - match GetModuleHandleA(CONFIG.disable_sdk.sdk_dll) { + match unsafe { GetModuleHandleA(CONFIG.disable_sdk.sdk_dll) } { Ok(handle) => break handle, Err(_) => thread::sleep(Duration::from_millis(1)), } @@ -47,8 +56,8 @@ unsafe fn thread_func() { interceptor .replace((krsdk_ex.0 as usize) + CONFIG.disable_sdk.sdk_go_away, dummy) .unwrap(); - println!("Successfully initialized!"); + thread::sleep(Duration::from_secs(u64::MAX)); } @@ -87,4 +96,4 @@ unsafe extern "system" fn DllMain(_: HINSTANCE, call_reason: u32, _: *mut ()) -> } true -} +} \ No newline at end of file diff --git a/src/offsets.rs b/src/offsets.rs index 41d935f..0b506b2 100644 --- a/src/offsets.rs +++ b/src/offsets.rs @@ -10,6 +10,7 @@ pub(crate) struct DisableSdkConfiguration { pub(crate) struct InjectConfiguration { pub(crate) f_pak_file_check: usize, + pub(crate) f_pak_file_check_preamble: u128, pub(crate) kuro_http_get: usize, #[cfg(not(feature = "enable-sdk"))] pub(crate) disable_sdk: DisableSdkConfiguration, @@ -18,6 +19,7 @@ pub(crate) struct InjectConfiguration { #[cfg(feature = "cn_beta_1_3_0")] pub(crate) const CONFIG: InjectConfiguration = InjectConfiguration { f_pak_file_check: 0x3D2F460, + f_pak_file_check_preamble: 0x943D80000000A8EC8148574157565340, kuro_http_get: 0xFC8CF0, #[cfg(not(feature = "enable-sdk"))] disable_sdk: DisableSdkConfiguration{ @@ -30,6 +32,7 @@ pub(crate) const CONFIG: InjectConfiguration = InjectConfiguration { #[cfg(feature = "cn_live_1_3_0")] pub(crate) const CONFIG: InjectConfiguration = InjectConfiguration { f_pak_file_check: 0x3D35DF0, + f_pak_file_check_preamble: 0x943D80000000A8EC8148574157565340, kuro_http_get: 0xFC9900, #[cfg(not(feature = "enable-sdk"))] disable_sdk: DisableSdkConfiguration{ @@ -42,6 +45,7 @@ pub(crate) const CONFIG: InjectConfiguration = InjectConfiguration { #[cfg(feature = "os_live_1_3_0")] pub(crate) const CONFIG: InjectConfiguration = InjectConfiguration { f_pak_file_check: 0x3CDC430, + f_pak_file_check_preamble: 0x943D80000000A8EC8148574157565340, kuro_http_get: 0xFC6C20, #[cfg(not(feature = "enable-sdk"))] disable_sdk: DisableSdkConfiguration{