/usr/share/doc/radare2/idc2rdb.idc is in radare2 0.9.6-3.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /*
* ida2rdb.idc
* ===========
*
* Exports an ida database in a format to be handled by radare
*
* author: pancake <@youterm.com>
*
* TODO:
* * Add stack frame related information (stack size, and so) as comments
*
*/
#include <idc.idc>
static dumpMeNot(fd, ea) {
auto func, comment, sz, i, ref;
// Loop from start to end in the current segment
//SegStart(ea);
for (func=ea; func != BADADDR && func < SegEnd(ea); func=NextFunction(func)) {
// If the current address is function process it
// if (GetFunctionFlags(func) != -1) {
sz = FindFuncEnd(func) - func;
fprintf(fd, "af+ 0x%08lx %d %s\n", func, sz, GetFunctionName(func));
comment = GetFunctionCmt(func, 0);
if (comment != "")
fprintf(fd, "CC %s@0x%08x\n", comment, func);
fprintf(fd, "CC framesize=%d@0x%08x\n", func, GetFrameSize(func));
// Find all code references to func
for (ref=RfirstB(func); ref != BADADDR; ref=RnextB(func, ref)) {
//fprintf(fd, "; xref from %08lX (%s)\n", ref, GetFunctionName(ref));
fprintf(fd, "Cx 0x%08lx 0x%08lx\n", func, ref);
}
// }
}
for (func=ea; func != BADADDR && func < SegEnd(ea); func=func+1) {
comment = CommentEx(func, 0);
if (comment != "")
fprintf(fd, "CC %s@0x%08x\n", comment, func);
comment = GetConstCmt(func, 0);
if (comment != "")
fprintf(fd, "CC %s@0x%08x\n", comment, func);
comment = GetEnumCmt(func, 0);
if (comment != "")
fprintf(fd, "CC %s@0x%08x\n", comment, func);
}
}
static main() {
auto fd;
auto file;
auto i, func, ref,sz;
auto ord,ea;
auto comment;
auto entry;
file = GetInputFile()+".txt";
fd = fopen(file, "w");
if (!fd) {
Message("Cannot open '"+file+"'\n");
Exit(1);
}
entry="";
// Walk entrypoints
for ( i=0; ; i++ ) {
ord = GetEntryOrdinal(i);
if ( ord == 0 ) break;
ea = GetEntryPoint(ord);
fprintf(fd, "entry=0x%08lx %s\n", ea, Name(ea));
entry = ea;
}
// XXX last entrypoint taken as ok??
dumpMeNot(fd, entry);
// eof
fclose(fd);
Message(file+"file generated.\n");
}
|