mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-23 05:38:12 +08:00
[+] 临时添加钉钉防撤回
This commit is contained in:
parent
07f52a4bdf
commit
e4b5d3d933
|
@ -798,5 +798,51 @@ namespace RevokeMsgPatcher
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
public App DingTalk()
|
||||
{
|
||||
return new App
|
||||
{
|
||||
Name = "DingTalk",
|
||||
MainAppRelativePath = @"main\current\DingTalk.exe",
|
||||
FileTargetInfos = new Dictionary<string, TargetInfo>
|
||||
{
|
||||
{
|
||||
"MainFrame.dll",
|
||||
new TargetInfo
|
||||
{
|
||||
Name = "MainFrame.dll",
|
||||
RelativePath = @"main\current\MainFrame.dll"
|
||||
}
|
||||
}
|
||||
},
|
||||
FileCommonModifyInfos = new Dictionary<string, List<CommonModifyInfo>>
|
||||
{
|
||||
{
|
||||
"MainFrame.dll",
|
||||
new List<CommonModifyInfo>
|
||||
{
|
||||
new CommonModifyInfo
|
||||
{
|
||||
Name="MainFrame.dll",
|
||||
StartVersion="4.0.00.00",
|
||||
EndVersion="",
|
||||
ReplacePatterns = new List<ReplacePattern>
|
||||
{
|
||||
new ReplacePattern
|
||||
{
|
||||
Search = ByteUtil.HexStringToByteArray("CC CC CC CC CC CC CC 55 8B EC 83 E4 F8 6A FF 68"),
|
||||
Replace = ByteUtil.HexStringToByteArray("CC CC CC CC CC CC CC C3 8B EC 83 E4 F8 6A FF 68"),
|
||||
Start = 0x400000,
|
||||
Category = "防撤回"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using RevokeMsgPatcher.Model;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -10,8 +11,8 @@ namespace RevokeMsgPatcher.Matcher
|
|||
// TODO 该逻辑需要优化!
|
||||
public static List<Change> FindChanges(string path, List<ReplacePattern> replacePatterns)
|
||||
{
|
||||
// 读取整个文件(dll)
|
||||
byte[] fileByteArray = File.ReadAllBytes(path);
|
||||
// 读取整个文件(dll) // 20200721 钉钉:读取 先不改了!
|
||||
byte[] fileByteArray = FileUtil.ReadFileBytes(path, replacePatterns[0].Start);
|
||||
|
||||
List<Change> changes = new List<Change>(); // 匹配且需要替换的地方
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ namespace RevokeMsgPatcher.Model
|
|||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主程序相对路径, 非必填, 用于主程序版本号的使用
|
||||
/// </summary>
|
||||
public string MainAppRelativePath { get; set; }
|
||||
|
||||
public Dictionary<string, TargetInfo> FileTargetInfos { get; set; }
|
||||
|
||||
public Dictionary<string, List<ModifyInfo>> FileModifyInfos { get; set; }
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace RevokeMsgPatcher.Model
|
|||
|
||||
public byte[] Replace { get; set; }
|
||||
|
||||
public int Start { get; set; }
|
||||
|
||||
public string Category { get; set; }
|
||||
|
||||
public ReplacePattern Clone()
|
||||
|
|
111
RevokeMsgPatcher/Modifier/DingTalkModifier.cs
Normal file
111
RevokeMsgPatcher/Modifier/DingTalkModifier.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using RevokeMsgPatcher.Model;
|
||||
using RevokeMsgPatcher.Utils;
|
||||
|
||||
namespace RevokeMsgPatcher.Modifier
|
||||
{
|
||||
class DingTalkModifier : AppModifier
|
||||
{
|
||||
public DingTalkModifier(App config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 钉钉
|
||||
/// x64: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\钉钉
|
||||
/// x86: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\钉钉
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string FindInstallPath()
|
||||
{
|
||||
string installPath = FindDingTalkInstallPathFromRegistry();
|
||||
if (!IsAllFilesExist(installPath))
|
||||
{
|
||||
foreach (string defaultPath in PathUtil.GetDefaultInstallPaths(@"DingDing"))
|
||||
{
|
||||
if (IsAllFilesExist(defaultPath))
|
||||
{
|
||||
return defaultPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return installPath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private string FindDingTalkInstallPathFromRegistry()
|
||||
{
|
||||
List<string> registryPaths = new List<string>();
|
||||
// 获取系统位数
|
||||
if (Environment.Is64BitProcess)
|
||||
{
|
||||
registryPaths.Add(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\钉钉");
|
||||
}
|
||||
else
|
||||
{
|
||||
registryPaths.Add(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\钉钉");
|
||||
}
|
||||
try
|
||||
{
|
||||
object uninstallExe = null;
|
||||
foreach (string registryPath in registryPaths)
|
||||
{
|
||||
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\钉钉");
|
||||
if (key == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
uninstallExe = key.GetValue("UninstallString");
|
||||
key.Close();
|
||||
if (uninstallExe != null && !string.IsNullOrEmpty(uninstallExe.ToString()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 再判断一次
|
||||
if (uninstallExe != null && !string.IsNullOrEmpty(uninstallExe.ToString()))
|
||||
{
|
||||
return uninstallExe.ToString().Replace("uninst.exe", "");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string GetVersion()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a.初始化修改器
|
||||
/// 使用主程序的版本
|
||||
/// </summary>
|
||||
/// <param name="installPath">APP安装路径</param>
|
||||
public new void InitEditors(string installPath)
|
||||
{
|
||||
string mainVersion = GetVersion();
|
||||
// 初始化文件修改器
|
||||
editors = new List<FileHexEditor>();
|
||||
foreach (TargetInfo info in config.FileTargetInfos.Values)
|
||||
{
|
||||
FileHexEditor editor = new FileHexEditor(installPath, info, mainVersion);
|
||||
editors.Add(editor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ namespace RevokeMsgPatcher.Modifier
|
|||
{
|
||||
get
|
||||
{
|
||||
// 获取当前最新的备份文件版本号
|
||||
return FileUtil.GetFileVersion(FileBakPath);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ namespace RevokeMsgPatcher.Modifier
|
|||
/// </summary>
|
||||
public List<Change> TargetChanges { get; set; }
|
||||
|
||||
public FileHexEditor(string installPath, TargetInfo target)
|
||||
public FileHexEditor(string installPath, TargetInfo target, string mainAppVersion = null)
|
||||
{
|
||||
FileTargetInfo = target.Clone();
|
||||
FileName = FileTargetInfo.Name;
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<Compile Include="Model\ReplacePattern.cs" />
|
||||
<Compile Include="Model\TargetInfo.cs" />
|
||||
<Compile Include="Modifier\AppModifier.cs" />
|
||||
<Compile Include="Modifier\DingTalkModifier.cs" />
|
||||
<Compile Include="Modifier\FileHexEditor.cs" />
|
||||
<Compile Include="Modifier\QQLiteModifier.cs" />
|
||||
<Compile Include="Modifier\QQModifier.cs" />
|
||||
|
|
|
@ -74,5 +74,15 @@ namespace RevokeMsgPatcher.Utils
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] ReadFileBytes(string path, int start)
|
||||
{
|
||||
using (FileStream fsSource = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
byte[] bytes = new byte[fsSource.Length - start];
|
||||
fsSource.Read(bytes, start, (int)fsSource.Length);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user