[英]Call method with Mono.Cecil
I have a question about Mono.Cecil. 我有一个关于Mono.Cecil的问题。 I have method
m
in class C
in namespace NS
. 我在名称空间
NS
中的类C
中具有方法m
。 The method returns String
. 该方法返回
String
。 I need to inject IL code into another method in other class that will call m
method. 我需要将IL代码注入另一个将调用
m
方法的类中的另一个方法。 How to do this? 这个怎么做?
You can use MethodDefinition.Body.GetILProcessor()
to receive an ILProcessor
object. 您可以使用
MethodDefinition.Body.GetILProcessor()
来接收ILProcessor
对象。 That allows you to further modify the method body and inject whatever IL code you want to add. 这使您可以进一步修改方法主体并注入要添加的任何IL代码。
You might get some basic ideas from Obfuscar.HideStrings
where new classes and methods are created from scratch, 您可能会从
Obfuscar.HideStrings
中获得一些基本的想法,其中从头开始创建新的类和方法,
https://github.com/lextm/obfuscar/blob/master/Obfuscar/Obfuscator.cs https://github.com/lextm/obfuscar/blob/master/Obfuscar/Obfuscator.cs
There are other open source projects based on Cecil, too. 也有其他基于Cecil的开源项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.