2014-09-29 52 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