Closed gagmeng closed 7 years ago
public Instruction[] GetInstructions(Target target)
{
var type = FindType(target.Namespace + "." + target.Class, target.NestedClasses);
MethodDef method = FindMethod(type, target.Method, target.Parameters, target.ReturnType);
return (Instruction[])method.Body.Instructions;
}
The above method should changed to as below:
public Instruction[] GetInstructions(Target target)
{
var type = FindType(target.Namespace + "." + target.Class, target.NestedClasses);
MethodDef method = FindMethod(type, target.Method, target.Parameters, target.ReturnType);
return new List
I'll change that today :) Thanks for the input!!
The codes are below:
Patcher patcher1 = new Patcher("xxxx.dll", true); Target target1 = new Target() { Namespace = "Pxxxx.App", Class = "Global", Method = "get_Code" }; Instruction[] instructions = patcher1.GetInstructions(target1);
Invalid cast exception pops up just likes that: Unable to cast object of type 'System.Collections.Generic.List`1[dnlib.DotNet.Emit.Instruction]' to type 'dnlib.DotNet.Emit.Instruction[]' in dnpatch.PatchHelper.GetInstructions(Target target)