IDA - 已发现正sp值错误

A D*_*Gem 7 ida disassembly

我们有一个DLL,我们已经失去了源代码,所以我试图通过IDA Dissembler弄清楚它是如何工作的.但是,似乎有一些我无法访问的功能,因为我收到以下错误:

Decompilation failure:
46AFAF: positive sp value has been found
Run Code Online (Sandbox Code Playgroud)

在IDA网站上看,它有这样的说法:

The stack pointer at the specified address is higher than the initial stack pointer.
Functions behaving so strangely can not be decompiled. If you see that the stack
pointer values are incorrect, modify them with the Alt-K (Edit, Functions, Change
stack pointer) command in IDA. 
Run Code Online (Sandbox Code Playgroud)

http://www.hex-rays.com/products/decompiler/manual/failures.shtml#04

由于我是整个Dissembling场景的新手,任何人都能够提供更多信息,说明是什么原因导致堆栈指针高于初始堆栈指针以及这是否可以修复.谢谢你的时间

Wil*_*eld 17

这通常发生在函数有多个返回时,而ida没有捕获到这个.解决方案是使用alt-k将堆栈指针偏移量更改回所需的值.

ARM代码的示例:

.text:00012A10                 MOV     R0, #1          ; -0xd0 + 0
.text:00012A14                 ADD     SP, SP, #0xC8   ; -0xd0 + 0xc8
.text:00012A18                 LDMFD   SP!, {R4,PC}    ; -0x08 - 0xc8 <<< modified
.text:00012A1C ; ---------------------------------------------------------------------------
.text:00012A1C
.text:00012A1C loc_12A1C                               ; CODE XREF: sub_129E4+20j
.text:00012A1C                 MOV     R3, #0          ; -0xd0 + 0
Run Code Online (Sandbox Code Playgroud)

在评论中我写了alt-k值.在0x12A18处,sp偏移被重新调整回-0xd0

  • 提示:在*Options*>*General*中,您可以在每条指令的左侧启用*显示堆栈指针*的选项,这样可以更容易地查看其更改位置和方式,尤其是在图形模式下. (15认同)