mercredi 25 avril 2018

Execute method from a loaded assembly

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





Aucun commentaire:

Enregistrer un commentaire