Hello,
Is there a way to take a chuck of msil code saved as a byte stream and reverse engineer it to some higher level code (e.g. C#)?
Edit: MSIL instructions that are not a whole assembly
Thanks,
Jon
Hello,
Is there a way to take a chuck of msil code saved as a byte stream and reverse engineer it to some higher level code (e.g. C#)?
Edit: MSIL instructions that are not a whole assembly
Thanks,
Jon
Reflector does just that... so yes, it is possible, assuming that you do have the correct context (to resolve type tokens etc.).
However, just as with Reflector, the reverse engineered code may be completely different than the original code, but it will have the same semantics (if there's no bug in the code generator).
Mono.Cecil offers some analysis functionality:
http://www.mono-project.com/Cecil
Not sure if it can analyze pure IL code.
Not sure it this will work, but ILDASM sounds about right:
The MSIL Disassembler is a companion tool to the MSIL Assembler (Ilasm.exe). Ildasm.exe takes a portable executable (PE) file that contains Microsoft intermediate language (MSIL) code and creates a text file suitable as input to Ilasm.exe.
Note the requirement for the file to be a PE file, so for anything practical this would still essentially be a managed assembly.
Since these instructions are low level, they will not necessarily correspond directly to high level code - even reflector will not give you the exact original code.
You may need to write your own tool in order to achieve this, as an assembly will contain some potentially required information (referenced assemblies, for instance).