mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-24 06:26:06 +08:00
[+] 重新架构逻辑
This commit is contained in:
parent
90076240b1
commit
92594da959
89
RevokeMsgPatcher/FormMain.Designer.cs
generated
89
RevokeMsgPatcher/FormMain.Designer.cs
generated
|
@ -39,10 +39,9 @@
|
|||
this.lblUpdatePachJson = new System.Windows.Forms.Label();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
|
@ -50,6 +49,7 @@
|
|||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||
|
@ -57,6 +57,7 @@
|
|||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.button5 = new System.Windows.Forms.Button();
|
||||
this.button6 = new System.Windows.Forms.Button();
|
||||
this.btnTest = new System.Windows.Forms.Button();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
|
@ -167,11 +168,29 @@
|
|||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(483, 74);
|
||||
this.tabPage1.Size = new System.Drawing.Size(483, 75);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "微信";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(50, 44);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(35, 12);
|
||||
this.label4.TabIndex = 10;
|
||||
this.label4.Text = "0.0.1";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(6, 44);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(41, 12);
|
||||
this.label3.TabIndex = 9;
|
||||
this.label3.Text = "版本:";
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.label5);
|
||||
|
@ -189,40 +208,6 @@
|
|||
this.tabPage2.Text = "QQ";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.label8);
|
||||
this.tabPage3.Controls.Add(this.label9);
|
||||
this.tabPage3.Controls.Add(this.textBox2);
|
||||
this.tabPage3.Controls.Add(this.label10);
|
||||
this.tabPage3.Controls.Add(this.button4);
|
||||
this.tabPage3.Controls.Add(this.button5);
|
||||
this.tabPage3.Controls.Add(this.button6);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Size = new System.Drawing.Size(483, 74);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "TIM";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(6, 44);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(41, 12);
|
||||
this.label3.TabIndex = 9;
|
||||
this.label3.Text = "版本:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(50, 44);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(35, 12);
|
||||
this.label4.TabIndex = 10;
|
||||
this.label4.Text = "0.0.1";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
|
@ -286,6 +271,22 @@
|
|||
this.button3.Text = "...";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.label8);
|
||||
this.tabPage3.Controls.Add(this.label9);
|
||||
this.tabPage3.Controls.Add(this.textBox2);
|
||||
this.tabPage3.Controls.Add(this.label10);
|
||||
this.tabPage3.Controls.Add(this.button4);
|
||||
this.tabPage3.Controls.Add(this.button5);
|
||||
this.tabPage3.Controls.Add(this.button6);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Size = new System.Drawing.Size(483, 75);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "TIM";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
|
@ -349,11 +350,22 @@
|
|||
this.button6.Text = "...";
|
||||
this.button6.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnTest
|
||||
//
|
||||
this.btnTest.Location = new System.Drawing.Point(380, 13);
|
||||
this.btnTest.Name = "btnTest";
|
||||
this.btnTest.Size = new System.Drawing.Size(62, 34);
|
||||
this.btnTest.TabIndex = 11;
|
||||
this.btnTest.Text = "Test!";
|
||||
this.btnTest.UseVisualStyleBackColor = true;
|
||||
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(491, 138);
|
||||
this.Controls.Add(this.btnTest);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Controls.Add(this.lblUpdatePachJson);
|
||||
this.Controls.Add(this.linkLabel1);
|
||||
|
@ -404,6 +416,7 @@
|
|||
private System.Windows.Forms.Button button4;
|
||||
private System.Windows.Forms.Button button5;
|
||||
private System.Windows.Forms.Button button6;
|
||||
private System.Windows.Forms.Button btnTest;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -158,5 +159,10 @@ namespace RevokeMsgPatcher
|
|||
});
|
||||
MessageBox.Show("当前所支持的微信版本:" + Environment.NewLine + versions);
|
||||
}
|
||||
|
||||
private void btnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
PathUtil.DisplayAllProgram();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace RevokeMsgPatcher.Model
|
|||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<Version> Versions { get; set; }
|
||||
public string[] ModifyFilePaths { get; set; }
|
||||
|
||||
public List<BinaryFile> ModifyFileInfos { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -8,7 +9,9 @@ namespace RevokeMsgPatcher.Model
|
|||
{
|
||||
public class BinaryFile
|
||||
{
|
||||
public string Name { get; set; }
|
||||
//public string Name { get {return Path.GetFileName(RelativePath); } }
|
||||
|
||||
public string RelativePath { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
||||
|
|
56
RevokeMsgPatcher/Modifier/AppModifier.cs
Normal file
56
RevokeMsgPatcher/Modifier/AppModifier.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using RevokeMsgPatcher.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
public abstract class AppModifier
|
||||
{
|
||||
private App config;
|
||||
|
||||
private List<FileHexEditor> editors;
|
||||
|
||||
// 1. 获取安装目录
|
||||
// 2. 验证安装目录 通过 BinaryFiles
|
||||
// 3. 判断所有 BinaryFiles 是否符合防撤回要求
|
||||
// 4. 备份所有 BinaryFiles // *.h.bak
|
||||
// 5. 对每个 BinaryFile 中的 Changes 循环修改(修改前要测试它的读写性质,是否被程序占用等)
|
||||
|
||||
// 获取版本号
|
||||
// 通过SHA1判断是否可以进行16进制编辑 先判断版本号 再判断SHA1 根据不同结果返回不同的提示
|
||||
|
||||
// ?多文件的备份回退 // 暂定有一个备份文件就点亮按钮
|
||||
|
||||
public abstract string FindInstallPath();
|
||||
|
||||
//public abstract bool ValidateInstallPath();
|
||||
|
||||
public abstract bool GetVersion();
|
||||
|
||||
public bool IsAllBinaryFilesExist(string installPath)
|
||||
{
|
||||
int success = 0;
|
||||
foreach(string relativePath in config.ModifyFilePaths)
|
||||
{
|
||||
string filePath = Path.Combine(installPath, relativePath);
|
||||
if(File.Exists(filePath))
|
||||
{
|
||||
success++;
|
||||
}
|
||||
}
|
||||
if(success == config.ModifyFilePaths.Length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
12
RevokeMsgPatcher/Modifier/FileHexEditor.cs
Normal file
12
RevokeMsgPatcher/Modifier/FileHexEditor.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
public class FileHexEditor
|
||||
{
|
||||
}
|
||||
}
|
12
RevokeMsgPatcher/Modifier/QQModifier.cs
Normal file
12
RevokeMsgPatcher/Modifier/QQModifier.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
class QQModifier
|
||||
{
|
||||
}
|
||||
}
|
12
RevokeMsgPatcher/Modifier/TIMModifier.cs
Normal file
12
RevokeMsgPatcher/Modifier/TIMModifier.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
class TIMModifier
|
||||
{
|
||||
}
|
||||
}
|
37
RevokeMsgPatcher/Modifier/WechatModifier.cs
Normal file
37
RevokeMsgPatcher/Modifier/WechatModifier.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
class WechatModifier : AppModifier
|
||||
{
|
||||
public override string FindInstallPath()
|
||||
{
|
||||
string installPath = PathUtil.FindInstallPathFromRegistry("Wecaht");
|
||||
if(!IsAllBinaryFilesExist(installPath))
|
||||
{
|
||||
foreach(string defaultPath in PathUtil.GetDefaultInstallPaths(@"Tencent\Wechat"))
|
||||
{
|
||||
if(IsAllBinaryFilesExist(defaultPath))
|
||||
{
|
||||
return defaultPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return installPath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool GetVersion()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,10 +60,18 @@
|
|||
<Compile Include="Model\BinaryFile.cs" />
|
||||
<Compile Include="Model\TargetFile.cs" />
|
||||
<Compile Include="Model\Version.cs" />
|
||||
<Compile Include="Modifier\AppModifier.cs" />
|
||||
<Compile Include="Modifier\FileHexEditor.cs" />
|
||||
<Compile Include="Modifier\QQModifier.cs" />
|
||||
<Compile Include="Modifier\TIMModifier.cs" />
|
||||
<Compile Include="Modifier\WechatModifier.cs" />
|
||||
<Compile Include="Patcher.cs" />
|
||||
<Compile Include="Utils\PathUtil.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Test.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="Utils\HexEditUtil.cs" />
|
||||
<EmbeddedResource Include="FormMain.resx">
|
||||
<DependentUpon>FormMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
13
RevokeMsgPatcher/Test.cs
Normal file
13
RevokeMsgPatcher/Test.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher
|
||||
{
|
||||
|
||||
class Test
|
||||
{
|
||||
}
|
||||
}
|
12
RevokeMsgPatcher/Utils/HexEditUtil.cs
Normal file
12
RevokeMsgPatcher/Utils/HexEditUtil.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Utils
|
||||
{
|
||||
class HexEditUtil
|
||||
{
|
||||
}
|
||||
}
|
77
RevokeMsgPatcher/Utils/PathUtil.cs
Normal file
77
RevokeMsgPatcher/Utils/PathUtil.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RevokeMsgPatcher.Utils
|
||||
{
|
||||
public class PathUtil
|
||||
{
|
||||
public static void DisplayAllProgram()
|
||||
{
|
||||
RegistryKey uninstallKey, programKey;
|
||||
uninstallKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
|
||||
string[] programKeys = uninstallKey.GetSubKeyNames();
|
||||
foreach (string keyName in programKeys)
|
||||
{
|
||||
programKey = uninstallKey.OpenSubKey(keyName);
|
||||
Console.WriteLine(keyName + " , " + programKey.GetValue("DisplayName") + " , " + programKey.GetValue("InstallLocation"));
|
||||
programKey.Close();
|
||||
}
|
||||
uninstallKey.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从注册表中寻找安装路径
|
||||
/// </summary>
|
||||
/// <param name="uninstallKeyName">
|
||||
/// 安装信息的注册表键名
|
||||
/// 微信:WeChat
|
||||
/// QQ:{052CFB79-9D62-42E3-8A15-DE66C2C97C3E}
|
||||
/// TIM:TIM
|
||||
/// </param>
|
||||
/// <returns>安装路径</returns>
|
||||
public static string FindInstallPathFromRegistry(string uninstallKeyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey key = Registry.LocalMachine.OpenSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{uninstallKeyName}");
|
||||
object installLocation = key.GetValue("InstallLocation");
|
||||
key.Close();
|
||||
if (installLocation != null && !string.IsNullOrEmpty(installLocation.ToString()))
|
||||
{
|
||||
return installLocation.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有可能的默认安装路径
|
||||
/// </summary>
|
||||
/// <param name="relativePath">Tencent\*</param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetDefaultInstallPaths(string relativePath)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
// 从默认安装目录查找
|
||||
string[] drives = Environment.GetLogicalDrives(); //获取当前计算机逻辑磁盘名称列表
|
||||
foreach (string d in drives)
|
||||
{
|
||||
string path = Path.Combine(d, $@"Program Files (x86)\{relativePath}");
|
||||
if(Directory.Exists(path))
|
||||
{
|
||||
list.Add(path);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user