mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-23 22:06:06 +08:00
[#] 1.优化特征码补丁方式的提示 2.还原时文件版本不同的情况下弹出提示
This commit is contained in:
parent
f448f9cb8e
commit
8ffb1ab0d3
|
@ -3,10 +3,7 @@ using RevokeMsgPatcher.Model.Enum;
|
|||
using RevokeMsgPatcher.Modifier;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -108,24 +105,15 @@ namespace RevokeMsgPatcher
|
|||
{
|
||||
if ((ex.ErrorCode == "not_support" || ex.ErrorCode == "maybe_modified") && modifier.EditorsHasCommonModifyInfos())
|
||||
{
|
||||
// 存在特征码修改替换信息的情况下,发起一次询问
|
||||
DialogResult useCommonPatch =
|
||||
MessageBox.Show("尝试使用精准匹配补丁程序时发生错误:【" +
|
||||
ex.Message + "】,不过该版本支持使用特征码替换补丁程序,当前建议继续尝试防撤回!是否继续尝试防撤回?",
|
||||
"是否使用特征码补丁", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||
if (useCommonPatch == DialogResult.OK)
|
||||
{
|
||||
type = PatchType.Common;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 存在特征码修改替换信息的情况下,尝试使用特征码替换
|
||||
type = PatchType.Common;
|
||||
}
|
||||
else
|
||||
{
|
||||
ga.RequestPageView($"{enName}/{version}/patch/sha1/ex/{ex.ErrorCode}", ex.Message);
|
||||
MessageBox.Show(ex.Message);
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -133,19 +121,19 @@ namespace RevokeMsgPatcher
|
|||
{
|
||||
ga.RequestPageView($"{enName}/{version}/patch/sha1/ex/{ex.HResult.ToString("x4")}", ex.Message);
|
||||
MessageBox.Show(ex.Message + " 请以管理员权限启动本程序,并确认当前应用(微信/QQ/TIM)处于关闭状态。");
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ga.RequestPageView($"{enName}/{version}/patch/sha1/ex/{ex.HResult.ToString("x4")}", ex.Message);
|
||||
MessageBox.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
return;
|
||||
}
|
||||
|
||||
// c.打补丁
|
||||
try
|
||||
{
|
||||
|
@ -153,6 +141,12 @@ namespace RevokeMsgPatcher
|
|||
ga.RequestPageView($"{enName}/{version}/patch/succ", "防撤回成功");
|
||||
MessageBox.Show("补丁安装成功!");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
ga.RequestPageView($"{enName}/{version}/patch/ex/{ex.ErrorCode}", ex.Message);
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
|
@ -211,8 +205,11 @@ namespace RevokeMsgPatcher
|
|||
EnableAllButton(false);
|
||||
try
|
||||
{
|
||||
modifier.Restore();
|
||||
MessageBox.Show("还原成功!");
|
||||
bool succ = modifier.Restore();
|
||||
if (succ)
|
||||
{
|
||||
MessageBox.Show("还原成功!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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", "特征码替换:可替换的特征数不正确");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user