Quellcode durchsuchen

清理旧版本文件和部分方法
修复联系人列表没有显示备注的问题

Suxue vor 1 Jahr
Ursprung
Commit
74ad9297c2

+ 23 - 0
Helpers/DecryptionHelper.cs

@@ -283,6 +283,29 @@ namespace WechatBakTool.Helpers
             }
             return saveFilePath;
         }
+        public static void DecryUserData(byte[] key, string source, string to)
+        {
+            string dbPath = source;
+            string decPath = to;
+            if (!Directory.Exists(decPath))
+                Directory.CreateDirectory(decPath);
+
+            string[] filePath = Directory.GetFiles(dbPath);
+            foreach (string file in filePath)
+            {
+                FileInfo info = new FileInfo(file);
+                var db_bytes = File.ReadAllBytes(file);
+                var decrypted_file_bytes = DecryptDB(db_bytes, key);
+                if (decrypted_file_bytes == null || decrypted_file_bytes.Length == 0)
+                {
+                    Console.WriteLine("解密后的数组为空");
+                }
+                else
+                {
+                    File.WriteAllBytes(Path.Combine(decPath, info.Name), decrypted_file_bytes);
+                }
+            }
+        }
     }
 
 }

+ 0 - 21
Helpers/ProcessHelper.cs

