Open loco-choco opened 3 years ago
Added so targets can now be inserted while patching.
To insert instructions you have to follow a similar path of replacing them at a given index:
Instruction(s)
Target
Indices
Index
InsertInstructions
Instruction[] insertingOpCodes = { Instruction.Create(OpCodes.Ldstr, "Hello Sir"), // String to print Instruction.Create(OpCodes.Call, p.BuildCall(typeof(Console), "WriteLine", typeof(void), new[] { typeof(string) })), // Console.WriteLine call }; Target insertingTarget = new Target() { Namespace = "Test", Class = "Program", Method = "Print", Instructions = insertingOpCodes, Indices = new[] { 3, 4 }, // Insert instructions at given index InsertInstructions = true // Tells the patcher to insert and not replace }; p.Patch(insertingTarget); p.Save("Test15.exe");
Before the patch:
After the patch:
Added so targets can now be inserted while patching.
To insert instructions you have to follow a similar path of replacing them at a given index:
Instruction(s)
to theTarget
;Indices
/Index
to theTarget
InsertInstructions
to true (which defaults to false so it is compatible with codes from before this change)Before the patch:
After the patch: