2014-09-29 53 views
0

所以我正在練習/慢慢地,但肯定地學習和刷新我的大會。這裏有一個隨機分解核函數爲例:裝配的新手,對於一些指令有點困惑

81a1e85f 8b450c   mov  eax,dword ptr [ebp+0Ch] // Moving value stored at memory address contained in the ebp register+0Ch to the eax register. 
81a1e862 8b4048   mov  eax,dword ptr [eax+48h] // Moving value stored at memory address contained in the eax register+48h to the eax register. 
81a1e865 8945f0   mov  dword ptr [ebp-10h],eax // Moving value stored at memory address contained in the epb-10h register to the eax register? 
81a1e868 6a00   push 0 // ? 
81a1e86a 8bc7   mov  eax,edi // Move contents of the edi register into eax. 
81a1e86c c745fc22010000 mov  dword ptr [ebp-4],122h // ? 
81a1e873 e8bf010000  call nt!PspGetPreviousProcessThread (81a1ea37) // Call the function name nt!PspGetPreviousProcessThread? 
81a1e878 8b5d14   mov  ebx,dword ptr [ebp+14h] // Moving value stored at memory address contained in the ebp register+14h to the ebx register. 

我是很新,大部分,所以毫無疑問,我現在不是錯了一些吧,還是錯在它的全部。任何人都可以讓我知道最重要的是我在哪裏評論過'?'因爲我不熟悉。

此外,括號內的任何內容 - 例如,[ebp-4],這被認爲是一個取消引用的指針,是正確的嗎?

+2

是,任何在括號中,如'[EBP - 4]'是取消引用指針。 「無論在'EBP'寄存器中,減4,用作地址」。更確切地說,在32位系統上,它是當前子程序的第一個局部變量。 – Powerslave 2014-09-29 14:26:10

回答

5
// Moving value stored at memory address contained in the ebp register+0Ch to the eax register. 
// correct 
    mov  eax,dword ptr [ebp+0Ch] 

// Moving value stored at memory address contained in the eax register+48h to the eax register. 
// correct 
    mov  eax,dword ptr [eax+48h] 

// Moving value stored at memory address contained in the epb-10h register to the eax register?  
// no, moving content of eax register (dword) to location [ebp-10h] 
mov  dword ptr [ebp-10h],eax 

// ? 
// pushes a 32-bit zero on stack - probably an argument to the call below 
    push 0 

// Move contents of the edi register into eax. 
// correct 
    mov  eax,edi 

// ? 
// store the 32-bit value 122h to location [ebp-4] 
    mov  dword ptr [ebp-4],122h 

// Call the function name nt!PspGetPreviousProcessThread? 
// correct 
    call nt!PspGetPreviousProcessThread (81a1ea37) 

// Moving value stored at memory address contained in the ebp register+14h to the ebx register 
// correct 
    mov  ebx,dword ptr [ebp+14h] 
+0

我會的時候會標記爲答案。 一個關於MOV指令的問題.... oops,hit hinter - 讓我編輯。 那麼,寄存器是否位於另一個寄存器之後,這個寄存器總是會被移到? 示例: 1-mov eax,dword ptr [ebp + 0Ch] ebp正在轉向eax。 2-mov dword ptr [ebp-10h],eax eax正在轉向ebp。 – ajdbnabad13 2014-09-29 14:29:15

+1

是的,在Intel語法中,目標位於左側,源位於右側。 (並非所有指令都修改目標,認爲'cmp','test'等等)。 – 2014-09-29 14:37:41

+0

謝謝,澄清非常感謝。 – ajdbnabad13 2014-09-29 14:42:25

4

此外,任何在括號 - [EBP-4]例如,這被認爲是一個 解除引用的指針,正確?

雖然在您提供的示例中這是正確的,但請注意,在所有x86/x64語法中都不是這樣。具體來說,負載有效地址(LEA)命令使用方括號,但不執行指針取消引用。例如:

LEA EAX, [EBP+4] 

會將EBP的值加4並將加法結果存儲在EAX中。

有從1998年的優秀文章由馬特·皮特里克是涵蓋了很多這些基本的(!):

http://www.microsoft.com/msj/0298/hood0298.aspx

+0

午睡,對於遲到的+1抱歉。非常感謝,謝謝你的澄清! – ajdbnabad13 2014-09-30 02:19:53