问题描述
|
谁能解释我下面的asm代码?它能做什么?
我已经评论了一下..
编辑:C ++,用MS Visual C ++ 2008 Express Eddition编译->重新组装
.text:39552AF5 pop ecx
.text:39552AF6 push eax ; void *
.text:39552AF7 lea eax,[ebp+procedureVariable_C] ; get a proc variable from stack to eax?
.text:39552AFA call sub_39501565 ; call procedure with arguments: eax(void) and the lea result?
.text:39552AFF mov ecx,dword_395D0A44 ; dword_395D0A44(\"official\") char gets moved into ecx
.text:39552B05 mov eax,ebx ; ?
.text:39552B07 call sub_39572981 ; ? no arguments?
.text:39501565 ; int __stdcall sub_39501565(void *)
.text:39501565 sub_39501565 proc near ; CODE XREF: sub_39501423+1Cp
.text:39501565 ; sub_39501803+1Cp ...
.text:39501565
.text:39501565 arg_0 = dword ptr 4
.text:39501565
.text:39501565 cmp [esp+arg_0],0
.text:3950156A push edi
.text:3950156B mov edi,eax
.text:3950156D jnz short loc_39501573
.text:3950156F xor eax,eax
.text:39501571 jmp short loc_39501583
.text:39501573 ; ---------------------------------------------------------------------------
.text:39501573
.text:39501573 loc_39501573: ; CODE XREF: sub_39501565+8j
.text:39501573 mov eax,[esp+4+arg_0]
.text:39501577 lea edx,[eax+1]
.text:3950157A
.text:3950157A loc_3950157A: ; CODE XREF: sub_39501565+1Aj
.text:3950157A mov cl,[eax]
.text:3950157C inc eax
.text:3950157D test cl,cl
.text:3950157F jnz short loc_3950157A
.text:39501581 sub eax,edx
.text:39501583
.text:39501583 loc_39501583: ; CODE XREF: sub_39501565+Cj
.text:39501583 push eax ; int
.text:39501584 push [esp+8+arg_0] ; void *
.text:39501588 call sub_39501524
.text:3950158D mov eax,edi
.text:3950158F pop edi
.text:39501590 retn 4
.text:39501590 sub_39501565 endp
解决方法
这部分
.text:39501573
.text:39501573 loc_39501573: ; CODE XREF: sub_39501565+8j
.text:39501573 mov eax,[esp+4+arg_0]
.text:39501577 lea edx,[eax+1]
.text:3950157A
.text:3950157A loc_3950157A: ; CODE XREF: sub_39501565+1Aj
.text:3950157A mov cl,[eax]
.text:3950157C inc eax
.text:3950157D test cl,cl
.text:3950157F jnz short loc_3950157A
.text:39501581 sub eax,edx
看起来它正在扫描一个nul字节并计算end - start + 1
,其中start + 1
来自edx
。
strlen
就是这样做的!
这里有魔术吗?!
, lea不取消任何引用。它只是对第二个参数中的寄存器进行算术运算,并将结果存储在第一个参数中。
lea eax,[ebp+procedureVariable_C];
假设“ 8”是一个常数偏移量,则将其加上该偏移量以计算指向相应变量的指针。
, 您想从SO中知道哪些您还不知道的东西?这是几个函数调用。第一个通过EAX中的引用传递局部参数,第二个将EAX作为参数传递,这可能是第一次调用的结果,或者可能只是传递给EBX中此块的内容。
我们不知道使用了什么调用约定,无论这个汇编器是反汇编的编译器输出还是“人类”编码,没有上下文,也没有知道函数执行或返回的线索。我们不能很好地提供帮助。
此代码没有什么异常。有什么问题?
Rgds,
马丁