diff --git a/src/lib.rs b/src/lib.rs index 08494f7..6c59968 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ unsafe fn thread_func() { util::disable_memprotect_guard(); Console::AllocConsole().unwrap(); - println!("Genshin Impact encryption patch\nMade by xeondev\nTo work with XilonenImpact: git.xeondev.com/reversedrooms/XilonenImpact"); + println!("Genshin Impact encryption patch\nMade by xeondev\nTo work with sakura-rs: git.xeondev.com/sakura-rs/sakura-rs"); println!("Base: {:X}", base); module_manager.enable(MhyContext::::new(base)); @@ -43,6 +43,7 @@ lazy_static! { } #[no_mangle] +#[allow(non_snake_case)] unsafe extern "system" fn DllMain(_: HINSTANCE, call_reason: u32, _: *mut ()) -> bool { if call_reason == DLL_PROCESS_ATTACH { std::thread::spawn(|| thread_func()); diff --git a/src/marshal.rs b/src/marshal.rs index 59ba5a7..f1a72cb 100644 --- a/src/marshal.rs +++ b/src/marshal.rs @@ -2,7 +2,7 @@ use std::ffi::CStr; use windows::{core::PCSTR, Win32::System::LibraryLoader::GetModuleHandleA}; -const PTR_TO_STRING_ANSI: usize = 0xF33F640; +const PTR_TO_STRING_ANSI: usize = 0xF85E020; type MarshalPtrToStringAnsi = unsafe extern "fastcall" fn(*const u8) -> *const u8; pub unsafe fn ptr_to_string_ansi(content: &CStr) -> *const u8 { diff --git a/src/modules/ccp_blocker.rs b/src/modules/ccp_blocker.rs index dc5a57e..f818215 100644 --- a/src/modules/ccp_blocker.rs +++ b/src/modules/ccp_blocker.rs @@ -30,9 +30,9 @@ impl MhyModule for MhyContext { unsafe extern "win64" fn on_getaddrinfo(reg: *mut Registers, _: usize) { let host_ptr = (*reg).rcx as *const i8; - let host = CStr::from_ptr(host_ptr); + let host = CStr::from_ptr(host_ptr).to_string_lossy(); - if host.to_string_lossy() == "dispatchcnglobal.yuanshen.com" { + if host == "dispatchosglobal.yuanshen.com" || host == "dispatchcnglobal.yuanshen.com" { std::ptr::copy_nonoverlapping(c"0.0.0.0".as_ptr(), (*reg).rcx as *mut i8, 9); } } diff --git a/src/modules/http.rs b/src/modules/http.rs index 0d19ce8..a44fd20 100644 --- a/src/modules/http.rs +++ b/src/modules/http.rs @@ -5,8 +5,8 @@ use crate::marshal; use anyhow::Result; use ilhook::x64::Registers; -const WEB_REQUEST_UTILS_MAKE_INITIAL_URL: usize = 0xFFDA8B0; -const BROWSER_LOAD_URL: usize = 0xFE06E40; +const WEB_REQUEST_UTILS_MAKE_INITIAL_URL: usize = 0x10421E00; +const BROWSER_LOAD_URL: usize = 0x10222B20; pub struct Http; diff --git a/src/modules/misc.rs b/src/modules/misc.rs index 2ab8a7c..bab72e6 100644 --- a/src/modules/misc.rs +++ b/src/modules/misc.rs @@ -1,21 +1,13 @@ -use std::ffi::CStr; - use super::{MhyContext, MhyModule, ModuleType}; use anyhow::Result; use ilhook::x64::Registers; -use windows::{core::PCSTR, Win32::System::LibraryLoader::GetModuleHandleA}; pub struct Misc; -const DYNAMIC_IMPORT: usize = 0x3F5240; -const SET_CUSTOM_PROPERTY_FLOAT: usize = 0x11E1880; +const SET_CUSTOM_PROPERTY_FLOAT: usize = 0x12199F0; impl MhyModule for MhyContext { unsafe fn init(&mut self) -> Result<()> { - // CNCBWin5.0.50 sound fix - self.interceptor - .attach(self.assembly_base + DYNAMIC_IMPORT, on_dynamic_import)?; - // Dither self.interceptor.replace( self.assembly_base + SET_CUSTOM_PROPERTY_FLOAT, @@ -32,17 +24,6 @@ impl MhyModule for MhyContext { } } -unsafe extern "win64" fn on_dynamic_import(reg: *mut Registers, _: usize) { - let symbol_name_ptr = *((*reg).rcx.wrapping_add(16) as *const usize); - let symbol_name = CStr::from_ptr(symbol_name_ptr as *const i8); - - // Hoyo forgot to package updated sound library and that's the missing export - if symbol_name.to_string_lossy() == "GetMusicSyncCallbackInfoPlayingSeq" { - let base = GetModuleHandleA(PCSTR::null()).unwrap().0 as usize; - *((*reg).rcx.wrapping_add(16) as *mut usize) = base + 0x2F6CD04; - } -} - unsafe extern "win64" fn set_custom_property_float_replacement( _: *mut Registers, _: usize, diff --git a/src/modules/security.rs b/src/modules/security.rs index eb16428..ca8a974 100644 --- a/src/modules/security.rs +++ b/src/modules/security.rs @@ -6,9 +6,9 @@ use super::{MhyContext, MhyModule, ModuleType}; use anyhow::Result; use ilhook::x64::Registers; -const MHYRSA_PERFORM_CRYPTO_ACTION: usize = 0x9DD5C8; -const KEY_SIGN_CHECK: usize = 0x9DF4BC; -const SDK_UTIL_RSA_ENCRYPT: usize = 0xF7A73C0; +const MHYRSA_PERFORM_CRYPTO_ACTION: usize = 0x95ED88; +const KEY_SIGN_CHECK: usize = 0x960C7C; +const SDK_UTIL_RSA_ENCRYPT: usize = 0xFC0CC30; const KEY_SIZE: usize = 268; static SERVER_PUBLIC_KEY: &[u8] = include_bytes!("../../server_public_key.bin");