in tools/ExeView/save.cpp [24:134]
BOOL SaveResources(HWND hWnd, PEXEINFO pExeInfo, LPSTR lpFile)
{
char szBuff[255];
LPSTR lp = (LPSTR)szBuff;
char szRCType[30];
LPCSTR lpn;
if (pExeInfo == NULL)
{
MessageBox(hWnd, "NO file open!",
"ExeView Error", MB_ICONSTOP | MB_OK);
return false;
}
PRESTYPE prt = pExeInfo->pResTable;
HFILE hFile = 0;
hFile = _lcreat(lpFile, 0);
if (!hFile)
{
MessageBox(hWnd, "Error opening file for write!",
"ExeView Error", MB_ICONSTOP | MB_OK);
return false;
}
lstrcpy(lp, "/********************************************************************\n\n Resources that were extracted from a binary that ran on 16-bit Windows.\n\n");
ADDITEM();
lstrcpy(lp, " Copyright(c) Microsoft Corporation.All rights reserved.\n Licensed under the MIT License.\n\n********************************************************************/\n\n");
ADDITEM();
while (prt)
{
int restype = 0;
PRESINFO pri = prt->pResInfoArray;
WORD wI = 0;
if (prt->wType & 0x8000)
{
WORD wType = prt->wType & 0x7fff;
if (wType == 0 || wType == 11 || wType == 13 || wType > 16)
{
lpn = (LPSTR)szRCType;
wsprintf(szRCType, "Unknown Type: %#04X\0", prt->wType);
}
else
{
lpn = rc_types[wType];
restype = wType;
}
}
else
{
lpn = prt->pResourceType;
// restype == 0
}
if (restype == (int)RT_MENU || restype == (int)RT_DIALOG || restype == (int)RT_STRING)
{
while (wI < prt->wCount)
{
RESPACKET rp;
LPRESPACKET lprp = &rp;
if (LoadResourcePacket(pExeInfo, prt, pri, lprp))
{
// for menu, dialog and string, dump details of this item
switch (restype)
{
case (int)RT_MENU:
SaveMenu(hFile, lprp);
break;
case (int)RT_DIALOG:
SaveDialog(hFile, lprp);
break;
case (int)RT_STRING:
SaveStringTable(hFile, lprp);
break;
}
FreeResourcePacket(lprp);
lstrcpy(lp, "\n");
ADDITEM();
}
pri++;
wI++;
}
prt = prt->pNext;
if (prt)
{
lstrcpy(lp, "\n");
ADDITEM();
}
}
else
{
prt = prt->pNext;
}
}
_lclose(hFile);
return TRUE;
}