forked from reversedrooms/hk4e-patch
Update for OSRELWin5.0.0
This commit is contained in:
parent
6d5a9f2098
commit
67bc2a2aaa
5 changed files with 7 additions and 95 deletions
|
@ -1,3 +1,3 @@
|
|||
# hk4e-patch
|
||||
|
||||
Genshin Impact encryption patch (4.8.50)
|
||||
Genshin Impact encryption patch (5.0.0)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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<Self, Box<dyn std::error::Error>> {
|
||||
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<T>(&self, func_name: &CStr) -> Result<Symbol<T>, 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::<Symbol<*mut usize>>(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
|
||||
}
|
Loading…
Reference in a new issue