yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.56k stars 1.62k forks source link

Invalid IL when explicit interface impl and same sig method exist #429

Closed ivan-danilov closed 8 years ago

ivan-danilov commented 8 years ago

See this question. If Rename protection is applied with flattening, and class have both IX.M() and M() methods - compiler generates former as Namespace.IX.M(), not just M(). But that discretion was lost during obfuscation, leading to invalid IL (PEVerify produces error about duplicate methods). It is being executed just fine though - probably current CLR implementation is forgiving here.

yck1509 commented 8 years ago

Hi, I tried the example code provided in the question and it passes peverify:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

[assembly: Obfuscation(Feature = "rename(mode=sequential,renPublic=true,flatten=true)", Exclude = false)]

namespace ClassLibrary1 {
    public interface IX { void M(); }
    public class Class1 : IX {
        void IX.M() { Console.WriteLine("IX.M()"); }
        public void M() { Console.WriteLine("M()"); }
    }
    public class Class2 {
        public static void Main(string[] args) {
            var x = new Class1();
            x.M();
            ((IX)x).M();
        }
    }
}
ivan-danilov commented 8 years ago

It was a code to check whether PEVerify reports correct error rather than to reproduce ConfuserEx issue... again, I have a case where it is reproduced perfectly, but can't share due to legal reasons, and don't know how to make a minimal repro (yet).

That's not a question, that's a bug lurking somewhere. Can share an assembly produced by ConfuserEx that does not pass PEVerify.

ivan-danilov commented 8 years ago

@yck1509 Got a permission and sent you an email (to the address you have in your commits). Both this issue and #413's repro is there. If it's not the correct one - contact me at van dot danilov at Gmail.