« ZERT patch | Main | Heads and tails »

Loop colorizer

Sometimes I need to know if the current instruction sequence belongs to a loop or not. If it does, I'd like to know the loop boundaries. It would be nice to have the current loop highlighted. If the highlight changes as I navigate in the listing, it would be just great.

This is why I created this colorizer plugin. Implementing it turned out to be easier than I thought :) Pretty simple stuff but still useful.

There are no controls, no setup, nothing: the plugin is fully automatic. The listing looks like this with it:

I used only cross-references to detect loops. This allows the plugin to work with any processor. It detects the outermost loop (however I have a feeling that the innermost loop would be better)...

As usual, the source code is available. In fact you have a chance of learning how to write this plugin and similar modules for IDA. We will be learning this and other things in detail during the advanced training held in Columbia, MD, Nov 1-2. If you are interested, send us a message!

Feel free to play with the plugin and improve it!

Download it here: http://hexblog.com/ida_pro/files/color_loops.zip

Comments

seems to give an access violation when I placed this plugin in IDA50 plugins and loaded a database

Same here with IDA 5.0:
Access violation at address 100E8403 in module 'ida.wll'. Read of address 9010ADEC.

This seems to happen when I switch to text-view and scroll.
I tried with different databases.
Looks like a problem when color_loops.plw calls ida_create_flow_chart.

Call stack:
100E8403 ida.wll
1006CE44 ida.wll
1006BA55 ida.wll (ida_create_flow_chart)
04AF2E8F color_loops.plw
04AF2212 color_loops.plw
04AF18F3 color_loops.plw
04AF1A30 color_loops.plw
10036EF4 ida.wll (ida_invoke_callbacks)
0045FA56 .text
10028159 ida.wll
400F6231 vcl60.bpl
400F5873 vcl60.bpl
0040226E .text
00567870 .text

I don't know enough yet about IDA plugins to determine the root cause.

Thanks for telling, I corrected the problem. Does it work now?

Like a charm :)
What was the problem?
I tried tracing IDA in IDA and comparing with the plugin source, but I guess I still lack experience..

No access violation now , cool plugin :)
thanks

The problem was due to separate memory pools in the ida kernel and plugin dll. I redirected memory allocation functions to the kernel.

hm, when IDA starts i get:

LoadLibrary(c:\programme\ida\plugins\loopcolorizer.plw) => error code 126
c:\programme\ida\plugins\loopcolorizer.plw: can't load file

plugins.cfg has config:

color_loops.plw loopcolorizer Ctrl-F12 3

even if i compile it myself.

ida version used is: 5.0

Wait a minute, your plugin is named color_loop.plw or loopcolorizer.plw?

To solve the problem, remove your line from plugins.cfg

Ditto, crashes for me too.

And just having the file in the "..\plugins" directory (sans line in "plugins.cfg") causes the crash!

Well, try to debug the plugin and find why it crashes. It comes with the source code.

How to change the background color (light yellow by default), please?

Grad the source code, change the color and recompile it. The color is hardcoded.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Latest news: Hex-Rays decompiler has been released!