Skip to content

Commit

Permalink
[+] 支持 Weixin 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Nov 6, 2024
1 parent 0f29f67 commit 39bc377
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 13 deletions.
1 change: 1 addition & 0 deletions RevokeMsgPatcher.Assistant/Data/2.0/patch.json

Large diffs are not rendered by default.

49 changes: 47 additions & 2 deletions RevokeMsgPatcher.Assistant/JsonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public Bag Bag()
return new Bag
{
Apps = AppConfig(),
LatestVersion = "1.9",
PatchVersion = 20240929,
LatestVersion = "2.0",
PatchVersion = 20241106,
Notice = "",
NoticeUrl = "",
};
Expand All @@ -34,6 +34,7 @@ public Dictionary<string, App> AppConfig()
return new Dictionary<string, App>
{
{ "Wechat" , Wechat() },
{ "Weixin" , Weixin() },
{ "QQ" , QQ() },
{ "TIM" , TIM() },
{ "QQLite" , QQLite() },
Expand Down Expand Up @@ -1389,5 +1390,49 @@ public App QQNT()
}
};
}

public App Weixin()
{
return new App
{
Name = "Weixin",
FileTargetInfos = new Dictionary<string, TargetInfo>
{
{
"Weixin.dll",
new TargetInfo
{
Name = "Weixin.dll",
RelativePath = "Weixin.dll",
StartVersion = "1.0.0.0"
}
}
},
FileCommonModifyInfos = new Dictionary<string, List<CommonModifyInfo>>
{
{
"Weixin.dll",
new List<CommonModifyInfo>
{
new CommonModifyInfo
{
Name="Weixin.dll",
StartVersion="4.0.0.0",
EndVersion="",
ReplacePatterns = new List<ReplacePattern>
{
new ReplacePattern
{
Search = ByteUtil.HexStringToByteArray("57 53 48 83 EC 20 48 89 CE 80 3D D1 F7 DC 05 00 75 21 48 B8"),
Replace = ByteUtil.HexStringToByteArray("57 53 48 83 EC 20 48 89 CE 80 3D D1 F7 DC 05 00 EB 21 48 B8"),
Category = "防撤回"
}
}
}
}
}
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<None Include="Data\1.7\patch.json" />
<None Include="Data\1.8\patch.json" />
<None Include="Data\1.9\patch.json" />
<None Include="Data\2.0\patch.json" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
23 changes: 18 additions & 5 deletions RevokeMsgPatcher/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions RevokeMsgPatcher/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public partial class FormMain : Form
private AppModifier modifier = null;

private WechatModifier wechatModifier = null;
private WeixinModifier weixinModifier = null;
private QQModifier qqModifier = null;
private TIMModifier timModifier = null;
private QQLiteModifier qqLiteModifier = null;
Expand All @@ -42,12 +43,14 @@ public void InitModifier()

// 初始化每个应用对应的修改者
wechatModifier = new WechatModifier(bag.Apps["Wechat"]);
weixinModifier = new WeixinModifier(bag.Apps["Weixin"]);
qqModifier = new QQModifier(bag.Apps["QQ"]);
timModifier = new TIMModifier(bag.Apps["TIM"]);
qqLiteModifier = new QQLiteModifier(bag.Apps["QQLite"]);
qqntModifier = new QQNTModifier(bag.Apps["QQNT"]);

rbtWechat.Tag = wechatModifier;
rbtWeixin.Tag = weixinModifier;
rbtQQ.Tag = qqModifier;
rbtTIM.Tag = timModifier;
rbtQQLite.Tag = qqLiteModifier;
Expand Down Expand Up @@ -347,6 +350,7 @@ private async void FormMain_Load(object sender, EventArgs e)
lblUpdatePachJson.ForeColor = Color.RoyalBlue;

wechatModifier.Config = newBag.Apps["Wechat"];
weixinModifier.Config = newBag.Apps["Weixin"];
qqModifier.Config = newBag.Apps["QQ"];
timModifier.Config = newBag.Apps["TIM"];
qqLiteModifier.Config = newBag.Apps["QQLite"];
Expand Down Expand Up @@ -384,6 +388,7 @@ private void lblUpdatePachJson_Click(object sender, EventArgs e)

tips += "支持以下版本" + Environment.NewLine;
tips += " ➯ 微信:" + wechatModifier.Config.GetSupportVersionStr() + Environment.NewLine;
tips += " ➯ 微信4.0:" + weixinModifier.Config.GetSupportVersionStr() + Environment.NewLine;
tips += " ➯ QQNT:" + qqntModifier.Config.GetSupportVersionStr() + Environment.NewLine;
tips += " ➯ QQ:" + qqModifier.Config.GetSupportVersionStr() + Environment.NewLine;
tips += " ➯ QQ轻聊版:" + qqLiteModifier.Config.GetSupportVersionStr() + Environment.NewLine;
Expand Down Expand Up @@ -411,6 +416,10 @@ private void radioButtons_CheckedChanged(object sender, EventArgs e)
{
modifier = (WechatModifier)rbtWechat.Tag;
}
else if (rbtWeixin.Checked)
{
modifier = (WeixinModifier)rbtWeixin.Tag;
}
else if (rbtQQ.Checked)
{
modifier = (QQModifier)rbtQQ.Tag;
Expand Down
2 changes: 1 addition & 1 deletion RevokeMsgPatcher/Modifier/WechatModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override string FindInstallPath()
string realPath = GetRealInstallPath(installPath);
if (string.IsNullOrEmpty(realPath))
{
List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\QQ");
List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\Wechat");
foreach (string defaultPath in defaultPathList)
{
realPath = GetRealInstallPath(defaultPath);
Expand Down
122 changes: 122 additions & 0 deletions RevokeMsgPatcher/Modifier/WeixinModifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using RevokeMsgPatcher.Model;
using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
using System.IO;

namespace RevokeMsgPatcher.Modifier
{
class WeixinModifier : AppModifier
{

public WeixinModifier(App config)
{
this.config = config;
}

public override void AfterPatchSuccess()
{
}

public override void AfterPatchFail()
{
}

/// <summary>
/// 自动寻找获取微信安装路径
/// </summary>
/// <returns></returns>
public override string FindInstallPath()
{
try
{
string installPath = PathUtil.FindInstallPathFromRegistryWOW6432Node("Weixin");
string realPath = null;
if (!string.IsNullOrEmpty(installPath))
{
installPath = Path.GetDirectoryName(installPath);
realPath = GetRealInstallPath(installPath);
}
if (string.IsNullOrEmpty(realPath))
{
List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\Weixin");
foreach (string defaultPath in defaultPathList)
{
realPath = GetRealInstallPath(defaultPath);
if (!string.IsNullOrEmpty(realPath))
{
return defaultPath;
}
}
}
else
{
return realPath;
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null;
}

/// <summary>
/// 微信目录结构
/// </summary>
/// <param name="basePath"></param>
/// <returns></returns>
private string GetRealInstallPath(string basePath)
{
if (basePath == null)
{
return null;
}
DirectoryInfo[] directories = new DirectoryInfo(basePath).GetDirectories();
PathUtil.SortByLastWriteTimeDesc(ref directories); // 按修改时间倒序
foreach (DirectoryInfo folder in directories)
{
if (IsAllFilesExist(folder.FullName))
{
return folder.FullName;
}
}
return null;
}


/// <summary>
/// 获取整个APP的当前版本
/// </summary>
/// <returns></returns>
public override string GetVersion()
{
if (editors != null && editors.Count > 0)
{
foreach (FileHexEditor editor in editors)
{
if (editor.FileName == "Weixin.dll")
{
return editor.FileVersion;
}
}
}
return "";
}

//public override bool ValidateAndInitialize(string installPath)
//{
// // 判断是否是安装路径
// if (!IsAllBinaryFilesExist(installPath))
// {
// return false;
// }

// // 初始化十六进制文件编辑器
// // 并寻找与之配对的版本修改信息
// InitEditors(installPath);

// return true;
//}
}
}
2 changes: 1 addition & 1 deletion RevokeMsgPatcher/Properties/Resources.resx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions RevokeMsgPatcher/RevokeMsgPatcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<Compile Include="Modifier\QQNTModifier.cs" />
<Compile Include="Modifier\QQModifier.cs" />
<Compile Include="Modifier\TIMModifier.cs" />
<Compile Include="Modifier\WeixinModifier.cs" />
<Compile Include="Modifier\WechatModifier.cs" />
<Compile Include="Utils\ByteUtil.cs" />
<Compile Include="Utils\Device.cs" />
Expand Down
Loading

0 comments on commit 39bc377

Please sign in to comment.