forked from huiyadanli/RevokeMsgPatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f29f67
commit 39bc377
Showing
10 changed files
with
218 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
//} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.