Compare commits
No commits in common. "master" and "0.1.4" have entirely different histories.
7 changed files with 30 additions and 56 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -3,7 +3,7 @@
|
||||||
use std::{sync::RwLock, time::Duration};
|
use std::{sync::RwLock, time::Duration};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use modules::{CcpBlocker, Misc};
|
use modules::Misc;
|
||||||
use windows::core::PCSTR;
|
use windows::core::PCSTR;
|
||||||
use windows::Win32::System::Console;
|
use windows::Win32::System::Console;
|
||||||
use windows::Win32::System::SystemServices::DLL_PROCESS_ATTACH;
|
use windows::Win32::System::SystemServices::DLL_PROCESS_ATTACH;
|
||||||
|
@ -18,19 +18,16 @@ use crate::modules::{Http, MhyContext, ModuleManager, Security};
|
||||||
|
|
||||||
unsafe fn thread_func() {
|
unsafe fn thread_func() {
|
||||||
let base = GetModuleHandleA(PCSTR::null()).unwrap().0 as usize;
|
let base = GetModuleHandleA(PCSTR::null()).unwrap().0 as usize;
|
||||||
let mut module_manager = MODULE_MANAGER.write().unwrap();
|
|
||||||
|
|
||||||
// Block query_security_file ASAP
|
std::thread::sleep(Duration::from_secs(12));
|
||||||
module_manager.enable(MhyContext::<CcpBlocker>::new(base));
|
|
||||||
|
|
||||||
std::thread::sleep(Duration::from_secs(14));
|
|
||||||
|
|
||||||
util::disable_memprotect_guard();
|
util::disable_memprotect_guard();
|
||||||
Console::AllocConsole().unwrap();
|
Console::AllocConsole().unwrap();
|
||||||
|
|
||||||
println!("Genshin Impact encryption patch\nMade by xeondev\nTo work with sakura-rs: git.xeondev.com/sakura-rs/sakura-rs");
|
println!("Genshin Impact encryption patch\nMade by xeondev\nTo work with XilonenImpact: git.xeondev.com/reversedrooms/XilonenImpact");
|
||||||
println!("Base: {:X}", base);
|
println!("Base: {:X}", base);
|
||||||
|
|
||||||
|
let mut module_manager = MODULE_MANAGER.write().unwrap();
|
||||||
module_manager.enable(MhyContext::<Http>::new(base));
|
module_manager.enable(MhyContext::<Http>::new(base));
|
||||||
module_manager.enable(MhyContext::<Security>::new(base));
|
module_manager.enable(MhyContext::<Security>::new(base));
|
||||||
module_manager.enable(MhyContext::<Misc>::new(base));
|
module_manager.enable(MhyContext::<Misc>::new(base));
|
||||||
|
@ -43,7 +40,6 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_snake_case)]
|
|
||||||
unsafe extern "system" fn DllMain(_: HINSTANCE, call_reason: u32, _: *mut ()) -> bool {
|
unsafe extern "system" fn DllMain(_: HINSTANCE, call_reason: u32, _: *mut ()) -> bool {
|
||||||
if call_reason == DLL_PROCESS_ATTACH {
|
if call_reason == DLL_PROCESS_ATTACH {
|
||||||
std::thread::spawn(|| thread_func());
|
std::thread::spawn(|| thread_func());
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::ffi::CStr;
|
||||||
|
|
||||||
use windows::{core::PCSTR, Win32::System::LibraryLoader::GetModuleHandleA};
|
use windows::{core::PCSTR, Win32::System::LibraryLoader::GetModuleHandleA};
|
||||||
|
|
||||||
const PTR_TO_STRING_ANSI: usize = 0xF85E020;
|
const PTR_TO_STRING_ANSI: usize = 0xF33F640;
|
||||||
type MarshalPtrToStringAnsi = unsafe extern "fastcall" fn(*const u8) -> *const u8;
|
type MarshalPtrToStringAnsi = unsafe extern "fastcall" fn(*const u8) -> *const u8;
|
||||||
|
|
||||||
pub unsafe fn ptr_to_string_ansi(content: &CStr) -> *const u8 {
|
pub unsafe fn ptr_to_string_ansi(content: &CStr) -> *const u8 {
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
use std::ffi::CStr;
|
|
||||||
|
|
||||||
use super::{MhyContext, MhyModule, ModuleType};
|
|
||||||
use anyhow::Result;
|
|
||||||
use ilhook::x64::Registers;
|
|
||||||
use windows::{
|
|
||||||
core::s,
|
|
||||||
Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct CcpBlocker;
|
|
||||||
|
|
||||||
impl MhyModule for MhyContext<CcpBlocker> {
|
|
||||||
unsafe fn init(&mut self) -> Result<()> {
|
|
||||||
let winsock2 = GetModuleHandleA(s!("Ws2_32.dll")).unwrap();
|
|
||||||
let getaddrinfo = GetProcAddress(winsock2, s!("getaddrinfo")).unwrap();
|
|
||||||
|
|
||||||
self.interceptor
|
|
||||||
.attach(getaddrinfo as usize, on_getaddrinfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn de_init(&mut self) -> Result<()> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_module_type(&self) -> super::ModuleType {
|
|
||||||
ModuleType::CcpBlocker
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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).to_string_lossy();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,8 +5,8 @@ use crate::marshal;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ilhook::x64::Registers;
|
use ilhook::x64::Registers;
|
||||||
|
|
||||||
const WEB_REQUEST_UTILS_MAKE_INITIAL_URL: usize = 0x10421E00;
|
const WEB_REQUEST_UTILS_MAKE_INITIAL_URL: usize = 0xFFDA8B0;
|
||||||
const BROWSER_LOAD_URL: usize = 0x10222B20;
|
const BROWSER_LOAD_URL: usize = 0xFE06E40;
|
||||||
|
|
||||||
pub struct Http;
|
pub struct Http;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
|
use std::ffi::CStr;
|
||||||
|
|
||||||
use super::{MhyContext, MhyModule, ModuleType};
|
use super::{MhyContext, MhyModule, ModuleType};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ilhook::x64::Registers;
|
use ilhook::x64::Registers;
|
||||||
|
use windows::{core::PCSTR, Win32::System::LibraryLoader::GetModuleHandleA};
|
||||||
|
|
||||||
pub struct Misc;
|
pub struct Misc;
|
||||||
|
|
||||||
const SET_CUSTOM_PROPERTY_FLOAT: usize = 0x12199F0;
|
const DYNAMIC_IMPORT: usize = 0x3F5240;
|
||||||
|
const SET_CUSTOM_PROPERTY_FLOAT: usize = 0x11E1880;
|
||||||
|
|
||||||
impl MhyModule for MhyContext<Misc> {
|
impl MhyModule for MhyContext<Misc> {
|
||||||
unsafe fn init(&mut self) -> Result<()> {
|
unsafe fn init(&mut self) -> Result<()> {
|
||||||
|
// CNCBWin5.0.50 sound fix
|
||||||
|
self.interceptor
|
||||||
|
.attach(self.assembly_base + DYNAMIC_IMPORT, on_dynamic_import)?;
|
||||||
|
|
||||||
// Dither
|
// Dither
|
||||||
self.interceptor.replace(
|
self.interceptor.replace(
|
||||||
self.assembly_base + SET_CUSTOM_PROPERTY_FLOAT,
|
self.assembly_base + SET_CUSTOM_PROPERTY_FLOAT,
|
||||||
|
@ -24,6 +32,17 @@ impl MhyModule for MhyContext<Misc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
unsafe extern "win64" fn set_custom_property_float_replacement(
|
||||||
_: *mut Registers,
|
_: *mut Registers,
|
||||||
_: usize,
|
_: usize,
|
||||||
|
|
|
@ -4,12 +4,10 @@ use anyhow::Result;
|
||||||
|
|
||||||
use crate::interceptor::Interceptor;
|
use crate::interceptor::Interceptor;
|
||||||
|
|
||||||
mod ccp_blocker;
|
|
||||||
mod http;
|
mod http;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod security;
|
mod security;
|
||||||
|
|
||||||
pub use ccp_blocker::CcpBlocker;
|
|
||||||
pub use http::Http;
|
pub use http::Http;
|
||||||
pub use misc::Misc;
|
pub use misc::Misc;
|
||||||
pub use security::Security;
|
pub use security::Security;
|
||||||
|
@ -43,7 +41,6 @@ pub enum ModuleType {
|
||||||
Http,
|
Http,
|
||||||
Security,
|
Security,
|
||||||
Misc,
|
Misc,
|
||||||
CcpBlocker,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MhyModule {
|
pub trait MhyModule {
|
||||||
|
|
|
@ -6,9 +6,9 @@ use super::{MhyContext, MhyModule, ModuleType};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ilhook::x64::Registers;
|
use ilhook::x64::Registers;
|
||||||
|
|
||||||
const MHYRSA_PERFORM_CRYPTO_ACTION: usize = 0x95ED88;
|
const MHYRSA_PERFORM_CRYPTO_ACTION: usize = 0x9DD5C8;
|
||||||
const KEY_SIGN_CHECK: usize = 0x960C7C;
|
const KEY_SIGN_CHECK: usize = 0x9DF4BC;
|
||||||
const SDK_UTIL_RSA_ENCRYPT: usize = 0xFC0CC30;
|
const SDK_UTIL_RSA_ENCRYPT: usize = 0xF7A73C0;
|
||||||
|
|
||||||
const KEY_SIZE: usize = 268;
|
const KEY_SIZE: usize = 268;
|
||||||
static SERVER_PUBLIC_KEY: &[u8] = include_bytes!("../../server_public_key.bin");
|
static SERVER_PUBLIC_KEY: &[u8] = include_bytes!("../../server_public_key.bin");
|
||||||
|
|
Loading…
Reference in a new issue