0

I want to execute a method from a loaded assembly, i saw this Dnlib - Execute IL MethodBody from loaded assembly

And, i wanted to do the same think, i search my function thank to a RVA adress(hardcoded), it well found, and I have tried to import it as you sayed:

BindingFlags eFlags = BindingFlags.Instance |BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

foreach (TypeDef type in module.GetTypes())
{
    Type classInstance = type.GetType();

    foreach (MethodDef method in type.Methods)
     {

       if (method.RVA.ToString() == RVA.ToString())
        {
             importedMethod = classInstance.GetMethod(method.Name, eFlags);

But it's failed, classInstance.GetMethod is executed but the variable importedMethod is always null. Do you have a idea where i made a mistake?

Thank you

Bloodaxe
  • 51
  • 4
  • So you want to load an assembly, find a type and call either a static member of the type, or instantiate the type and call a method on the instantiated object? – spender Apr 25 '18 at 20:44
  • Unless I misunderstand your question, it doesn't look like you'll need dnlib to do this. – spender Apr 25 '18 at 20:46

0 Answers0