本文整理匯總了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;
}
}