2015-10-06 27 views
0

如果我的彙編代碼...瞭解裝配和堆棧%以上EBP下面VS

0x08048cc4 <+0>:  push %ebp 
    0x08048cc5 <+1>:  mov %esp,%ebp 
    0x08048cc7 <+3>:  push %esi 
    0x08048cc8 <+4>:  push %ebx 
    0x08048cc9 <+5>:  sub $0x20,%esp 
    0x08048ccc <+8>:  lea -0x10(%ebp),%eax // input 3 
    0x08048ccf <+11>: mov %eax,0xc(%esp) 
    0x08048cd3 <+15>: lea -0xc(%ebp),%eax  // input 2 
    0x08048cd6 <+18>: mov %eax,0x8(%esp) 
    0x08048cda <+22>: movl $0x804a1aa,0x4(%esp) 
    0x08048ce2 <+30>: mov 0x8(%ebp),%eax  // input 1 
    0x08048ce5 <+33>: mov %eax,(%esp) 
    0x08048ce8 <+36>: call 0x804870c <[email protected]> 

有沒有辦法在< +36打印輸入1,2,3如果我設置的斷點值>?

我知道我可以在< +8>中保持休息,並且每次都做一些(gdb)我的%eax。但有一種更好的方式在< 36>

我的輸入爲14,115做這在一個斷點(輸入2,輸入3) 輸入1是格式( 「%d,%d」)

我試圖做這樣的事情,但還沒有完全明白我讀什麼..

(gdb) x /20wx $esp 
0xbffff070: 0x0804b820 0x0804a1aa 0xbffff08c 0xbffff088 
0xbffff080: 0x00000001 0x7a000002 0x00000073 0x0000000e 
0xbffff090: 0xbffff168 0xbffff164 0xbffff0c8 0x08048a4d 
0xbffff0a0: 0x0804b820 0x08049f2c 0x00000000 0xb7e5164d 
0xbffff0b0: 0xb7fc93c4 0xb7fff000 0xb7fc9000 0x00000000 

(gdb) x /20wx $ebp 
0xbffff098: 0xbffff0c8 0x08048a4d 0x0804b820 0x08049f2c 
0xbffff0a8: 0x00000000 0xb7e5164d 0xb7fc93c4 0xb7fff000 
0xbffff0b8: 0xb7fc9000 0x00000000 0x08049e60 0x00000000 
0xbffff0c8: 0x00000000 0xb7e37a83 0x00000002 0xbffff164 
0xbffff0d8: 0xbffff170 0xb7feccea 0x00000002 0xbffff164 

(gdb) x /20wd $ebp 
0xbffff098: -1073745720 134515277 134527008 134520620 
0xbffff0a8: 0 -1209723315 -1208183868 -1207963648 
0xbffff0b8: -1208184832 0 134520416 0 
0xbffff0c8: 0 -1209828733 2 -1073745564 
0xbffff0d8: -1073745552 -1208038166 2 -1073745564 
+0

二元炸彈? –

回答

1

在+36 sscanf尚未被調用,所以你只能看到隨機存儲垃圾您稱爲input2/3的兩個輸出變量。

Input1不是格式,它是要解析的字符串。

什麼是呼叫貌似是:sscanf(input1, "%d %d", &input2, &input3)

當然你可以檢查變量,使用x/s $eaxinput1x/dinput2/3

(gdb) x/s $eax 
0xffffdba6:  "14 115" 
(gdb) ni 
(gdb) x/d $ebp-0xc 
0xffffd97c:  14 
(gdb) x/d $ebp-0x10 
0xffffd978:  115 

(注意:我已在sscanf之前打印input1 ,但之後的其他人)。 請參閱格式說明符的gdb幫助。