@@ -13,27 +13,6 @@ namespace WechatBakTool.Helpers
 {
     public class ProcessHelper
     {
-        
-        public static Process? GetProcess(string ProcessName)
-        {
-            Process[] processes = Process.GetProcessesByName(ProcessName);
-            if (processes.Length == 0)
-                return null;
-            else if(processes.Length > 1) {
-                SelectWechat selectWechat = new SelectWechat();
-                MessageBox.Show("检测到有多个微信,请选择本工作区对应的微信");
-                selectWechat.ShowDialog();
-                if (selectWechat.SelectProcess == null)
-                    return null;
-
-                Process? p = processes.ToList().Find(x => x.Id.ToString() == selectWechat.SelectProcess.ProcessId);
-                if (p == null)
-                    return null;
-                return p;
-            }
-            else
-                return processes[0];
-        }
         public static ProcessModule? FindProcessModule(int ProcessId, string ModuleName)
         {
             Process process = Process.GetProcessById(ProcessId);

+ 0 - 185
Helpers/WechatDBHelper.cs

@@ -1,185 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading.Tasks;
-using WechatBakTool.Model;
-
-namespace WechatBakTool.Helpers
-{
-    public class WechatDBHelper
-    {
-        private static string ResPath = "";
-        private static string CurrentPath = AppDomain.CurrentDomain.BaseDirectory;
-        private static string UserWorkPath = "";
-        private static int MaxMediaDBCount = 0;
-        private static int MaxMsgDBCount = 0;
-        public static DBInfo GetDBInfo()
-        {
-            return new DBInfo() { MaxMediaDBCount = MaxMediaDBCount, MaxMsgDBCount = MaxMsgDBCount, UserPath = UserWorkPath, ResPath = ResPath };
-        }
-
-        public static DBInfo GetDBinfoOnLocal(string path)
-        {
-            string md5 = GetMd5Hash(path);
-            string tmpPath = Path.Combine(CurrentPath, md5);
-
-            string decPath = Path.Combine(tmpPath, "DecDB");
-            string[] files = Directory.GetFiles(decPath);
-            int media = 0;
-            int msg = 0;
-            foreach(string file in files)
-            {
-                FileInfo fileInfo = new FileInfo(file);
-                if(fileInfo.Extension == ".db")
-                {
-                    string name = fileInfo.Name.Replace(".db", "");
-                    if(name.Substring(0,3) == "MSG")
-                    {
-                        name = name.Replace("MSG", "");
-                        int currentDB = int.Parse(name);
-                        if(currentDB > msg)
-                            msg = currentDB;
-                        continue;
-                    }
-                    if(name.Substring(0,8)== "MediaMSG")
-                    {
-                        name = name.Replace("MediaMSG", "");
-                        int currentDB = int.Parse(name);
-                        if (currentDB > media)
-                            media = currentDB;
-                        continue;
-                    }
-                }
-            }
-            return new DBInfo() { MaxMediaDBCount = media, MaxMsgDBCount = msg, UserPath = tmpPath, ResPath = path };
-        }
-
-        public static void CreateUserWorkPath(string path)
-        {
-            ResPath = path;
-            string md5 = GetMd5Hash(path);
-            string tmpPath = Path.Combine(CurrentPath, md5);
-            if (!Directory.Exists(tmpPath))
-            {
-                Directory.CreateDirectory(tmpPath);
-            }
-            UserWorkPath = tmpPath;
-        }
-
-        public static string MoveUserData(string path)
-        {
-            if(UserWorkPath != "")
-            {
-                //创建db库
-                string db = Path.Combine(UserWorkPath, "DB");
-                if (!Directory.Exists(db))
-                {
-                    Directory.CreateDirectory(db);
-                }
-
-                //核心数据库查找
-                List<string> dbPathArray = new List<string>();
-
-                string userDBPath = Path.Combine(path, "Msg");
-                if (!Directory.Exists(userDBPath))
-                    return "用户目录不存在,创建失败";
-
-                string mainDB = Path.Combine(userDBPath, "MicroMsg.db");
-                if (!File.Exists(mainDB))
-                    return "微信主数据库不存在,创建失败";
-                else
-                    dbPathArray.Add(mainDB);
-
-                string actDB = Path.Combine(userDBPath, "MultiSearchChatMsg.db");
-                if(!File.Exists(actDB))
-                    return "微信附件数据库不存在,创建失败";
-                else
-                    dbPathArray.Add(actDB);
-
-                string dbmsg = Path.Combine(userDBPath, "Multi");
-                bool mediaDBExists = false;
-                bool msgDBExists = false;
-                for(int i = 0; i < 100; i++)
-                {
-                    string mediaDBPath = Path.Combine(dbmsg, string.Format("MediaMSG{0}.db", i.ToString()));
-                    string msgDBPath = Path.Combine(dbmsg, string.Format("MSG{0}.db", i.ToString()));
-
-                    mediaDBExists = File.Exists(mediaDBPath);
-                    msgDBExists = File.Exists(msgDBPath);
-
-                    if (i == 0 && !mediaDBExists && !msgDBExists)
-                    {
-                        return "微信聊天记录数据不存在,创建失败";
-                    }
-
-                    if(mediaDBExists)
-                        dbPathArray.Add(mediaDBPath);
-
-                    if (msgDBExists)
-                        dbPathArray.Add(msgDBPath);
-
-                    if (!msgDBExists && !msgDBExists)
-                        break;
-                }
-
-                foreach(string dbPath in dbPathArray) { 
-                    FileInfo file = new FileInfo(dbPath);
-                    string to = Path.Combine(db, file.Name);
-                    if(!File.Exists(to))
-                        File.Copy(dbPath, to);
-                }
-                return "";
-
-            }
-            return "请复制目录至文本框内";
-        }
-        public static void DecryUserData(byte[] key,string source,string to)
-        {
-            string dbPath = source;
-            string decPath = to;
-            if(!Directory.Exists(decPath))
-                Directory.CreateDirectory(decPath);
-
-            string[] filePath = Directory.GetFiles(dbPath);
-            foreach (string file in filePath)
-            {
-                FileInfo info = new FileInfo(file);
-                var db_bytes = File.ReadAllBytes(file);
-                var decrypted_file_bytes = DecryptionHelper.DecryptDB(db_bytes, key);
-                if (decrypted_file_bytes == null || decrypted_file_bytes.Length == 0)
-                {
-                    Console.WriteLine("解密后的数组为空");
-                }
-                else
-                {
-                    File.WriteAllBytes(Path.Combine(decPath, info.Name), decrypted_file_bytes);
-                }
-            }
-        }
-        private static string GetMd5Hash(string input)
-        {
-            using (MD5 md5Hash = MD5.Create())
-            {
-                // Convert the input string to a byte array and compute the hash.
-                byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
-
-                // Create a new Stringbuilder to collect the bytes
-                // and create a string.
-                StringBuilder sBuilder = new StringBuilder();
-
-                // Loop through each byte of the hashed data 
-                // and format each one as a hexadecimal string.
-                for (int i = 0; i < data.Length; i++)
-                {
-                    sBuilder.Append(data[i].ToString("x2"));
-                }
-
-                // Return the hexadecimal string.
-                return sBuilder.ToString();
-            }
-        }
-    }
-}

+ 0 - 42
Main.xaml

@@ -1,42 +0,0 @@
-<Window x:Class="WechatBakTool.Main"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:WechatBakTool"
-        mc:Ignorable="d"
-        WindowStartupLocation="CenterScreen"
-        Title="溯雪微信备份工具" Height="450" Width="800">
-    <Grid>
-        <ListView Name="list_workspace" Margin="15,50,0,20" HorizontalAlignment="Left" Width="230" Grid.RowSpan="2" SelectionChanged="list_workspace_SelectionChanged">
-            <ListView.View>
-                <GridView>
-                    <GridViewColumn Header="原始id" Width="140" DisplayMemberBinding="{Binding UserName,Mode=TwoWay}" />
-                    <GridViewColumn Header="是否解密" Width="80" DisplayMemberBinding="{Binding Decrypt,Mode=TwoWay}" />
-                </GridView>
-            </ListView.View>
-        </ListView>
-        <Label Content="工作区:" HorizontalAlignment="Left" Margin="15,15,0,0" VerticalAlignment="Top" Height="25" Width="58"/>
-        <Button Content="新增" Width="50" HorizontalAlignment="Left" Margin="194,20,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.343,0.521" Height="19" Click="Button_Click_1"/>
-        <Label Content="用户路径:-" Name="user_path" HorizontalAlignment="Left" Margin="278,68,0,0" VerticalAlignment="Top" Height="25" Width="500"/>
-        <Button Content="解密" IsEnabled="False" Width="50" HorizontalAlignment="Left" Margin="285,20,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.343,0.521" Name="btn_decrypt" Click="btn_decrypt_Click" Height="19"/>
-        <Button Content="读取" IsEnabled="False" Width="50" HorizontalAlignment="Left" Margin="285,47,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.343,0.521" Name="btn_read" Click="btn_read_Click" Height="19" />
-
-        <ListView Name="list_sessions" Margin="278,130,0,20" HorizontalAlignment="Left" Width="290" MouseDoubleClick="list_sessions_MouseDoubleClick">
-            <ListView.View>
-                <GridView>
-                    <GridViewColumn Header="昵称" Width="120" DisplayMemberBinding="{Binding NickName}" />
-                    <GridViewColumn Header="原始id" Width="140" DisplayMemberBinding="{Binding UserName}" />
-                </GridView>
-            </ListView.View>
-        </ListView>
-        <Button Content="导出所选人员聊天记录" HorizontalAlignment="Left" Margin="609,130,0,0" VerticalAlignment="Top" Width="140" Click="Button_Click"/>
-        <Label Content="搜索:" HorizontalAlignment="Left" Margin="278,92,0,0" VerticalAlignment="Top"/>
-        <TextBox Name="find_user" HorizontalAlignment="Left" Margin="323,96,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="194" Height="20"/>
-        <Button Name="btn_search" Content="搜索" HorizontalAlignment="Left" Margin="525,96,0,0" VerticalAlignment="Top" Width="43" Click="btn_search_Click"/>
-        <Button Name="btn_analyse" Content="消息分析工具" HorizontalAlignment="Left" Margin="609,160,0,0" VerticalAlignment="Top" Width="140" Click="btn_analyse_Click"/>
-        <CheckBox Name="cb_del_search" Content="已删除人员强制从记录搜索" HorizontalAlignment="Left" Margin="610,99,0,0" VerticalAlignment="Top"/>
-        <RadioButton Name="rb_find_file" GroupName="find_addr_function" Content="使用version.json进行基址查找" HorizontalAlignment="Left" Margin="348,22,0,0" VerticalAlignment="Top" IsChecked="True"/>
-        <RadioButton Name="rb_find_mem" GroupName="find_addr_function" Content="使用推定进行基址查找【推荐】" HorizontalAlignment="Left" Margin="546,22,0,0" VerticalAlignment="Top" Checked="rb_find_mem_Checked"/>
-    </Grid>
-</Window>

+ 0 - 302
Main.xaml.cs

@@ -1,302 +0,0 @@
-using K4os.Compression.LZ4;
-using K4os.Compression.LZ4.Encoders;
-using K4os.Compression.LZ4.Streams;
-using Newtonsoft.Json;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Reflection.PortableExecutable;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Xml;
-using WechatBakTool.Helpers;
-using WechatBakTool.Interface;
-using WechatBakTool.Model;
-
-namespace WechatBakTool
-{
-    /// <summary>
-    /// Main.xaml 的交互逻辑
-    /// </summary>
-    public partial class Main : Window
-    {
-        private UserBakConfig? CurrentUserBakConfig = null;
-        private WXUserReader? UserReader = null;
-        private ObservableCollection<UserBakConfig> userBakConfigs = new ObservableCollection<UserBakConfig>();
-        public Main()
-        {
-            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
-            InitializeComponent();
-            LoadWorkspace();
-            this.Title += $" {Application.ResourceAssembly.GetName().Version}";
-        }
-
-        private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
-        {
-            MessageBox.Show("发生了未知错误,记录已写入到根目录err.log,如果可以,欢迎反馈给开发人员,非常感谢", "错误");
-            File.AppendAllText("err.log", "\r\n\r\n\r\n=============================\r\n");
-            File.AppendAllText("err.log", string.Format("异常时间:{0}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
-            File.AppendAllText("err.log", e.Exception.ToString());
-            return;
-        }
-
-        private void LoadWorkspace()
-        {
-            userBakConfigs.Clear();
-            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "workspace");
-            if (Directory.Exists(path))
-            {
-                string[] files = Directory.GetFiles(path);
-                foreach(string file in files)
-                {
-                    string type = file.Substring(file.Length - 5, 5);
-                    if(type == ".json")
-                    {
-                        string jsonString = File.ReadAllText(file);
-                        UserBakConfig? userBakConfig = null;
-                        try
-                        {
-                            userBakConfig = JsonConvert.DeserializeObject<UserBakConfig>(jsonString);
-                        }
-                        catch
-                        {
-                            MessageBox.Show("读取到异常工作区文件,请确认备份数据是否正常\r\n文件路径:" + file,"错误");
-                        }
-                        if(userBakConfig != null)
-                        {
-                            userBakConfigs.Add(userBakConfig);
-                        }
-                    }
-                }
-            }
-            list_workspace.ItemsSource = userBakConfigs;
-        }
-
-        private void btn_decrypt_Click(object sender, RoutedEventArgs e)
-        {
-            if(CurrentUserBakConfig != null)
-            {
-                if (!CurrentUserBakConfig.Decrypt)
-                {
-                    bool? mem_find_key = rb_find_mem.IsChecked;
-                    if(mem_find_key == null)
-                    {
-                        MessageBox.Show("请选择key获取方式");
-                        return;
-                    }
-                    byte[]? key = null;
-                    try
-                    {
-                        //key = DecryptionHelper.GetWechatKey((bool)mem_find_key,CurrentUserBakConfig.Account);
-                        if (key == null)
-                            MessageBox.Show("获取到的秘钥为空");
-                        //File.AppendAllText("debug.log", BitConverter.ToString(key, 0));
-                    }
-                    catch (Exception ex)
-                    {
-                        if(ex.Source == "Newtonsoft.Json")
-                        {
-                            MessageBox.Show("版本文件读取失败,请检查版本文件内容是否为正确的json格式", "错误");
-                        }
-                        else
-                        {
-                            MessageBox.Show(ex.Message);
-                        }
-                        return;
-                    }
-                    //byte[]? key = DecryptionHelper.GetWechatKey();
-                    if (key == null)
-                    {
-                        MessageBox.Show("微信密钥获取失败,请检查微信是否打开,或者版本不兼容");
-                        return;
-                    }
-                    string key_string = BitConverter.ToString(key, 0).Replace("-", string.Empty).ToLower().ToUpper();
-                    string source = Path.Combine(CurrentUserBakConfig.UserWorkspacePath, "OriginalDB");
-                    string to = Path.Combine(CurrentUserBakConfig.UserWorkspacePath, "DecDB");
-                    try
-                    {
-                        WechatDBHelper.DecryUserData(key, source, to);
-                        MessageBox.Show("解密完成,请点击读取数据");
-                        CurrentUserBakConfig.Decrypt = true;
-                        WXWorkspace.SaveConfig(CurrentUserBakConfig);
-                        LoadWorkspace();
-                    }
-                    catch (Exception ex)
-                    {
-                        MessageBox.Show("解密过程出现错误:" + ex.Message);
-                    }
-                }
-            }
-        }
-
-        private void btn_read_Click(object sender, RoutedEventArgs e)
-        {
-            if(CurrentUserBakConfig == null)
-            {
-                MessageBox.Show("请先选择工作区");
-                return;
-            }
-            UserReader = new WXUserReader(CurrentUserBakConfig);
-            list_sessions.ItemsSource = UserReader.GetWXContacts();
-        }
-
-        private void list_workspace_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            CurrentUserBakConfig = list_workspace.SelectedItem as UserBakConfig;
-            if(CurrentUserBakConfig != null)
-            {
-                user_path.Content = "用户路径:" + CurrentUserBakConfig.UserResPath;
-                if (CurrentUserBakConfig.Decrypt)
-                {
-                    btn_decrypt.IsEnabled = false;
-                    btn_read.IsEnabled = true;
-                }
-                else
-                {
-                    btn_decrypt.IsEnabled = true;
-                    btn_read.IsEnabled = false;
-                }
-            }
-        }
-
-        private void list_sessions_MouseDoubleClick(object sender, MouseButtonEventArgs e)
-        {
-
-        }
-
-        private void Button_Click(object sender, RoutedEventArgs e)
-        {
-            WXContact? wXContact = list_sessions.SelectedItem as WXContact;
-            if(UserReader == null)
-            {
-                MessageBox.Show("请先点击读取已解密工作区");
-                return;
-            }
-            if(wXContact == null || CurrentUserBakConfig == null)
-            {
-                MessageBox.Show("请先选择要导出的联系人");
-                return;
-            }
-
-            IExport export = new HtmlExport();
-            export.InitTemplate(wXContact);
-            export.SetMsg(UserReader, wXContact);
-            export.SetEnd();
-            //string path = UserReader.GetSavePath(wXContact);
-            string path = Path.Combine(CurrentUserBakConfig.UserWorkspacePath, wXContact.UserName + ".html");
-            export.Save(path);
-            MessageBox.Show("导出完成");
-        }
-
-        private void Button_Click_1(object sender, RoutedEventArgs e)
-        {
-            SelectWechat selectWechat = new SelectWechat();
-            selectWechat.ShowDialog();
-            if(selectWechat.SelectProcess != null)
-            {
-                string path = selectWechat.SelectProcess.DBPath.Replace("\\Msg\\MicroMsg.db", "");
-                try
-                {
-                    WXWorkspace wXWorkspace = new WXWorkspace(path, selectWechat.SelectProcess.Account);
-                    wXWorkspace.MoveDB();
-                    MessageBox.Show("创建工作区成功");
-                    LoadWorkspace();
-                }
-                catch (Exception)
-                {
-                    MessageBox.Show("创建工作区失败,请检查路径是否正确");
-                }
-            }
-        }
-
-        private void btn_search_Click(object sender, RoutedEventArgs e)
-        {
-            if(UserReader == null)
-            {
-                MessageBox.Show("请先读取工作区数据");
-                return;
-            }
-            if(cb_del_search.IsChecked != null)
-            {
-                if (!(bool)cb_del_search.IsChecked)
-                    list_sessions.ItemsSource = UserReader.GetWXContacts(find_user.Text);
-                else
-                {
-                    List<WXMsg>? wXMsgs = UserReader.GetWXMsgs(find_user.Text);
-                    if(wXMsgs != null)
-                    {
-                        if(wXMsgs.Count > 0)
-                        {
-                            List<WXContact> wXContacts = new List<WXContact>() { new WXContact() { NickName = wXMsgs[0].StrTalker, UserName = wXMsgs[0].StrTalker } };
-                            list_sessions.ItemsSource = wXContacts;
-                        }
-                    }
-                }
-            }
-            
-        }
-
-        private void btn_analyse_Click(object sender, RoutedEventArgs e)
-        {
-            if(UserReader == null || CurrentUserBakConfig == null)
-            {
-                MessageBox.Show("请先读取数据");
-                return;
-            }
-            Analyse analyse = new Analyse(CurrentUserBakConfig, UserReader);
-            analyse.Show();
-        }
-
-        private void rb_find_mem_Checked(object sender, RoutedEventArgs e)
-        {
-            if(CurrentUserBakConfig!= null)
-            {
-                if (string.IsNullOrEmpty(CurrentUserBakConfig.Account))
-                {
-                    MessageBox.Show("使用该功能需要填写用户名,请务必确认用户名已经正确填写,否则请重建工作区");
-                    return;
-                }
-            }
-        }
-
-        private void Button_Click_2(object sender, RoutedEventArgs e)
-        {
-            var list = UserReader.GetWXChatRooms();
-            var users = UserReader.GetWXContacts();
-            Hashtable hashtable = new Hashtable();
-            foreach(var u in users)
-            {
-                hashtable[u.UserName] = u;
-            }
-            foreach(var room in list)
-            {
-                if(room.ChatRoomName == "20647511469@chatroom")
-                {
-                    string[] ids = room.UserNameList.Split("^G");
-                    foreach(string id in ids) {
-                        if (hashtable.ContainsKey(id))
-                        {
-                            WXContact? contact = hashtable[id] as WXContact;
-                            Debug.WriteLine($"{id} 是 ${contact.NickName}");
-                        }
-                        else
-                        {
-                            Debug.WriteLine("不存在");
-                        }
-                    }
-                }
-            }
-        }
-    }
-}

+ 8 - 1
Pages/Workspace.xaml

@@ -137,7 +137,14 @@
                 </Style>
             </Button.Resources>
         </Button>
-        <Button x:Name="btn_open_workspace" Width="90" Height="30" Content="打开文件夹" BorderBrush="Transparent" BorderThickness="0" Background="#2775b6" Foreground="White" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,380,15" Click="btn_open_workspace_Click">
+        <Button x:Name="btn_open_workspace" Width="80" Height="30" Content="打开文件夹" BorderBrush="Transparent" BorderThickness="0" Background="#2775b6" Foreground="White" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,390,15" Click="btn_open_workspace_Click">
+            <Button.Resources>
+                <Style TargetType="{x:Type Border}">
+                    <Setter Property="CornerRadius" Value="3"/>
+                </Style>
+            </Button.Resources>
+        </Button>
+        <Button x:Name="btn_analyse" Width="80" Height="30" Content="旧版消息工具" BorderBrush="Transparent" BorderThickness="0" Background="#2775b6" Foreground="White" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,292,15" Click="btn_analyse_Click" >
             <Button.Resources>
                 <Style TargetType="{x:Type Border}">
                     <Setter Property="CornerRadius" Value="3"/>

+ 11 - 0
Pages/Workspace.xaml.cs

@@ -105,5 +105,16 @@ namespace WechatBakTool.Pages
         {
             Process.Start("explorer.exe ", Main2.CurrentUserBakConfig!.UserWorkspacePath);
         }
+
+        private void btn_analyse_Click(object sender, RoutedEventArgs e)
+        {
+            if (UserReader == null || Main2.CurrentUserBakConfig == null)
+            {
+                MessageBox.Show("请先读取数据");
+                return;
+            }
+            Analyse analyse = new Analyse(Main2.CurrentUserBakConfig, UserReader);
+            analyse.Show();
+        }
     }
 }

+ 8 - 6
README.md

@@ -1,8 +1,8 @@
 
 # WechatBakTool
-基于C#开发的微信聊天记录备份分析工具
+基于C#开发的微信聊天记录备份分析工具,努力做最好用的微信备份工具。
 
-- 理论支持64位版本所有微信*
+- 理论支持64位版本所有微信[1]
 - 工作区概念,支持多微信切换操作。
 - 支持导出Html文件
 - 支持聊天频率分析,全消息库内容搜索
@@ -11,7 +11,7 @@
 - [x] 图片
 - [x] 语音
 - [x] 分享链接
-- [x] 群聊(导出是支持的,名字显示新版本补完)
+- [x] 群聊
 - [ ] 文件
 - [ ] 表情
 
@@ -24,7 +24,6 @@
 > [!NOTE]
 > 本分支为项目开发分支,变动较为频繁且可能不可用<br/>
 > 如果你希望观察作者的开发动态,可以参考这个分支。<br/>
-
 <br/>
 
 ### 免责声明
@@ -37,7 +36,7 @@
 ### 近期开发规划
 本项目技术栈为:
 C# + .NET6.0 + WPF MVVM(目前MVVM不是特别完全!莫喷!) <br/>
-- [ ] 新版本UI界面开发
+- [x] ~~新版本UI界面开发~~
 - [ ] 完善各类消息支持
 - [ ] 性能优化
 - [ ] 打包资源文件夹
@@ -63,4 +62,7 @@ C# + .NET6.0 + WPF MVVM(目前MVVM不是特别完全!莫喷!) <br/>
 3. 解密微信语音,我是直接调用解密,反正都要ffmpeg,多一个也是多,多两个也是多,懒得头铁实现: [kn007/silk-v3-decoder](https://github.com/kn007/silk-v3-decoder)
 4. 解密微信图片 [吾爱破解chenhahacjl/微信 DAT 图片解密 (C#)](https://www.52pojie.cn/forum.php?mod=viewthread&tid=1507922)
 5. 参考了句柄名称实现,注意获取句柄别看这里,#10 这个issue就是血泪 [huiyadanli/RevokeMsgPatcher](https://github.com/huiyadanli/RevokeMsgPatcher)
-6. 参考了句柄获取 [FuzzySecurity/Sharp-Suite](https://github.com/FuzzySecurity/Sharp-Suite)
+6. 参考了句柄获取 [FuzzySecurity/Sharp-Suite](https://github.com/FuzzySecurity/Sharp-Suite)
+
+### 其他声明
+[1] 理论支持所有64位版本指用户名推断获取Key模式,地址直接获取方式需要version.json支持,更新不是很及时。

+ 0 - 27
SelectWechat.xaml

@@ -1,27 +0,0 @@
-<Window x:Class="WechatBakTool.SelectWechat"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:WechatBakTool"
-        mc:Ignorable="d"
-        WindowStartupLocation="CenterScreen"
-        Title="选择微信" Height="310" Width="600">
-    <Grid>
-        <Label Content="请选择您要打开的微信:" HorizontalAlignment="Left" Margin="29,27,0,0" VerticalAlignment="Top"/>
-        <ListView Name="list_process" Margin="32,55,32,110" SelectionChanged="list_process_SelectionChanged" >
-            <ListView.View>
-                <GridView>
-                    <GridViewColumn Header="进程名" Width="80" DisplayMemberBinding="{Binding ProcessName}" />
-                    <GridViewColumn Header="PID" Width="50" DisplayMemberBinding="{Binding ProcessId}" />
-                    <GridViewColumn Header="路径" Width="300" DisplayMemberBinding="{Binding DBPath}" />
-                </GridView>
-            </ListView.View>
-        </ListView>
-        <Button Name="btn_close" Content="确定并返回" HorizontalAlignment="Left" Margin="241,245,0,0" VerticalAlignment="Top" Width="97" Click="btn_close_Click"/>
-        <Label Content="用户名:" HorizontalAlignment="Left" Margin="34,190,0,0" VerticalAlignment="Top"/>
-        <TextBox Name="txt_username" HorizontalAlignment="Left" Margin="95,195,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="297"/>
-        <Label Content="注意确认用户名是否正确,如修改过用户名,请自行填写!如果需要使用推定方式获取Key必须正确!" HorizontalAlignment="Left" Margin="35,215,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
-
-    </Grid>
-</Window>

+ 0 - 142
SelectWechat.xaml.cs

@@ -1,142 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-using System.Xml.Linq;
-using WechatBakTool.Helpers;
-using WechatBakTool.Model;
-
-namespace WechatBakTool
-{
-    /// <summary>
-    /// SelectWechat.xaml 的交互逻辑
-    /// </summary>
-    public partial class SelectWechat : Window
-    {
-        List<ProcessInfo> processInfos = new List<ProcessInfo>();
-        public ProcessInfo? SelectProcess { get; set; } = null;
-        public SelectWechat()
-        {
-            InitializeComponent();
-            //GetWechatProcess();
-            GetWechatProcessInfos();
-            list_process.ItemsSource = processInfos;
-        }
-
-        private void GetWechatProcessInfos()
-        {
-            processInfos.Clear();
-            Process[] processes = Process.GetProcessesByName("wechat");
-            foreach (Process p in processes)
-            {
-                var lHandles = NativeAPIHelper.GetHandleInfoForPID((uint)p.Id);
-                foreach (var h in lHandles)
-                {
-                    string name = NativeAPIHelper.FindHandleName(h, p);
-                    if (name != "")
-                    {
-                        // 预留handle log
-                        if (File.Exists("handle.log"))
-                        {
-                            File.AppendAllText("handle.log", string.Format("{0}|{1}|{2}|{3}\n", p.Id, h.ObjectTypeIndex, h.HandleValue, name));
-                        }
-                        if (name.Contains("\\MicroMsg.db") && name.Substring(name.Length - 3, 3) == ".db")
-                        {
-                            ProcessInfo info = new ProcessInfo();
-                            info.ProcessId = p.Id.ToString();
-                            info.ProcessName = p.ProcessName;
-                            info.DBPath = DevicePathMapper.FromDevicePath(name);
-                            processInfos.Add(info);
-                        }
-                    }
-                }
-            }
-        }
-
-        public void GetWechatProcess()
-        {
-            Process p = new Process();
-            p.StartInfo.FileName = "tools/handle64.exe";
-            p.StartInfo.Arguments = "-p wechat.exe";
-            p.StartInfo.UseShellExecute = false;
-            p.StartInfo.CreateNoWindow = true;
-            p.StartInfo.RedirectStandardOutput = true;
-            p.Start();
-
-            string i = p.StandardOutput.ReadToEnd();
-            if (i.Contains("SYSINTERNALS SOFTWARE LICENSE TERMS"))
-            {
-                MessageBox.Show("请先同意Handle64的使用协议,同意后关闭弹窗重新打开新增工作区即可");
-                Process p1 = new Process();
-                p1.StartInfo.FileName = "tools/handle64.exe";
-                p1.StartInfo.Arguments = "-p wechat.exe";
-                p1.Start();
-            }
-
-            string[] lines = i.Split(new string[] { "\r\n" }, StringSplitOptions.None);
-            bool hitFind = false;
-            ProcessInfo processInfo = new ProcessInfo();
-            foreach (string line in lines)
-            {
-                if (line.Length < 6)
-                    continue;
-
-                if (line.Substring(0, 6).ToLower() == "wechat")
-                {
-                    hitFind = true;
-                    processInfo = new ProcessInfo();
-                    string[] lineInfo = line.Split(' ');
-                    processInfo.ProcessName = lineInfo[0];
-                    processInfo.ProcessId = lineInfo[2];
-                }
-                if (hitFind)
-                {
-                    if (line.Substring(line.Length - 11, 11) == "MicroMsg.db")
-                    {
-                        Regex regex = new Regex("[a-zA-Z]:\\\\([a-zA-Z0-9() ]*\\\\)*\\w*.*\\w*");
-                        string path = regex.Match(line).Value;
-                        processInfo.DBPath = path;
-                        processInfos.Add(processInfo);
-                        hitFind = false;
-                    }
-                }
-            }
-
-            list_process.ItemsSource = processInfos;
-        }
-
-        private void list_process_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            SelectProcess = list_process.SelectedItem as ProcessInfo;
-            if(SelectProcess != null)
-            {
-                string[] name_raw = SelectProcess.DBPath.Split("\\");
-                txt_username.Text = name_raw[name_raw.Length - 3];
-                
-            }
-            
-        }
-
-        private void btn_close_Click(object sender, RoutedEventArgs e)
-        {
-            if (SelectProcess != null)
-            {
-                SelectProcess.Account = txt_username.Text;
-            }
-            Close();
-        }
-    }
-}

+ 3 - 0
WXUserReader.cs

@@ -140,6 +140,9 @@ namespace WechatBakTool
 
             foreach (WXContact contact in contacts)
             {
+                if(contact.Remark != "")
+                    contact.NickName = contact.Remark;
+
                 byte[]? imgBytes = GetHeadImgCahce(contact.UserName);
                 if (imgBytes != null)
                 {

+ 1 - 1
WXWorkspace.cs

@@ -47,7 +47,7 @@ namespace WechatBakTool
                 string source = Path.Combine(UserBakConfig.UserWorkspacePath, "OriginalDB");
                 string to = Path.Combine(UserBakConfig.UserWorkspacePath, "DecDB");
 
-                WechatDBHelper.DecryUserData(key, source, to);
+                DecryptionHelper.DecryUserData(key, source, to);
                 UserBakConfig.Decrypt = true;
 
                 WXUserReader reader = new WXUserReader(UserBakConfig);

+ 3 - 3
WechatBakTool.csproj

@@ -6,9 +6,9 @@
     <Nullable>enable</Nullable>
     <UseWPF>true</UseWPF>
     <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
-    <AssemblyVersion>0.6.0.2</AssemblyVersion>
-    <FileVersion>0.6.0.2</FileVersion>
-    <Version>0.6.0.2</Version>
+    <AssemblyVersion>0.9.0.0</AssemblyVersion>
+    <FileVersion>0.9.0.0</FileVersion>
+    <Version>0.9.0.0</Version>
   </PropertyGroup>
 
   <ItemGroup>