954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Compiling unmanaged code to C#

Hi there, I am having some trouble compiling what I believe to be unmanaged code (output from monodis) back into C# for analysis.
What is the correct procedure or program to use for this?

Thanks.

PS. I don’t know whether it would help at all, but the output begins like this:

.assembly extern mscorlib
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly extern System.Windows.Forms
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly extern System
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly extern System.Drawing
{
  .ver 2:0:0:0
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
}
.assembly 'HelloWorld'
{
  .custom instance void class [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::'.ctor'(bool) =  (01 00 00 00 00 ) // .....
jt3204
Newbie Poster
16 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

That looks like the code from an IL disassembler such as ILDADM (comes with Visual Studio), it would be in the program's manifest. What you're looking at are using statements. It translates to

using System;
using System.Windows.Forms;
using System.Drawing;


If you'd like, you can do a google search on converting IL to C# code.

apegram
LINQ!
Team Colleague
552 posts since Jan 2010
Reputation Points: 327
Solved Threads: 135
 

Ahh so it does make sense!
I have tried using ILASM to recompile it, but I kept getting an error message.

Can you recommend a specific program that you would think works?

jt3204
Newbie Poster
16 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Not a clue. Although that appears to be little more than the standard "hello world" program. If I had to bet, I'd wager it's little more than a small winform program that does nothing more than display the phrase "Hello world!" to the user, either through a message box or printed to a label on a form. If you have the rest of the IL, you can most likely figure out what's happening. If you need help writing a Hello World program, there are plenty of samples on the internet.

Edit: how about .NET Reflector

http://www.red-gate.com/products/reflector/

apegram
LINQ!
Team Colleague
552 posts since Jan 2010
Reputation Points: 327
Solved Threads: 135
 

Yes, you're right - it isn't actually a 'Hello World' program.
I do have the rest of the IL, and I understand what it does, but my aim is to compile what I have into a more-usable form for use Visual Studio or a similar program.
I shall keep searching for other ways to do this - hopefully someone else might have a suggestion or two.

Thanks

jt3204
Newbie Poster
16 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: