2

How can I color functions that contain loops in IDApython ?

If the end of the basic block can jump to start of basic block it's good enough, even in the rare case this is not a loop. But how do i implement this ?

EDIT: This is not good cause the loop can span multiple basic blocks. Or, maybe if the ecx register is used ? I don't care if I have some false positives ?

perror
  • 19,083
  • 29
  • 87
  • 150
Vision
  • 21
  • 3

1 Answers1

7

There is an IDA plugin called Loop Detection that does that, it comes with source code and a paper explaining how it works. Have a look at loop_detection.cpp and refer to the paper for an explanation of how it works.

Plugin with source code : http://www.openrce.org/downloads/details/9/Loop_Detection Paper: http://www.uninformed.org/?v=1&a=2&t=pdf

Looking for uses of ecx is not a good approach as this register is often used for other purposes. A better approach is to look for back edges between blocks.

ekse
  • 2,208
  • 13
  • 19