diff --git a/RevokeMsgPatcher/FormMain.cs b/RevokeMsgPatcher/FormMain.cs index b0ff41d..b53e2a1 100644 --- a/RevokeMsgPatcher/FormMain.cs +++ b/RevokeMsgPatcher/FormMain.cs @@ -188,6 +188,7 @@ namespace RevokeMsgPatcher { EnableAllButton(false); RadioButton radioButton = sender as RadioButton; + // 切换使用不同的防撤回对象 if (rbtWechat.Checked) { modifier = (WechatModifier)rbtWechat.Tag; diff --git a/RevokeMsgPatcher/JsonData.cs b/RevokeMsgPatcher/JsonData.cs index f21817d..87b15a4 100644 --- a/RevokeMsgPatcher/JsonData.cs +++ b/RevokeMsgPatcher/JsonData.cs @@ -162,23 +162,23 @@ namespace RevokeMsgPatcher { Name = "IM.dll", Version = "2.3.2.21173", - SHA1Before = "c6632339fbe675312a70ae4620e70699c258cd36", - SHA1After = "e9ddc5cc681950796fc8fe4c55f580428c890b51", + SHA1Before = "ecf3e69f3fb100ffe2fee095ffded591b9781024", + SHA1After = "0514d1304e7ac46b4d33386ec3313888f5ae7171", Changes = new List { new Change { - Position = 0x0005009F, + Position = 0x0004D78A, Content = new byte[] { 0xEB, 0x90, 0x90, 0x90, 0x90 } }, new Change { - Position = 0x000502BC, + Position = 0x0004D9A7, Content = new byte[] { 0xEB, 0x90, 0x90, 0x90, 0x90 } }, new Change { - Position = 0x0005046C, + Position = 0x0004DB57, Content = new byte[] { 0xEB, 0x08, 0x90, 0x90, 0x90, 0x90 } } } diff --git a/RevokeMsgPatcher/Model/TargetFile.cs b/RevokeMsgPatcher/Model/TargetFile.cs deleted file mode 100644 index f4c8819..0000000 --- a/RevokeMsgPatcher/Model/TargetFile.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RevokeMsgPatcher.Model -{ - public class TargetFile - { - public string FileName { get; set; } - - public string Version { get; set; } - - public string SHA1Before { get; set; } - - public string SHA1After { get; set; } - - public long Position { get; set; } - - public byte Content { get; set; } - } -} diff --git a/RevokeMsgPatcher/Model/Version.cs b/RevokeMsgPatcher/Model/Version.cs deleted file mode 100644 index d14d55c..0000000 --- a/RevokeMsgPatcher/Model/Version.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RevokeMsgPatcher.Model -{ - public class Version - { - public string AppVersion { get; set; } - - public List Files { get; set; } - } -} diff --git a/RevokeMsgPatcher/Patcher.cs b/RevokeMsgPatcher/Patcher.cs deleted file mode 100644 index 91f575f..0000000 --- a/RevokeMsgPatcher/Patcher.cs +++ /dev/null @@ -1,92 +0,0 @@ -using RevokeMsgPatcher.Model; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Web.Script.Serialization; -using File = System.IO.File; - -namespace RevokeMsgPatcher -{ - public class Patcher - { - private string intallPath; - public string IntallPath - { - get { return intallPath; } - set - { - intallPath = value; - if (!string.IsNullOrEmpty(intallPath) && Util.IsWechatInstallPath(intallPath)) - { - dllPath = Path.Combine(intallPath, "WeChatWin.dll"); - bakPath = Path.Combine(intallPath, "WeChatWin.dll.h.bak"); - } - else - { - intallPath = null; - dllPath = null; - bakPath = null; - } - } - } - - private string dllPath; - private string bakPath; - - public string DllPath { get => dllPath; } - public string BakPath { get => bakPath; } - - private List targetFiles; - private TargetFile currentFile; - - public List TargetFiles { get => targetFiles; } - - public Patcher() - { - JavaScriptSerializer serializer = new JavaScriptSerializer(); - targetFiles = serializer.Deserialize>(Properties.Resources.PatchJson); - } - - public void SetNewPatchJson(string json) - { - JavaScriptSerializer serializer = new JavaScriptSerializer(); - targetFiles = serializer.Deserialize>(json); - } - - public string JudgeVersion() - { - string sha1 = Util.ComputeFileSHA1(dllPath); - Debug.WriteLine(sha1); - - foreach (TargetFile t in targetFiles) - { - if (sha1 == t.SHA1After) - { - return "done"; - } - if (sha1 == t.SHA1Before) - { - currentFile = t; - return t.Version; - } - } - return null; - } - - public bool Patch() - { - if (currentFile != null) - { - File.Copy(dllPath, bakPath, true); - bool done = Util.EditHex(dllPath, currentFile.Position, currentFile.Content); - if (!done) - { - File.Copy(bakPath, dllPath, true); - } - return done; - } - return false; - } - - } -} diff --git a/RevokeMsgPatcher/RevokeMsgPatcher.csproj b/RevokeMsgPatcher/RevokeMsgPatcher.csproj index 78cdd0e..4536741 100644 --- a/RevokeMsgPatcher/RevokeMsgPatcher.csproj +++ b/RevokeMsgPatcher/RevokeMsgPatcher.csproj @@ -59,21 +59,17 @@ - - - - FormMain.cs diff --git a/RevokeMsgPatcher/Util.cs b/RevokeMsgPatcher/Util.cs deleted file mode 100644 index 3b40939..0000000 --- a/RevokeMsgPatcher/Util.cs +++ /dev/null @@ -1,109 +0,0 @@ -using Microsoft.Win32; -using System; -using System.Diagnostics; -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace RevokeMsgPatcher -{ - public class Util - { - - /// - /// 自动查找安装路径 - /// - /// 安装路径 - public static string AutoFindInstallPath() - { - // 微信的注册表路径 - try - { - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\WeChat"); - object installLocation = key.GetValue("InstallLocation"); - key.Close(); - if (installLocation == null || string.IsNullOrEmpty(installLocation.ToString()) || !IsWechatInstallPath(installLocation.ToString())) - { - // 从默认安装目录查找 - string[] drives = Environment.GetLogicalDrives(); //获取当前计算机逻辑磁盘名称列表 - foreach (string d in drives) - { - string assertPath = Path.Combine(d, @"Program Files (x86)\Tencent\WeChat"); - if (IsWechatInstallPath(assertPath)) - { - return assertPath; - } - } - } - else - { - return installLocation.ToString(); - } - } - catch(Exception e) - { - Console.WriteLine(e.Message); - } - return null; - } - - /// - /// 通过文件是否存在判断是否是安装目录 - /// - /// 安装目录 - /// - public static bool IsWechatInstallPath(string path) - { - return File.Exists(Path.Combine(path, "WeChatWin.dll")) && File.Exists(Path.Combine(path, "WeChat.exe")); - } - - /// - /// 获取文件版本 - /// - /// - /// - public static string GetFileVersion(string path) - { - FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(path); - return fileVersionInfo.FileVersion; - } - - /// - /// 计算文件SHA1 - /// - /// - /// - public static string ComputeFileSHA1(string s) - { - FileStream file = new FileStream(s, FileMode.Open); - SHA1 sha1 = new SHA1CryptoServiceProvider(); - byte[] retval = sha1.ComputeHash(file); - file.Close(); - - StringBuilder sc = new StringBuilder(); - for (int i = 0; i < retval.Length; i++) - { - sc.Append(retval[i].ToString("x2")); - } - return sc.ToString(); - } - - /// - /// 修改文件指定位置的字节 - /// - /// WeChatWin.dll 的路径 - /// 偏移位置 - /// 修改后的值 - /// - public static bool EditHex(string path, long position, byte after) - { - using (var stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)) - { - stream.Position = position; - stream.WriteByte(after); - } - return true; - - } - } -}