Skip to content

InstructionCounter plugin for IDA Pro

The InstructionCounter plugin for IDA Pro is actually the first plugin I've ever succesfully finished. The main reason for this is probably that it's not exactly a very complicated plugin but basically a copy / paste of the template code from Steve Micallef's awesome IDA plugin tutorial with just a few extra lines added.

The plugin counts all instructions used in a file, orders them by their frequency of occurrence and prints all that information to a text file of your choice.

Here's what the output looks like:

Opcode distribution of file: D:\Coding\nes\new\Page_15.idb
Total opcodes: 6390

0001. 001337    20.92%      LDA
0002. 001022    15.99%      STA
0003. 000589     9.22%      JSR
0004. 000260     4.07%      RTS
0005. 000205     3.21%      AND
0006. 000198     3.10%      LDX
0007. 000186     2.91%      CMP
0008. 000178     2.79%      ADC
0009. 000177     2.77%      BNE
0010. 000171     2.68%      BEQ
...

The ZIP file contains the complete Visual C++ source code and the compiled plugin for IDA 4.8 and IDA 4.9.

There are two minor problems I'm having which are mentioned in the source file. Unfortunately none of the people I bug about my IDA problems have been online in the last few days.

Furthermore I was convinced that a plugin like that already exists but I didn't find anything at the IDA Palace when I needed it a few days ago. If there's really already a plugin like that let me know.