【问题标题】:Mono.Cecil get/resolve RVA of method after method insertionMono.Cecil 在方法插入后获取/解析方法的 RVA
【发布时间】:2012-11-04 08:52:35
【问题描述】:

如何在不重新加载整个模块的情况下解决我注入的方法的 RVA?
我总是得到 0 作为添加方法的 RVA。无论如何都可以在不编写和重新加载程序集的情况下检索 RVA?谢谢!

AssemblyDefinition asm = AssemblyDefinition.ReadAssembly("hello.exe"); 
ModuleDefinition mod = asm.MainModule;
TypeDefinition modType= mod.GetType("PrintClass"); //get class found in hello.exe
MethodDefinition MethodToInject= new MethodDefinition("PrintMethod", ..., ...); //filled
modType.Methods.Add(MethodToInject);

int InjectedRVA = MethodToInject.RVA; //Always get 0
InjectedRVA = modType.Methods.FirstOrDefault(mtd => mtd.Name == "PrintMethod").RVA; //Also get 0

asm.MainModule.Write("output.exe"); //write output

【问题讨论】:

    标签: .net mono.cecil


    【解决方案1】:

    新方法 RVA 在写入时计算,但模型未更新。我想我们可以认为这是一个错误。

    现在您必须分析生成的程序集。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      • 2017-04-12
      • 2013-12-19
      • 2017-05-30
      • 2018-09-30
      • 1970-01-01
      相关资源
      最近更新 更多