From a7b4174ffb10d393d1eb28e53ad5d1ca17c0657d Mon Sep 17 00:00:00 2001 From: traffic95 Date: Sat, 24 May 2025 00:25:44 +0200 Subject: [PATCH] CNBeta2.0.4 support --- launcher/src/main.rs | 2 +- vivian/src/lib.rs | 4 ++-- vivian/src/modules/crypto.rs | 10 +++++----- vivian/src/modules/hoyopass_patch.rs | 8 ++++---- vivian/src/modules/network.rs | 22 +++++++++++++++++++--- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 9f27341..b611481 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -12,7 +12,7 @@ use windows::Win32::System::Threading::{ PROCESS_INFORMATION, STARTUPINFOA, }; -const GAME_EXECUTABLE: PCSTR = s!("ZenlessZoneZero.exe"); +const GAME_EXECUTABLE: PCSTR = s!("ZenlessZoneZeroBeta.exe"); const INJECT_DLL: &str = "vivian.dll"; fn inject_standard(h_target: HANDLE, dll_path: &str) -> bool { diff --git a/vivian/src/lib.rs b/vivian/src/lib.rs index b958196..1999791 100644 --- a/vivian/src/lib.rs +++ b/vivian/src/lib.rs @@ -31,8 +31,8 @@ unsafe fn thread_fn() { thread::sleep(Duration::from_secs(5)); util::disable_memory_protection(); - println!("vivian-patch (1.7.0 PROD) is initializing"); - println!("to work with vivian-rs: https://git.xeondev.com/vivian-rs/vivian-rs"); + println!("vivian-patch (2.0.4 BETA) is initializing"); + println!("to work with vivian-rs: https://git.xeondev.com/traffic95/vivian-rs/src/branch/CNBeta2.0.4"); let mut module_manager = NapModuleManager::default(); module_manager.add::(); diff --git a/vivian/src/modules/crypto.rs b/vivian/src/modules/crypto.rs index 9085e4d..a141a50 100644 --- a/vivian/src/modules/crypto.rs +++ b/vivian/src/modules/crypto.rs @@ -7,14 +7,14 @@ use crate::{ util::{import, GAME_ASSEMBLY_BASE}, }; -import!(rsa_create() -> usize = 0x19034F20); -import!(rsa_from_xml_string(instance: usize, xml_string: usize) -> usize = 0x19035160); -import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x1242D60); +import!(rsa_create() -> usize = 0x1B56B2E0); +import!(rsa_from_xml_string(instance: usize, xml_string: usize) -> usize = 0x1B56B520); +import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x115F1B0); pub unsafe fn initialize_rsa_public_key() { const SERVER_PUBLIC_KEY: &str = include_str!("../../server_public_key.xml"); let rsa_public_key_backdoor_field = - ((*(GAME_ASSEMBLY_BASE.wrapping_add(0x4E072F0) as *const usize)) + 235872) as *mut usize; + ((*(GAME_ASSEMBLY_BASE.wrapping_add(0x5552100) as *const usize)) + 252792) as *mut usize; let rsa = rsa_create(); rsa_from_xml_string( @@ -44,7 +44,7 @@ pub unsafe fn replace_sdk_public_key_string_literal() { pub unsafe fn monitor_network_state(interceptor: &mut Interceptor) { interceptor .attach( - GAME_ASSEMBLY_BASE.wrapping_add(0xAE84F80), + GAME_ASSEMBLY_BASE.wrapping_add(0xD8AAEC0), on_network_state_change, ) .unwrap(); diff --git a/vivian/src/modules/hoyopass_patch.rs b/vivian/src/modules/hoyopass_patch.rs index 9ad2907..27f5abf 100644 --- a/vivian/src/modules/hoyopass_patch.rs +++ b/vivian/src/modules/hoyopass_patch.rs @@ -4,10 +4,10 @@ use crate::util::GAME_ASSEMBLY_BASE; use super::{ModuleInitError, NapModule, NapModuleContext}; -const ON_COMBO_INIT_SUCCESS: usize = 0x18AE4030; -const STATICS: usize = 0x4E072F0; -const STATIC_ID: usize = 34344; -const FIELD_OFFSET: usize = 0x48; +const ON_COMBO_INIT_SUCCESS: usize = 0x1ACA72F0; +const STATICS: usize = 0x5552100; +const STATIC_ID: usize = 34512; +const FIELD_OFFSET: usize = 64; pub struct HoyopassPatch; diff --git a/vivian/src/modules/network.rs b/vivian/src/modules/network.rs index ea56e98..b39299d 100644 --- a/vivian/src/modules/network.rs +++ b/vivian/src/modules/network.rs @@ -2,11 +2,12 @@ use std::ffi::CString; use ilhook::x64::Registers; -use crate::util::{self, import}; +use crate::util::{self, import, read_csharp_string}; use super::{ModuleInitError, NapModule, NapModuleContext}; -const MAKE_INITIAL_URL: usize = 0x1ACB6C70; +const MAKE_INITIAL_URL: usize = 0x1D1458E0; +const WEB_REQUEST_CREATE: usize = 0x1CC2D2A0; pub struct Network; @@ -17,11 +18,26 @@ impl NapModule for NapModuleContext { Network::on_make_initial_url, )?; + self.interceptor.attach( + self.base.wrapping_add(WEB_REQUEST_CREATE), + on_web_request_create, + )?; + Ok(()) } } -import!(il2cpp_string_new(cstr: *const u8) -> usize = 0x1242D60); +unsafe extern "win64" fn on_web_request_create(reg: *mut Registers, _: usize) { + 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 = 0x115F1B0); impl Network { const SDK_URL: &str = "http://127.0.0.1:20100";