SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 301 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"

The concept
of a stack can best be explained by remembering the stack of lunch trays in your school
cafeteria. As you put a tray on the stack, the previous trays on the stack are covered up. As
you take a tray from the stack, you take the tray from the top of the stack, which happens
to be the last one put on. More formally, in computer science terms, the stack is a data
structure that has the quality of a first in, last out (FILO) queue.
The process of putting items on the stack is called a push and is done in the assembly
code language with the push command. Likewise, the process of taking an item from
the stack is called a pop and is accomplished with the pop command in assembly language
code.
In memory, each process maintains its own stack within the stack segment of memory.
Remember, the stack grows backwards from the highest memory addresses to the
lowest. Two important registers deal with the stack: extended base pointer (ebp) and
extended stack pointer (esp). As Figure 7-1 indicates, the ebp register is the base of the
current stack frame of a process (higher address). The esp register always points to the
top of the stack (lower address).
Function Calling Procedure
As explained in Chapter 6, a function is a self-contained module of code that is called by
other functions, including the main function.


Pages:
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313