Skip to content

Commit

Permalink
集成 LiteLoaderQQNT
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Jun 14, 2024
1 parent f734a67 commit 8b63257
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RevokeMsgPatcher.Assistant/Data/1.8/patch.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion RevokeMsgPatcher.Assistant/JsonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ public App QQNT()
{
Search = ByteUtil.HexStringToByteArray("48 89 CE 48 8B 11 4C 8B 41 08 49 29 D0 48 8B 49 18 E8 3F 3F 3F 3F"),
Replace = ByteUtil.HexStringToByteArray("48 89 CE 48 8B 11 4C 8B 41 08 49 29 D0 48 8B 49 18 B8 01 00 00 00"),
Category = "去校验"
Category = "LiteLoaderQQNT+插件列表+防撤回"
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions RevokeMsgPatcher/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void btnPatch_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(@"防撤回(老) 和 防撤回带提示(新) 两个功能二选一即可!
1. 防撤回(老) 没有提示;
1. 防撤回(老) 没有提示,新版本会出现撤回自己消息不断转圈的情况(实际撤回成功)
2. 防撤回带提示(新) 有撤回提示 但是存在以下问题:
a. 如果正在和对方聊天时,对方撤回了消息,那撤回提示依然不会显示,只有在左侧预览窗有显示撤回,需要切换到和别人的聊天窗再切回来才能看到撤回提示,如果是把聊天拉出单独窗口,一直不会有撤回提示。
Expand Down Expand Up @@ -221,7 +221,7 @@ c. 部分历史消息无法防撤回;
{
modifier.Patch();
ga.RequestPageView($"{enName}/{version}/patch/succ", "补丁安装成功");
MessageBox.Show("补丁安装成功!");
MessageBox.Show("补丁安装成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (BusinessException ex)
{
Expand Down Expand Up @@ -280,7 +280,16 @@ private void btnRestore_Click(object sender, EventArgs e)
EnableAllButton(false);
try
{
bool succ = modifier.Restore();
bool succ;
if (rbtQQNT.Checked)
{
succ = qqntModifier.Restore();
}
else
{
succ = modifier.Restore();
}

if (succ)
{
MessageBox.Show("还原成功!");
Expand Down
17 changes: 17 additions & 0 deletions RevokeMsgPatcher/Modifier/AppModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public void SetVersionLabelAndCategoryCategories(Label label, Panel panel)
if (j == editors.Count)
{
label.Text = version + "(支持特征防撤回)";
// QQNT 特殊处理
if (config.Name == "QQNT")
{
label.Text = version + "(支持LiteLoader)";
}

label.ForeColor = Color.LimeGreen;
UIController.AddCategoryCheckBoxToPanel(panel, categories.ToArray(), installed.ToArray());
}
Expand Down Expand Up @@ -256,6 +262,8 @@ public bool EditorsHasCommonModifyInfos()
/// <param name="installPath">APP安装路径</param>
public bool InitEditors(string installPath)
{
InstallPath = null;

// 初始化文件修改器
editors = new List<FileHexEditor>();
foreach (TargetInfo info in config.FileTargetInfos.Values)
Expand All @@ -275,6 +283,8 @@ public bool InitEditors(string installPath)
return false;
}

InstallPath = installPath;

return true;
}

Expand Down Expand Up @@ -413,6 +423,8 @@ public bool Patch()
done.Add(editor);
}
}

AfterPatchSuccess();
}
catch (Exception ex)
{
Expand All @@ -422,6 +434,7 @@ public bool Patch()
editor.Restore();
}

AfterPatchFail();
throw ex;
}

Expand Down Expand Up @@ -478,5 +491,9 @@ public bool Restore()
throw new Exception("备份文件不存在,还原失败!");
}
}

public abstract void AfterPatchSuccess();

public abstract void AfterPatchFail();
}
}
8 changes: 8 additions & 0 deletions RevokeMsgPatcher/Modifier/QQLiteModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ public QQLiteModifier(App config)
this.config = config;
}

public override void AfterPatchSuccess()
{
}

public override void AfterPatchFail()
{
}

/// <summary>
/// 自动寻找获取微信安装路径
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions RevokeMsgPatcher/Modifier/QQModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ public QQModifier(App config)
this.config = config;
}

public override void AfterPatchSuccess()
{
}

public override void AfterPatchFail()
{
}

/// <summary>
/// 自动寻找获取微信安装路径
/// </summary>
Expand Down
68 changes: 68 additions & 0 deletions RevokeMsgPatcher/Modifier/QQNTModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace RevokeMsgPatcher.Modifier
{
Expand Down Expand Up @@ -75,5 +78,70 @@ public override string GetVersion()

return "";
}

public string GetIndexJsPath()
{
if (string.IsNullOrEmpty(InstallPath))
{
throw new Exception("未获取到QQNT安装路径或者QQNT安装路径不合法");
}

string indexPath = Path.Combine(InstallPath, @"resources\app\app_launcher\index.js");
if (!File.Exists(indexPath))
{
throw new Exception("未找到index.js文件");
}

return indexPath;
}

public string GetLiteLoaderPath()
{
return Path.Combine(Application.StartupPath, @"LiteLoaderQQNT");
}

public override void AfterPatchSuccess()
{
string indexPath = GetIndexJsPath();
string content = File.ReadAllText(indexPath);
// 正则 require\(String.raw`.*`\);
string pattern = @"require\(String.raw`.*`\);";
string replacement = $"require(String.raw`{GetLiteLoaderPath()}`);";
if (Regex.IsMatch(content, pattern))
{
content = Regex.Replace(content, pattern, replacement);
}
else
{
content = replacement + "\n" + content;
}

File.WriteAllText(indexPath, content);
}

public override void AfterPatchFail()
{
try
{
string indexPath = GetIndexJsPath();
string content = File.ReadAllText(indexPath);
string pattern = @"require\(String.raw`.*`\);\n";
if (Regex.IsMatch(content, pattern))
{
content = Regex.Replace(content, pattern, "");
File.WriteAllText(indexPath, content);
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}

public new bool Restore()
{
AfterPatchFail();
return base.Restore();
}
}
}
9 changes: 9 additions & 0 deletions RevokeMsgPatcher/Modifier/TIMModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ public TIMModifier(App config)
{
this.config = config;
}

public override void AfterPatchSuccess()
{
}

public override void AfterPatchFail()
{
}

/// <summary>
/// 自动寻找获取微信安装路径
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions RevokeMsgPatcher/Modifier/WechatModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public WechatModifier(App config)
this.config = config;
}

public override void AfterPatchSuccess()
{
}

public override void AfterPatchFail()
{
}

/// <summary>
/// 自动寻找获取微信安装路径
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions RevokeMsgPatcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
//[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7")]
[assembly: AssemblyFileVersion("1.7")]
[assembly: AssemblyVersion("1.8")]
[assembly: AssemblyFileVersion("1.8")]
2 changes: 1 addition & 1 deletion RevokeMsgPatcher/Properties/Resources.resx

Large diffs are not rendered by default.

0 comments on commit 8b63257

Please sign in to comment.