-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtilities.cs
27 lines (25 loc) · 869 Bytes
/
Utilities.cs
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
[HarmonyPatch(typeof(ResolutionConfig), "GetResolutionConfigOrNull")]
public static class PrintOutIlCode
{
[HarmonyTranspiler]
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
string file = null;
try
{
var codes = new List<CodeInstruction>(instructions);
for (var i = 0; i < codes.Count; i++)
{
var code = codes[i];
file += (i + " : " + code.opcode + " : " + code.operand + "\n");
}
File.WriteAllText("il-code.txt", file, Encoding.Default);
return codes.AsEnumerable();
}
catch (System.Exception ex)
{
File.WriteAllText("il-code.txt", ex.Message + " : " + ex.Source + " : " + ex.StackTrace, Encoding.Default);
}
return null;
}
}