This repository was archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (51 loc) · 1.96 KB
/
Program.cs
File metadata and controls
56 lines (51 loc) · 1.96 KB
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
using System;
using System.Collections.Generic;
using ILject.Core;
namespace ILject.SamplePatch
{
internal class Program
{
// ReSharper disable once UnusedMember.Local
// ReSharper disable once SuggestBaseTypeForParameter
private static void Main(string[] args)
{
var arguments = ValidateArguments(args);
if (arguments.IsValid)
{
var context = new PatchContext(arguments.CoreExecutableName);
context.LoadInjectors(new[] {new SampleCoreInjector()});
context.RunInjectors();
context.Run();
Console.WriteLine($"Finished running .NET Core injection sample.{Environment.NewLine}Press Any key to continue");
Console.ReadKey(true);
context = new PatchContext(arguments.FrameworkExecutableName);
context.LoadInjectors(new[] {new SampleFrameworkInjector()});
context.RunInjectors();
context.Run();
Console.WriteLine("Finished running .NET Framework injection sample.");
}
Console.WriteLine("Press any key to quit");
Console.ReadKey(true);
}
private static Arguments ValidateArguments(IReadOnlyList<string> args)
{
var arguments = new Arguments {IsValid = args.Count == 2};
if (arguments.IsValid)
{
arguments.CoreExecutableName = args[0];
arguments.FrameworkExecutableName = args[1];
}
else
{
Console.Error.WriteLine("Invalid usage. Correct usage is \"ILject core-filename framework-filename\"");
}
return arguments;
}
internal class Arguments
{
public bool IsValid { get; set; }
public string CoreExecutableName { get; set; }
public string FrameworkExecutableName { get; set; }
}
}
}