mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-23 05:46:07 +08:00
[+] 文案修改,添加提示,添加更详细的行为追踪
This commit is contained in:
parent
aa27f8a7b9
commit
33dbb63659
14
RevokeMsgPatcher/BusinessException.cs
Normal file
14
RevokeMsgPatcher/BusinessException.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace RevokeMsgPatcher
|
||||
{
|
||||
class BusinessException : ApplicationException
|
||||
{
|
||||
public string ErrorCode { get; protected set; }
|
||||
|
||||
public BusinessException(string errcode, string message) : base(message)
|
||||
{
|
||||
ErrorCode = errcode;
|
||||
}
|
||||
}
|
||||
}
|
1
RevokeMsgPatcher/FormMain.Designer.cs
generated
1
RevokeMsgPatcher/FormMain.Designer.cs
generated
|
@ -116,6 +116,7 @@
|
|||
// lblUpdatePachJson
|
||||
//
|
||||
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.Name = "lblUpdatePachJson";
|
||||
this.lblUpdatePachJson.Size = new System.Drawing.Size(308, 12);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace RevokeMsgPatcher
|
|||
InitModifier();
|
||||
InitControls();
|
||||
|
||||
ga.RequestPageView("/main", "进入主界面");
|
||||
ga.RequestPageView($"/main/{thisVersion}", $"进入{thisVersion}版本主界面");
|
||||
}
|
||||
|
||||
private void InitControls()
|
||||
|
@ -86,7 +86,9 @@ namespace RevokeMsgPatcher
|
|||
}
|
||||
|
||||
// 记录点了什么应用的防撤回
|
||||
ga.RequestPageView(GetCheckedRadioButtonNameEn() + "/patch", "点击防撤回");
|
||||
string enName = GetCheckedRadioButtonNameEn(); // 应用英文名
|
||||
string version = modifier.GetVersion(); // 应用版本
|
||||
ga.RequestPageView($"{enName}/{version}/patch", "点击防撤回");
|
||||
|
||||
EnableAllButton(false);
|
||||
// a.重新初始化编辑器
|
||||
|
@ -96,28 +98,44 @@ namespace RevokeMsgPatcher
|
|||
{
|
||||
modifier.ValidateAndFindModifyInfo();
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
ga.RequestPageView($"{enName}/{version}/patch/sha1/ex/{ex.ErrorCode}", ex.Message);
|
||||
MessageBox.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ga.RequestPageView($"{enName}/{version}/patch/sha1/ex/{ex.HResult.ToString("x4")}", ex.Message);
|
||||
MessageBox.Show(ex.Message + " 请以管理员权限启动本程序,并确认当前应用(微信/QQ/TIM)处于关闭状态。");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ga.RequestPageView(GetCheckedRadioButtonNameEn() + "/patch/sha1/ex", ex.Message);
|
||||
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
|
||||
{
|
||||
modifier.Patch();
|
||||
ga.RequestPageView(GetCheckedRadioButtonNameEn() + "/patch/succ", "防撤回成功");
|
||||
ga.RequestPageView($"{enName}/{version}/patch/succ", "防撤回成功");
|
||||
MessageBox.Show("补丁安装成功!");
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
ga.RequestPageView(GetCheckedRadioButtonNameEn() + "/patch/ex", ex.Message);
|
||||
MessageBox.Show(ex.Message + " 请以管理员权限启动本程序,并确认微信处于关闭状态。");
|
||||
ga.RequestPageView($"{enName}/{version}/patch/ex/{ex.HResult.ToString("x4")}", ex.Message);
|
||||
MessageBox.Show(ex.Message + " 请以管理员权限启动本程序,并确认当前应用(微信/QQ/TIM)处于关闭状态。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
EnableAllButton(true);
|
||||
btnRestore.Enabled = modifier.BackupExists();
|
||||
}
|
||||
|
@ -183,7 +201,7 @@ namespace RevokeMsgPatcher
|
|||
string json = await GetPathJsonAsync();
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
lblUpdatePachJson.Text = "[ 获取失败 ]";
|
||||
lblUpdatePachJson.Text = "[ 获取最新补丁信息失败 ]";
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -205,7 +223,7 @@ namespace RevokeMsgPatcher
|
|||
else
|
||||
{
|
||||
needUpdate = false;
|
||||
lblUpdatePachJson.Text = "[ 获取成功 ]";
|
||||
lblUpdatePachJson.Text = "[ 获取成功,点击查看更多信息 ]";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -259,7 +277,6 @@ namespace RevokeMsgPatcher
|
|||
|
||||
private void radioButtons_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ga.RequestPageView(GetCheckedRadioButtonNameEn() + "/switch", "切换标签页");
|
||||
EnableAllButton(false);
|
||||
RadioButton radioButton = sender as RadioButton;
|
||||
// 切换使用不同的防撤回对象
|
||||
|
@ -277,6 +294,7 @@ namespace RevokeMsgPatcher
|
|||
}
|
||||
txtPath.Text = modifier.FindInstallPath();
|
||||
lblVersion.Text = modifier.GetVersion();
|
||||
ga.RequestPageView($"{GetCheckedRadioButtonNameEn()}/{lblVersion.Text}/switch", "切换标签页");
|
||||
EnableAllButton(true);
|
||||
// 显示是否能够备份还原
|
||||
if (!string.IsNullOrEmpty(txtPath.Text))
|
||||
|
|
|
@ -124,17 +124,17 @@ namespace RevokeMsgPatcher.Modifier
|
|||
// 补丁后SHA1匹配上,肯定已经打过补丁
|
||||
if (matchingSHA1After != null)
|
||||
{
|
||||
throw new Exception($"你已经安装过此补丁,文件路径:{editor.FilePath}");
|
||||
throw new BusinessException("installed", $"你已经安装过此补丁,文件路径:{editor.FilePath}");
|
||||
}
|
||||
// 全部不匹配,说明不支持
|
||||
if (matchingSHA1Before == null && matchingSHA1After == null && matchingVersion == null)
|
||||
{
|
||||
throw new Exception($"不支持此版本:{editor.FileVersion},文件路径:{editor.FilePath}");
|
||||
throw new BusinessException("not_support", $"不支持此版本:{editor.FileVersion},文件路径:{editor.FilePath}");
|
||||
}
|
||||
// SHA1不匹配,版本匹配,可能dll已经被其他补丁程序修改过
|
||||
if ((matchingSHA1Before == null && matchingSHA1After == null) && matchingVersion != null)
|
||||
{
|
||||
throw new Exception($"程序支持此版本:{editor.FileVersion}。但是文件校验不通过,请确认是否使用过其他补丁程序。文件路径:{editor.FilePath}");
|
||||
throw new BusinessException("maybe_modified", $"程序支持此版本:{editor.FileVersion}。但是文件校验不通过,请确认是否使用过其他补丁程序。文件路径:{editor.FilePath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
@ -49,6 +50,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BusinessException.cs" />
|
||||
<Compile Include="FormMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -65,6 +67,7 @@
|
|||
<Compile Include="Modifier\QQModifier.cs" />
|
||||
<Compile Include="Modifier\TIMModifier.cs" />
|
||||
<Compile Include="Modifier\WechatModifier.cs" />
|
||||
<Compile Include="Utils\Device.cs" />
|
||||
<Compile Include="Utils\FileUtil.cs" />
|
||||
<Compile Include="Utils\GAHelper.cs" />
|
||||
<Compile Include="Utils\HttpUtil.cs" />
|
||||
|
|
151
RevokeMsgPatcher/Utils/Device.cs
Normal file
151
RevokeMsgPatcher/Utils/Device.cs
Normal file
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace RevokeMsgPatcher.Utils
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
private static string macID = null;
|
||||
private static string osVersion = null;
|
||||
|
||||
private static string fingerPrint = null;
|
||||
|
||||
#region PROP, get it only once
|
||||
|
||||
public static string MacID
|
||||
{
|
||||
get
|
||||
{
|
||||
if (macID == null)
|
||||
{
|
||||
macID = ObtainMacID();
|
||||
}
|
||||
return macID;
|
||||
}
|
||||
}
|
||||
|
||||
public static string OSVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (osVersion == null)
|
||||
{
|
||||
var name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
|
||||
select x.GetPropertyValue("Caption")).FirstOrDefault();
|
||||
osVersion = name != null ? name.ToString() : "Unknown";
|
||||
}
|
||||
return osVersion;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Calculate GUID
|
||||
/// </summary>
|
||||
/// <returns>GUID</returns>
|
||||
public static string Value()
|
||||
{
|
||||
if (fingerPrint == null)
|
||||
{
|
||||
fingerPrint = GetHash(
|
||||
"MAC >> " + MacID
|
||||
);
|
||||
}
|
||||
return fingerPrint;
|
||||
}
|
||||
|
||||
private static string GetHash(string s)
|
||||
{
|
||||
MD5 sec = new MD5CryptoServiceProvider();
|
||||
ASCIIEncoding enc = new ASCIIEncoding();
|
||||
byte[] bt = enc.GetBytes(s);
|
||||
return GetHexString(sec.ComputeHash(bt));
|
||||
}
|
||||
|
||||
private static string GetHexString(byte[] bt)
|
||||
{
|
||||
string s = string.Empty;
|
||||
for (int i = 0; i < bt.Length; i++)
|
||||
{
|
||||
byte b = bt[i];
|
||||
int n, n1, n2;
|
||||
n = (int)b;
|
||||
n1 = n & 15;
|
||||
n2 = (n >> 4) & 15;
|
||||
if (n2 > 9)
|
||||
s += ((char)(n2 - 10 + (int)'A')).ToString();
|
||||
else
|
||||
s += n2.ToString();
|
||||
if (n1 > 9)
|
||||
s += ((char)(n1 - 10 + (int)'A')).ToString();
|
||||
else
|
||||
s += n1.ToString();
|
||||
if ((i + 1) != bt.Length && (i + 1) % 2 == 0) s += "-";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
#region Original Device ID Getting Code
|
||||
|
||||
public static string ObtainMacID()
|
||||
{
|
||||
return Identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");
|
||||
}
|
||||
|
||||
private static string Identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
|
||||
{
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
ManagementClass mc = new ManagementClass(wmiClass);
|
||||
ManagementObjectCollection moc = mc.GetInstances();
|
||||
foreach (ManagementObject mo in moc)
|
||||
{
|
||||
if (mo[wmiMustBeTrue].ToString() == "True")
|
||||
{
|
||||
//Only get the first one
|
||||
if (result == "")
|
||||
{
|
||||
result = mo[wmiProperty].ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string Identifier(string wmiClass, string wmiProperty)
|
||||
{
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
ManagementClass mc = new ManagementClass(wmiClass);
|
||||
ManagementObjectCollection moc = mc.GetInstances();
|
||||
foreach (ManagementObject mo in moc)
|
||||
{
|
||||
//Only get the first one
|
||||
if (result == "")
|
||||
{
|
||||
result = mo[wmiProperty].ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ namespace RevokeMsgPatcher.Utils
|
|||
// 根据实际使用分析账号设置
|
||||
private const string tid = "UA-80358493-2"; // GA Tracking ID / Property ID.
|
||||
|
||||
private static readonly string cid = Guid.NewGuid().ToString(); // Anonymous Client ID.
|
||||
private static readonly string cid = Device.Value(); // Anonymous Client ID. // Guid.NewGuid().ToString()
|
||||
|
||||
// 屏幕分辨率(可选)
|
||||
private static readonly string sr = Screen.PrimaryScreen.Bounds.Width + "x" + Screen.PrimaryScreen.Bounds.Height;
|
||||
|
|
Loading…
Reference in New Issue
Block a user