forked from Tinob/Ishiiruka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadDolphinMap.idc
62 lines (55 loc) · 1.44 KB
/
ReadDolphinMap.idc
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
/* ReadDolphinMap.idc
Loads Dolphin .map files into IDA Pro.
Carl Kenner, 2014
*/
#include <idc.idc>
static main(void)
{
auto fh;
auto fname;
auto pusha, popa;
auto start, end;
auto success;
auto count;
auto line;
auto ea; // column 1
auto name; // column 30
auto p;
auto code;
fname = AskFile(0,"*.map","Load a .map file from Dolphin emulator...");
fh = fopen(fname, "r");
if (fh == 0) {
Message("Can't open %s\n", fname);
return;
}
Message("Loading %s dolphin map file:\n", fname);
for (count = 0; 1; count++) {
line = readstr(fh);
if (line == -1)
break;
if (strlen(line)>30 && line[0]!=" ") {
ea = xtol(substr(line,0,8));
name = substr(line,29,strlen(line)-1);
if (substr(name,0,3)!="zz_") {
if (!MakeNameEx(ea,name,SN_NOCHECK | SN_PUBLIC | SN_NON_AUTO |SN_NOWARN)) {
MakeNameEx(ea,name+"_2",SN_NOCHECK | SN_PUBLIC | SN_NON_AUTO );
}
Message("ea='%x', name='%s'\n", ea, name);
} else {
MakeNameEx(ea,name,SN_NOCHECK | SN_PUBLIC | SN_AUTO | SN_WEAK | SN_NOWARN);
}
} else if (strlen(line)>30) {
ea = xtol(substr(line,18,18+8));
p = strstr(line, " \t");
if (p>=30 && ea!=0) {
name = substr(line,30,p);
code = substr(line,p+2,strlen(line));
SetFunctionCmt(ea, code, 0);
if (!MakeNameEx(ea,name,SN_NOCHECK | SN_PUBLIC | SN_NON_AUTO |SN_NOWARN)) {
MakeNameEx(ea,name+"_2",SN_NOCHECK | SN_PUBLIC | SN_NON_AUTO );
}
}
}
}
Message("Dolphin map file done.\n");
}