IDA IDC Tutorials: Additional Auto-Commenting

https://www.hex-rays.com/products/ida/support/tutorials/idc/autocomment.shtml

This program creates a segment at paragraph 0x40 and comments the BIOS data area. You should load and execute this file to see the names of BIOS data area variables.

//-------------------------------------------------------------------------
static CW(off,name,cmt) {
  auto x;
  x = [ 0x40, off ];
  MakeWord(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

//-------------------------------------------------------------------------
static CD(off,name,cmt) {
  auto x;
  x = [ 0x40, off ];
  MakeDword(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

//-------------------------------------------------------------------------
static CB(off,name,cmt) {
  auto x;
  x = [ 0x40, off ];
  MakeByte(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

//-------------------------------------------------------------------------
static CmtBdata() {
 CW(0x000,"com_port_1","Base I/O address of 1st serial I/O port");
 CW(0x002,"com_port_2","Base I/O address of 2nd serial I/O port");
 CW(0x004,"com_port_3","Base I/O address of 3rd serial I/O port");
 CW(0x006,"com_port_4","Base I/O address of 4th serial I/O port");

 CW(0x008,"prn_port_1","Base I/O address of 1st parallel I/O port");
 CW(0x00A,"prn_port_2","Base I/O address of 2nd parallel I/O port");
 CW(0x00C,"prn_port_3","Base I/O address of 3rd parallel I/O port");
 CW(0x00E,"prn_port_4","Base I/O address of 4th parallel I/O port");
 MakeArray([0x40,0x01E ], 16 );
 CB(0x03E,"dsk_recal_stat",     "Recalibrate floppy drive bits\n"
                "   3       2       1       0\n"
                "drive-3 drive-2 drive-1 drive-0\n"
                "\n"
                "bit 7 = interrupt flag");
CW(0x0CE,"days_since1_80",     "Days since 1-Jan-1980 counter");
 MakeArray(0x4AC,0xCE-0xAC);
}

//-------------------------------------------------------------------------
static main() {
  if ( !SegCreate(0x400,0x4D0,0x40,0,0,2) ) {
    Warning("Can't create BIOS data segment.");
    return;
  }
  SegRename(0x400,"bdata");
  SegClass(0x400,"BIOSDATA");
  CmtBdata();
}
#include <idc.idc>

//-------------------------------------------------------------------------
static CW(off,name,cmt) {
  auto x;
  x = 0x400 + off;
  MakeWord(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

//-------------------------------------------------------------------------
static CD(off,name,cmt) {
  auto x;
  x = 0x400 + off;
  MakeDword(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

//-------------------------------------------------------------------------
static CB(off,name,cmt) {
  auto x;
  x = 0x400 + off;
  MakeByte(x);
  MakeName(x,name);
  MakeRptCmt(x,cmt);
}

 

posted @ 2013-09-12 08:52  IAmAProgrammer  阅读(409)  评论(0编辑  收藏  举报