Skip to content

Commit ade04a1

Browse files
committed
fix: 修复解锁 120fps 和网络加密 patch
- 120fps: 改用 MOV EAX,60→120 的 pattern,不再依赖 DipSw 分支 - 网络加密: 恢复 known_offsets(aob_scan 无法搜索 .rdata 段字符串) - TLS: 保留 WinHttpOpenRequest IAT hook
1 parent 6fd9682 commit ade04a1

3 files changed

Lines changed: 35 additions & 114 deletions

File tree

src/config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ impl Config {
130130
.unwrap_or(default)
131131
}
132132

133-
pub fn get_bool(&self, section: &str, key: &str, default: bool) -> bool {
134-
self.section(section)
135-
.and_then(|table| table.get(key))
136-
.and_then(toml::Value::as_bool)
137-
.unwrap_or(default)
138-
}
139-
140133
pub fn get_string(&self, section: &str, key: &str, default: &str) -> String {
141134
self.section(section)
142135
.and_then(|table| table.get(key))

src/patches/network.rs

Lines changed: 27 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::config::Config;
2+
use crate::patch_engine::{apply_patch, PatchDef};
23
use crate::util::api::Api;
34
use crate::util::iat_hook::hook_iat;
4-
use crate::util::pattern;
55
use std::ffi::c_void;
66
use std::sync::atomic::{AtomicUsize, Ordering};
77

@@ -18,103 +18,35 @@ type WinHttpOpenRequestFn = unsafe extern "system" fn(
1818
static ORIG_OPEN_REQUEST: AtomicUsize = AtomicUsize::new(0);
1919

2020
pub fn apply(api: &Api, config: &Config) {
21-
apply_disable_encryption(api, config);
21+
apply_patch(
22+
api,
23+
config,
24+
&PatchDef {
25+
name: "关闭网络加密 1",
26+
section: "DisableEncryption",
27+
pattern: None,
28+
pattern_offset: 0,
29+
known_offsets: &[0x17D200C],
30+
expected: &[0xF5],
31+
patch: &[0x00],
32+
},
33+
);
34+
apply_patch(
35+
api,
36+
config,
37+
&PatchDef {
38+
name: "关闭网络加密 2",
39+
section: "DisableEncryption",
40+
pattern: None,
41+
pattern_offset: 0,
42+
known_offsets: &[0x17D2010],
43+
expected: &[0xF5],
44+
patch: &[0x00],
45+
},
46+
);
2247
apply_disable_tls(api, config);
2348
}
2449

25-
fn apply_disable_encryption(api: &Api, config: &Config) {
26-
if !config.is_enabled("DisableEncryption") {
27-
return;
28-
}
29-
30-
let found = pattern::scan_bytes(api, b"cannot encrypt.\0");
31-
if found == 0 {
32-
api.log_warn("关闭网络加密: 未找到加密标识字符串");
33-
return;
34-
}
35-
36-
let addr_bytes = (found as u32).to_le_bytes();
37-
// 68 [addr] = PUSH <string_addr>
38-
let mut push_sig = [0u8; 5];
39-
push_sig[0] = 0x68;
40-
push_sig[1..5].copy_from_slice(&addr_bytes);
41-
42-
let text_base = api.text_base();
43-
let text_size = api.text_size();
44-
let mut search_start = text_base;
45-
let mut patched = 0u32;
46-
47-
loop {
48-
let remaining = text_size.saturating_sub((search_start - text_base) as u32);
49-
if remaining < 5 {
50-
break;
51-
}
52-
53-
let push_site = api.aob_scan(search_start, remaining, &push_sig, "xxxxx");
54-
if push_site == 0 {
55-
break;
56-
}
57-
58-
if let Some(func_start) = find_function_start(api, push_site, text_base) {
59-
if patch_encrypt_flag_in_function(api, func_start, push_site) {
60-
patched += 1;
61-
}
62-
}
63-
64-
search_start = push_site + 5;
65-
}
66-
67-
if patched > 0 {
68-
api.log_info(&format!("补丁已应用: 关闭网络加密 ({patched} 处)"));
69-
} else {
70-
api.log_warn("关闭网络加密: 未找到加密标志");
71-
}
72-
}
73-
74-
fn find_function_start(api: &Api, addr: usize, text_base: usize) -> Option<usize> {
75-
// 55 8B EC 6A FF = PUSH EBP / MOV EBP,ESP / PUSH -1
76-
let prologue = [0x55, 0x8B, 0xEC, 0x6A, 0xFF];
77-
for back in 1..0x800usize {
78-
let candidate = addr.checked_sub(back)?;
79-
if candidate < text_base {
80-
return None;
81-
}
82-
let mut buf = [0u8; 5];
83-
if api.mem_read(candidate, &mut buf) && buf == prologue {
84-
return Some(candidate);
85-
}
86-
}
87-
None
88-
}
89-
90-
fn patch_encrypt_flag_in_function(api: &Api, func_start: usize, ref_site: usize) -> bool {
91-
let func_end = ref_site + 0x200;
92-
// MOV dword ptr [param_1+4], imm32 → C7 41 04 xx xx xx xx
93-
let mut scan_addr = func_start;
94-
while scan_addr < func_end {
95-
let remaining = (func_end - scan_addr) as u32;
96-
if remaining < 7 {
97-
break;
98-
}
99-
let site = api.aob_scan(scan_addr, remaining, &[0xC7, 0x41, 0x04], "xxx");
100-
if site == 0 {
101-
break;
102-
}
103-
let mut val_buf = [0u8; 4];
104-
if api.mem_read(site + 3, &mut val_buf) {
105-
let val = u32::from_le_bytes(val_buf);
106-
if val != 0 && val < 0x1000 {
107-
let zero = [0u8; 4];
108-
if api.mem_write(site + 3, &zero) {
109-
return true;
110-
}
111-
}
112-
}
113-
scan_addr = site + 7;
114-
}
115-
false
116-
}
117-
11850
fn apply_disable_tls(api: &Api, config: &Config) {
11951
if !config.is_enabled("DisableTLS") {
12052
return;

src/patches/unlock_120fps.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@ pub fn apply(api: &Api, config: &Config) {
77
return;
88
}
99

10-
let patch_name = if config.get_bool("Unlock120fps", "force", false) {
11-
"强制解锁 120fps"
12-
} else {
13-
"解锁 120fps"
14-
};
15-
16-
// v2.45 的 120fps 解锁与 120Hz 检测绕过共用同一处分支补丁。
10+
// B9 78 00 00 00 B8 3C 00 00 00 0F 45 C1
11+
// = MOV ECX,120 / MOV EAX,60 / CMOVNZ EAX,ECX
12+
// 改 MOV EAX,60 → MOV EAX,120 强制 120fps
1713
apply_patch(
1814
api,
1915
config,
2016
&PatchDef {
21-
name: patch_name,
17+
name: "解锁 120fps",
2218
section: "Unlock120fps",
23-
pattern: Some("85 C0 74 3F ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 81 BC 24 34 02 00 00 80 07 00 00"),
24-
pattern_offset: 0,
19+
pattern: Some("B9 78 00 00 00 B8 3C 00 00 00 0F 45 C1"),
20+
pattern_offset: 5,
2521
known_offsets: &[],
26-
expected: &[0x85, 0xC0, 0x74, 0x3F],
27-
patch: &[0xEB, 0x30, 0xEB, 0x2E],
22+
expected: &[0xB8, 0x3C, 0x00, 0x00, 0x00],
23+
patch: &[0xB8, 0x78, 0x00, 0x00, 0x00],
2824
},
2925
);
3026
}

0 commit comments

Comments
 (0)