Skip to content

Commit

Permalink
fixed #5
Browse files Browse the repository at this point in the history
  • Loading branch information
SpenserCai committed Mar 9, 2023
1 parent fc67d9d commit 5026b77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Binary file modified Release/GoWxDump.exe
Binary file not shown.
37 changes: 33 additions & 4 deletions wechat_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"unsafe"

"golang.org/x/sys/windows/registry"

"golang.org/x/sys/windows"
)

Expand Down Expand Up @@ -118,14 +120,41 @@ func GetWeChatKey(process windows.Handle, offset uintptr) (string, error) {

}

func GetWeChatFromRegistry() (string, error) {
// 打开注册表的微信路径:HKEY_CURRENT_USER\Software\Tencent\WeChat\FileSavePath
key, err := registry.OpenKey(registry.CURRENT_USER, `Software\Tencent\WeChat`, registry.QUERY_VALUE)
if err != nil {
return "", err
}
defer key.Close()
//获取key的值
value, _, err := key.GetStringValue("FileSavePath")
if err != nil {
return "", err
}
return value, nil

}

func GetWeChatDir() (string, error) {
// 获取%USERPROFILE%/Documents目录
profile, err := os.UserHomeDir()
msgDir := ""
wDir, err := GetWeChatFromRegistry()
if err != nil {
return "", err
}
// 获取微信消息目录
msgDir := filepath.Join(profile, "Documents", "WeChat Files")
// 如果wDir为MyDocument:
if wDir == "MyDocument:" {
// 获取%USERPROFILE%/Documents目录
profile, err := os.UserHomeDir()
if err != nil {
return "", err
}
// 获取微信消息目录
msgDir = filepath.Join(profile, "Documents", "WeChat Files")
} else {
// 获取微信消息目录
msgDir = filepath.Join(wDir, "WeChat Files")
}
// 判断目录是否存在
_, err = os.Stat(msgDir)
if err != nil {
Expand Down

0 comments on commit 5026b77

Please sign in to comment.