Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does compiling to native code in .Net remove the MSIL completely?

I'm wondering if, in the context of disassembling .Net code (Redgate .Net reflector, etc), is it more secure to compile your code to native, using Ngen? That is, does that mean someone would now need IDA and ASM skills to disassemble (and make sense) of your code vs the relatively trivial de-compiling of MSIL?

Yes, I'm aware that MS provides a obfuscater for exactly this purpose, but I'm curious if compiling to native is a better solution, with some tradeoffs(no JIT).

Thanks.

like image 579
Kim Sun-wu Avatar asked Dec 30 '10 05:12

Kim Sun-wu


People also ask

Can you compile C# to native code?

NET Native is a precompilation technology for building and deploying UWP apps. . NET Native is included with Visual Studio 2015 and later versions. It automatically compiles the release version of UWP apps that are written in managed code (C# or Visual Basic) to native code.

What does .NET compile to?

In . NET, programs are not compiled into executable files; they are compiled into Microsoft Intermediate Language (MSIL) files, which the CLR then executes. The MSIL (often shortened to IL) files that C# produces are identical to the IL files that other . NET languages produce; the platform is language-agnostic.

How. net code is compiled?

NET Framework are written in a particular programming language and compiled into intermediate language (IL). At run time, a just-in-time (JIT) compiler is responsible for compiling the IL into native code for the local machine just before a method is executed for the first time.


1 Answers

ngen doesn't remove the MSIL (or rather, the native binary produced by ngen is unusable without also having the MSIL file). MSIL is still used by the verifier to determine whether to load assemblies in partial-trust scenarios, and for reflection.

There's a lot of good information here.

like image 170
Ben Voigt Avatar answered Sep 25 '22 18:09

Ben Voigt