Reversing : The Hacker's Guide to Reverse Engineering

(ff) #1
■■ Switch blocks: Switch blocks (also known as n-way conditionals) usually
take an input value and define multiple code blocks that can get exe-
cuted for different input values. One or more values are assigned to
each code block, and the program jumps to the correct code block in
runtime based on the incoming input value. The compiler implements
this feature by generating code that takes the input value and searches
for the correct code block to execute, usually by consulting a lookup
table that has pointers to all the different code blocks.
■■ Loops: Loops allow programs to repeatedly execute the same code
block any number of times. A loop typically manages a counter that
determines the number of iterations already performed or the number
of iterations that remain. All loops include some kind of conditional
statement that determines when the loop is interrupted. Another way to
look at a loop is as a conditional statement that is identical to a condi-
tional block, with the difference that the conditional block is executed
repeatedly. The process is interrupted when the condition is no longer
satisfied.

High-Level Languages


High-level languages were made to allow programmers to create software
without having to worry about the specific hardware platform on which their
program would run and without having to worry about all kinds of annoying
low-level details that just aren’t relevant for most programmers. Assembly lan-
guage has its advantages, but it is virtually impossible to create large and com-
plex software on assembly language alone. High-level languages were made to
isolate programmers from the machine and its tiny details as much as possible.
The problem with high-level languages is that there are different demands
from different people and different fields in the industry. The primary tradeoff
is between simplicity and flexibility. Simplicity means that you can write a rel-
atively short program that does exactly what you need it to, without having to
deal with a variety of unrelated machine-level details. Flexibility means that
there isn’t anything that you can’t do with the language. High-level languages
are usually aimed at finding the right balance that suits most of their users. On
one hand, there are certain things that happen at the machine-level that pro-
grammers just don’t need to know about. On the other, hiding certain aspects
of the system means that you lose the ability to do certain things.
When you reverse a program, you usually have no choice but to get your
hands dirty and become aware of many details that happen at the machine
level. In most cases, you will be exposed to such obscure aspects of the inner
workings of a program that even the programmers that wrote them were
unaware of. The challenge is to sift through this information with enough
understanding of the high-level language used and to try to reach a close


Low-Level Software 33
Free download pdf