Reversing : The Hacker's Guide to Reverse Engineering

(ff) #1
479

CHAPTER


This appendix discusses the most common logical and control flow constructs
used in high-level languages and demonstrates how they are implemented in
IA-32 assembly language. The idea is to provide a sort of dictionary for typical
assembly language sequences you are likely to run into while reversing IA-32
assembly language code.
This appendix starts off with a detailed explanation of how logic is imple-
mented in IA-32, including how operands are compared and the various con-
ditional codes used by the conditional branch instructions. This is followed by
a detailed examination of every popular control flow construct and how it is
implemented in assembly language, including loops and a variety of condi-
tional blocks. The next section discusses branchless logic, and demonstrates
the most common branchless logic sequences. Finally, I’ve included a brief dis-
cussion on the impact of working-set tuning on the reversing process for Win-
dows applications.

Understanding Low-Level Logic


The most basic element in software that distinguishes your average pocket cal-
culator from a full-blown computer is the ability to execute a sequence of log-
ical and conditional instructions. The following sections demonstrate the most
common types of low-level logical constructs frequently encountered while

Deciphering Code Structures


APPENDIX


A


21_574817 appa.qxd 3/16/05 8:52 PM Page 479

Free download pdf