mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-24 03:56:30 +00:00
8ee7ed23e4
* Release 0.9.9.12 * Move injection to injector executable (#554) * Fix logview missing history (#556) Closes #526 * Detect unresponsive Guild Wars instance (#557) Closes #534 Closes #422
64 lines
1.3 KiB
C#
64 lines
1.3 KiB
C#
using Daybreak.Injector;
|
|
using System.Diagnostics;
|
|
|
|
var processId = -1;
|
|
var pathToDll = string.Empty;
|
|
|
|
if (args.Length != 4)
|
|
{
|
|
Console.WriteLine("Daybreak Injector");
|
|
Console.WriteLine("Usage:");
|
|
Console.WriteLine("Daybreak.Injector.exe -p [PROCESS_ID] -d [PATH_TO_DLL]");
|
|
return -1;
|
|
}
|
|
|
|
for (var i = 0; i < args.Length - 1; i++)
|
|
{
|
|
if (args[i].ToLower() == "-p" &&
|
|
int.TryParse(args[i + 1], out var parsedId))
|
|
{
|
|
processId = parsedId;
|
|
i++;
|
|
}
|
|
else if (args[i].ToLower() == "-d")
|
|
{
|
|
pathToDll = args[i + 1];
|
|
i++;
|
|
}
|
|
}
|
|
|
|
if (processId == -1)
|
|
{
|
|
Console.WriteLine("Error: Process id was not specified");
|
|
return -1;
|
|
}
|
|
|
|
if (pathToDll == string.Empty)
|
|
{
|
|
Console.WriteLine("Error: Path to dll was not specified");
|
|
return -1;
|
|
}
|
|
|
|
if (!File.Exists(pathToDll))
|
|
{
|
|
Console.WriteLine("Error: Provided dll could not be found");
|
|
return -1;
|
|
}
|
|
|
|
var maybeProcess = Process.GetProcessById(processId);
|
|
if (maybeProcess is null)
|
|
{
|
|
Console.WriteLine("Error: Could not find desired process");
|
|
return -1;
|
|
}
|
|
|
|
var result = await ProcessInjector.Inject(maybeProcess, pathToDll, CancellationToken.None);
|
|
if (result is false)
|
|
{
|
|
Console.WriteLine("Error: Failed to inject dll");
|
|
return -1;
|
|
}
|
|
|
|
Console.WriteLine("Injected dll");
|
|
return 0;
|