Reversing : The Hacker's Guide to Reverse Engineering

(ff) #1
approximation of what was in the original source code. How this is done
depends heavily on the specific programming language used for developing
the program.
From a reversing standpoint, the most important thing about a high-level
programming language is how strongly it hides or abstracts the underlying
machine. Some languages such as C provide a fairly low-level perspective on
the machine and produce code that directly runs on the target processor. Other
languages such as Java provide a substantial level of separation between the
programmer and the underlying processor.
The following sections briefly discuss today’s most popular programming
languages:

C

The C programming language is a relatively low-level language as high-level
languages go. C provides direct support for memory pointers and lets you
manipulate them as you please. Arrays can be defined in C, but there is no
bounds checking whatsoever, so you can access any address in memory that
you please. On the other hand, C provides support for the common high-level
features found in other, higher-level languages. This includes support for
arrays and data structures, the ability to easily implement control flow code
such as conditional code and loops, and others.
C is a compiled language, meaning that to run the program you must run
the source code through a compiler that generates platform-specific program
binaries. These binaries contain machine code in the target processor’s own
native language. C also provides limited cross-platform support. To run a pro-
gram on more than one platform you must recompile it with a compiler that
supports the specific target platform.
Many factors have contributed to C’s success, but perhaps most important is
the fact that the language was specifically developed for the purpose of writ-
ing the Unix operating system. Modern versions of Unix such as the Linux
operating system are still written in C. Also, significant portions of the
Microsoft Windows operating system were also written in C (with the rest of
the components written in C++).
Another feature of C that greatly affected its commercial success has been its
high performance. Because C brings you so close to the machine, the code
written by programmers is almost directly translated into machine code by
compilers, with very little added overhead. This means that programs written
in C tend to have very high runtime performance.
C code is relatively easy to reverse because it is fairly similar to the machine
code. When reversing one tries to read the machine code and reconstruct the

34 Chapter 2

Free download pdf