本文整理汇总了C#中Mono.Cecil.MethodDefinition.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.Resolve方法的具体用法?C# MethodDefinition.Resolve怎么用?C# MethodDefinition.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.MethodDefinition
的用法示例。
在下文中一共展示了MethodDefinition.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: inject_method
static AssemblyDefinition inject_method(AssemblyDefinition ad, MethodDefinition method, MethodDefinition method_tobe_inject)
{
try
{
ILProcessor ilp = method.Body.GetILProcessor();
Instruction ins_first = ilp.Body.Instructions[0];
Instruction ins = ilp.Create(OpCodes.Call, ad.MainModule.Import(method_tobe_inject.Resolve()));
ilp.InsertBefore(ins_first, ins);
return ad;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
}
示例2: hookStaticVoidMethodAtEnd_Int
private static bool hookStaticVoidMethodAtEnd_Int(MethodDefinition hookedMethod, MethodDefinition callMeth)
{
try {
HashSet<Instruction> retInstructions = new HashSet<Instruction>();
foreach (Instruction instr in hookedMethod.Body.Instructions) {
if (instr.OpCode == OpCodes.Ret) {
retInstructions.Add(instr);
}
}
CilWorker initProc = hookedMethod.Body.CilWorker;
bool overriden = false;
foreach (Instruction ret in retInstructions) {
initProc.InsertBefore(ret, initProc.Create(OpCodes.Call,
baseAssembly.MainModule.Import(callMeth.Resolve())));
overriden = true;
}
return overriden;
} catch {
return false;
}
}
示例3: hookStaticVoidMethodAtBegin_Int
private static bool hookStaticVoidMethodAtBegin_Int(MethodDefinition hookedMethod, MethodDefinition callMeth)
{
try {
CilWorker initProc = hookedMethod.Body.CilWorker;
initProc.InsertBefore(hookedMethod.Body.Instructions[0], initProc.Create(OpCodes.Call,
baseAssembly.MainModule.Import(callMeth.Resolve())));
return true;
} catch {
return false;
}
}