From 67bc2a2aaaeced49cf96a2100184eaeebf118ac1 Mon Sep 17 00:00:00 2001 From: xeon Date: Tue, 27 Aug 2024 00:25:10 +0300 Subject: [PATCH] Update for OSRELWin5.0.0 --- README.md | 2 +- src/marshal.rs | 2 +- src/modules/http.rs | 4 +- src/modules/security.rs | 6 +-- src/version.rs | 88 ----------------------------------------- 5 files changed, 7 insertions(+), 95 deletions(-) delete mode 100644 src/version.rs diff --git a/README.md b/README.md index 961ec5f..baf2031 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # hk4e-patch -Genshin Impact encryption patch (4.8.50) +Genshin Impact encryption patch (5.0.0) diff --git a/src/marshal.rs b/src/marshal.rs index f85aea3..c0cf23d 100644 --- a/src/marshal.rs +++ b/src/marshal.rs @@ -2,7 +2,7 @@ use std::ffi::CStr; use crate::util; -const PTR_TO_STRING_ANSI: usize = 0x104F80F0; +const PTR_TO_STRING_ANSI: usize = 0x103CBB00; 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/http.rs b/src/modules/http.rs index 99ab612..67e9a08 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 = 0x1119FF40; -const BROWSER_LOAD_URL: usize = 0x10FD8450; +const WEB_REQUEST_UTILS_MAKE_INITIAL_URL: usize = 0x110107A0; +const BROWSER_LOAD_URL: usize = 0x10E55670; pub struct Http; diff --git a/src/modules/security.rs b/src/modules/security.rs index bcd8bbc..4add928 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 = 0xC3DEDB; -const KEY_SIGN_CHECK: usize = 0xC4236D; -const SDK_UTIL_RSA_ENCRYPT: usize = 0x10A02A60; +const MHYRSA_PERFORM_CRYPTO_ACTION: usize = 0xC37F9B; +const KEY_SIGN_CHECK: usize = 0xC3C42D; +const SDK_UTIL_RSA_ENCRYPT: usize = 0x1088E510; const KEY_SIZE: usize = 268; static SERVER_PUBLIC_KEY: &[u8] = include_bytes!("../../server_public_key.bin"); diff --git a/src/version.rs b/src/version.rs deleted file mode 100644 index b463125..0000000 --- a/src/version.rs +++ /dev/null @@ -1,88 +0,0 @@ -use libloading::{Error, Library, Symbol}; -use std::arch::asm; -use std::env; -use std::ffi::{CStr, CString}; - -pub struct VersionDllProxy { - library: Library, -} - -impl VersionDllProxy { - pub fn new() -> Result> { - let system_directory = env::var("windir")? + ("\\System32\\"); - let dll_path = system_directory + "version.dll"; - let library = unsafe { Library::new(dll_path) }?; - Ok(Self { library }) - } - - fn get_function(&self, func_name: &CStr) -> Result, Error> { - unsafe { self.library.get(func_name.to_bytes_with_nul()) } - } - - pub fn load_functions(&self) -> Result<(), Error> { - for (i, &name) in FUNCTION_NAMES.iter().enumerate() { - let fn_ptr = self.get_function::>(name)?; - unsafe { ORIGINAL_FUNCTIONS[i] = **fn_ptr }; - println!("Loaded function {}@{:p}", name.to_str().unwrap(), unsafe { - ORIGINAL_FUNCTIONS[i] - }); - } - Ok(()) - } -} - -macro_rules! count_exprs { - () => {0usize}; - ($head:expr, $($tail:expr,)*) => {1usize + count_exprs!($($tail,)*)}; -} - -macro_rules! version_dll_proxy { - ($($fn_name:ident),*) => { - static FUNCTION_NAMES: &[&CStr] = &[ - $( - unsafe { CStr::from_bytes_with_nul_unchecked(concat!(stringify!($fn_name), "\0").as_bytes()) } - ),*, - ]; - - #[no_mangle] - static mut ORIGINAL_FUNCTIONS: [*const usize; count_exprs!($($fn_name,)*)] = [0 as *const usize; count_exprs!($($fn_name,)*)]; - - $( - #[no_mangle] - extern "C" fn $fn_name() { - let function_name = FUNCTION_NAMES - .iter() - .position(|&name| name == CString::new(stringify!($fn_name)).unwrap().as_ref()) - .unwrap(); - let fn_addr = unsafe { ORIGINAL_FUNCTIONS[function_name] }; - unsafe { - asm! { - "call {tmp}", - tmp = in(reg) fn_addr, - clobber_abi("C") - } - } - } - )* - }; -} - -version_dll_proxy! { - GetFileVersionInfoA, - GetFileVersionInfoByHandle, - GetFileVersionInfoExA, - GetFileVersionInfoExW, - GetFileVersionInfoSizeA, - GetFileVersionInfoSizeExA, - GetFileVersionInfoSizeExW, - GetFileVersionInfoSizeW, - GetFileVersionInfoW, - VerFindFileA, - VerFindFileW, - VerInstallFileA, - VerInstallFileW, - VerLanguageNameA, - VerLanguageNameW, - VerQueryValueA, - VerQueryValueW -}