[+] 显示当前应用的版本是否被支持

This commit is contained in:
huiyadanli 2020-01-01 16:43:56 +08:00
parent 8630dc83df
commit 604f84b0f6
7 changed files with 333 additions and 51 deletions

View File

@ -29,6 +29,8 @@
private void InitializeComponent()
{
this.txtInfo = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.btnGetVersion = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// txtInfo
@ -36,14 +38,36 @@
this.txtInfo.Location = new System.Drawing.Point(12, 12);
this.txtInfo.Multiline = true;
this.txtInfo.Name = "txtInfo";
this.txtInfo.Size = new System.Drawing.Size(484, 238);
this.txtInfo.Size = new System.Drawing.Size(484, 182);
this.txtInfo.TabIndex = 0;
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(12, 211);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(75, 23);
this.btnSearch.TabIndex = 1;
this.btnSearch.Text = "查找测试";
this.btnSearch.UseVisualStyleBackColor = true;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// btnGetVersion
//
this.btnGetVersion.Location = new System.Drawing.Point(106, 211);
this.btnGetVersion.Name = "btnGetVersion";
this.btnGetVersion.Size = new System.Drawing.Size(91, 23);
this.btnGetVersion.TabIndex = 2;
this.btnGetVersion.Text = "获取文件版本";
this.btnGetVersion.UseVisualStyleBackColor = true;
this.btnGetVersion.Click += new System.EventHandler(this.btnGetVersion_Click);
//
// FormAssisant
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(508, 262);
this.ClientSize = new System.Drawing.Size(508, 252);
this.Controls.Add(this.btnGetVersion);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.txtInfo);
this.Name = "FormAssisant";
this.Text = "冷血无情的助手界面";
@ -56,6 +80,8 @@
#endregion
private System.Windows.Forms.TextBox txtInfo;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Button btnGetVersion;
}
}

View File

@ -1,12 +1,10 @@
using System;
using RevokeMsgPatcher.Matcher;
using RevokeMsgPatcher.Model;
using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RevokeMsgPatcher.Assistant
@ -32,7 +30,89 @@ namespace RevokeMsgPatcher.Assistant
string path = Path.Combine(directory.FullName, "patch.json");
File.WriteAllText(path, json);
txtInfo.AppendText("生成完毕!位置:" + path);
txtInfo.AppendText("生成完毕!位置:" + path + Environment.NewLine);
}
private void btnSearch_Click(object sender, EventArgs e)
{
byte[] fileByteArray = File.ReadAllBytes(@"");
byte[] searchBytes = 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");
byte[] replaceBytes = 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");
//int[] indexs = FuzzyMatcher.MatchAll(fileByteArray, searchBytes);
int[] indexs = FuzzyMatcher.MatchNotReplaced(fileByteArray, searchBytes, replaceBytes);
txtInfo.AppendText("查找结果位置:" + string.Join(",", indexs) + Environment.NewLine);
// 371130
List<Change> changes = ComputChanges(indexs, searchBytes, replaceBytes);
foreach (Change c in changes)
{
txtInfo.AppendText("替换位置:" + Convert.ToString(c.Position, 16) + " 替换内容:" + ByteUtil.ByteArrayToHexString(c.Content) + Environment.NewLine);
}
}
public static List<Change> ComputChanges(int[] indexs, byte[] searchBytes, byte[] replaceBytes)
{
if (searchBytes.Length != replaceBytes.Length)
{
throw new Exception("查询串与替换串长度不同!");
}
// 一个替换串存在多个替换点的情况
List<Change> changeOffsets = new List<Change>(); // 查询串与替换串变化偏移
List<byte> diff = null;
for (int i = 0; i < searchBytes.Length; i++)
{
if (searchBytes[i] != replaceBytes[i])
{
if (diff == null)
{
diff = new List<byte>();
Change offset = new Change
{
Position = i
};
changeOffsets.Add(offset);
}
diff.Add(replaceBytes[i]);
}
else
{
if (diff != null)
{
changeOffsets.Last().Content = diff.ToArray();
diff = null;
}
}
}
// 最后一位也是要被替换的情况
if (diff != null)
{
changeOffsets.Last().Content = diff.ToArray();
diff = null;
}
if (changeOffsets.Count == 0)
{
throw new Exception("查询串与替换串完全相同!请联系作者确认远端补丁信息的正确性。");
}
List<Change> changes = new List<Change>();
foreach (int index in indexs)
{
foreach (Change offset in changeOffsets)
{
Change c = offset.Clone();
c.Position += index;
changes.Add(c);
}
}
return changes;
}
private void btnGetVersion_Click(object sender, EventArgs e)
{
string version = FileUtil.GetFileVersion(@"");
txtInfo.AppendText("文件版本:" + version + Environment.NewLine);
}
}
}

