How do i resolve the RVA of the method i have injected without reloading the entire module?
I am always getting 0 as the RVA of the added method. Is there anyway to retrieve the RVA without writing and reloading the assembly? Thanks!
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