dimanche 3 septembre 2017

.net obfuscation for reflected methods

I want to obfuscate my application. However, I use a lot of reflection in it, especially Type.GetMethod in order to create generic methods with a dynamic type.

Ex:

        private void button1_Click(object sender, EventArgs e)
    {
        MethodInfo info = this.GetType().GetMethod("ShowInMessageBox", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        MethodInfo generic = info.MakeGenericMethod(typeof(int));

        String result = (String)generic.Invoke(this, new Object[] { 1234 });

        MessageBox.Show(result);
    }

    [Obfuscation(Exclude =true)]
    private String ShowInMessageBox<T>(T item)
    {
        return item.ToString();
    }

However, both ConfuserEx and Dotfuscator will not change the string in 'GetMethod("ShowInMessageBox")' and so my application will simply not work once obfuscated.

Other than using [Obfuscation(Exclude =true)], is there an other way to successfully obfuscate reflected methods?

Thank you.





Aucun commentaire:

Enregistrer un commentaire