-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSamples.cs
More file actions
63 lines (52 loc) · 1.5 KB
/
Samples.cs
File metadata and controls
63 lines (52 loc) · 1.5 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
57
58
59
60
61
62
63
namespace Interceptor
{
using System;
using Interceptor.Hooking;
class Samples
{
public static int A(int x, int y)
{
Console.WriteLine($"Program.A({x}, {y})");
return x + y;
}
public static int B(int x, int y)
{
Console.WriteLine($"Program.B({x}, {y})");
return x + y;
}
public class Foo
{
public void A()
{
Console.WriteLine("Foo.A");
}
public void B()
{
Console.WriteLine("Foo.B");
}
public void G(int x)
{
Console.WriteLine($"Foo.G{x}");
}
};
public static void G(Foo foo, int x)
{
Console.WriteLine($"Program.Foo.G({x})");
}
static void Main(string[] args)
{
Interceptor[] interceptor = new[]
{
new Interceptor(typeof(Samples).GetMethod("A"), typeof(Samples).GetMethod("B")),
new Interceptor(typeof(Foo).GetMethod("A"), typeof(Foo).GetMethod("B")),
new Interceptor(typeof(Foo).GetMethod("G"), typeof(Samples).GetMethod("G")),
};
A(1, 2);
Foo foo = new Foo();
foo.A();
foo.G(3);
interceptor[2].Invoke(() => foo.G(3));
Console.ReadKey(false);
}
}
}