Browse Source

版本支持拆分

Suxue 1 year ago
parent
commit
b0d4210c04
4 changed files with 38 additions and 4 deletions
  1. 20 2
      Helpers/DecryptionHelper.cs
  2. 6 0
      Model/Common.cs
  3. 6 2
      WechatPCMsgBakTool.csproj
  4. 6 0
      version.json

+ 20 - 2
Helpers/DecryptionHelper.cs

@@ -1,10 +1,16 @@
-using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Security.Cryptography;
 using System.Text;
+using System.Text.Json.Serialization;
 using System.Threading.Tasks;
+using WechatPCMsgBakTool.Model;
+
 namespace WechatPCMsgBakTool.Helpers
 {
     public class DecryptionHelper
@@ -33,8 +39,20 @@ namespace WechatPCMsgBakTool.Helpers
             {
                 return null;
             }
+
+            string json = File.ReadAllText("version.json");
+            List<VersionInfo>? info = JsonConvert.DeserializeObject<List<VersionInfo>?>(json);
+            if (info == null)
+                return null;
+            if (info.Count == 0)
+                return null;
+
+            VersionInfo? cur = info.Find(x => x.Version == version);
+            if (cur == null)
+                return null;
+
             //这里加的是版本偏移量,兼容不同版本把这个加给改了
-            long baseAddress = (long)module.BaseAddress + 62031872;
+            long baseAddress = (long)module.BaseAddress + cur.BaseAddr;
             byte[]? bytes = ProcessHelper.ReadMemoryDate(process.Handle, (IntPtr)baseAddress, 8);
             if (bytes != null)
             {

+ 6 - 0
Model/Common.cs

@@ -19,4 +19,10 @@ namespace WechatPCMsgBakTool.Model
         public string UserName { get; set; } = "";
         public string NickName { get; set; } = "";
     }
+
+    public class VersionInfo
+    {
+        public string Version { get; set; } = "";
+        public int BaseAddr { get; set; }
+    }
 }

+ 6 - 2
WechatPCMsgBakTool.csproj

@@ -6,11 +6,12 @@
     <Nullable>enable</Nullable>
     <UseWPF>true</UseWPF>
     <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
-    <AssemblyVersion>0.2.0.0</AssemblyVersion>
-    <FileVersion>0.2.0.0</FileVersion>
+    <AssemblyVersion>0.2.1.0</AssemblyVersion>
+    <FileVersion>0.2.1.0</FileVersion>
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
     <PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
   </ItemGroup>
 
@@ -27,6 +28,9 @@
     <None Update="Tools\silk_v3_decoder.exe">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Update="version.json">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
 
 </Project>

+ 6 - 0
version.json

@@ -0,0 +1,6 @@
+[
+	{
+		"Version": "3.9.6.33",
+		"BaseAddr": 62031872
+	}
+]