Reversing : The Hacker's Guide to Reverse Engineering

(ff) #1

.NET Programming Languages


.NET is not tied to any specific language (other than IL), and compilers have
been written to support numerous programming languages. The following are
the most popular programming languages used in the .NET environment.
C# C Sharp is the .NET programming language in the sense that it was
designed from the ground up as the “native” .NET language. It has a
syntax that is similar to that of C++, but is functionally more similar to
Java than to C++. Both C# and Java are object oriented, allowing only a
single level of inheritance. Both languages are type safe, meaning that
they do not allow any misuse of data types (such as unsafe typecasting,
and so on). Additionally, both languages work with a garbage collector
and don’t support explicit deletion of objects (in fact, no .NET language
supports explicit deletion of object—they are all based on garbage
collection).
Managed C++ Managed C++ is an extension to Microsoft’s C/C++ com-
piler (cl.exe), which can produce a managed IL executable from C++
code.
Visual Basic .NET Microsoft has created a Visual Basic compiler for
.NET, which means that they’ve essentially eliminated the old Visual
Basic virtual machine (VBVM) component, which was the runtime com-
ponent in which all Visual Basic programs executed in previous versions
of the platform. Visual Basic .NET programs now run using the CLR,
which means that essentially at this point Visual Basic executables are
identical to C# and Managed C++ executables: They all consist of man-
aged IL code and metadata.
J# J Sharp is simply an implementation of Java for .NET. Microsoft pro-
vides a Java-compatible compiler for .NET which produces IL executa-
bles instead of Java bytecode. The idea is obviously to allow developers
to easily port their Java programs to .NET.
One remarkable thing about .NET and all of these programming languages
is their ability to easily interoperate. Because of the presence of metadata that
accurately describes an executable, programs can interoperate at the object
level regardless of the programming language they are created in. It is possible
for one program to seamlessly inherit a class from another program even if one
was written in C# and the other in Visual Basic .NET, for instance.

Common Type System (CTS)


The Common Type System (CTS) governs the organization of data types in
.NET programs. There are two fundamental data types: values and references.
Values are data types that represent actual data, while reference types represent

428 Chapter 12

Free download pdf