Open Wall-AF opened 2 years ago
It seems that class VarnodeContext
the method getStackRegister(...)
is using the "parent" register (if it has one) and if that is commented out, the stack depth is corrected.
https://github.com/NationalSecurityAgency/ghidra/blob/7a30cefebb91ddb25a6c4030e67001202fd20936/Ghidra/Features/Base/src/main/java/ghidra/program/util/VarnodeContext.java#L358-L373
The questions are:
Describe the bug The stack depth is lost (i.e. zeroed and ends up '-'ve) after a call to another function inside the one you are decompiling on applications using
SP
as the stack pointer.To Reproduce Steps to reproduce the behavior:
Listing:
view has the "Stack Depth" column visible,Expected behavior To use the correct register/value to determine the stak depth after a function call.
Attachments There are 2 examples in the attachmement dragmedi_FUN_1008_1434.zip
Environment (please complete the following information):
Additional context When looking at a 16-bit x86 application the stack pointer is
SP
. Tracking this through theSymbolcPropogator
class I've discovered in methodhandleFunctionSideEffects(...)
the stack varnode used to adjust the current position isESP
and dispite that being added to thecontext
earlier in the process, I don't believe theSP
value is propagated toESP
resulting in a big fat zero in subsequent calculations instead of the value stored inSP
!