@@ -185,9 +185,15 @@ fn read_string(pid: u32, addr: usize, size: usize) -> Result<String> {
185
185
186
186
CloseHandle ( hprocess) ?;
187
187
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)
191
197
}
192
198
}
193
199
}
@@ -520,9 +526,16 @@ fn dump_wechat_info_v4(
520
526
read_string_or_ptr ( pid, phone_str_address - 0x20 , nick_name_length as usize ) . unwrap ( ) ;
521
527
522
528
let account_name_length = read_number :: < u64 > ( pid, phone_str_address - 0x30 ) . unwrap ( ) ;
523
- let account_name =
529
+ let mut account_name =
524
530
read_string_or_ptr ( pid, phone_str_address - 0x40 , account_name_length as _ ) . unwrap ( ) ;
525
531
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
+
526
539
let data_dir = if special_data_dir. is_some ( ) {
527
540
special_data_dir
528
541
. unwrap ( )
@@ -1060,7 +1073,7 @@ fn cli() -> clap::Command {
1060
1073
use clap:: { arg, value_parser, Command } ;
1061
1074
1062
1075
Command :: new ( "wechat-dump-rs" )
1063
- . version ( "1.0.17 " )
1076
+ . version ( "1.0.18 " )
1064
1077
. about ( "A wechat db dump tool" )
1065
1078
. author ( "REinject" )
1066
1079
. help_template ( "{name} ({version}) - {author}\n {about}\n {all-args}" )
0 commit comments