-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathExample.cs
More file actions
43 lines (31 loc) · 1.17 KB
/
Example.cs
File metadata and controls
43 lines (31 loc) · 1.17 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
using System.IO;
/// <summary>
/// Example assembly, inject with the arguments:
///
/// MonoJunkie.exe -dll "ExampleAssembly.dll" -namespace ExampleAssembly -class Example -method OnLoad -exe targetexe.exe
///
/// </summary>
namespace ExampleAssembly {
public class Example {
/// <summary>
/// Only static methods (that take no arguments) can be called from MonoJunkie.
///
/// Classes that the method lives in will not be instantiated (there is nothing to stop you from instantiating it yourself in the static method, though)!
/// </summary>
public static void OnLoad() {
//In the real world, there is no guarantee we will be able to use standard input/output in the process. I prefer using log files.
using (StreamWriter @out = new StreamWriter(new FileStream("ExampleAssembly.log", FileMode.OpenOrCreate))) {
//Let us know everything is okay and we're up and running.
@out.WriteLine("Injection worked! Bye!");
@out.Flush();
@out.Close();
}
}
/// <summary>
/// Unload methods can also be called remotely by MonoJunkie.
/// </summary>
public static void OnUnload() {
//...
}
}
}