📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  IDA Pro  >>  How to fix ebp manually so stack variables can be detetcted?

Topic created on: February 16, 2009 16:43 CST by klaymen .

Hi all,
This is probably a stupid question, but I didn't find out how to fix a situation in IDA when the ebp register is not set directly at the start of a function, but within an exception handler initialization stub that's called as fist thing in a function? In detail it looks like this:

fct: mov     eax, handler
     call    installExceptionHandler
     sub     esp, 60h
     ...

And the stub is as follows:

installExceptionHandler:
  push    0FFFFFFFFh
  push    eax
  mov     eax, large fs:0
  push    eax
  mov     eax, [esp+0Ch]
  mov     large fs:0, esp
  mov     [esp+0Ch], ebp
  lea     ebp, [esp+0Ch]
  push    eax
  retn

This will set up a frame like that:
ebp:    old-ebp
ebp-4:  -1
ebp-8:  handler
ebp-12: next-seh   <= esp

Unfortunately when IDA analyzes "fct:" above it does not notice that ebp is set in installExceptionHandler and subsequently does not translate accesses to local variables relative to ebp as it should. From then on it will only show things like "[ebp-18h]" without resolving it to local stack variables. This is particularly bad if you're using the HexRays decompiler plugin, you can't give any type informations. Is there any way to tell IDA how ebp is aligned manually so it can detect accesses to local variables in the function?

Thanks in advance, klaymen

  cseagle     February 17, 2009 03:09.27 CST
at a minimum, you need to edit function "fct" (Alt-p) and check the "bp based frame" checkbox and set the "saved registers" to 4 bytes.  You also need to account for the 12 additional bytes that installExceptionHandler places on the stack, otherwise IDA's stack math will be wrong.  One way to do this is to edit installExceptionHandler and set its purged bytes to 12.  I don't have a good example to test this on, but that will get you close.  Ultimately you may need to tweak fct's' saved registers and installExceptionHandler's purged bytes to get things exactly right.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit