Thanks guys. I updated the code, cause the original is atrocious. Made the instructions a bit clearer. Also, fixed a bug that would occurred when an input file was created with dumpbin's /all switch (don't recommend using that switch anyway, but its fixed if you do).
Here's the main work section of the new code. Nothing fancy.
try
{
ifstream inFile;
inFile.open(argv[1], ios::in);
if(!inFile.good()) {
cerr << argv[1] << " could not be opened for read." << endl;
exit(1);
}
string sOutFile(argv[2]);
sOutFile += ".und";
ofstream outFile;
outFile.open(sOutFile.c_str(), ios::out | ios::trunc);
if(!outFile.good()) {
cerr << sOutFile << " could not be created." << endl;
exit(1);
}
string sLine;
string sResult(1024, '\0');
while(getline(inFile, sLine, '\n'))
{
size_t nStart = sLine.find_first_of('?');
if(nStart != string::npos) {
size_t nEnd = sLine.find_first_of(' ', nStart);
if(nEnd != string::npos) {
sLine = sLine.substr(nStart, nEnd - nStart);
} else {
sLine = sLine.substr(nStart);
}
DWORD dwErr = UnDecorateSymbolName(sLine.c_str(), &sResult[0],1024, 0);
if(dwErr) {
outFile << sResult.c_str() << endl;
} else {
dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&sResult[0], 1024, NULL);
cerr << sResult.c_str();
}
}
}
}