cil

Are there tools to compile CIL to a binary?

After seeing a previous post "Making Applications programmed in .NET languages work on older machines", I've got to wonder; Are there tools to compile CIL to a binary? If so, you could convert a CIL file to a native Windows app if you didn't want the user to require the .NET framework? Or even target the linux platform from .NET! Tha...

C# - are all Enum constants?

Are all Enum enumerations constants? Do they get converted to their value at compile-time, or at run-time? ...

C# - Do method names get compiled into the EXE?

Do class, method and variable names get included in the MSIL after compiling a Windows App project into an EXE? For obfuscation - less names, harder to reverse engineer. And for performance - shorter names, faster access. e.g. So if methods ARE called via name: Keep names short, better performance for named-lookup. Keep names crypt...

API for getting IL from byte array

There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array (or do it for me)? I...

Indexing arrays with enums in C#

I have a lot of fixed-size collections of numbers where each entry can be accessed with a constant. Naturally this seems to point to arrays and enums: enum StatType { Foo = 0, Bar // ... } float[] stats = new float[...]; stats[StatType.Foo] = 1.23f; The problem with this is of course that you cannot use an enum to index a...

Java's Virtual Machine and CLR

As a sort of follow up to the questions called "Differences between MSIL and Java bytecode?" what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framwork Common Language Runtime (CLR) works? Also, is the .NET framework CLR a "virtual machine" or does it not have the attributes of a vir...

Is there a tool to select some code in Visual Studio and have it show the corresponding MSIL?

Lately I've found myself constantly running ILDASM to study the MSIL output of my programs. Are there any utilities to streamline this? Ideally, it would be nice to select some source code and have it compile, disassemble and emit the selected C# code in MSIL. Anyone know of such a thing? ...

How would one access object properties in CIL (MSIL)?

I'm an absolute beginner, you see. Say I have a string object on the stack and want to get the number of characters in it - its .Length property. How would I get the int32 number hidden inside? Many thanks in advance! ...

Where can I get a list of all MSIL codes and their hex values?

Does anyone have a list or chart of all MSIL codes and their corresponding hex values? ...

Programmatic MSIL injection

Let's say I have a buggy application like this: using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("2 + 1 = {0}", Add(2, 1)); } static int Add(int x, int y) { return x + x; // <-- oops! } }...

How can I scan MSIL code to find certain function calls

Hi all, I am to build a SOA gui framework, and I'd like to autodetect services, and service dependencies from client modules. I have code such as this so far, which works using attributes, placed on class modules: [ServiceProvider(typeof(DemoService3))] [ServiceConsumer(typeof(DemoService1))] I am wondering how I can scan for these a...

Advantages of CIL knowledge in .NET

What are the advantages of understanding CIL? Do you have to know assembly to understand it? The code in these files looks similar. How do I learn more about it? Any books about it like Jon Skeet's C# book? ...

What can you do in MSIL that you cannot do in C# or vb.NET?

All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly? Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language. So far we have this: 1. Tail recursion 2. Generic Co/Contravariance 3. Overloads which differ only in re...

[C#] What does this compiler-generated enumerator mean?

I wrote a fairly complex method that yield-returns IEnumerable<string>, but when I inspected the compiler output in Reflector, I didn't understand a specific part of the compiler-generated implementation of IEnumerator: void IDisposable.Dispose() { switch (this.<>1__state) { case 1: case 2: case 3: ...

A .net disassembler/decompiler

I am looking for a disassembler or better, a decompiler for .net. The situation is that the source code for an assembly written by one of my predecessors is lost and I'd like to take a look to see what it's doing. I know that ildasm comes with the Visual Studio installation so I can get at the MSIL, but I was hoping there was a program...

in .NET when you pass a class instance/interface as a parameter do you pass one object or the full vtable

If you are passing an interface or an instance of a class as a parameter, are we passing many objects or the full vtable, because once you call a method on the instance it need to recurse the vtable and call the appropriate one right? How does this work? ...

MSIL: "Operation could destabilize the runtime" exception

Hi! I've been playing with PostSharp a bit and I ran into a nasty problem. Following IL in Silverlight assembly: .method public hidebysig specialname newslot virtual final instance void set_AccountProfileModifiedAt(valuetype [mscorlib]System.DateTime 'value') cil managed { .maxstack 2 .locals ( [0] bool ~propertyHasCh...

Turning off JIT, and controlling codeflow in MSIL (own VM)

Hi, I'm writing my own scripting language in C#, with some features I like, and I chose to use MSIL as output's bytecode (Reflection.Emit is quite useful, and I dont have to think up another bytecode). It works, emits executable, which can be run ( even decompiled with Reflector :) )and is quite fast. But - I want to run multiple 'proce...

IDE for MSIL

There's any number of questions about MSIL on SO but none that directly answer this. I've been using Textpad which does have a syntax definition file for MSIL and then using ILASM in a command prompt window. I did find a reference to ILIDE but the link is broken. Is there an IDE or add-on / plugin to Visual Studio / Eclipse for MSIL t...

MSIL debuggers - Mdbg, Dbgclr, Cordbg

I've been doing some MSIL work and have come across references to these three debuggers. What's the difference between them? Is one of them better than the others wrt. functionality? Are there others that I have missed? ...