90 likes | 212 Views
Exercise 1 Given the code as seen in the example, we start with the following in memory:. Addr 100h FFh FEh FDh FCh FBh FAh. STACK. ESP. 00h 61h. ESP (new). PUSH msg. ESP. Addr 100h FFh FEh FDh FCh FBh FAh. STACK. 00h 61h. We now perform: MOV AX,[ESP]
E N D
Exercise 1 Given the code as seen in the example, we start with the following in memory: Addr 100h FFh FEh FDh FCh FBh FAh STACK ESP 00h 61h ESP (new) PUSH msg
ESP Addr 100h FFh FEh FDh FCh FBh FAh STACK 00h 61h We now perform: MOV AX,[ESP] Which gives us: AX = 00 61h
Addr 100h FFh FEh FDh FCh FBh FAh STACK 00h 61h 00h 62h ESP PUSH msg+2 ESP (new)
Addr 100h FFh FEh FDh FCh FBh FAh STACK 00h 61h 00h 62h MOV EAX, [esp] EAX = 00 61 00 62h ESP
Addr FCh FBh FAh F9h F8h F7h F6h STACK ESP 64h 00h 63h 00h PUSH dword ptr msg+3 LEA eax, msg ESP (new) EAX = 00 00 00 00h
Addr FCh FBh FAh F9h F8h F7h F6h STACK 64h 00h 63h 00h ESP (new) POP word ptr [EAX] MOV AX, msg ESP EAX = 00 00 63 00h
Addr 100h FFh FEh FDh FCh FBh FAh STACK 00h 61h 00h 62h 64h 00h ESP (new) POP EAX EAX = 00 62 64 00h ESP
Addr 100h FFh FEh FDh FCh FBh FAh STACK ESP (new) 00h 61h 00h 62h 64h 00h ESP POP AX EAX = 00 62 00 61h
Exercise 2 • A) EIP is loaded with the address of PROC1. Hence EIP = 456h. ESP is decremented by 4. Hence ESP = 7FFCh • B) ESP points to the return address (ie: the address of MOV BX,AX. Hence ESP = 11Ah.