0

如何在不重新加载整个模块的情况下解决我注入的方法的 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
4

1 回答 1

2

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

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

于 2012-11-02T10:14:09.687 回答