试图找出以下反汇编列表

时间:2013-02-24 08:49:30

标签: assembly x86 disassembly wchar-t ida

我正在查看IDA pro中Win32可执行文件的以下反汇编并得到snwprintf部分,但我不明白mov ecx, [eax+4]指令的目的(他们是否放弃了部分内容)在这里串?)。

loc_4018E7:
mov     eax, 0DEEDh
push    eax
push    offset asc_402270 ; "%X"
push    4               ; size_t no. chars
lea     ecx, [ebp+var_inpPassStr]
push    ecx             ; wchar_t * opBuffer
call    ds:_snwprintf   ; convert number to HEX string
add     esp, 10h
xor     edx, edx
mov     [ebp+var_8], dx
mov     eax, [ebp+arg_inpPass]
mov     ecx, [eax+4]
mov     [ebp+var_14], ecx
lea     edx, [ebp+var_inpPassStr]
push    edx             ; wchar_t *
call    ds:wcslen
add     esp, 4
mov     esi, eax
mov     eax, [ebp+var_14]
push    eax             ; wchar_t *
call    ds:wcslen
add     esp, 4
cmp     esi, eax
jnz     short loc_401984; this prints "invalid pass"

对此的任何见解都会很棒。

3 个答案:

答案 0 :(得分:1)

mov     eax, [ebp+arg_inpPass]
mov     ecx, [eax+4]

使用函数参数的值(反汇编程序名为eax)加载arg_inpPass,这恰好是一个指针,然后取消引用它,跳过前4个字节。

在不知道代码正在做什么或看到更多代码的情况下,无法分辨为什么跳过前4个字节。可能是指针指向一个结构,并且函数有兴趣在偏移量4处访问它的成员。它可能是其他东西。

答案 1 :(得分:-1)

首先,ebp在此反汇编块期间未设置,可能是在此反汇编块之前的某些行。如果这是用汇编语言编写的,它可能指向其他地方而不是堆栈,因为它通常用于更高级别的语言(C,C ++等)。

mov     eax, [ebp+arg_inpPass]    ; read a dword variable (it's a pointer)
                                  ; from the stack into eax
mov     ecx, [eax+4]              ; use that pointer plus 4 to read a dword value
                                  ; from memory into ecx
mov     [ebp+var_14], ecx         ; store the value read into ecx into
                                  ; a local variable (in the stack)

答案 2 :(得分:-1)

mov     eax, [ebp+arg_inpPass]
mov     ecx, [eax+4]
mov     [ebp+var_14], ecx

第一行,从[ebp + arg_inpPass]指向的地址加载4个字节(32位或DWORD)

第二行从前一行地址加上4位加载4位,这意味着如果eax是12345678h,则ecx变为地址1234567Ch指向的32位值

第三行将ecx的值移动到[ebp + var_14],

指向的地址

你确定第一行不是LEA指令吗?如果它真的是一个mov,那么代码提供了一种访问用户提供的内存位置的方法。