2 // *****************************************************************************
4 // Name: ida_vtables.idc
5 // Desc: Recreates the methods of a class from a vtable
7 // Ver: 1.0b - July 20, 2006 - By Sirmabus
8 // Ver: 2.0 - July 7, 2006 by BAILOPAN
9 // �������������������������������������������������������������������������-��-
11 // -----------------------------------------------------------------------------
17 auto pAddress, iIndex;
18 auto szFilePath, hFile;
21 SetStatus(IDA_STATUS_WORK);
23 // User selected vtable block
24 pAddress = ScreenEA();
26 if (pAddress == BADADDR)
28 Message("** No vtable selected! Aborted **");
29 Warning("No vtable selected!\nSelect vtable block first.");
30 SetStatus(IDA_STATUS_READY);
34 skipAmt = AskLong(1, "Number of vtable entries to ignore for indexing:");
36 // Request output header file
37 SetStatus(IDA_STATUS_WAITING);
38 if ((szFilePath = AskFile(1, "*.txt", "Select output dump file:")) == 0)
41 SetStatus(IDA_STATUS_READY);
46 if ((hFile = fopen(szFilePath, "wb")) != 0)
48 auto szFuncName, szFullName, BadHits;
53 fprintf(hFile, "// Auto reconstructed from vtable block @ 0x%08X\n// from \"%s\", by ida_vtables.idc\n", pAddress, GetInputFile());
55 /* For linux, skip the first entry */
56 if (Dword(pAddress) == 0)
58 pAddress = pAddress + 8;
61 pAddress = pAddress + (skipAmt * 4);
63 // Loop through the vtable block
64 while (pAddress != BADADDR)
67 real_addr = Dword(pAddress);
69 szFuncName = Name(real_addr);
70 if (strlen(szFuncName) == 0)
74 szFullName = Demangle(szFuncName, INF_LONG_DN);
77 szFullName = szFuncName;
79 if (strstr(szFullName, "_ZN") != -1)
82 Warning("You must toggle GCC v3.x demangled names!\n");
85 fprintf(hFile, "%d\t%s\n", iIndex, szFullName);
87 pAddress = pAddress + 4;
92 Message("Successfully wrote %d vtable entries.\n", iIndex);
96 Message("** Error opening \"%s\"! Aborted **\n", szFilePath);
97 Warning("Error creating \"%s\"!\n", szFilePath);
100 Message("\nDone.\n\n");
101 SetStatus(IDA_STATUS_READY);