Remove the ILDASM suppressildasmattribute limit

Source: Internet
Author: User


Original: Remove the suppressildasmattribute limit of ildasm





I was going to have a Chinese one today. NET program, when opened with ILDASM, there is a "protected module-cannot be disassembled" error message






After seeing this error, I try to open it with Ilspy, and everything is OK. Online search, the original is suppressildasmattribute this attribute to get.



About Suppressildasmattribute This property, which can be declared in the assembly, after declaring this property, ILDASM does not disassemble the assembly, thus playing a certain degree of protection. Use the Suppressildasmattribute to prevent the MSIL Anti-translation tool from using this article.



However, this suppressildasmattribute is a gentleman agreement, even with this statement, the compiler does not have any additional protection operations, but ILDASM does not disassemble it. Third-party anti-compilation tools like Ilspy, reflector and so on are all ignoring this property, basically a kind of deceiving. There is an article in the garden about the function limitation and release of ILDASM more detailed introduction to this.



So what if we're going to use ildasm to cross Suppressildasmattribute's restricted disassembler? One way is to write a program to modify the IL Code of the assembly, remove the Suppressildasmattribute attribute , the code is as follows (requires Mono.cecil library support):


  public static void RemoveSuppressIldasmAttribute(string input, string output)
    {
        AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(input);
        foreach (CustomAttribute attribute in assembly.CustomAttributes)
        {
            if (attribute.Constructor.DeclaringType.Name == "SuppressIldasmAttribute")
            {
                assembly.CustomAttributes.Remove(attribute);
                break;
            }
        }

        assembly.Name.PublicKey = null;
        assembly.Name.PublicKeyToken = null;
        assembly.Write(output);
    }



Using this function to remove the Suppressildasmattribute attribute in the assembly, you can open it with ILDASM.



This method is a little cumbersome, in the previous article on the functional limitations of ILDASM and the release of another solution: the direct removal of ildasm in the limitations of Suppressildasmattribute , This allows you to open an assembly with the Suppressildasmattribute declaration. The original text has been given a modified ILDasm.exe download, but because the article published earlier, the ILDasm.exe version is also older, to use the latest ILDasm.exe must be modified by ourselves. The original text is modified by the way of disassembly, more troublesome, here is a simple method.



1. Change the ILDasm.exe to an extension (remember to back up the original file) and open it with VisualStudio.



PS: The reason is to change the extension, because I want to edit in 16, if not to change the extension, vs it as an EXE open, can only modify the resource file, if you use UltraEdit or Winhex programs such as the 16 binary editing can not change the extension.



2. Find the Suppressildasmattribute string






3. Change it to one of the other strings






4. Save the changes and restore the extension to. exe so that your new ILDasm.exe ignores Suppressildasmattribute.









Remove the ILDASM suppressildasmattribute limit


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.