mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2026-09-12 01:00:49 +08:00
集成 LiteLoaderQQNT
This commit is contained in:
@@ -134,6 +134,12 @@ namespace RevokeMsgPatcher.Modifier
|
||||
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());
|
||||
}
|
||||
@@ -256,6 +262,8 @@ namespace RevokeMsgPatcher.Modifier
|
||||
/// <param name="installPath">APP安装路径</param>
|
||||
public bool InitEditors(string installPath)
|
||||
{
|
||||
InstallPath = null;
|
||||
|
||||
// 初始化文件修改器
|
||||
editors = new List<FileHexEditor>();
|
||||
foreach (TargetInfo info in config.FileTargetInfos.Values)
|
||||
@@ -275,6 +283,8 @@ namespace RevokeMsgPatcher.Modifier
|
||||
return false;
|
||||
}
|
||||
|
||||
InstallPath = installPath;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -413,6 +423,8 @@ namespace RevokeMsgPatcher.Modifier
|
||||
done.Add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
AfterPatchSuccess();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -422,6 +434,7 @@ namespace RevokeMsgPatcher.Modifier
|
||||
editor.Restore();
|
||||
}
|
||||
|
||||
AfterPatchFail();
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@@ -478,5 +491,9 @@ namespace RevokeMsgPatcher.Modifier
|
||||
throw new Exception("备份文件不存在,还原失败!");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void AfterPatchSuccess();
|
||||
|
||||
public abstract void AfterPatchFail();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,14 @@ namespace RevokeMsgPatcher.Modifier
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public override void AfterPatchSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public override void AfterPatchFail()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动寻找获取微信安装路径
|
||||
/// </summary>
|
||||
|
||||
@@ -12,6 +12,14 @@ namespace RevokeMsgPatcher.Modifier
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public override void AfterPatchSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public override void AfterPatchFail()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动寻找获取微信安装路径
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -75,5 +78,70 @@ namespace RevokeMsgPatcher.Modifier
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,15 @@ namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public override void AfterPatchSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public override void AfterPatchFail()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动寻找获取微信安装路径
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,14 @@ namespace RevokeMsgPatcher.Modifier
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public override void AfterPatchSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public override void AfterPatchFail()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动寻找获取微信安装路径
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user