Assembly Language for Beginners

(nextflipdebug2) #1

1.9. SCANF()


MSVC: x86 + OllyDbg


Things are even simpler here:


Figure 1.15:OllyDbg: afterscanf()execution

The variable is located in the data segment. After thePUSHinstruction (pushing the address ofx) gets
executed, the address appears in the stack window. Right-click on that row and select “Follow in dump”.
The variable will appear in the memory window on the left. After we have entered 123 in the console,
0x7Bappears in the memory window (see the highlighted screenshot regions).


But why is the first byte7B? Thinking logically,00 00 00 7Bmust be there. The cause for this is referred
asendianness, andx86useslittle-endian. Thisimpliesthatthelowestbyteiswrittenfirst, andthehighest
written last. Read more about it at:2.8 on page 464. Back to the example, the 32-bit value is loaded from
this memory address intoEAXand passed toprintf().


The memory address ofxis0x00C53394.

Free download pdf