forked from ObolSquad/trigger-patch
Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
8c1ea6605f | |||
c264b37593 |
6 changed files with 48 additions and 33 deletions
|
@ -12,7 +12,7 @@ use windows::Win32::System::Threading::{
|
||||||
PROCESS_INFORMATION, STARTUPINFOA,
|
PROCESS_INFORMATION, STARTUPINFOA,
|
||||||
};
|
};
|
||||||
|
|
||||||
const GAME_EXECUTABLE: PCSTR = s!("ZenlessZoneZeroBeta.exe");
|
const GAME_EXECUTABLE: PCSTR = s!("ZenlessZoneZero.exe");
|
||||||
const INJECT_DLL: &str = "trigger.dll";
|
const INJECT_DLL: &str = "trigger.dll";
|
||||||
|
|
||||||
fn inject_standard(h_target: HANDLE, dll_path: &str) -> bool {
|
fn inject_standard(h_target: HANDLE, dll_path: &str) -> bool {
|
||||||
|
|
|
@ -4,12 +4,9 @@ use std::{thread, time::Duration};
|
||||||
|
|
||||||
use interceptor::Interceptor;
|
use interceptor::Interceptor;
|
||||||
use modules::{
|
use modules::{
|
||||||
censorship_patch::CensorshipPatch,
|
censorship_patch::CensorshipPatch, crypto::{
|
||||||
crypto::{
|
|
||||||
initialize_rsa_public_key, monitor_network_state, replace_sdk_public_key_string_literal,
|
initialize_rsa_public_key, monitor_network_state, replace_sdk_public_key_string_literal,
|
||||||
},
|
}, hoyopass_patch::HoyopassPatch, network::Network, NapModuleManager
|
||||||
network::Network,
|
|
||||||
NapModuleManager,
|
|
||||||
};
|
};
|
||||||
use windows::{
|
use windows::{
|
||||||
core::s,
|
core::s,
|
||||||
|
@ -36,6 +33,7 @@ unsafe fn thread_fn() {
|
||||||
let mut module_manager = NapModuleManager::default();
|
let mut module_manager = NapModuleManager::default();
|
||||||
module_manager.add::<Network>();
|
module_manager.add::<Network>();
|
||||||
module_manager.add::<CensorshipPatch>();
|
module_manager.add::<CensorshipPatch>();
|
||||||
|
module_manager.add::<HoyopassPatch>();
|
||||||
module_manager.init().expect("failed to initialize modules");
|
module_manager.init().expect("failed to initialize modules");
|
||||||
|
|
||||||
initialize_rsa_public_key();
|
initialize_rsa_public_key();
|
||||||
|
|
|
@ -7,14 +7,14 @@ use crate::{
|
||||||
util::{import, read_csharp_string, GAME_ASSEMBLY_BASE},
|
util::{import, read_csharp_string, GAME_ASSEMBLY_BASE},
|
||||||
};
|
};
|
||||||
|
|
||||||
import!(rsa_create() -> usize = 0x69100D0);
|
import!(rsa_create() -> usize = 0x18F33050);
|
||||||
import!(rsa_from_xml_string(instance: usize, xml_string: usize) -> usize = 0x6910310);
|
import!(rsa_from_xml_string(instance: usize, xml_string: usize) -> usize = 0x18F33290);
|
||||||
import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x3538F0);
|
import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x2E7FC0);
|
||||||
|
|
||||||
pub unsafe fn initialize_rsa_public_key() {
|
pub unsafe fn initialize_rsa_public_key() {
|
||||||
const SERVER_PUBLIC_KEY: &str = include_str!("../../server_public_key.xml");
|
const SERVER_PUBLIC_KEY: &str = include_str!("../../server_public_key.xml");
|
||||||
let rsa_public_key_backdoor_field =
|
let rsa_public_key_backdoor_field =
|
||||||
((*(GAME_ASSEMBLY_BASE.wrapping_add(0x4F251C0) as *const usize)) + 244080) as *mut usize;
|
((*(GAME_ASSEMBLY_BASE.wrapping_add(0x4EB7100) as *const usize)) + 244072) as *mut usize;
|
||||||
|
|
||||||
let rsa = rsa_create();
|
let rsa = rsa_create();
|
||||||
rsa_from_xml_string(
|
rsa_from_xml_string(
|
||||||
|
@ -33,14 +33,14 @@ pub unsafe fn initialize_rsa_public_key() {
|
||||||
pub unsafe fn replace_sdk_public_key_string_literal() {
|
pub unsafe fn replace_sdk_public_key_string_literal() {
|
||||||
const SDK_PUBLIC_KEY: &str = include_str!("../../sdk_public_key.xml");
|
const SDK_PUBLIC_KEY: &str = include_str!("../../sdk_public_key.xml");
|
||||||
|
|
||||||
*(GAME_ASSEMBLY_BASE.wrapping_add(0x5237348) as *mut usize) = il2cpp_string_new(
|
*(GAME_ASSEMBLY_BASE.wrapping_add(0x51C92D8) as *mut usize) = il2cpp_string_new(
|
||||||
CString::new(SDK_PUBLIC_KEY)
|
CString::new(SDK_PUBLIC_KEY)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_bytes_with_nul()
|
.to_bytes_with_nul()
|
||||||
.as_ptr(),
|
.as_ptr(),
|
||||||
) as usize;
|
) as usize;
|
||||||
|
|
||||||
*(GAME_ASSEMBLY_BASE.wrapping_add(0x5257948) as *mut usize) = il2cpp_string_new(
|
*(GAME_ASSEMBLY_BASE.wrapping_add(0x5257950) as *mut usize) = il2cpp_string_new(
|
||||||
[
|
[
|
||||||
27818, 40348, 47410, 27936, 51394, 33172, 51987, 33287, 44524, 39195, 47922, 8238,
|
27818, 40348, 47410, 27936, 51394, 33172, 51987, 33287, 44524, 39195, 47922, 8238,
|
||||||
53932, 42445, 929, 38470, 27758, 56475, 5938, 26471, 58462, 55701, 37675, 22326, 36428,
|
53932, 42445, 929, 38470, 27758, 56475, 5938, 26471, 58462, 55701, 37675, 22326, 36428,
|
||||||
|
@ -63,14 +63,14 @@ pub unsafe fn replace_sdk_public_key_string_literal() {
|
||||||
pub unsafe fn monitor_network_state(interceptor: &mut Interceptor) {
|
pub unsafe fn monitor_network_state(interceptor: &mut Interceptor) {
|
||||||
interceptor
|
interceptor
|
||||||
.attach(
|
.attach(
|
||||||
GAME_ASSEMBLY_BASE.wrapping_add(0x86F05A0),
|
GAME_ASSEMBLY_BASE.wrapping_add(0x773B460),
|
||||||
on_network_state_change,
|
on_network_state_change,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
interceptor
|
interceptor
|
||||||
.attach(
|
.attach(
|
||||||
GAME_ASSEMBLY_BASE.wrapping_add(0x9326760),
|
GAME_ASSEMBLY_BASE.wrapping_add(0x8F88960),
|
||||||
download_data_slave,
|
download_data_slave,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
32
trigger/src/modules/hoyopass_patch.rs
Normal file
32
trigger/src/modules/hoyopass_patch.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
use ilhook::x64::Registers;
|
||||||
|
|
||||||
|
use crate::util::GAME_ASSEMBLY_BASE;
|
||||||
|
|
||||||
|
use super::{ModuleInitError, NapModule, NapModuleContext};
|
||||||
|
|
||||||
|
const ON_COMBO_INIT_SUCCESS: usize = 0x18FAD620;
|
||||||
|
const STATICS: usize = 0x4EB7100;
|
||||||
|
const STATIC_ID: usize = 34352;
|
||||||
|
const FIELD_OFFSET: usize = 67;
|
||||||
|
|
||||||
|
pub struct HoyopassPatch;
|
||||||
|
|
||||||
|
impl NapModule for NapModuleContext<HoyopassPatch> {
|
||||||
|
unsafe fn init(&mut self) -> Result<(), ModuleInitError> {
|
||||||
|
self.interceptor.attach(
|
||||||
|
self.base.wrapping_add(ON_COMBO_INIT_SUCCESS),
|
||||||
|
HoyopassPatch::on_combo_init_success,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HoyopassPatch {
|
||||||
|
pub unsafe extern "win64" fn on_combo_init_success(_: *mut Registers, _: usize) {
|
||||||
|
let statics = *(GAME_ASSEMBLY_BASE.wrapping_add(STATICS) as *mut usize);
|
||||||
|
let config_manager = *(statics.wrapping_add(STATIC_ID) as *mut usize);
|
||||||
|
*(config_manager.wrapping_add(FIELD_OFFSET) as *mut bool) = false;
|
||||||
|
println!("HoYoPassPatch - OnComboInitSuccess()");
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ use crate::{interceptor::Interceptor, util};
|
||||||
|
|
||||||
pub mod censorship_patch;
|
pub mod censorship_patch;
|
||||||
pub mod crypto;
|
pub mod crypto;
|
||||||
|
pub mod hoyopass_patch;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
|
|
@ -2,12 +2,11 @@ use std::ffi::CString;
|
||||||
|
|
||||||
use ilhook::x64::Registers;
|
use ilhook::x64::Registers;
|
||||||
|
|
||||||
use crate::util::{self, import, read_csharp_string};
|
use crate::util::{self, import};
|
||||||
|
|
||||||
use super::{ModuleInitError, NapModule, NapModuleContext};
|
use super::{ModuleInitError, NapModule, NapModuleContext};
|
||||||
|
|
||||||
const MAKE_INITIAL_URL: usize = 0x7CE75F0;
|
const MAKE_INITIAL_URL: usize = 0x6D2C560;
|
||||||
const WEB_REQUEST_CREATE: usize = 0x798F080;
|
|
||||||
|
|
||||||
pub struct Network;
|
pub struct Network;
|
||||||
|
|
||||||
|
@ -18,26 +17,11 @@ impl NapModule for NapModuleContext<Network> {
|
||||||
Network::on_make_initial_url,
|
Network::on_make_initial_url,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.interceptor.attach(
|
|
||||||
self.base.wrapping_add(WEB_REQUEST_CREATE),
|
|
||||||
on_web_request_create,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "win64" fn on_web_request_create(reg: *mut Registers, _: usize) {
|
import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x2E7FC0);
|
||||||
let s = read_csharp_string((*reg).rcx as usize);
|
|
||||||
if s.contains("StandaloneWindows64/cn/") {
|
|
||||||
let s = s.replace("StandaloneWindows64/cn/", "StandaloneWindows64/oversea/");
|
|
||||||
println!("replaced: {s}");
|
|
||||||
(*reg).rcx =
|
|
||||||
il2cpp_string_new(CString::new(s).unwrap().to_bytes_with_nul().as_ptr()) as u64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x3538F0);
|
|
||||||
|
|
||||||
impl Network {
|
impl Network {
|
||||||
const SDK_URL: &str = "http://127.0.0.1:20100";
|
const SDK_URL: &str = "http://127.0.0.1:20100";
|
||||||
|
|
Loading…
Reference in a new issue