[#] 1.优化特征码补丁方式的提示 2.还原时文件版本不同的情况下弹出提示

This commit is contained in:
huiyadanli
2020-01-01 19:21:28 +08:00
parent f448f9cb8e
commit 8ffb1ab0d3
3 changed files with 49 additions and 29 deletions
+19 -1
View File
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace RevokeMsgPatcher.Modifier
{
@@ -347,7 +348,24 @@ namespace RevokeMsgPatcher.Modifier
{
foreach (FileHexEditor editor in editors)
{
editor.Restore();
string currVersion = editor.FileVersion;
string bakVersion = editor.BackupFileVersion;
if (currVersion != bakVersion)
{
DialogResult dr = MessageBox.Show(
$"当前文件:{editor.FilePath},版本:{currVersion}" + Environment.NewLine +
$"备份文件:{editor.FileBakPath},版本:{bakVersion}" + Environment.NewLine +
$"两者版本不一致,是否继续还原?",
"提示 ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
editor.Restore();
}
else
{
return false;
}
}
}
return true;
}
+11 -6
View File
@@ -5,9 +5,6 @@ using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RevokeMsgPatcher.Modifier
{
@@ -34,6 +31,14 @@ namespace RevokeMsgPatcher.Modifier
}
}
public string BackupFileVersion
{
get
{
return FileUtil.GetFileVersion(FileBakPath);
}
}
public string sha1;
public string FileSHA1
{
@@ -143,11 +148,11 @@ namespace RevokeMsgPatcher.Modifier
}
if (matchNum == FileCommonModifyInfo.ReplacePatterns.Count)
{
throw new Exception("特征码替换:当前应用已经防撤回");
throw new BusinessException("already_replace", "特征码替换:当前应用已经防撤回");
}
else
{
throw new Exception("特征码替换:没有搜索到撤回的相关特征");
throw new BusinessException("not_found_to_replace", "特征码替换:没有搜索到撤回的相关特征");
}
}
else if (needReplaceNum == FileCommonModifyInfo.ReplacePatterns.Count)
@@ -160,7 +165,7 @@ namespace RevokeMsgPatcher.Modifier
}
else
{
throw new Exception("特征码替换:可替换的特征数不正确");
throw new BusinessException("found_num_err", "特征码替换:可替换的特征数不正确");
}
}