I would like to answer my own question. Firstly, we need to understand that funcap annotates disassembly with anterior comments which are helpful most of the time. But, sometimes it can provide redundant information which can hinder the normal workflow. Unlike normal comments and repeatable comments which usually appear at the end of the line, anterior comments appear above any instruction or data. While posterior comments appear below any given data or instruction in disassembly.
Therefore, the above problem of clearing comments can be broken down into 2 steps:
- Delete anterior comments while retaining other comments at the end of line(comments, repeatable comments).
- Set the color of the disassembly view to default.
Opening and deleting every individual comment manually using Insert is a tedious task. We can automate this (boring) task using IDC script or IDAPython script.
clear_comments.idc - idc script
// clear_comments.idc - clear all (anterior)comments by funcap using IDC
#include <idc.idc>
static main(void) {
auto ea;
for (ea=MinEA(); ea != BADADDR; ea=NextHead(ea, BADADDR))
{
DelExtLnA(ea, 0); // delete anterior comments
SetColor(ea, CIC_FUNC, DEFCOLOR); // set default color of functions and data
SetColor(ea, CIC_ITEM, DEFCOLOR);
}
Message("[*] refreshing disassembly.");
Refresh();
Message(".ok\n");
Message("[*] refreshing lists.");
RefreshLists();
Message(".ok\n");
}
clear_comments.py - idapython script
# clear_comments.py - clear all (anterior)comments by funcap using IDAPython (python 2.7.10)
from idaapi import *
from idc import DelExtLnA, SetColor, Refresh, RefreshLists
def refresh_disassembly():
Refresh()
return "disassembly"
def refresh_lists():
RefreshLists()
return "lists"
def clear_comments():
ea = idaapi.cvar.inf.minEA
while ea != BADADDR:
DelExtLnA(ea, 0) # delete anterior comments
SetColor(ea, CIC_FUNC, DEFCOLOR) # set default color of functions and data
SetColor(ea, CIC_ITEM, DEFCOLOR)
ea = idaapi.next_head(ea, idaapi.cvar.inf.maxEA)
print "[*] refreshing", refresh_disassembly(), "..ok"
print "[*] refreshing", refresh_lists(), "..ok"
return None
clear_comments()
Note 1: I have tested the idapython script in IDA 6.6 with python 2.7.10. For using this script with python 3.x.x we just need some minor adjustments to print(...)
statements at line:22
line:23
only.
Note 2: These scripts can be used to delete pseudo comments or to reset the color of the disassembly view to default.