Skip to content

Commit 05fe49a

Browse files
committed
Replace the account name with wxid if it is empty.
1 parent 019ec60 commit 05fe49a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wechat-dump-rs"
3-
version = "1.0.17"
3+
version = "1.0.18"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

src/main.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,15 @@ fn read_string(pid: u32, addr: usize, size: usize) -> Result<String> {
185185

186186
CloseHandle(hprocess)?;
187187

188-
match buffer.iter().position(|&x| x == 0) {
189-
Some(pos) => Ok(String::from_utf8(buffer[..pos].to_vec())?),
190-
None => Ok(String::from_utf8(buffer)?),
188+
let buf_str = match buffer.iter().position(|&x| x == 0) {
189+
Some(pos) => String::from_utf8(buffer[..pos].to_vec())?,
190+
None => String::from_utf8(buffer)?,
191+
};
192+
193+
if buf_str.len() != size {
194+
Err(anyhow::anyhow!("invalid utf8 string"))
195+
} else {
196+
Ok(buf_str)
191197
}
192198
}
193199
}
@@ -520,9 +526,16 @@ fn dump_wechat_info_v4(
520526
read_string_or_ptr(pid, phone_str_address - 0x20, nick_name_length as usize).unwrap();
521527

522528
let account_name_length = read_number::<u64>(pid, phone_str_address - 0x30).unwrap();
523-
let account_name =
529+
let mut account_name =
524530
read_string_or_ptr(pid, phone_str_address - 0x40, account_name_length as _).unwrap();
525531

532+
// No account name
533+
if account_name.is_empty() {
534+
let wxid_length = read_number::<u64>(pid, phone_str_address - 0x50).unwrap();
535+
let wxid = read_string_or_ptr(pid, phone_str_address - 0x60, wxid_length as _).unwrap();
536+
account_name = wxid;
537+
}
538+
526539
let data_dir = if special_data_dir.is_some() {
527540
special_data_dir
528541
.unwrap()
@@ -1060,7 +1073,7 @@ fn cli() -> clap::Command {
10601073
use clap::{arg, value_parser, Command};
10611074

10621075
Command::new("wechat-dump-rs")
1063-
.version("1.0.17")
1076+
.version("1.0.18")
10641077
.about("A wechat db dump tool")
10651078
.author("REinject")
10661079
.help_template("{name} ({version}) - {author}\n{about}\n{all-args}")

0 commit comments

Comments
 (0)