Files
Shrink-IDC/Program.cs
Eicy 2b7632344e +发信代码
Signed-off-by: Eicy <im@crash.work>
2024-12-18 01:43:47 +08:00

71 lines
2.3 KiB
C#

using Debugger;
using Grpc.Core;
using Shrink.API;
using Shrink.Command;
using Shrink.Login;
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);*/
const int port = 50051;
var server = new Server
{
Services = { BotService.BindService(new BotServiceImpl()) },
Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine($"gRPC server listening on port {port}");
await QrCode.Instance.Login();
await Commands.Instance.Init();
await Commands.Instance.Run();
//await server.ShutdownAsync();
}
/*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}");
}*/
}