1

How to clear the comments created by funcap and restore database to it's previous state?

I tried reanalyzing the program but comments do not seems to go away from database.

Though, checking-off Comments in IDA Options seems to work, but it also remove comments that I have made.

enter image description here

1 Answer 1

1

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:

  1. Delete anterior comments while retaining other comments at the end of line(comments, repeatable comments).
  2. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.