(Removed, see the info a few posts down)
This IDA script (.IDC) is used to import
Code: Select all
(Removed, see the script a few posts down)
maybe this will help someone besides me
Moderator: MacroQuest Developers
Code: Select all
(Removed, see the script a few posts down)

Code: Select all
// ConvertCSV.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// The one and only application object
CWinApp theApp;
using namespace std;
CString CleanName(CString Str)
{
// remove <x>;
// remove (x)
// remove extra words
int Pos=Str.Find('<');
while(Pos>=0)
{
int Len=Str.GetLength();
int Count=0;
for (int PosB = Pos ; PosB < Len ; PosB++)
{
if (Str.GetAt(PosB)=='<')
Count++;
else if (Str.GetAt(PosB)=='>')
{
Count--;
if (Count<=0)
break;
}
}
// int PosB=Str.Find('>');
if (PosB>0)
{
Str.Delete(Pos,PosB-Pos+1);
Pos=Str.Find('<');
}
else
break;
}
Pos=Str.Find('(');
if (Pos>=0)
Str=Str.Left(Pos);
Pos=Str.ReverseFind(' ');
if (Pos>=0)
Str.Delete(0,Pos+1);
Str.Replace(':','_');
Str.Replace('~','d');
return Str;
}
CString GetAttribute(CString Str, int N)
{
int nAttr=0;
int Len = Str.GetLength();
bool quotes=false;
CString Out;
for (int i = 0 ; i < Len ; i++)
{
char c=Str.GetAt(i);
if (c==',' && !quotes)
{
nAttr++;
if (N==nAttr)
return Out;
Out="";
}
else if (c=='"')
{
quotes=!quotes;
}
else
{
Out.AppendChar(c);
}
}
return "";
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
printf("ConvertCSV\n");
CStdioFile InFile;
if (!InFile.Open("c:\\path\\to\\Undecorated_testeqgame_map.csv",CFile::modeRead|CFile::shareDenyNone))
{
printf("Failed to open Undecorated_testeqgame_map.csv\n");
return 0;
}
CStdioFile OutFile;
if (!OutFile.Open("c:\\path\\to\\ida-import.txt",CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone))
{
printf("Failed to open ida-import.txt\n");
return 0;
}
CString Input;
while(InFile.ReadString(Input))
{
CString Output;
CString Offset=GetAttribute(Input,4);
CString Name=GetAttribute(Input,1);
CString Cleaned=CleanName(Name);
if (Offset.GetLength()
&& Offset.GetAt(0)=='0'
&& Cleaned.GetLength()
&& Cleaned.Find('\'')==-1
&& Name.CompareNoCase("`string'")
&& Name.Find("operator")==-1
&& Name.Find("destructor")==-1
&& Name.Find("constructor")==-1
&& Name.Left(2).Compare("_$")
)
{
Output.Format("%s %s %s\n",Offset,Cleaned,Name);
OutFile.WriteString(Output);
}
}
}
return nRetCode;
}
Code: Select all
static main() {
auto fh;
auto stemp,sleft,smiddle,sright,pos;
fh=fopen("c:\\path\\to\\ida-import.txt","r");
if (fh==0)
{
Message("Could not open ida-import.txt\n");
return;
}
Message("Beginning import map script\n");
SetStatus(3);
while(stemp != -1)
{
stemp=readstr(fh);
if (stemp != -1)
{
// 01234567890 pos
// 12345678901 len
// "100 abcdefg"
// 1234567
pos=strstr(stemp," ");
if (pos != -1)
{
sleft=substr(stemp,0,pos);
// strip both the space and the \n
smiddle=substr(stemp,pos+1,strlen(stemp)-1);
pos=strstr(smiddle," ");
sright=substr(smiddle,pos+1,strlen(smiddle)-1);
smiddle=substr(smiddle,0,pos);
MakeName(xtol(sleft),smiddle);
MakeRptCmt(xtol(sleft),sright);
}
}
}
fclose(fh);
SetStatus(0);
Message("Done!\n");
}
donations for this month's patches.