📚 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  >>  Propagating type information in IDA Pro, C++

Topic created on: May 13, 2008 01:59 CDT by sensille .

Is there a way to tell IDA that this register/local variable points to a structure of specific type?
I can right-click on e.g. [esi+010h] and change the '010h' to a structure offset, but this will not be propagated. I'd like to get the information "ESI ist pointer to struct _foo" to propagated as far as possible, even down function calls and into local variables.
This would make analysis of especially C++ much easier.

Thanks for any hints.

  nezumi     May 14, 2008 08:32.29 CDT
to apply a structure to all reg references, you have to write x86 emulator, tracing actual value of reg. for example:

mov eax, [esi+0x8]
sub esi, 0x4
mov ebx, [esi+0xC]

as far as you see: [esi+0x8] and [esi+0xC] point to the same field of the structure, however, to find out this, you have to trace esi value. if you're sure, that your register isn't change, a simple IDC-script helps you. just select the area, get operand of all instructions and convert operand to structure member if register matches

  RolfRolles     May 14, 2008 10:02.49 CDT
The closest thing IDA has is selection-T, but Hex-Rays has some decent support for the intraprocedural version of what you're discussing.

  nezumi     May 14, 2008 11:18.27 CDT
um? selection-T applies structure to all registers with appropriate operands, while sensille asks for the certain register, so we need to write a simple IDC-script to enumerate commands, get operands as text, looking for our register.

  RolfRolles     May 14, 2008 11:50.01 CDT
In the GUI version, selection-T works on a single-register granularity.  See the "register" drop box in the top/left corner of the dialog.

  sensille     May 15, 2008 00:04.54 CDT
I've seen IDA tracing register values when the address of an imported function gets loaded into a register and being called indirectly later on. IDA will then put a comment on the call pointing to the function loaded earlier.
So I thought IDA might have built-in register tracing capabilities and I just missed the 'assume register points to struct' switch.
I found the 'idastruct' plugin by rjohnson and the description looks promising, it might be what I'm searching for. As soon as I'm able to get it to work I'll check it out. Otherwise I'll dig into how to write plugins and try me luck.
The main idea is to get a large C++ binary annotated quickly so that you can see how far the objects/structures spread, so you could start reading in the middle of it without the need to painfully trace every single call up to that point just to find out which structures the registers point to.
Also it would be possible to search where a certain structure component gets modified. One might even add xrefs to the structure members, though I don't know if that is possible with the current IDC/plugin command set.

  nezumi     May 15, 2008 00:33.53 CDT
RolfRolles
in my 4.7 (console) there is nothing like that (my employer gave me 5.2, but I don't use it quite often due to compatible issues with my old scripts/plugins).

  nezumi     May 15, 2008 02:02.33 CDT
hm, IDA 4.7 gui has this feature with register. I missed it, coz I use only console version and keep gui-version just to take screen-shots for my papers.

  nezumi     May 15, 2008 02:17.30 CDT
sensille
yes, IDA tracks register values, see:
\IDA\SDK\include\ua.hpp and \IDA\SDK\module\...\emp.cpp

  sensille     May 15, 2008 03:01.43 CDT
hm, value tracking is not type tracking, but I could just assign a magic value representing a specific struct to a register and let IDA track the value. In a later pass I could use this info to convert the structure offsets.
I see, I have to dive deeper into this...

  nezumi     May 15, 2008 05:07.39 CDT
you got the point. using IDA-Pro emulators you can trace reg. changing, even more! if two different registers are match and point to the same memory location - their values have to be converted into structures as well.

but remember: IDA Pro emulates just a few instructions and quite often gives you wrong result. however, you may improve x86 emulator, since there is well-know open source plug-in designed for emulation debugging, and emulates almost all frequently used instructions.

my point is: IDA-Pro is an interactive disassembler, so, don't try to automate everything, turning her into Sourcer-like stuff. use your own hand and brain, man!

  sensille     May 15, 2008 06:52.13 CDT
> nezumiIDA Pro emulates just a few instructions and quite often gives you wrong result. however, you may improve x86 emulator, since there is well-know open source plug-in designed for emulation debugging, and emulates almost all frequently used instructions.

I currently look into bochs to see if I can use the CPU module for accurate emulation.

> nezumimy point is: IDA-Pro is an interactive disassembler, so, don\'t try to automate everything, turning her into Sourcer-like stuff. use your own hand and brain, man!

I can't fully agree. What can be automated should be automated. Imagine an IDA Pro without xrefs, or without function recognition!

"Sourcer" is a good cue: I misread it as 'sorcerer', which is how I feel with my current project: I'm stuck, the amount of code is overwhelming, I have to go back into seclusion and work a mightier spell.

My point is: there will still be enough work left for my hands and brain ;-)

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