-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
57 lines (49 loc) · 1.89 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Mono.Cecil;
using Mono.Cecil.Cil;
using Shrink.Service;
namespace Shrink;
public static class Program
{
public static async Task Main()
{
/*var originalAssemblyPath = "Lagrange.Core.dll";
var tempAssemblyPath = "ModifiedExternalAssembly.dll";
var oldUrl = "自己找";
var newUrl = "自己找";
ModifyAssembly(originalAssemblyPath, tempAssemblyPath, oldUrl, newUrl);*/
await BotService.Instance.Login();
await BotPassiveMsgHandler.Instance.Init();
await BotPassiveMsgHandler.Instance.Run();
}
/*private static void ModifyAssembly(string originalAssemblyPath, string tempAssemblyPath, string oldUrl, string newUrl)
{
var assembly = AssemblyDefinition.ReadAssembly(originalAssemblyPath);
var module = assembly.MainModule;
// 查找LinuxSigner类型
var linuxSignerType = module.Types.FirstOrDefault(t => t.Name == "LinuxSigner");
if (linuxSignerType == null)
{
Console.WriteLine("无LinuxSigner类型");
return;
}
// 查找构造函数
var constructor = linuxSignerType.Methods.FirstOrDefault(m => m.IsConstructor);
if (constructor == null)
{
Console.WriteLine("无构造函数");
return;
}
var ilProcessor = constructor.Body.GetILProcessor();
foreach (var instruction in constructor.Body.Instructions)
{
// 检查是否是加载字符串操作
if (instruction.OpCode == OpCodes.Ldstr && instruction.Operand is string str && str == oldUrl)
{
instruction.Operand = newUrl; // 替换为新URL
Console.WriteLine($"替换: {oldUrl}为{newUrl}");
}
}
assembly.Write(tempAssemblyPath);
Console.WriteLine($"已将修改后的程序集保存在{tempAssemblyPath}");
}*/
}