mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-23 22:06:06 +08:00
[+] 补丁可选功能
This commit is contained in:
parent
5a99342f61
commit
56842e911d
1
RevokeMsgPatcher.Assistant/Data/0.9/patch.json
Normal file
1
RevokeMsgPatcher.Assistant/Data/0.9/patch.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@ namespace RevokeMsgPatcher
|
|||
return new Bag
|
||||
{
|
||||
Apps = AppConfig(),
|
||||
LatestVersion = "0.8",
|
||||
LatestVersion = "0.9",
|
||||
Notice = ""
|
||||
};
|
||||
}
|
||||
|
@ -76,12 +76,14 @@ namespace RevokeMsgPatcher
|
|||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("00 85 C0 74 7B 8B C8 E8"),
|
||||
Replace = ByteUtil.HexStringToByteArray("00 85 C0 EB 7B 8B C8 E8")
|
||||
Replace = ByteUtil.HexStringToByteArray("00 85 C0 EB 7B 8B C8 E8"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 55 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7"),
|
||||
Replace = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC C3 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7")
|
||||
Replace = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC C3 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7"),
|
||||
Category = "多开"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -95,12 +97,14 @@ namespace RevokeMsgPatcher
|
|||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("00 85 C0 74 32 B9"),
|
||||
Replace = ByteUtil.HexStringToByteArray("00 85 C0 EB 32 B9")
|
||||
Replace = ByteUtil.HexStringToByteArray("00 85 C0 EB 32 B9"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 55 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7"),
|
||||
Replace = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC C3 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7")
|
||||
Replace = ByteUtil.HexStringToByteArray("C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC C3 8B EC 83 EC 14 53 56 57 6A FF 0F 57 C0 C7"),
|
||||
Category = "多开"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,17 +360,20 @@ namespace RevokeMsgPatcher
|
|||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC 68 3F 3F 3F 54 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC 68 3F 3F 3F 54 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 51 68 3F 3F 3F 54 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 EB 08 90 90 90 90 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 EB 08 90 90 90 90 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -667,17 +674,20 @@ namespace RevokeMsgPatcher
|
|||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC 68 3F 3F 3F 54 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 E8 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC 68 3F 3F 3F 54 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("1C E9 9D 00 00 00 8B 45 F0 8D 55 EC 52 89 5D EC EB 09 90 90 90 8B 08 50 FF 51 78 85 C0 79 2D 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
},
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 51 68 3F 3F 3F 54 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C"),
|
||||
Replace = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 EB 08 90 90 90 90 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C")
|
||||
Replace = ByteUtil.HexStringToByteArray("8B 75 14 8D 4D F4 83 C4 20 33 FF 89 7D F4 8B 06 EB 08 90 90 90 90 56 FF 50 78 85 C0 79 39 8D 45 0C C7 45 0C"),
|
||||
Category = "防撤回"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
</Compile>
|
||||
<None Include="Data\0.7\patch.json" />
|
||||
<None Include="Data\0.8\patch.json" />
|
||||
<None Include="Data\0.9\patch.json" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
|
52
RevokeMsgPatcher/FormMain.Designer.cs
generated
52
RevokeMsgPatcher/FormMain.Designer.cs
generated
|
@ -48,6 +48,7 @@
|
|||
this.高级ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.特征码防撤回强制ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.手动输入补丁信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.通用微信多开工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.支持版本ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.常见问题ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -56,7 +57,8 @@
|
|||
this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.作者ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.主页ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.通用微信多开工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.lblCategory = new System.Windows.Forms.Label();
|
||||
this.panelCategories = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -72,11 +74,11 @@
|
|||
// btnPatch
|
||||
//
|
||||
this.btnPatch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnPatch.Location = new System.Drawing.Point(378, 85);
|
||||
this.btnPatch.Location = new System.Drawing.Point(378, 108);
|
||||
this.btnPatch.Name = "btnPatch";
|
||||
this.btnPatch.Size = new System.Drawing.Size(98, 23);
|
||||
this.btnPatch.TabIndex = 3;
|
||||
this.btnPatch.Text = "一键防撤回!";
|
||||
this.btnPatch.Text = "安装补丁";
|
||||
this.btnPatch.UseVisualStyleBackColor = true;
|
||||
this.btnPatch.Click += new System.EventHandler(this.btnPatch_Click);
|
||||
//
|
||||
|
@ -104,7 +106,7 @@
|
|||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(14, 116);
|
||||
this.label1.Location = new System.Drawing.Point(14, 139);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(101, 12);
|
||||
this.label1.TabIndex = 6;
|
||||
|
@ -113,7 +115,7 @@
|
|||
// linkLabel1
|
||||
//
|
||||
this.linkLabel1.AutoSize = true;
|
||||
this.linkLabel1.Location = new System.Drawing.Point(121, 116);
|
||||
this.linkLabel1.Location = new System.Drawing.Point(121, 139);
|
||||
this.linkLabel1.Name = "linkLabel1";
|
||||
this.linkLabel1.Size = new System.Drawing.Size(41, 12);
|
||||
this.linkLabel1.TabIndex = 7;
|
||||
|
@ -124,7 +126,7 @@
|
|||
// btnRestore
|
||||
//
|
||||
this.btnRestore.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRestore.Location = new System.Drawing.Point(290, 85);
|
||||
this.btnRestore.Location = new System.Drawing.Point(290, 108);
|
||||
this.btnRestore.Name = "btnRestore";
|
||||
this.btnRestore.Size = new System.Drawing.Size(82, 23);
|
||||
this.btnRestore.TabIndex = 8;
|
||||
|
@ -137,7 +139,7 @@
|
|||
this.lblUpdatePachJson.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblUpdatePachJson.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.lblUpdatePachJson.ForeColor = System.Drawing.Color.OrangeRed;
|
||||
this.lblUpdatePachJson.Location = new System.Drawing.Point(168, 118);
|
||||
this.lblUpdatePachJson.Location = new System.Drawing.Point(168, 141);
|
||||
this.lblUpdatePachJson.Name = "lblUpdatePachJson";
|
||||
this.lblUpdatePachJson.Size = new System.Drawing.Size(308, 12);
|
||||
this.lblUpdatePachJson.TabIndex = 9;
|
||||
|
@ -148,7 +150,7 @@
|
|||
// lblVersion
|
||||
//
|
||||
this.lblVersion.AutoSize = true;
|
||||
this.lblVersion.Location = new System.Drawing.Point(85, 90);
|
||||
this.lblVersion.Location = new System.Drawing.Point(85, 113);
|
||||
this.lblVersion.Name = "lblVersion";
|
||||
this.lblVersion.Size = new System.Drawing.Size(0, 12);
|
||||
this.lblVersion.TabIndex = 10;
|
||||
|
@ -156,7 +158,7 @@
|
|||
// lblVersionTag
|
||||
//
|
||||
this.lblVersionTag.AutoSize = true;
|
||||
this.lblVersionTag.Location = new System.Drawing.Point(14, 90);
|
||||
this.lblVersionTag.Location = new System.Drawing.Point(14, 113);
|
||||
this.lblVersionTag.Name = "lblVersionTag";
|
||||
this.lblVersionTag.Size = new System.Drawing.Size(65, 12);
|
||||
this.lblVersionTag.TabIndex = 9;
|
||||
|
@ -255,6 +257,13 @@
|
|||
this.手动输入补丁信息ToolStripMenuItem.Visible = false;
|
||||
this.手动输入补丁信息ToolStripMenuItem.Click += new System.EventHandler(this.手动输入补丁信息ToolStripMenuItem_Click);
|
||||
//
|
||||
// 通用微信多开工具ToolStripMenuItem
|
||||
//
|
||||
this.通用微信多开工具ToolStripMenuItem.Name = "通用微信多开工具ToolStripMenuItem";
|
||||
this.通用微信多开工具ToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
|
||||
this.通用微信多开工具ToolStripMenuItem.Text = "通用微信多开工具";
|
||||
this.通用微信多开工具ToolStripMenuItem.Click += new System.EventHandler(this.通用微信多开工具ToolStripMenuItem_Click);
|
||||
//
|
||||
// 帮助ToolStripMenuItem
|
||||
//
|
||||
this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -317,18 +326,29 @@
|
|||
this.主页ToolStripMenuItem.Text = "软件主页";
|
||||
this.主页ToolStripMenuItem.Click += new System.EventHandler(this.主页ToolStripMenuItem_Click);
|
||||
//
|
||||
// 通用微信多开工具ToolStripMenuItem
|
||||
// lblCategory
|
||||
//
|
||||
this.通用微信多开工具ToolStripMenuItem.Name = "通用微信多开工具ToolStripMenuItem";
|
||||
this.通用微信多开工具ToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
|
||||
this.通用微信多开工具ToolStripMenuItem.Text = "通用微信多开工具";
|
||||
this.通用微信多开工具ToolStripMenuItem.Click += new System.EventHandler(this.通用微信多开工具ToolStripMenuItem_Click);
|
||||
this.lblCategory.AutoSize = true;
|
||||
this.lblCategory.Location = new System.Drawing.Point(14, 89);
|
||||
this.lblCategory.Name = "lblCategory";
|
||||
this.lblCategory.Size = new System.Drawing.Size(65, 12);
|
||||
this.lblCategory.TabIndex = 20;
|
||||
this.lblCategory.Text = "可选功能:";
|
||||
//
|
||||
// panelCategories
|
||||
//
|
||||
this.panelCategories.Location = new System.Drawing.Point(83, 85);
|
||||
this.panelCategories.Name = "panelCategories";
|
||||
this.panelCategories.Size = new System.Drawing.Size(201, 18);
|
||||
this.panelCategories.TabIndex = 22;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(490, 146);
|
||||
this.ClientSize = new System.Drawing.Size(490, 169);
|
||||
this.Controls.Add(this.panelCategories);
|
||||
this.Controls.Add(this.lblCategory);
|
||||
this.Controls.Add(this.rbtQQLite);
|
||||
this.Controls.Add(this.lblUpdatePachJson);
|
||||
this.Controls.Add(this.lblVersion);
|
||||
|
@ -388,6 +408,8 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem 手动输入补丁信息ToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem 特征码防撤回强制ToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem 通用微信多开工具ToolStripMenuItem;
|
||||
private System.Windows.Forms.Label lblCategory;
|
||||
private System.Windows.Forms.FlowLayoutPanel panelCategories;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using RevokeMsgPatcher.Model;
|
||||
using RevokeMsgPatcher.Forms;
|
||||
using RevokeMsgPatcher.Model;
|
||||
using RevokeMsgPatcher.Modifier;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
|
@ -75,7 +76,7 @@ namespace RevokeMsgPatcher
|
|||
if (!string.IsNullOrEmpty(txtPath.Text))
|
||||
{
|
||||
modifier.InitEditors(txtPath.Text);
|
||||
modifier.SetVersionLabel(lblVersion);
|
||||
modifier.SetVersionLabelAndCategoryCategories(lblVersion, panelCategories);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +97,19 @@ namespace RevokeMsgPatcher
|
|||
EnableAllButton(false);
|
||||
// a.重新初始化编辑器
|
||||
modifier.InitEditors(txtPath.Text);
|
||||
// b.计算SHA1,验证文件完整性,寻找对应的补丁信息(精确版本、通用特征码两种补丁信息)
|
||||
// b.获取选择的功能
|
||||
string[] categories = UIController.GetCategoriesFromPanel(panelCategories);
|
||||
if (panelCategories.Controls.Count > 0 && (categories == null || categories.Length == 0))
|
||||
{
|
||||
MessageBox.Show("请至少选择一项功能");
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
return;
|
||||
}
|
||||
// c.计算SHA1,验证文件完整性,寻找对应的补丁信息(精确版本、通用特征码两种补丁信息)
|
||||
try
|
||||
{
|
||||
modifier.ValidateAndFindModifyInfo();
|
||||
modifier.ValidateAndFindModifyInfo(categories);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
|
@ -126,11 +136,11 @@ namespace RevokeMsgPatcher
|
|||
return;
|
||||
}
|
||||
|
||||
// c.打补丁
|
||||
// d.打补丁
|
||||
try
|
||||
{
|
||||
modifier.Patch();
|
||||
ga.RequestPageView($"{enName}/{version}/patch/succ", "防撤回成功");
|
||||
ga.RequestPageView($"{enName}/{version}/patch/succ", "补丁安装成功");
|
||||
MessageBox.Show("补丁安装成功!");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
|
@ -185,7 +195,7 @@ namespace RevokeMsgPatcher
|
|||
if (!string.IsNullOrEmpty(txtPath.Text))
|
||||
{
|
||||
modifier.InitEditors(txtPath.Text);
|
||||
modifier.SetVersionLabel(lblVersion);
|
||||
modifier.SetVersionLabelAndCategoryCategories(lblVersion, panelCategories);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +230,8 @@ namespace RevokeMsgPatcher
|
|||
private async void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
// 异步获取最新的补丁信息
|
||||
string json = await HttpUtil.GetPatchJsonAsync();
|
||||
//string json = await HttpUtil.GetPatchJsonAsync();
|
||||
string json = null; // local test
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
lblUpdatePachJson.Text = "[ 获取最新补丁信息失败 ]";
|
||||
|
@ -304,11 +315,12 @@ namespace RevokeMsgPatcher
|
|||
EnableAllButton(true);
|
||||
lblVersion.Text = "";
|
||||
btnRestore.Enabled = false;
|
||||
panelCategories.Controls.Clear();
|
||||
// 显示是否能够备份还原
|
||||
if (!string.IsNullOrEmpty(txtPath.Text))
|
||||
{
|
||||
modifier.InitEditors(txtPath.Text);
|
||||
modifier.SetVersionLabel(lblVersion);
|
||||
modifier.SetVersionLabelAndCategoryCategories(lblVersion, panelCategories);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
}
|
||||
ga.RequestPageView($"{GetCheckedRadioButtonNameEn()}/{lblVersion.Text}/switch", "切换标签页");
|
||||
|
|
66
RevokeMsgPatcher/Forms/UIController.cs
Normal file
66
RevokeMsgPatcher/Forms/UIController.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RevokeMsgPatcher.Forms
|
||||
{
|
||||
public class UIController
|
||||
{
|
||||
public static void AddCategoryCheckBoxToPanel(Panel panel, string[] categories = null)
|
||||
{
|
||||
if (categories != null && categories.Length != 0)
|
||||
{
|
||||
panel.Controls.Clear();
|
||||
for (int i = 0; i < categories.Length; i++)
|
||||
{
|
||||
CheckBox chk = new CheckBox
|
||||
{
|
||||
Text = categories[i],
|
||||
Name = "chkCategoriesIndex" + i,
|
||||
Checked = true,
|
||||
AutoSize = true
|
||||
};
|
||||
// 只有一个选项时,必选
|
||||
if (categories.Length == 1)
|
||||
{
|
||||
chk.Enabled = false;
|
||||
}
|
||||
panel.Controls.Add(chk);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMsgToPanel(panel, "无功能选项");
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddMsgToPanel(Panel panel, string msg)
|
||||
{
|
||||
panel.Controls.Clear();
|
||||
Label label = new Label
|
||||
{
|
||||
Name = "lblCategoriesMsg",
|
||||
Text = msg,
|
||||
TextAlign = ContentAlignment.MiddleLeft
|
||||
};
|
||||
panel.Controls.Add(label);
|
||||
}
|
||||
|
||||
public static string[] GetCategoriesFromPanel(Panel panel)
|
||||
{
|
||||
List<string> categories = new List<string>();
|
||||
foreach (CheckBox checkBox in panel.Controls)
|
||||
{
|
||||
if (checkBox.Checked)
|
||||
{
|
||||
categories.Add(checkBox.Text);
|
||||
}
|
||||
}
|
||||
return categories.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace RevokeMsgPatcher.Matcher
|
|||
{
|
||||
if (IsAllReplaced(fileByteArray, replacePatterns))
|
||||
{
|
||||
throw new BusinessException("match_already_replace", "特征比对:当前应用已经安装了防撤回补丁!");
|
||||
throw new BusinessException("match_already_replace", "特征比对:当前应用已经安装了对应功能的补丁!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,7 +64,6 @@ namespace RevokeMsgPatcher.Matcher
|
|||
return changes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool IsAllReplaced(byte[] fileByteArray, List<ReplacePattern> replacePatterns)
|
||||
|
|
|
@ -24,12 +24,24 @@ namespace RevokeMsgPatcher.Model
|
|||
o.StartVersion = StartVersion;
|
||||
o.EndVersion = EndVersion;
|
||||
List<ReplacePattern> cs = new List<ReplacePattern>();
|
||||
foreach(ReplacePattern c in ReplacePatterns)
|
||||
foreach (ReplacePattern c in ReplacePatterns)
|
||||
{
|
||||
cs.Add(c.Clone());
|
||||
}
|
||||
o.ReplacePatterns = cs;
|
||||
return o;
|
||||
}
|
||||
|
||||
public List<string> GetCategories()
|
||||
{
|
||||
if (ReplacePatterns != null && ReplacePatterns.Count > 0)
|
||||
{
|
||||
return ReplacePatterns.Select(p => p.Category).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace RevokeMsgPatcher.Model
|
|||
|
||||
public byte[] Replace { get; set; }
|
||||
|
||||
public string Category { get; set; }
|
||||
|
||||
public ReplacePattern Clone()
|
||||
{
|
||||
ReplacePattern o = new ReplacePattern();
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using RevokeMsgPatcher.Matcher;
|
||||
using RevokeMsgPatcher.Forms;
|
||||
using RevokeMsgPatcher.Matcher;
|
||||
using RevokeMsgPatcher.Model;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
|
@ -44,11 +46,13 @@ namespace RevokeMsgPatcher.Modifier
|
|||
/// 操作版本号显示控件的内容和样式
|
||||
/// </summary>
|
||||
/// <param name="label">显示版本的控件</param>
|
||||
public void SetVersionLabel(System.Windows.Forms.Label label)
|
||||
public void SetVersionLabelAndCategoryCategories(Label label, Panel panel)
|
||||
{
|
||||
string version = GetVersion();
|
||||
// 补丁信息中是否都有对应的版本
|
||||
int i = 0, j = 0;
|
||||
// 特征码匹配的时候的可选功能项
|
||||
SortedSet<string> categories = new SortedSet<string>();
|
||||
foreach (FileHexEditor editor in editors) // 多种文件
|
||||
{
|
||||
// 精确版本匹配
|
||||
|
@ -75,6 +79,14 @@ namespace RevokeMsgPatcher.Modifier
|
|||
// editor.FileVersion 在 StartVersion 和 EndVersion 之间
|
||||
if (IsInVersionRange(editor.FileVersion, commonModifyInfo.StartVersion, commonModifyInfo.EndVersion))
|
||||
{
|
||||
// 取出特征码的功能类型
|
||||
foreach (string c in commonModifyInfo.GetCategories())
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
categories.Add(c);
|
||||
}
|
||||
}
|
||||
inRange = true;
|
||||
break;
|
||||
}
|
||||
|
@ -91,16 +103,19 @@ namespace RevokeMsgPatcher.Modifier
|
|||
{
|
||||
label.Text = version + "(已支持)";
|
||||
label.ForeColor = Color.Green;
|
||||
UIController.AddMsgToPanel(panel, "只有基于特征的补丁才能选择功能");
|
||||
}
|
||||
else if (j == editors.Count)
|
||||
{
|
||||
label.Text = version + "(支持特征防撤回)";
|
||||
label.ForeColor = Color.LimeGreen;
|
||||
UIController.AddCategoryCheckBoxToPanel(panel, categories.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
label.Text = version + "(不支持)";
|
||||
label.ForeColor = Color.Red;
|
||||
UIController.AddMsgToPanel(panel, "无功能选项");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -220,7 +235,8 @@ namespace RevokeMsgPatcher.Modifier
|
|||
/// <summary>
|
||||
/// b.验证文件完整性,寻找对应的补丁信息
|
||||
/// </summary>
|
||||
public void ValidateAndFindModifyInfo()
|
||||
/// <param name="categories">操作类型(防撤回或者多开等),为空则是所有操作</param>
|
||||
public void ValidateAndFindModifyInfo(string[] categories)
|
||||
{
|
||||
// 寻找对应文件版本与SHA1的修改信息
|
||||
foreach (FileHexEditor editor in editors) // 多种文件
|
||||
|
@ -263,6 +279,7 @@ namespace RevokeMsgPatcher.Modifier
|
|||
// SHA1不匹配说明精准替换肯定不支持
|
||||
if (matchingSHA1Before == null && matchingSHA1After == null)
|
||||
{
|
||||
// 尝试使用特征码替换
|
||||
// 多个版本范围,匹配出对应版本可以使用的特征
|
||||
if (config.FileCommonModifyInfos != null)
|
||||
{
|
||||
|
@ -272,8 +289,14 @@ namespace RevokeMsgPatcher.Modifier
|
|||
// 存在对应的特征时不报错
|
||||
if (editor.FileCommonModifyInfo != null && editor.FileCommonModifyInfo.ReplacePatterns != null)
|
||||
{
|
||||
List<ReplacePattern> replacePatterns = editor.FileCommonModifyInfo.ReplacePatterns;
|
||||
// 根据需要操作的功能类型(防撤回或者多开等)筛选特征码
|
||||
if (categories.Length > 0)
|
||||
{
|
||||
replacePatterns = editor.FileCommonModifyInfo.ReplacePatterns.Where(info => categories.Contains(info.Category)).ToList();
|
||||
}
|
||||
// 如果能顺利得到 TargetChanges 不报错则可以使用特征替换方式
|
||||
editor.TargetChanges = ModifyFinder.FindChanges(editor.FilePath, editor.FileCommonModifyInfo.ReplacePatterns);
|
||||
editor.TargetChanges = ModifyFinder.FindChanges(editor.FilePath, replacePatterns);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -63,6 +63,7 @@
|
|||
<Compile Include="Forms\FormPatchInfo.Designer.cs">
|
||||
<DependentUpon>FormPatchInfo.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\UIController.cs" />
|
||||
<Compile Include="Matcher\BoyerMooreMatcher.cs" />
|
||||
<Compile Include="Matcher\FuzzyMatcher.cs" />
|
||||
<Compile Include="Matcher\ModifyFinder.cs" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user