[+] 显示当前应用的版本是否被支持
This commit is contained in:
30
RevokeMsgPatcher.Assistant/FormAssisant.Designer.cs
generated
30
RevokeMsgPatcher.Assistant/FormAssisant.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user