View File

@ -68,8 +68,6 @@
<DependentUpon>FormAssisant.cs</DependentUpon>
</Compile>
<Compile Include="JsonData.cs" />
<Compile Include="Matcher\BoyerMooreMatcher.cs" />
<Compile Include="Matcher\FuzzyMatcher.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormAssisant.resx">

View File

@ -43,14 +43,26 @@
this.rbtQQ = new System.Windows.Forms.RadioButton();
this.rbtTIM = new System.Windows.Forms.RadioButton();
this.label5 = new System.Windows.Forms.Label();
this.panelMask = new System.Windows.Forms.Panel();
this.rbtQQLite = new System.Windows.Forms.RadioButton();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
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();
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.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// lblPathTag
//
this.lblPathTag.AutoSize = true;
this.lblPathTag.Location = new System.Drawing.Point(12, 34);
this.lblPathTag.Location = new System.Drawing.Point(14, 63);
this.lblPathTag.Name = "lblPathTag";
this.lblPathTag.Size = new System.Drawing.Size(65, 12);
this.lblPathTag.TabIndex = 1;
@ -59,11 +71,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(372, 56);
this.btnPatch.Location = new System.Drawing.Point(374, 85);
this.btnPatch.Name = "btnPatch";
this.btnPatch.Size = new System.Drawing.Size(102, 23);
this.btnPatch.TabIndex = 3;
this.btnPatch.Text = "点我防撤回!";
this.btnPatch.Text = "一键防撤回!";
this.btnPatch.UseVisualStyleBackColor = true;
this.btnPatch.Click += new System.EventHandler(this.btnPatch_Click);
//
@ -71,7 +83,7 @@
//
this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtPath.Location = new System.Drawing.Point(82, 29);
this.txtPath.Location = new System.Drawing.Point(84, 58);
this.txtPath.Name = "txtPath";
this.txtPath.Size = new System.Drawing.Size(352, 21);
this.txtPath.TabIndex = 4;
@ -80,7 +92,7 @@
// btnChoosePath
//
this.btnChoosePath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnChoosePath.Location = new System.Drawing.Point(440, 27);
this.btnChoosePath.Location = new System.Drawing.Point(442, 56);
this.btnChoosePath.Name = "btnChoosePath";
this.btnChoosePath.Size = new System.Drawing.Size(34, 23);
this.btnChoosePath.TabIndex = 5;
@ -91,7 +103,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 87);
this.label1.Location = new System.Drawing.Point(14, 116);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(101, 12);
this.label1.TabIndex = 6;
@ -100,7 +112,7 @@
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(119, 87);
this.linkLabel1.Location = new System.Drawing.Point(121, 116);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(41, 12);
this.linkLabel1.TabIndex = 7;
@ -111,7 +123,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(264, 56);
this.btnRestore.Location = new System.Drawing.Point(266, 85);
this.btnRestore.Name = "btnRestore";
this.btnRestore.Size = new System.Drawing.Size(102, 23);
this.btnRestore.TabIndex = 8;
@ -124,7 +136,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.SystemColors.Highlight;
this.lblUpdatePachJson.Location = new System.Drawing.Point(166, 89);
this.lblUpdatePachJson.Location = new System.Drawing.Point(168, 118);
this.lblUpdatePachJson.Name = "lblUpdatePachJson";
this.lblUpdatePachJson.Size = new System.Drawing.Size(308, 12);
this.lblUpdatePachJson.TabIndex = 9;
@ -135,7 +147,7 @@
// lblVersion
//
this.lblVersion.AutoSize = true;
this.lblVersion.Location = new System.Drawing.Point(83, 61);
this.lblVersion.Location = new System.Drawing.Point(85, 90);
this.lblVersion.Name = "lblVersion";
this.lblVersion.Size = new System.Drawing.Size(0, 12);
this.lblVersion.TabIndex = 10;
@ -143,7 +155,7 @@
// lblVersionTag
//
this.lblVersionTag.AutoSize = true;
this.lblVersionTag.Location = new System.Drawing.Point(12, 61);
this.lblVersionTag.Location = new System.Drawing.Point(14, 90);
this.lblVersionTag.Name = "lblVersionTag";
this.lblVersionTag.Size = new System.Drawing.Size(65, 12);
this.lblVersionTag.TabIndex = 9;
@ -153,7 +165,7 @@
//
this.rbtWechat.AutoSize = true;
this.rbtWechat.Checked = true;
this.rbtWechat.Location = new System.Drawing.Point(82, 7);
this.rbtWechat.Location = new System.Drawing.Point(84, 36);
this.rbtWechat.Name = "rbtWechat";
this.rbtWechat.Size = new System.Drawing.Size(47, 16);
this.rbtWechat.TabIndex = 12;
@ -165,7 +177,7 @@
// rbtQQ
//
this.rbtQQ.AutoSize = true;
this.rbtQQ.Location = new System.Drawing.Point(140, 7);
this.rbtQQ.Location = new System.Drawing.Point(142, 36);
this.rbtQQ.Name = "rbtQQ";
this.rbtQQ.Size = new System.Drawing.Size(35, 16);
this.rbtQQ.TabIndex = 13;
@ -176,7 +188,7 @@
// rbtTIM
//
this.rbtTIM.AutoSize = true;
this.rbtTIM.Location = new System.Drawing.Point(186, 7);
this.rbtTIM.Location = new System.Drawing.Point(188, 36);
this.rbtTIM.Name = "rbtTIM";
this.rbtTIM.Size = new System.Drawing.Size(41, 16);
this.rbtTIM.TabIndex = 14;
@ -187,38 +199,119 @@
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 9);
this.label5.Location = new System.Drawing.Point(14, 38);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(65, 12);
this.label5.TabIndex = 16;
this.label5.Text = "选择应用:";
//
// panelMask
//
this.panelMask.Location = new System.Drawing.Point(140, 127);
this.panelMask.Name = "panelMask";
this.panelMask.Size = new System.Drawing.Size(157, 58);
this.panelMask.TabIndex = 17;
this.panelMask.Visible = false;
//
// rbtQQLite
//
this.rbtQQLite.AutoSize = true;
this.rbtQQLite.Location = new System.Drawing.Point(235, 7);
this.rbtQQLite.Location = new System.Drawing.Point(237, 36);
this.rbtQQLite.Name = "rbtQQLite";
this.rbtQQLite.Size = new System.Drawing.Size(71, 16);
this.rbtQQLite.TabIndex = 18;
this.rbtQQLite.Text = "QQ轻聊版";
this.rbtQQLite.UseVisualStyleBackColor = true;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.menuStrip1.Size = new System.Drawing.Size(490, 25);
this.menuStrip1.TabIndex = 19;
this.menuStrip1.Text = "menuStrip1";
//
// 高级ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "高级ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "高级";
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "关于";
//
// 作者ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "作者ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "作者";
//
// 主页ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "主页ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "软件主页";
//
// 帮助ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "帮助ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "帮助";
//
// 支持版本ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "支持版本ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "支持版本";
//
// 常见问题ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "常见问题ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "常见问题";
//
// 防撤回原理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "防撤回原理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "防撤回原理";
//
// 完整文档ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "完整文档ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "完整文档";
//
// 特征码防撤回ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "特征码防撤回ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "特征码防撤回";
//
// 手动输入补丁信息ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "手动输入补丁信息ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.ToolStripMenuItem.Text = "手动输入补丁信息";
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(490, 110);
this.ClientSize = new System.Drawing.Size(490, 146);
this.Controls.Add(this.rbtQQLite);
this.Controls.Add(this.lblUpdatePachJson);
this.Controls.Add(this.panelMask);
this.Controls.Add(this.lblVersion);
this.Controls.Add(this.lblVersionTag);
this.Controls.Add(this.label5);
@ -232,12 +325,16 @@
this.Controls.Add(this.btnChoosePath);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.MinimumSize = new System.Drawing.Size(506, 149);
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "微信/QQ/TIM防撤回补丁";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -258,8 +355,19 @@
private System.Windows.Forms.RadioButton rbtQQ;
private System.Windows.Forms.RadioButton rbtTIM;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Panel panelMask;
private System.Windows.Forms.RadioButton rbtQQLite;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@ -76,7 +76,7 @@ namespace RevokeMsgPatcher
if (!string.IsNullOrEmpty(txtPath.Text))
{
modifier.InitEditors(txtPath.Text);
lblVersion.Text = modifier.GetVersion();
modifier.SetVersionLabel(lblVersion);
btnRestore.Enabled = modifier.BackupExists();
}
}
@ -178,7 +178,7 @@ namespace RevokeMsgPatcher
if (!string.IsNullOrEmpty(txtPath.Text))
{
modifier.InitEditors(txtPath.Text);
lblVersion.Text = modifier.GetVersion();
modifier.SetVersionLabel(lblVersion);
btnRestore.Enabled = modifier.BackupExists();
}
}
@ -237,6 +237,7 @@ namespace RevokeMsgPatcher
needUpdate = false;
lblUpdatePachJson.Text = "[ 获取成功,点击查看更多信息 ]";
}
InitControls();
}
catch (Exception ex)
{
@ -295,7 +296,7 @@ namespace RevokeMsgPatcher
if (!string.IsNullOrEmpty(txtPath.Text))
{
modifier.InitEditors(txtPath.Text);
lblVersion.Text = modifier.GetVersion();
modifier.SetVersionLabel(lblVersion);
btnRestore.Enabled = modifier.BackupExists();
}
ga.RequestPageView($"{GetCheckedRadioButtonNameEn()}/{lblVersion.Text}/switch", "切换标签页");

View File

@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@ -1,10 +1,8 @@
using RevokeMsgPatcher.Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RevokeMsgPatcher.Modifier
{
@ -39,6 +37,71 @@ namespace RevokeMsgPatcher.Modifier
/// <returns></returns>
public abstract string GetVersion();
/// <summary>
/// 操作版本号显示控件的内容和样式
/// </summary>
/// <param name="label">显示版本的控件</param>
public void SetVersionLabel(System.Windows.Forms.Label label)
{
string version = GetVersion();
// 补丁信息中是否都有对应的版本
int i = 0, j = 0;
foreach (FileHexEditor editor in editors) // 多种文件
{
// 精确版本匹配
bool haven = false;
foreach (ModifyInfo modifyInfo in config.FileModifyInfos[editor.FileName]) // 多个版本信息
{
if (editor.FileVersion == modifyInfo.Version)
{
haven = true;
break;
}
}
if (haven)
{
i++;
}
// 匹配出对应版本是否有可以使用的特征
if (config.FileCommonModifyInfos != null)
{
bool inRange = false;
foreach (CommonModifyInfo commonModifyInfo in config.FileCommonModifyInfos[editor.FileName])
{
// editor.FileVersion 在 StartVersion 和 EndVersion 之间
if (IsInVersionRange(editor.FileVersion, commonModifyInfo.StartVersion, commonModifyInfo.EndVersion))
{
inRange = true;
break;
}
}
if (inRange)
{
j++;
}
}
}
// 全部都有对应匹配的版本
if (i == editors.Count)
{
label.Text = version + "(已支持)";
label.ForeColor = Color.Green;
}
else if (j == editors.Count)
{
label.Text = version + "(支持特征码防撤回)";
label.ForeColor = Color.LimeGreen;
}
else
{
label.Text = version + "(不支持)";
label.ForeColor = Color.Red;
}
}
/// <summary>
/// 判断APP安装路径内是否都存在要修改的文件
/// </summary>
@ -149,14 +212,17 @@ namespace RevokeMsgPatcher.Modifier
}
}
// 多个版本范围,匹配通用的补丁替换方式
foreach (CommonModifyInfo commonModifyInfo in config.FileCommonModifyInfos[editor.FileName])
// 多个版本范围,匹配出对应版本可以使用的特征
if (config.FileCommonModifyInfos != null)
{
// editor.FileVersion 在 StartVersion 和 EndVersion 之间
if (IsInVersionRange(editor.FileVersion, commonModifyInfo.StartVersion, commonModifyInfo.EndVersion))
foreach (CommonModifyInfo commonModifyInfo in config.FileCommonModifyInfos[editor.FileName])
{
editor.FileCommonModifyInfo = commonModifyInfo;
break;
// editor.FileVersion 在 StartVersion 和 EndVersion 之间
if (IsInVersionRange(editor.FileVersion, commonModifyInfo.StartVersion, commonModifyInfo.EndVersion))
{
editor.FileCommonModifyInfo = commonModifyInfo;
break;
}
}
}