Common Language Infrastructure (CLI)
Common Language Infrastructure (CLI)
Managed Assembly
.Net obfuscator utility will help protect reverse engineering the MSIL.
These utilities “scrambles” the names of all the private symbols in your
managed module metadata but not the IL code.
There are several .Net obfuscation tools available in the market like
Skater .NET Obfuscator, etc,...
Code Obfuscation
The below link provides various third party tools for C# programming…
http://msdn.microsoft.com/en-us/vcsharp/aa336818.aspx
Just In Time (JIT)
The figure below shows what happens the first time a method is called.
JIT will compile the MSIL as and when the code block is visited by the EE.
Just In Time (JIT)
The figure below shows what the situation looks like when WriteLine is called the
second time:
Just In Time (JIT)
Process incurs a performance hit only the first time (startup time delay).
The important thing to note is that the process incurs a performance hit only
the first time a method is called. All subsequent calls to the method execute at
the full speed of the native code: Verification and compilation to native code is
not performed again.
Econo-JIT
Econo-JIT compiles only those methods that are called at runtime. However,
these compiled methods are removed when they are not required.
Normal-JIT
Normal-JIT compiles only those methods that are called at runtime. These
methods are compiled the first time they are called, and then they are stored in
cache. When the same methods are called again, the compiled code from cache
is used for execution.
Native Image Generator (Ngen) by MS Optimizes this Startup Delay.
Native Image Generator (Ngen) by Microsoft is an approach to reduce the initial
delay. Ngen pre-compiles (or "pre-jits") bytecode in a Common Intermediate
Language image into machine native code. As a result, no runtime compilation
is needed. .NET framework 2.0 shipped with Visual Studio 2005 runs Ngen on all
of the Microsoft library DLLs right after the installation.
Code Verification
While compiling IL into native CPU instructions, the CLR performs a process called
verification. Verification examines the high-level IL code and ensures that
everything it does is “safe.”
For example, verification checks that no memory is read from without having
previously been written to, that every method is called with the correct number
of parameters, that each parameter is of the correct type, that every method’s
return value is used properly, that every method has a return statement, and so
on.
The metadata for each managed module includes all the method and type
information used by the verification process. If the IL code is determined to be
“unsafe,” then a System.Security.VerifierException exception is thrown,
preventing the method from executing.
Code Verification
Code Verification checks that no memory is read from without having
previously been written to
Memory
Heap
100001
Global
Stack
100002
10
Unsafe Code
Unsafe Code
Unsafe code is required when you call native functions that require
pointers. Eg: Win32 API
To ensure that all methods in your managed module contain verifiably safe IL,
you can use the PEVerify.exe utility that ships with the .NET Framework SDK.
When Microsoft developers test their C# and Visual Basic.NET compilers, they
run the resulting module through PEVerify to ensure that the compiler always
produces verifiably safe code. If PEVerify detects unsafe code, then Microsoft
fixes the compiler.
AppDomain
In Windows, each process has its own virtual address space. Separate address
spaces are necessary because Windows can’t trust the application code. It is
entirely possible (and unfortunately, all too common) that an application will read
from or write to an invalid memory address.
The CLR does, in fact, offer the ability to execute multiple managed applications
in a single OS process. Each managed application is called an AppDomain. By
default, every managed EXE will run in its own separate address space.
Application Domain [AppDomain]