Use reflector. filedisassembler to decompile DLL

Source: Internet
Author: User
Tags reflector
From http://www.cnblogs.com/wuliangbo

Reflector for. Net: http://www.aisto.com/roeder/dotnet/

Tool for reflector. filedisassembler. dll CS file: http://www.denisbauer.com/Downloads/Reflector.FileDisassembler.zip

1. Download reflector.filedisassembler.zip and decompress the package to obtain some files. The reflector. filedisassembler. dll is compiled, and the others are its source code;

2. Open reflector, add-ins under the View menu, and add reflector. filedisassembler. DLL to it;

3. Open a DLL, EXE, or MCL file. Of course, you must support. Net files.

4. Select the DLL to be decompiled (displayed in the list), select Tools-> file discycler, and the path for storing source code is displayed in the right window. Click Generate!

However, using filedisassembler to compile a CS file may cause a bug where variables, classes, and namespaces are sometimes renamed.

Fortunately, when filedisassembler is released with the source code, it saves the need for reflect. After all, the temporary variable name generated by the machine still looks uncomfortable. It's easy to fix this bug. I modified the createfile method and added a getuniquefilename method. The source code is as follows:

Private streamwriter createfile (string directory, string filename)
{
Directory = directory. Replace ("<","_");
Directory = directory. Replace ("> ","_");
Directory = directory. Replace (":","_");
Directory = directory. Replace ("| ","_");
Directory = directory. Replace ("? ","_");
Directory = directory. Replace ("*","_");
Directory = path. Combine (this. outputdirectory, directory );

Ilanguage Language = This. languagemanager. activelanguage;
String fileextension = language. fileextension;

Filename = filename. Replace ("<","_");
Filename = filename. Replace ("> ","_");
Filename = filename. Replace (":","_");
Filename = filename. Replace ("| ","_");
Filename = filename. Replace ("? ","_");
Filename = filename. Replace ("*","_");
Filename = path. Combine (directory, filename );
Filename = path. changeextension (filename, fileextension );

Filename = getuniquefilename (filename );
This. writeline (filename );

Directory = filename. substring (0, filename. lastindexof ('""'));
If (! Directory. exists (directory ))
{
Directory. createdirectory (directory );
}

Streamwriter writer = new streamwriter (filename );
Return writer;
}

Private hashtable filenames = new hashtable ();

Private string getuniquefilename (string filename)
{
String strextension = path. getextension (filename );
Filename = filename. Replace (strextension ,"");

String _ filename = filename. tolower ();
Bool bfirstrename = true;
While (filenames. Contains (_ filename ))
{
String existfilename = (string) filenames [_ filename];
String [] efnparts = existfilename. Split (New char [] {'"'});
String [] fnparts = filename. Split (New char [] {'""'});
For (INT I = 0; I <fnparts. length; ++ I)
{
If (efnparts [I]! = Fnparts [I])
{
If (bfirstrename)
{
Fnparts [I] + = '_';
Bfirstrename = false;
}
Fnparts [I] + = 'X ';
Break;
}
}
Filename = string. empty;
For (INT I = 0; I <fnparts. length; ++ I)
{
Filename + = '"' + fnparts [I];
}
Filename = filename. substring (1 );
_ Filename = filename. tolower ();
}
Filenames [_ filename] = filename;
Return filename + strextension;
}

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.