Augmenting Predefined Comments with loadint

In Chapter 7 we covered IDA’s concept of auto comments, which, when enabled, cause IDA to display comments describing each assembly language instruction. Two examples of such comments are shown in the following listing:

.text:08048654                 lea     ecx, [esp+arg_0] ; Load Effective Address
.text:08048658                 and     esp, 0FFFFFFF0h ; Logical AND

The source of these predefined comments is the file <IDADIR>/ida.int, which contains comments sorted first by CPU type and second by instruction type. When auto comments are turned on, IDA searches for comments associated with each instruction in the disassembly and displays them in the right margin if they are present in ida.int.

The loadint[91] utilities provide you with the ability to modify existing comments or add new comments to ida.int. As with the other add-on utilities we have discussed, loadint is documented in a readme.txt file included with the loadint distribution. The loadint distribution also contains the predefined comments for all of IDA’s processor modules in the form of numerous .cmt files. Modifying existing comments is a simple matter of locating the comment file associated with your processor of interest (for example, pc.cmt for x86), making changes to any comments whose text you wish to modify, running loadint to re-create the ida.int comment file, and finally copying the resulting ida.int file into your main IDA directory, where it will be loaded the next time IDA is launched. A simple run to rebuild the comment database looks like the following:

$ ./loadint comment.cmt ida.int
Comment base loader. Version 2.04. Copyright (c) 1991-2011 Hex-Rays

17566 cases, 17033 strings, total length: 580575

Examples of changes that you might wish to make include modifying existing comments or enabling comments for instructions that have no assigned comment. In the pc.cmt file, for example, several of the more common instructions are commented out so as not to generate too many comments when auto comments are enabled. The following lines, extracted from pc.cmt, demonstrate that x86 mov instructions do not generate comments by default:

NN_ltr:                 "Load Task Register"
//NN_mov:               "Move Data"
NN_movsp:               "Move to/from Special Registers"

Should you wish to enable comments for mov instructions, you would uncomment the middle line and rebuild the comment database as detailed previously.

A note buried within the documentation for loadint points out that loadint must be able to locate the file ida.hlp, which is included with your IDA distribution. If you receive the following error message, you should copy ida.hlp into your loadint directory and then rerun loadint.

$ ./loadint comment.cmt ida.int
Comment base loader. Version 2.04. Copyright (c) 1991-2011 Hex-Rays
Can't initialize help system.
File name: 'ida.hlp', Reason: can't find file (take it from IDA distribution).

Alternatively, you may use the -n switch with loadint to specify the location of <IDADIR>, as shown in the following command line:

$ ./loadint -n <IDADIR> comment.cmt ida.int

The file comment.cmt serves as the master input file to the loadint process. The syntax for this file is described in the loadint documentation. In a nutshell, comment.cmt creates the mappings from processor types to associated comment files. Individual processor-specific comment files in turn specify the mappings from specific instructions to the associated comment text for each instruction. The entire process is governed by several sets of enumerated (C-style enums) constants that define all of the processor types (found in comment.cmt) and all of the possible instructions for each processor (found in allins.hpp).

If you want to add predefined comments for a completely new processor type, the process is somewhat more involved than simply changing existing comments and is fairly closely linked to the process for creating new processor modules (see Chapter 19). Without diving too deeply into processor modules, providing comments for a completely new processor type requires that you first create a new enumerated constant set (shared with your processor module) within allins.hpp that defines one constant for each instruction in the instruction set of interest. Second, you must create a comment file that maps each enumerated instruction constant to its associated comment text. Third, you must define a new constant for your processor type (again, shared with your processor module) and create an entry in comment.cmt that maps your processor type to its associated comment file. Once you have completed these steps, you must run loadint to build a new comment database that incorporates your new processor type and associated comments.



[91] The current version is loadint61.zip.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.182.96