diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbb74b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates +.vs/ + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Mine +Tmp/ +/packages/ diff --git a/RevokeMsgPatcher.sln b/RevokeMsgPatcher.sln new file mode 100644 index 0000000..e632b93 --- /dev/null +++ b/RevokeMsgPatcher.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevokeMsgPatcher", "RevokeMsgPatcher\RevokeMsgPatcher.csproj", "{977BF781-CED8-4389-9404-0FA08FDF21DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {977BF781-CED8-4389-9404-0FA08FDF21DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {977BF781-CED8-4389-9404-0FA08FDF21DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {977BF781-CED8-4389-9404-0FA08FDF21DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {977BF781-CED8-4389-9404-0FA08FDF21DF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {56DAEA8C-77F7-4E55-A7AF-CE9F23F2C1A6} + EndGlobalSection +EndGlobal diff --git a/RevokeMsgPatcher/App.config b/RevokeMsgPatcher/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/RevokeMsgPatcher/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RevokeMsgPatcher/FormMain.Designer.cs b/RevokeMsgPatcher/FormMain.Designer.cs new file mode 100644 index 0000000..31898f6 --- /dev/null +++ b/RevokeMsgPatcher/FormMain.Designer.cs @@ -0,0 +1,142 @@ +namespace RevokeMsgPatcher +{ + partial class FormMain + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); + this.label2 = new System.Windows.Forms.Label(); + this.btnPatch = new System.Windows.Forms.Button(); + this.txtPath = new System.Windows.Forms.TextBox(); + this.btnChoosePath = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.btnRestore = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(17, 15); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 12); + this.label2.TabIndex = 1; + this.label2.Text = "微信路径:"; + // + // 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(409, 10); + this.btnPatch.Name = "btnPatch"; + this.btnPatch.Size = new System.Drawing.Size(102, 23); + this.btnPatch.TabIndex = 3; + this.btnPatch.Text = "点我防撤回!"; + this.btnPatch.UseVisualStyleBackColor = true; + this.btnPatch.Click += new System.EventHandler(this.btnPatch_Click); + // + // txtPath + // + 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(88, 12); + this.txtPath.Name = "txtPath"; + this.txtPath.Size = new System.Drawing.Size(275, 21); + this.txtPath.TabIndex = 4; + // + // 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(369, 10); + this.btnChoosePath.Name = "btnChoosePath"; + this.btnChoosePath.Size = new System.Drawing.Size(34, 23); + this.btnChoosePath.TabIndex = 5; + this.btnChoosePath.Text = "..."; + this.btnChoosePath.UseVisualStyleBackColor = true; + this.btnChoosePath.Click += new System.EventHandler(this.btnChoosePath_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 44); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(101, 12); + this.label1.TabIndex = 6; + this.label1.Text = "软件主页(开源):"; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(112, 44); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(41, 12); + this.linkLabel1.TabIndex = 7; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "GitHub"; + // + // 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(409, 39); + this.btnRestore.Name = "btnRestore"; + this.btnRestore.Size = new System.Drawing.Size(102, 23); + this.btnRestore.TabIndex = 8; + this.btnRestore.Text = "备份还原"; + this.btnRestore.UseVisualStyleBackColor = true; + this.btnRestore.Click += new System.EventHandler(this.btnRestore_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(523, 69); + this.Controls.Add(this.btnRestore); + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnChoosePath); + this.Controls.Add(this.txtPath); + this.Controls.Add(this.btnPatch); + this.Controls.Add(this.label2); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "FormMain"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "微信防撤回补丁"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnPatch; + private System.Windows.Forms.TextBox txtPath; + private System.Windows.Forms.Button btnChoosePath; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.Button btnRestore; + } +} + diff --git a/RevokeMsgPatcher/FormMain.cs b/RevokeMsgPatcher/FormMain.cs new file mode 100644 index 0000000..2d04d36 --- /dev/null +++ b/RevokeMsgPatcher/FormMain.cs @@ -0,0 +1,117 @@ +using System; +using System.IO; +using System.Windows.Forms; + +namespace RevokeMsgPatcher +{ + public partial class FormMain : Form + { + Patcher patcher = null; + + public FormMain() + { + InitializeComponent(); + patcher = new Patcher(); + txtPath.Text = Util.AutoFindInstallPath(); + if (!string.IsNullOrEmpty(txtPath.Text)) + { + patcher.IntallPath = txtPath.Text; + btnRestore.Enabled = File.Exists(patcher.BakPath); + } + } + + private void btnPatch_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(txtPath.Text) || !Util.IsWechatInstallPath(txtPath.Text)) + { + MessageBox.Show("请选择微信安装路径!"); + return; + } + patcher.IntallPath = txtPath.Text; + + try + { + btnPatch.Enabled = false; + string version = patcher.JudgeVersion(); + if (!string.IsNullOrEmpty(version)) + { + if (version == "done") + { + MessageBox.Show("已经安装过防撤回补丁了"); + btnPatch.Enabled = true; + return; + } + + if (patcher.Patch()) + { + MessageBox.Show("成功安装防撤回补丁!原 WeChatWin.dll 文件已经备份到 " + patcher.BakPath + " ,如果有问题可以手动覆盖恢复"); + } + else + { + MessageBox.Show("防撤回补丁安装失败!"); + } + btnRestore.Enabled = File.Exists(patcher.BakPath); + } + else + { + MessageBox.Show("当前微信版本不被支持:" + Util.GetFileVersion(patcher.DllPath)); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + MessageBox.Show(ex.Message); + } + btnPatch.Enabled = true; + } + + private void txtPath_TextChanged(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(txtPath.Text)) + { + patcher.IntallPath = txtPath.Text; + btnRestore.Enabled = File.Exists(patcher.BakPath); + } + } + + private void btnChoosePath_Click(object sender, EventArgs e) + { + FolderBrowserDialog dialog = new FolderBrowserDialog(); + dialog.Description = "请选择微信安装路径"; + if (dialog.ShowDialog() == DialogResult.OK) + { + if (string.IsNullOrEmpty(dialog.SelectedPath) || !Util.IsWechatInstallPath(dialog.SelectedPath)) + { + MessageBox.Show("无法找到微信关键文件,请选择正确的微信安装路径!"); + } + else + { + txtPath.Text = dialog.SelectedPath; + } + } + } + + private void btnRestore_Click(object sender, EventArgs e) + { + btnRestore.Enabled = false; + try + { + if (File.Exists(patcher.BakPath)) + { + File.Copy(patcher.BakPath, patcher.DllPath, true); + MessageBox.Show("还原成功"); + } + else + { + MessageBox.Show("备份文件不存在"); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + MessageBox.Show(ex.Message); + } + btnRestore.Enabled = File.Exists(patcher.BakPath); + } + } +} diff --git a/RevokeMsgPatcher/FormMain.resx b/RevokeMsgPatcher/FormMain.resx new file mode 100644 index 0000000..97c6724 --- /dev/null +++ b/RevokeMsgPatcher/FormMain.resx @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAAAAAAAAAAAAAAAAAAAA + AADn7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/W2t//zdHW/+bt8f/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5u3y/6Omqf/N1Nb/sbW4/83R1v/m7fH/5+3y/+ft + 8v/m7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5Oru/7O3uf/O0tf/y9DU/7C0 + t/+5vcD/s7i6/9TZ3f/n7PL/5+zy/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+zy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7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5u3y/+bt + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft8v/n7fL/5+3y/+ft + 8v/n7fL/5+3y/+ft8v/n7fL/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/RevokeMsgPatcher/Model/TargetFile.cs b/RevokeMsgPatcher/Model/TargetFile.cs new file mode 100644 index 0000000..f4c8819 --- /dev/null +++ b/RevokeMsgPatcher/Model/TargetFile.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RevokeMsgPatcher.Model +{ + public class TargetFile + { + public string FileName { get; set; } + + public string Version { get; set; } + + public string SHA1Before { get; set; } + + public string SHA1After { get; set; } + + public long Position { get; set; } + + public byte Content { get; set; } + } +} diff --git a/RevokeMsgPatcher/Patcher.cs b/RevokeMsgPatcher/Patcher.cs new file mode 100644 index 0000000..5154494 --- /dev/null +++ b/RevokeMsgPatcher/Patcher.cs @@ -0,0 +1,86 @@ +using RevokeMsgPatcher.Model; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Web.Script.Serialization; + +namespace RevokeMsgPatcher +{ + public class Patcher + { + + private string intallPath; + public string IntallPath + { + get { return intallPath; } + set + { + intallPath = value; + if (!string.IsNullOrEmpty(intallPath) && Util.IsWechatInstallPath(intallPath)) + { + dllPath = Path.Combine(intallPath, "WeChatWin.dll"); + bakPath = Path.Combine(intallPath, "WeChatWin.dll.h.bak"); + } + else + { + intallPath = null; + dllPath = null; + bakPath = null; + } + } + } + + private string dllPath; + private string bakPath; + + public string DllPath { get => dllPath; } + public string BakPath { get => bakPath; } + + private List targetFiles; + private TargetFile currentFile; + + public Patcher() + { + JavaScriptSerializer serializer = new JavaScriptSerializer(); + targetFiles = serializer.Deserialize>(Properties.Resources.PatchJson); + } + + public string JudgeVersion() + { + string sha1 = Util.ComputeFileSHA1(dllPath); + Debug.WriteLine(sha1); + + foreach (TargetFile t in targetFiles) + { + if (sha1 == t.SHA1After) + { + return "done"; + } + if (sha1 == t.SHA1Before) + { + currentFile = t; + return t.Version; + } + } + + return null; + } + + public bool Patch() + { + if (currentFile != null) + { + File.Copy(dllPath, bakPath, true); + bool done = Util.EditHex(dllPath, currentFile.Position, currentFile.Content); + if (!done) + { + File.Copy(bakPath, dllPath, true); + } + return done; + } + return false; + } + + } +} diff --git a/RevokeMsgPatcher/Program.cs b/RevokeMsgPatcher/Program.cs new file mode 100644 index 0000000..6141c46 --- /dev/null +++ b/RevokeMsgPatcher/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RevokeMsgPatcher +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormMain()); + } + } +} diff --git a/RevokeMsgPatcher/Properties/AssemblyInfo.cs b/RevokeMsgPatcher/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c5bf89b --- /dev/null +++ b/RevokeMsgPatcher/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("RevokeMsgPatcher")] +[assembly: AssemblyDescription("微信防撤回补丁")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("huiyadanli")] +[assembly: AssemblyProduct("RevokeMsgPatcher")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("977bf781-ced8-4389-9404-0fa08fdf21df")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +//[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RevokeMsgPatcher/Properties/Resources.Designer.cs b/RevokeMsgPatcher/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4b62cbf --- /dev/null +++ b/RevokeMsgPatcher/Properties/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace RevokeMsgPatcher.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RevokeMsgPatcher.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找类似 [{"FileName":"WeChatWin.dll","Version":"2.6.8.52","SHA1Before":"88131302f664df6a657c9ca49d152da536fe5729","SHA1After":"8d1454b73831644181e962c1fa0ea4e2da4124a3","Position":2453049,"Content":117},{"FileName":"WeChatWin.dll","Version":"2.6.8.51","SHA1Before":"d0a5517b1292a751501b00b4b1f0702db2d9fc30","SHA1After":"53e7b1525d49bf2c3250a8131ff0ba2510779b78","Position":2452614,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.8.37","SHA1Before":"7e01f8b04a158a4a50bc5a6e67c2fb8b02233170","SHA1After":"a1895 [字符串的其余部分被截断]"; 的本地化字符串。 + /// + internal static string PatchJson { + get { + return ResourceManager.GetString("PatchJson", resourceCulture); + } + } + } +} diff --git a/RevokeMsgPatcher/Properties/Resources.resx b/RevokeMsgPatcher/Properties/Resources.resx new file mode 100644 index 0000000..27ac4a3 --- /dev/null +++ b/RevokeMsgPatcher/Properties/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + [{"FileName":"WeChatWin.dll","Version":"2.6.8.52","SHA1Before":"88131302f664df6a657c9ca49d152da536fe5729","SHA1After":"8d1454b73831644181e962c1fa0ea4e2da4124a3","Position":2453049,"Content":117},{"FileName":"WeChatWin.dll","Version":"2.6.8.51","SHA1Before":"d0a5517b1292a751501b00b4b1f0702db2d9fc30","SHA1After":"53e7b1525d49bf2c3250a8131ff0ba2510779b78","Position":2452614,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.8.37","SHA1Before":"7e01f8b04a158a4a50bc5a6e67c2fb8b02233170","SHA1After":"a1895004415fe9bcd7e690bd6e482b833b515599","Position":2452614,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.7.57","SHA1Before":"80a91aaf941bcb1c24a7d672838ac73e9ebb2e40","SHA1After":"a0d3f9a45a835f97aef7fe0872387d8cfb5c25a4","Position":2433413,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.7.40","SHA1Before":"04bd0cb28df6630b518f42a3f9c2caa4a9359fbc","SHA1After":"13c91cf1d4609959771fd137b9a86a5ca365e1b6","Position":2432934,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.7.32","SHA1Before":"a02519c1007ee6723947c262c720d63c619f633e","SHA1After":"f3007471ca8734c29783c25f0bb49949a783a44","Position":2432806,"Content":116},{"FileName":"WeChatWin.dll","Version":"2.6.6.28","SHA1Before":"0b19cb17a62c3ea0efce0fb675a1d3b17845cba3","SHA1After":"260948656725446b818ea668273ceff02ddfb44d","Position":2401678,"Content":116}] + + \ No newline at end of file diff --git a/RevokeMsgPatcher/Properties/Settings.Designer.cs b/RevokeMsgPatcher/Properties/Settings.Designer.cs new file mode 100644 index 0000000..1de01ec --- /dev/null +++ b/RevokeMsgPatcher/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RevokeMsgPatcher.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/RevokeMsgPatcher/Properties/Settings.settings b/RevokeMsgPatcher/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/RevokeMsgPatcher/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/RevokeMsgPatcher/RevokeMsgPatcher.csproj b/RevokeMsgPatcher/RevokeMsgPatcher.csproj new file mode 100644 index 0000000..5b77683 --- /dev/null +++ b/RevokeMsgPatcher/RevokeMsgPatcher.csproj @@ -0,0 +1,93 @@ + + + + + Debug + AnyCPU + {977BF781-CED8-4389-9404-0FA08FDF21DF} + WinExe + RevokeMsgPatcher + RevokeMsgPatcher + v4.5 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + icon.ico + + + + + + + + + + + + + + + + + + Form + + + FormMain.cs + + + + + + + + FormMain.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + \ No newline at end of file diff --git a/RevokeMsgPatcher/Util.cs b/RevokeMsgPatcher/Util.cs new file mode 100644 index 0000000..32e8668 --- /dev/null +++ b/RevokeMsgPatcher/Util.cs @@ -0,0 +1,102 @@ +using Microsoft.Win32; +using System; +using System.Diagnostics; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace RevokeMsgPatcher +{ + public class Util + { + + /// + /// 自动查找安装路径 + /// + /// 安装路径 + public static string AutoFindInstallPath() + { + // 微信的注册表路径 + RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\WeChat"); + object installLocation = key.GetValue("InstallLocation"); + key.Close(); + if (installLocation == null || string.IsNullOrEmpty(installLocation.ToString()) || !IsWechatInstallPath(installLocation.ToString())) + { + // 从默认安装目录查找 + string[] drives = Environment.GetLogicalDrives(); //获取当前计算机逻辑磁盘名称列表 + foreach (string d in drives) + { + string assertPath = Path.Combine(d, @"Program Files (x86)\Tencent\WeChat"); + if (IsWechatInstallPath(assertPath)) + { + return assertPath; + } + } + } + else + { + return installLocation.ToString(); + } + return null; + } + + /// + /// 通过文件是否存在判断是否是安装目录 + /// + /// 安装目录 + /// + public static bool IsWechatInstallPath(string path) + { + return File.Exists(Path.Combine(path, "WeChatWin.dll")) && File.Exists(Path.Combine(path, "WeChat.exe")); + } + + /// + /// 获取文件版本 + /// + /// + /// + public static string GetFileVersion(string path) + { + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(path); + return fileVersionInfo.FileVersion; + } + + /// + /// 计算文件SHA1 + /// + /// + /// + public static string ComputeFileSHA1(string s) + { + FileStream file = new FileStream(s, FileMode.Open); + SHA1 sha1 = new SHA1CryptoServiceProvider(); + byte[] retval = sha1.ComputeHash(file); + file.Close(); + + StringBuilder sc = new StringBuilder(); + for (int i = 0; i < retval.Length; i++) + { + sc.Append(retval[i].ToString("x2")); + } + return sc.ToString(); + } + + /// + /// 修改文件指定位置的字节 + /// + /// WeChatWin.dll 的路径 + /// 偏移位置 + /// 修改后的值 + /// + public static bool EditHex(string path, long position, byte after) + { + using (var stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)) + { + stream.Position = position; + stream.WriteByte(after); + } + return true; + + } + } +} diff --git a/RevokeMsgPatcher/icon.ico b/RevokeMsgPatcher/icon.ico new file mode 100644 index 0000000..cf59834 Binary files /dev/null and b/RevokeMsgPatcher/icon.ico differ