Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

765 lines
35 KiB

  1. //////////////////////////////////////////////////////////////////////////
  2. //
  3. // The format of the token file is:
  4. // [[TYPE ID|RES ID|Item ID|Flags|Status Flags|Item Name]]=
  5. // this is the standar format used by several token file tools in MS.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. //
  9. // Author: Alessandro Muti
  10. // Date: 12/02/94
  11. //
  12. ///////////////////////////////////////////////////////////////////////////////
  13. #include <afx.h>
  14. #include "iodll.h"
  15. #include "main.h"
  16. #include "token.h"
  17. #include "vktbl.h"
  18. #include "imagehlp.h"
  19. extern CMainApp theApp;
  20. /*******************************************************\
  21. This is the part were the real code starts.
  22. The function Bingen generate a binary from a token file.
  23. If the user select the -u options then we perform a
  24. token checking otherwise we'll be compatible with RLMAN
  25. and just trust the ID.
  26. \*******************************************************/
  27. CMainApp::Error_Codes CMainApp::BinGen()
  28. {
  29. Error_Codes iErr = ERR_NOERROR;
  30. CTokenFile m_tokenfile;
  31. CToken * pToken;
  32. iErr = (CMainApp::Error_Codes)m_tokenfile.Open(m_strSrcTok, m_strTgtTok);
  33. if(iErr) {
  34. return iErr;
  35. }
  36. WriteCon(CONERR, "%s\r\n", CalcTab("", 79, '-'));
  37. // Copy the Src binary over the target
  38. // Now we can go and open an handle to the SrcExe file
  39. HANDLE hModule = RSOpenModule(m_strInExe, NULL);
  40. if ((int)(UINT_PTR)hModule < LAST_ERROR) {
  41. // error or warning
  42. WriteCon(CONERR, "%s", CalcTab(m_strInExe, m_strInExe.GetLength()+5, ' '));
  43. IoDllError((int)(UINT_PTR)hModule);
  44. return ERR_FILE_NOTSUPP;
  45. } else {
  46. LPCSTR lpszType = 0L;
  47. LPCSTR lpszRes = 0L;
  48. DWORD dwLang = 0L;
  49. DWORD dwItem = 0L;
  50. DWORD dwItemId;
  51. LPRESITEM lpResItem = NULL;
  52. CString strResName = "";
  53. BOOL bSkip;
  54. BOOL bSkipLang = FALSE;
  55. WORD wCount = 0;
  56. CString strFaceName;
  57. WORD wPointSize;
  58. BYTE bCharSet;
  59. // before we do anything else we have to check how many languages we have in the file
  60. CString strLang;
  61. char szLang[8];
  62. BOOL b_multi_lang = FALSE;
  63. USHORT usInputLang = MAKELANGID(m_usIPriLangId, m_usISubLangId);
  64. if((b_multi_lang = RSLanguages(hModule, strLang.GetBuffer(1024))) && !IsFlag(INPUT_LANG))
  65. {
  66. // this is a multiple language file but we don't have an input language specified
  67. // Fail, but warn the user that he has to set the input language to continue.
  68. strLang.ReleaseBuffer();
  69. theApp.SetReturn(ERROR_FILE_MULTILANG);
  70. WriteCon(CONERR, "Multiple language file. Please specify an input language %s.\r\n", strLang);
  71. goto exit;
  72. }
  73. strLang.ReleaseBuffer();
  74. // Convert the language in to the hex value
  75. if (usInputLang)
  76. sprintf(szLang,"0x%3X", usInputLang);
  77. else
  78. sprintf(szLang,"0x000");
  79. // Check if the input language that we got is a valid one
  80. if(IsFlag(INPUT_LANG) && strLang.Find(szLang)==-1)
  81. {
  82. WriteCon(CONERR, "The language %s in not a valid language for this file.\r\n", szLang);
  83. WriteCon(CONERR, "Valid languages are: %s.\r\n", strLang);
  84. theApp.SetReturn(ERROR_RES_NOT_FOUND);
  85. goto exit;
  86. }
  87. CString strFileName = m_strInExe;
  88. CString strFileType;
  89. CString strTokenDir = "";
  90. int pos = m_strInExe.ReverseFind('\\');
  91. if(pos!=-1)
  92. {
  93. strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
  94. }
  95. else
  96. if((pos = m_strInExe.ReverseFind(':'))!=-1)
  97. {
  98. strFileName = m_strInExe.Right(m_strInExe.GetLength()-pos-1);
  99. }
  100. pos = m_strTgtTok.ReverseFind('\\');
  101. if(pos==-1)
  102. pos = m_strTgtTok.ReverseFind(':');
  103. if(pos!=-1)
  104. strTokenDir = m_strTgtTok.Left(pos+1);
  105. if (m_strSymPath[0] && m_strSymPath != m_strOutputSymPath)
  106. {
  107. CString strInDebugFile;
  108. CString strOutDebugFile;
  109. HANDLE hDebugFile = FindDebugInfoFile(
  110. strFileName.GetBuffer(MAX_PATH),
  111. m_strSymPath.GetBuffer(MAX_PATH),
  112. strInDebugFile.GetBuffer(MAX_PATH)
  113. );
  114. strInDebugFile.ReleaseBuffer();
  115. if ( hDebugFile == NULL ) {
  116. return (Error_Codes)IoDllError(ERROR_IO_SYMBOLFILE_NOT_FOUND);
  117. }
  118. CloseHandle(hDebugFile);
  119. strOutDebugFile = m_strOutputSymPath + strInDebugFile.Right(strInDebugFile.GetLength()-m_strSymPath.GetLength());
  120. if (!CopyFile(strInDebugFile.GetBuffer(MAX_PATH), strOutDebugFile.GetBuffer(MAX_PATH),FALSE))
  121. {
  122. CString strTmp;
  123. strTmp = strOutDebugFile.Left(strOutDebugFile.GetLength()-strFileName.GetLength()-1);
  124. CreateDirectory(strTmp.GetBuffer(MAX_PATH),NULL);
  125. if (!CopyFile(strInDebugFile.GetBuffer(MAX_PATH), strOutDebugFile.GetBuffer(MAX_PATH),FALSE))
  126. {
  127. return (Error_Codes)IoDllError(ERROR_FILE_SYMPATH_NOT_FOUND);
  128. }
  129. }
  130. }
  131. WriteCon(CONOUT, "Processing\t");
  132. WriteCon(CONBOTH, "%s", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
  133. RSFileType(m_strInExe, strFileType.GetBuffer(10));
  134. strFileType.ReleaseBuffer();
  135. WriteCon(CONBOTH, "%s", CalcTab(strFileType, strFileType.GetLength()+5, ' '));
  136. if(IsFlag(WARNING))
  137. WriteCon(CONBOTH, "\r\n");
  138. while ((lpszType = RSEnumResType(hModule, lpszType)))
  139. {
  140. // Check if is one of the type we care about
  141. if(HIWORD(lpszType)==0)
  142. switch(LOWORD(lpszType))
  143. {
  144. case 1:
  145. case 2:
  146. case 3:
  147. case 4:
  148. case 5:
  149. case 6:
  150. case 9:
  151. case 10:
  152. case 11:
  153. case 12:
  154. case 14:
  155. case 16:
  156. case 23:
  157. case 240:
  158. case 1024:
  159. case 2110:
  160. bSkip = FALSE;
  161. break;
  162. default:
  163. bSkip = TRUE;
  164. }
  165. else
  166. bSkip = FALSE;
  167. lpszRes = 0L;
  168. dwLang = 0L;
  169. dwItem = 0L;
  170. CString strText;
  171. int iTokenErr = 0;
  172. while ((!bSkip) && (lpszRes = RSEnumResId(hModule, lpszType, lpszRes))) {
  173. while ((dwLang = RSEnumResLang(hModule, lpszType, lpszRes, dwLang))) {
  174. // Check if we have to skip this language
  175. if(b_multi_lang && (LOWORD(dwLang)!=usInputLang))
  176. bSkipLang = TRUE;
  177. else
  178. bSkipLang = FALSE;
  179. while ((!bSkipLang) && (dwItem = RSEnumResItemId(hModule, lpszType, lpszRes, dwLang, dwItem))) {
  180. // Now Get the Data
  181. DWORD dwImageSize = RSGetResItemData( hModule,
  182. lpszType,
  183. lpszRes,
  184. dwLang,
  185. dwItem,
  186. m_pBuf,
  187. MAX_BUF_SIZE );
  188. lpResItem = (LPRESITEM)m_pBuf;
  189. if(((wCount++ % 50)==0) && !(IsFlag(WARNING)))
  190. WriteCon(CONOUT, ".");
  191. if (HIWORD(lpszType))
  192. {
  193. if (lstrcmp (lpszType,"REGINST") == 0)
  194. {
  195. //
  196. // Currently there is no id for REGINST defined
  197. // in nt. We just use this 2200 for now.
  198. //
  199. lpResItem->dwTypeID = 2200;
  200. }
  201. }
  202. lpResItem->dwLanguage = theApp.GetOutLang();
  203. // Version stamp use class name as res id
  204. if(lpResItem->lpszResID)
  205. strResName = lpResItem->lpszResID;
  206. else strResName = "";
  207. if(lpResItem->dwTypeID==16)
  208. {
  209. strResName = lpResItem->lpszClassName;
  210. }
  211. switch(LOWORD(lpResItem->dwTypeID))
  212. {
  213. case 4:
  214. {
  215. if(!(lpResItem->dwFlags & MF_POPUP))
  216. dwItemId = (LOWORD(lpResItem->dwItemID)==0xffff ? HIWORD(lpResItem->dwItemID) : lpResItem->dwItemID);
  217. else dwItemId = lpResItem->dwItemID;
  218. }
  219. break;
  220. case 5:
  221. dwItemId = (LOWORD(lpResItem->dwItemID)==0xffff ? HIWORD(lpResItem->dwItemID) : lpResItem->dwItemID);
  222. break;
  223. case 11:
  224. dwItemId = LOWORD(lpResItem->dwItemID);
  225. break;
  226. default:
  227. dwItemId = lpResItem->dwItemID;
  228. }
  229. if (lpResItem->dwTypeID==1 || lpResItem->dwTypeID==12
  230. || lpResItem->dwTypeID==14)
  231. {
  232. // if user don't want to append redundant cursors,
  233. // bitmaps, and icons, we make it NULL
  234. if (IsFlag(LEANAPPEND) && IsFlag(APPEND)){
  235. dwImageSize=0;
  236. RSUpdateResImage(hModule,lpszType,lpszRes,dwLang,0,lpResItem,dwImageSize);
  237. }
  238. continue;
  239. }
  240. // Is this a bitmap?
  241. if(lpResItem->dwTypeID==2
  242. || lpResItem->dwTypeID==3
  243. || lpResItem->dwTypeID==23
  244. || lpResItem->dwTypeID== 240
  245. || lpResItem->dwTypeID== 1024
  246. || lpResItem->dwTypeID== 2110
  247. || lpResItem->dwTypeID== 2200)
  248. {
  249. if (IsFlag(LEANAPPEND)
  250. && IsFlag(APPEND)
  251. && (lpResItem->dwTypeID == 2
  252. || lpResItem->dwTypeID == 3))
  253. {
  254. dwImageSize=0;
  255. RSUpdateResImage(hModule,lpszType,lpszRes,dwLang,0,lpResItem,dwImageSize);
  256. continue;
  257. }
  258. // Search for a token with this ID
  259. pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
  260. lpResItem->dwResID,
  261. dwItemId,
  262. strResName);
  263. if(pToken!=NULL)
  264. {
  265. // Get the name of the input image
  266. strText = pToken->GetTgtText();
  267. // Open the file
  268. CFile inputFile;
  269. if(!inputFile.Open(strText,
  270. CFile::modeRead |
  271. CFile::shareDenyNone |
  272. CFile::typeBinary ) &&
  273. !inputFile.Open(strTokenDir + strText,
  274. CFile::modeRead |
  275. CFile::shareDenyNone |
  276. CFile::typeBinary))
  277. {
  278. WriteCon(CONERR, "Input file %s not found! Using Src file data!\r\n", strTokenDir+strText);
  279. goto skip;
  280. }
  281. DWORD dwSize = inputFile.GetLength();
  282. BYTE * pInputBuf = (BYTE*)new BYTE[dwSize];
  283. if(pInputBuf==NULL)
  284. {
  285. WriteCon(CONERR, "Error allocating memory for the image! (%d)\r\n", dwSize);
  286. goto skip;
  287. }
  288. BYTE * pInputBufOrigin = pInputBuf;
  289. inputFile.ReadHuge(pInputBuf, inputFile.GetLength());
  290. CString strTmp = pToken->GetTokenID();
  291. WriteCon(CONWRN, "Using image in file %s for ID %s\"]]!\r\n", strText.GetBuffer(0), strTmp.GetBuffer(0));
  292. BYTE * pInputImage=(BYTE *) new BYTE[dwSize];
  293. DWORD dwImageSize;
  294. // remove the header from the file
  295. switch(lpResItem->dwTypeID)
  296. {
  297. case 2:
  298. {
  299. dwImageSize = dwSize - sizeof(BITMAPFILEHEADER);
  300. pInputBuf += sizeof(BITMAPFILEHEADER);
  301. }
  302. break;
  303. case 3:
  304. {
  305. dwImageSize = dwSize - sizeof(ICONHEADER);
  306. pInputBuf += sizeof(ICONHEADER);
  307. }
  308. case 23:
  309. case 240:
  310. case 1024:
  311. case 2110:
  312. case 2200:
  313. {
  314. dwImageSize = dwSize;
  315. }
  316. break;
  317. default:
  318. break;
  319. }
  320. memcpy(pInputImage, pInputBuf, dwImageSize);
  321. //
  322. // We need to keep output lang info seperately,
  323. // because we dont't have lpResItem to send
  324. // the info to io for icons and bitmaps.
  325. //
  326. DWORD dwUpdLang = theApp.GetOutLang();
  327. // Update the resource
  328. RSUpdateResImage(hModule,lpszType,lpszRes,dwLang,dwUpdLang, pInputImage,dwImageSize);
  329. delete pInputBufOrigin;
  330. delete pInputImage;
  331. }
  332. else
  333. {
  334. goto skip;
  335. }
  336. }
  337. // is this an accelerator
  338. else if(lpResItem->dwTypeID==9)
  339. {
  340. // Search for a token with this ID
  341. pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
  342. lpResItem->dwResID,
  343. dwItemId,
  344. strResName);
  345. if(pToken!=NULL)
  346. {
  347. CAccel acc(pToken->GetTgtText());
  348. if( (lpResItem->dwFlags & 0x80)==0x80 )
  349. lpResItem->dwFlags = acc.GetFlags() | 0x80;
  350. else
  351. lpResItem->dwFlags = acc.GetFlags();
  352. lpResItem->dwStyle = acc.GetEvent();
  353. if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
  354. {
  355. // we have an error, warn the user
  356. WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  357. lpResItem->dwTypeID,
  358. lpResItem->dwResID,
  359. dwItemId,
  360. 0,
  361. 4,
  362. strResName);
  363. AddNotFound();
  364. }
  365. }
  366. }
  367. else
  368. {
  369. // Search for a token with this ID
  370. pToken = (CToken *)m_tokenfile.GetToken(lpResItem->dwTypeID,
  371. lpResItem->dwResID,
  372. dwItemId,
  373. Format(lpResItem->lpszCaption),
  374. strResName);
  375. }
  376. if(pToken!=NULL) {
  377. iTokenErr = pToken->GetLastError();
  378. if(pToken->GetFlags() & ISEXTSTYLE){
  379. CString strStyle= pToken->GetTgtText();
  380. lpResItem->dwExtStyle = strtol(strStyle, (char**)0,16);
  381. // Get the real Token
  382. pToken = (CToken *)m_tokenfile.GetToken(lpResItem->dwTypeID,
  383. lpResItem->dwResID,
  384. dwItemId,
  385. Format(lpResItem->lpszCaption),
  386. strResName);
  387. if(pToken!=NULL)
  388. wCount++;
  389. }
  390. // Check if is a dialog font name
  391. if(pToken != NULL &&
  392. ((pToken->GetFlags() & ISDLGFONTNAME) ||
  393. (pToken->GetFlags() & ISDLGFONTSIZE)))
  394. {
  395. if(theApp.IsFlag(CMainApp::FONTS))
  396. {
  397. int iColon;
  398. CString strTgtFaceName = pToken->GetTgtText();
  399. // This should be the font description token
  400. if( strTgtFaceName.IsEmpty() || ((iColon = strTgtFaceName.Find(':'))==-1) )
  401. WriteCon(CONWRN, "Using Src file FaceName for ID %s\"]]!\r\n", pToken->GetTokenID());
  402. // Check if the dialog has the DS_SETFONT flag set, otherwise let the user
  403. // know that we can't do much with his font description
  404. if( (lpResItem->dwStyle & DS_SETFONT)!=DS_SETFONT )
  405. WriteCon(CONWRN, "Dialog ID %s\"]] is missing the DS_SETFONT bit. Cannot change font!\r\n", pToken->GetTokenID());
  406. else
  407. {
  408. strFaceName = strTgtFaceName.Left(iColon);
  409. strFaceName.TrimRight();
  410. strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
  411. strTgtFaceName.TrimLeft();
  412. //sscanf( strTgtFaceName, "%d", &wPointSize );
  413. if ((iColon=strTgtFaceName.Find(':'))!=-1) {
  414. wPointSize=(WORD)atoi(strTgtFaceName.Left(iColon));
  415. strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
  416. bCharSet = (BYTE)atoi(strTgtFaceName);
  417. lpResItem->bCharSet = bCharSet;
  418. }else{
  419. wPointSize=(WORD)atoi(strTgtFaceName);
  420. }
  421. lpResItem->lpszFaceName = strFaceName.GetBuffer(0);
  422. lpResItem->wPointSize = wPointSize;
  423. strFaceName.ReleaseBuffer();
  424. }
  425. }
  426. // Get the real Token
  427. pToken = (CToken *)m_tokenfile.GetToken(lpResItem->dwTypeID,
  428. lpResItem->dwResID,
  429. dwItemId,
  430. Format(lpResItem->lpszCaption),
  431. strResName);
  432. if(pToken!=NULL)
  433. wCount++;
  434. }
  435. }
  436. if(pToken!=NULL && !pToken->GetLastError())
  437. {
  438. strText = UnFormat(pToken->GetTgtText());
  439. if(m_tokenfile.GetTokenSize(pToken, &lpResItem->wX, &lpResItem->wY,
  440. &lpResItem->wcX, &lpResItem->wcY))
  441. wCount++;
  442. lpResItem->lpszCaption = strText.GetBuffer(0);
  443. // Static control and style flag is set. We need
  444. // to take style alignment change as well
  445. if (LOBYTE(lpResItem->wClassName) == 0x82 &&
  446. theApp.IsFlag(CMainApp::ALIGNMENT))
  447. {
  448. //Get style alignment token
  449. pToken = (CToken *)m_tokenfile.GetToken(
  450. lpResItem->dwTypeID,
  451. lpResItem->dwResID,
  452. dwItemId,
  453. Format(lpResItem->lpszCaption),
  454. strResName);
  455. if (pToken!=NULL)
  456. {
  457. wCount++;
  458. CString strStyle=pToken->GetTgtText();
  459. if (strStyle=="SS_CENTER")
  460. lpResItem->dwStyle |= SS_CENTER;
  461. else if (strStyle=="SS_RIGHT")
  462. {
  463. //reset the alignment bit
  464. lpResItem->dwStyle &= 0xfffffffc;
  465. lpResItem->dwStyle |= SS_RIGHT;
  466. }
  467. else if (strStyle=="SS_LEFT")
  468. lpResItem->dwStyle &= 0xfffffffc;
  469. else
  470. //use provided style is wrong. warn!
  471. WriteCon(CONWRN, "Using Src file alignment style for ID %s\"]]!\r\n", pToken->GetTokenID());
  472. }
  473. }
  474. if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
  475. {
  476. // we have an error, warn the user
  477. WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  478. lpResItem->dwTypeID,
  479. lpResItem->dwResID,
  480. dwItemId,
  481. 0,
  482. 4,
  483. strResName);
  484. AddNotFound();
  485. }
  486. strText.ReleaseBuffer();
  487. }
  488. else
  489. {
  490. pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
  491. lpResItem->dwResID,
  492. dwItemId,
  493. strResName);
  494. if(pToken!=NULL)
  495. {
  496. if(pToken->GetFlags() & ISEXTSTYLE){
  497. CString strStyle= pToken->GetTgtText();
  498. lpResItem->dwExtStyle = strtol(strStyle, (char**)0,16);
  499. // Get the real Token
  500. pToken = (CToken *)m_tokenfile.GetNoCaptionToken(lpResItem->dwTypeID,
  501. lpResItem->dwResID,
  502. dwItemId,
  503. strResName);
  504. if(pToken!=NULL)
  505. wCount++;
  506. }
  507. // Check if is a dialog font name
  508. if(pToken != NULL &&
  509. ((pToken->GetFlags() & ISDLGFONTNAME) ||
  510. (pToken->GetFlags() & ISDLGFONTSIZE)))
  511. {
  512. if(theApp.IsFlag(CMainApp::FONTS))
  513. {
  514. int iColon;
  515. CString strTgtFaceName = pToken->GetTgtText();
  516. // This should be the font description token
  517. if( strTgtFaceName.IsEmpty() || ((iColon = strTgtFaceName.Find(':'))==-1) )
  518. WriteCon(CONWRN, "Using Src file FaceName for ID %s\"]]!\r\n", pToken->GetTokenID());
  519. // Check if the dialog has the DS_SETFONT flag set, otherwise let the user
  520. // know that we can't do much with his font description
  521. if( (lpResItem->dwStyle & DS_SETFONT)!=DS_SETFONT )
  522. WriteCon(CONWRN, "Dialog ID %s\"]] is missing the DS_SETFONT bit. Cannot change font!\r\n", pToken->GetTokenID());
  523. else
  524. {
  525. strFaceName = strTgtFaceName.Left(iColon);
  526. strFaceName.TrimRight();
  527. strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
  528. strTgtFaceName.TrimLeft();
  529. // sscanf( strTgtFaceName, "%d", &wPointSize );
  530. if ((iColon=strTgtFaceName.Find(':'))!=-1){
  531. wPointSize=(WORD)atoi(strTgtFaceName.Left(iColon));
  532. strTgtFaceName = strTgtFaceName.Right(strTgtFaceName.GetLength() - iColon-1);
  533. bCharSet = (BYTE)atoi(strTgtFaceName);
  534. lpResItem->bCharSet = bCharSet;
  535. }else{
  536. wPointSize=(WORD)atoi(strTgtFaceName);
  537. }
  538. lpResItem->lpszFaceName = strFaceName.GetBuffer(0);
  539. lpResItem->wPointSize = wPointSize;
  540. strFaceName.ReleaseBuffer();
  541. }
  542. }
  543. if(m_tokenfile.GetTokenSize(pToken, &lpResItem->wX, &lpResItem->wY,
  544. &lpResItem->wcX, &lpResItem->wcY))
  545. wCount++;
  546. }
  547. // Check if is a dialog size
  548. else if(pToken->GetFlags() & ISCOR)
  549. {
  550. pToken->GetTgtSize(&lpResItem->wX, &lpResItem->wY,
  551. &lpResItem->wcX, &lpResItem->wcY);
  552. }
  553. // Just size and/or font updated
  554. if(IoDllError(RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE)))
  555. {
  556. // we have an error, warn the user
  557. WriteCon(CONWRN, "Error updating token\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  558. lpResItem->dwTypeID,
  559. lpResItem->dwResID,
  560. dwItemId,
  561. 0,
  562. 4,
  563. strResName);
  564. AddNotFound();
  565. }
  566. }
  567. else
  568. {
  569. switch(LOWORD(lpszType))
  570. {
  571. case 4:
  572. case 5:
  573. case 6:
  574. case 10:
  575. case 11:
  576. // No Token was found for this ID
  577. // Leave it for now but here will come the
  578. // PSEUDO Translation code.
  579. if(strlen(lpResItem->lpszCaption) && !iTokenErr)
  580. {
  581. WriteCon(CONWRN, "ID not found\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  582. lpResItem->dwTypeID,
  583. lpResItem->dwResID,
  584. dwItemId,
  585. 0,
  586. 4,
  587. strResName);
  588. AddNotFound();
  589. }
  590. break;
  591. case 9:
  592. WriteCon(CONWRN, "ID not found\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  593. lpResItem->dwTypeID,
  594. lpResItem->dwResID,
  595. dwItemId,
  596. 0,
  597. 4,
  598. strResName);
  599. AddNotFound();
  600. break;
  601. break;
  602. case 16:
  603. if (theApp.IsFlag(CMainApp::NOVERSION) &&
  604. (strResName==TEXT("FileVersion") ||
  605. strResName==TEXT("ProductVersion") ||
  606. strResName==TEXT("Platform"))){
  607. //
  608. // do nothing
  609. //
  610. }else if(strlen(lpResItem->lpszCaption) && !iTokenErr){
  611. WriteCon(CONWRN, "ID not found\t[[%hu|%hu|%hu|%hu|%hu|\"%s\"]]\r\n",
  612. lpResItem->dwTypeID,
  613. lpResItem->dwResID,
  614. dwItemId,
  615. 0,
  616. 4,
  617. strResName);
  618. AddNotFound();
  619. }
  620. break;
  621. default:
  622. break;
  623. }
  624. // Let's update the item anyway, since the language might have changed
  625. // RSUpdateResItemData(hModule,lpszType,lpszRes,dwLang,dwItem,lpResItem,MAX_BUF_SIZE);
  626. }
  627. }
  628. skip:;
  629. }
  630. }
  631. }
  632. }
  633. iErr=(Error_Codes)IoDllError(RSWriteResFile(hModule, m_strOutExe, NULL,m_strOutputSymPath));
  634. if ((int)iErr > 0){
  635. //WriteCon(CONERR, "%s", CalcTab(m_strOutExe, m_strOutExe.GetLength()+5, ' '));
  636. goto exit;
  637. }
  638. WriteCon(CONBOTH, " %hu(%hu) Items\r\n", wCount, m_wIDNotFound);
  639. // Check if some items were removed from the file
  640. if(wCount<m_tokenfile.GetTokenNumber() ||
  641. m_wIDNotFound ||
  642. m_wCntxChanged ||
  643. m_wResized)
  644. WriteCon(CONWRN, "%s\tToken: ", CalcTab(strFileName, strFileName.GetLength()+5, ' '));
  645. if(wCount<m_tokenfile.GetTokenNumber())
  646. {
  647. SetReturn(ERROR_RET_RESIZED);
  648. WriteCon(CONWRN, "Removed %d ", m_tokenfile.GetTokenNumber()-wCount);
  649. }
  650. if(m_wIDNotFound)
  651. WriteCon(CONWRN, "Not Found %d ", m_wIDNotFound);
  652. if(m_wCntxChanged)
  653. WriteCon(CONWRN, "Contex Changed %d ", m_wCntxChanged);
  654. if(m_wResized)
  655. WriteCon(CONWRN, "Resize Changed %d ", m_wResized);
  656. if(wCount<m_tokenfile.GetTokenNumber() ||
  657. m_wIDNotFound ||
  658. m_wCntxChanged ||
  659. m_wResized)
  660. WriteCon(CONWRN, "\r\n");
  661. }
  662. exit:
  663. RSCloseModule(hModule);
  664. return iErr;
  665. }