Leaked source code of windows server 2003
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.

2349 lines
90 KiB

  1. #include "precomp.h"
  2. #include "ie4comp.h"
  3. #include "ieaklite.h"
  4. extern TCHAR g_szCustIns[];
  5. extern TCHAR g_szMastInf[];
  6. extern TCHAR g_szDefInf[];
  7. extern TCHAR g_szSignup[];
  8. extern TCHAR g_szBuildTemp[];
  9. extern TCHAR g_szIEAKProg[];
  10. extern TCHAR g_szWizRoot[];
  11. extern TCHAR g_szWizPath[];
  12. extern TCHAR g_szLanguage[];
  13. extern TCHAR g_szActLang[];
  14. extern TCHAR g_szTempSign[];
  15. extern TCHAR g_szBuildRoot[];
  16. extern TCHAR g_szSrcRoot[];
  17. extern TCHAR g_szCustInf[];
  18. extern TCHAR g_szAllModes[];
  19. extern TCHAR g_szDeskTemp[];
  20. extern TCHAR g_szUnsignedFiles[];
  21. extern TCHAR g_szTitle[];
  22. extern TCHAR g_szInstallFolder[];
  23. extern TCHAR g_szCifVer[];
  24. extern TCHAR g_szDestCif[];
  25. extern TCHAR g_szCif[];
  26. extern TCHAR g_szCustCif[];
  27. extern TCHAR g_szCustItems[];
  28. extern TCHAR g_szMyCptrPath[];
  29. extern TCHAR g_szCtlPanelPath[];
  30. extern TCHAR g_szCustIcmPro[];
  31. extern TCHAR g_szKey[];
  32. extern TCHAR g_szJobVersion[];
  33. extern BOOL g_fIntranet, g_fNoSignup, g_fServerless, g_fServerKiosk, g_fServerICW, g_fInteg, g_fOCW, g_fBranded;
  34. extern BOOL g_fSilent, g_fStealth;
  35. extern BOOL g_fCD, g_fLAN, g_fDownload, g_fBrandingOnly;
  36. extern BOOL g_fBatch;
  37. extern BOOL g_fBatch2;
  38. extern BOOL g_fCustomICMPro;
  39. extern BOOL g_fDone, g_fCancelled;
  40. extern BOOL g_fUseIEWelcomePage;
  41. extern UINT g_uiNumCabs;
  42. extern int g_iInstallOpt;
  43. extern int g_nCustComp;
  44. extern int g_iSelOpt;
  45. extern int g_nModes;
  46. extern int g_iSelSite;
  47. extern int g_nDownloadUrls;
  48. extern PCOMPONENT g_paComp;
  49. extern COMPONENT g_aCustComponents[20];
  50. extern SITEDATA g_aCustSites[NUMSITES];
  51. extern SHFILEOPSTRUCT g_shfStruc;
  52. extern HWND g_hStatusDlg;
  53. extern HWND g_hProgress;
  54. extern HANDLE g_hDownloadEvent;
  55. extern HRESULT CabUpFolder(HWND hWnd, LPTSTR szFolderPath, LPTSTR szDestDir, LPTSTR szCabname,
  56. LPTSTR szDisplayName, LPTSTR szGuid, LPTSTR szAddReg);
  57. extern void WriteModesToCif(CCifRWComponent_t * pCifRWComponent_t, LPCTSTR pcszModes);
  58. extern void UpdateProgress(int);
  59. extern BOOL AnySelection(PCOMPONENT pComp);
  60. extern BOOL CopyISK( LPTSTR szDestPath, LPTSTR szSourcePath );
  61. extern void BuildIE4Folders(HWND hWnd);
  62. static TCHAR s_szIE4SetupDir[MAX_PATH];
  63. static DWORD s_dwTicksPerUnit;
  64. // Private forward decalarations
  65. static void WritePIDValues(LPCTSTR pcszInsFile, LPCTSTR pcszSetupInf);
  66. static void WriteURDComponent(CCifRWFile_t *lpCifRWFileDest, LPCTSTR pcszModes);
  67. void SetCompSize(LPTSTR szCab, LPTSTR szSect, DWORD dwInstallSize);
  68. // BUGBUG: <oliverl> should probably persist this server side only info in a server side file for IEAK6
  69. void SaveSignupFiles()
  70. {
  71. HANDLE hFind;
  72. WIN32_FIND_DATA fd;
  73. TCHAR szIndex[8];
  74. TCHAR szSignupFiles[MAX_PATH];
  75. int i = 0;
  76. WritePrivateProfileString(IS_SIGNUP, NULL, NULL, g_szCustIns);
  77. PathCombine(szSignupFiles, g_szSignup, TEXT("*"));
  78. hFind = FindFirstFile(szSignupFiles, &fd);
  79. if (hFind != INVALID_HANDLE_VALUE)
  80. {
  81. while (1)
  82. {
  83. if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  84. && (StrCmp(fd.cFileName, TEXT(".")) != 0)
  85. && (StrCmp(fd.cFileName, TEXT("..")) != 0))
  86. {
  87. wnsprintf(szIndex, countof(szIndex), FILE_TEXT, i++);
  88. WritePrivateProfileString(IS_SIGNUP, szIndex, fd.cFileName, g_szCustIns);
  89. }
  90. if (!FindNextFile(hFind, &fd))
  91. break;
  92. }
  93. FindClose(hFind);
  94. }
  95. }
  96. DWORD CopyIE4Files(void)
  97. {
  98. DWORD res;
  99. HRESULT hr;
  100. int i;
  101. TCHAR szSectBuf[1024];
  102. PCOMPONENT pComp;
  103. TCHAR szTemp[MAX_PATH];
  104. TCHAR szTo[5 * MAX_PATH];
  105. TCHAR szFrom[2 * MAX_PATH];
  106. TCHAR szCDF[MAX_PATH];
  107. TCHAR szActSetupTitle[MAX_PATH];
  108. ZeroMemory(szFrom, sizeof(szFrom));
  109. SetAttribAllEx(g_szBuildTemp, TEXT("*.*"), FILE_ATTRIBUTE_NORMAL, TRUE);
  110. g_shfStruc.pFrom = szFrom;
  111. PathCombine(szFrom, g_szWizRoot, TEXT("TOOLS"));
  112. res = CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szBuildTemp);
  113. if (res) return(res);
  114. PathCombine(szFrom, g_szWizRoot, TEXT("IEBIN"));
  115. PathAppend(szFrom, g_szLanguage);
  116. PathAppend(szFrom, TEXT("OPTIONAL"));
  117. PathRemoveBackslash(szFrom);
  118. res = CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szBuildTemp);
  119. if (res) return(res);
  120. PathCombine(szCDF, g_szBuildTemp, TEXT("bootie42.cdf"));
  121. if (!PathFileExists(szCDF) || !SetFileAttributes(szCDF, FILE_ATTRIBUTE_NORMAL))
  122. return (DWORD) -1;
  123. PathCombine(g_szTempSign, g_szBuildTemp, TEXT("CUSTSIGN"));
  124. CreateDirectory(g_szTempSign, NULL);
  125. if (ISNONNULL(g_szSignup))
  126. {
  127. DeleteFileInDir(TEXT("signup.txt"), g_szTempSign);
  128. // if ICW signup method is specified, create the signup.txt file
  129. if (g_fServerICW)
  130. {
  131. TCHAR szIspFile[MAX_PATH];
  132. TCHAR szEntryName[MAX_PATH];
  133. TCHAR szBuf[MAX_PATH * 2];
  134. HANDLE hFile;
  135. PathCombine(szIspFile, g_szTempSign, TEXT("signup.txt"));
  136. if ((hFile = CreateFile(szIspFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
  137. FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
  138. {
  139. HANDLE hFind;
  140. WIN32_FIND_DATA fd;
  141. LoadString(g_rvInfo.hInst, IDS_ISPINFILEHEADER, szBuf, countof(szBuf));
  142. WriteStringToFile(hFile, szBuf, StrLen(szBuf));
  143. PathCombine(szIspFile, g_szSignup, TEXT("*.isp"));
  144. hFind = FindFirstFile(szIspFile, &fd);
  145. if (hFind != INVALID_HANDLE_VALUE)
  146. {
  147. do
  148. {
  149. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  150. || (StrCmp(fd.cFileName, TEXT(".")) == 0)
  151. || (StrCmp(fd.cFileName, TEXT("..")) == 0))
  152. continue;
  153. PathCombine(szIspFile, g_szSignup, fd.cFileName);
  154. GetPrivateProfileString(TEXT("Entry"), TEXT("Entry_Name"), TEXT(""), szEntryName,
  155. countof(szEntryName), szIspFile);
  156. wnsprintf(szBuf, countof(szBuf), TEXT("%s,\"%s\"\r\n"), fd.cFileName, szEntryName);
  157. WriteStringToFile(hFile, szBuf, StrLen(szBuf));
  158. }
  159. while (FindNextFile(hFind, &fd));
  160. FindClose(hFind);
  161. }
  162. CloseHandle(hFile);
  163. }
  164. }
  165. SaveSignupFiles();
  166. // NOTE: ApplyIns logic should happen *before* copying signup files to the temp folder
  167. // IMPORTANT (pritobla):
  168. // Apply INS function just appends the content of g_szCustIns to the signup ins files.
  169. // At this point, there are no common sections between g_szCustIns and the signup ins files.
  170. // Any other setting that's gonna be added (for example: WriteNoClearToINSFiles() call below),
  171. // should be done *after* this call.
  172. ApplyINSFiles(g_szSignup, g_szCustIns);
  173. // should write NoClear=1 to the [Branding] section to preserve the settings applied by install.ins
  174. WriteNoClearToINSFiles(g_szSignup);
  175. // copy all the files from the signup folder to the temp dir
  176. res = CopyFilesSrcToDest(g_szSignup, TEXT("*.*"), g_szTempSign);
  177. if (g_fServerless)
  178. {
  179. TCHAR szSignupIsp[MAX_PATH];
  180. // (pritobla)
  181. // NOTE: Since the signup folder is separate for each signup mode (ICW, kiosk & serverless),
  182. // there is no need to delete *.isp and *.cab files. But I'm doing it anyways just in
  183. // case they copied files from a server-based folder. Downside of this is that even if
  184. // the ISP wants to include .isp or .cab files (for whatever reason), they can't do so.
  185. // for serverless signup, don't need any .isp or *.cab files; so delete them.
  186. DeleteFileInDir(TEXT("*.isp"), g_szTempSign);
  187. DeleteFileInDir(TEXT("*.cab"), g_szTempSign);
  188. // BUGBUG: should write Serverless=1 to the INS files in the signup folder and not in the temp folder
  189. // should write Serverless=1 in the [Branding] section to avoid being whacked by ICW
  190. FixINSFiles(g_szTempSign);
  191. // BUGBUG: we should add signup.isp to the Signup section in install.ins for IEAKLite mode cleanup
  192. // write the magic number to signup.isp in the temp location so that ICW doesn't complain
  193. PathCombine(szSignupIsp, g_szTempSign, TEXT("signup.isp"));
  194. WritePrivateProfileString(IS_BRANDING, FLAGS, TEXT("16319"), szSignupIsp);
  195. WritePrivateProfileString(NULL, NULL, NULL, szSignupIsp);
  196. }
  197. else
  198. {
  199. // server based signup -- don't need any .ins or .cab files
  200. DeleteINSFiles(g_szTempSign);
  201. DeleteFileInDir(TEXT("*.cab"), g_szTempSign);
  202. // IMPORTANT: the fact that we are deleting *.ins means that copying of install.ins
  203. // from the target dir should happen after this
  204. // For ICW signup, even though we specify icwsign.htm as the html file, inetcfg.dll checks for
  205. // the existence of signup.htm (old code) and if it isn't there, it will launch ICW in normal mode.
  206. // Hack here is to copy icwsign.htm as signup.htm if it doesn't exist already (it would exist already
  207. // if Single Disk Branding media and ICW signup mode are selected).
  208. if (g_fServerICW)
  209. {
  210. if (!PathFileExistsInDir(TEXT("signup.htm"), g_szTempSign))
  211. {
  212. TCHAR szICWSign[MAX_PATH],
  213. szSignup[MAX_PATH];
  214. PathCombine(szICWSign, g_szTempSign, TEXT("icwsign.htm"));
  215. PathCombine(szSignup, g_szTempSign, TEXT("signup.htm"));
  216. // BUGBUG: we should add signup.htm to the Signup section in install.ins for IEAKLite mode cleanup
  217. CopyFile(szICWSign, szSignup, FALSE);
  218. }
  219. }
  220. }
  221. }
  222. // IMPORTANT: install.ins should be copied only after signup files have been processed.
  223. // copy install.ins from the target dir to the temp location
  224. ZeroMemory(szFrom, 2*MAX_PATH);
  225. StrCpy(szFrom, g_szCustIns);
  226. PathCombine(szTo, g_szTempSign, PathFindFileName(szFrom));
  227. CopyFile(szFrom, szTo, FALSE);
  228. // write pid values and clear from the INS in the temp dir, if necessary
  229. if (!g_fBatch && !g_fBatch2)
  230. WritePIDValues(szTo, g_szCustInf);
  231. PathCombine(szTemp, g_szBuildRoot, TEXT("INS"));
  232. PathAppend(szTemp, GetOutputPlatformDir());
  233. PathAppend(szTemp, g_szLanguage);
  234. res |= CopyFilesSrcToDest(szTemp, TEXT("*.inf"), g_szTempSign);
  235. PathCombine(szTemp, g_szTempSign, TEXT("iesetup.inf"));
  236. DeleteFile(szTemp);
  237. ZeroMemory(szFrom, MAX_PATH);
  238. g_shfStruc.pFrom = szFrom;
  239. g_shfStruc.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
  240. g_shfStruc.pTo = g_szBuildTemp;
  241. if (!g_fBatch && !g_fBatch2)
  242. {
  243. ICifRWComponent * pCifRWComponent;
  244. CCifRWComponent_t * pCifRWComponent_t;
  245. DWORD dwVer, dwBuild;
  246. TCHAR szVersion[32];
  247. g_lpCifRWFileVer->Flush();
  248. for (pComp = g_paComp; *pComp->szSection; pComp++ )
  249. {
  250. g_lpCifRWFile->CreateComponent(pComp->szSection, &pCifRWComponent);
  251. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  252. pCifRWComponent_t->GetVersion(&dwVer, &dwBuild);
  253. ConvertDwordsToVersionStr(szVersion, dwVer, dwBuild);
  254. if (pComp->iImage != RED && (StrCmpI(szVersion, pComp->szVersion)))
  255. pCifRWComponent_t->CopyComponent(g_szCifVer);
  256. delete pCifRWComponent_t;
  257. }
  258. g_lpCifRWFile->Flush();
  259. }
  260. PathCombine(g_szDestCif, g_szBuildTemp, TEXT("iesetup.cif"));
  261. CopyFile(g_szCif, g_szDestCif, FALSE);
  262. hr = GetICifRWFileFromFile_t(&g_lpCifRWFileDest, g_szDestCif);
  263. {
  264. TCHAR szActSetupBitmap2[MAX_PATH];
  265. if (GetPrivateProfileString( IS_ACTIVESETUP, IK_WIZBMP, TEXT(""),
  266. szActSetupBitmap2, countof(szActSetupBitmap2), g_szCustIns ))
  267. {
  268. InsWriteQuotedString( TEXT("Strings"), TEXT("FILE15"), TEXT("ActSetup.Bmp"), szCDF );
  269. WritePrivateProfileString( TEXT("SourceFiles0"), TEXT("%FILE15%"), TEXT(""), szCDF );
  270. InsWriteQuotedString(BRANDING, IK_WIZBMP, TEXT("actsetup.bmp"), g_szCustInf);
  271. }
  272. if (GetPrivateProfileString( IS_ACTIVESETUP, IK_WIZBMP2, TEXT(""),
  273. szActSetupBitmap2, countof(szActSetupBitmap2), g_szCustIns ))
  274. {
  275. InsWriteQuotedString( TEXT("Strings"), TEXT("FILE16"), TEXT("topsetup.Bmp"), szCDF );
  276. WritePrivateProfileString( TEXT("SourceFiles0"), TEXT("%FILE16%"), TEXT(""), szCDF );
  277. InsWriteQuotedString(BRANDING, IK_WIZBMP2, TEXT("topsetup.bmp"), g_szCustInf);
  278. }
  279. if (GetPrivateProfileString( IS_ACTIVESETUP, IK_WIZTITLE, TEXT(""),
  280. szActSetupTitle, countof(szActSetupTitle), g_szCustIns ))
  281. {
  282. InsWriteQuotedString( BRANDING, IK_WIZTITLE, szActSetupTitle, g_szCustInf );
  283. g_lpCifRWFileDest->SetDescription(szActSetupTitle);
  284. WritePrivateProfileString(TEXT("Version"), TEXT("DisplayName"), szActSetupTitle, g_szCustInf);
  285. }
  286. if (InsGetBool(IS_BRANDING, IK_ALT_SITES_URL, FALSE, g_szCustIns))
  287. InsWriteBool(IS_CUSTOM, IK_ALT_SITES_URL, TRUE, g_szCustInf);
  288. }
  289. if (g_fCustomICMPro)
  290. {
  291. ICifRWComponent * pCifRWComponent;
  292. CCifRWComponent_t * pCifRWComponent_t;
  293. TCHAR szTempBuf[MAX_PATH];
  294. g_lpCifRWFileDest->CreateComponent(CUSTCMSECT, &pCifRWComponent);
  295. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  296. GetPrivateProfileString( CUSTCMSECT, TEXT("DisplayName"), TEXT(""), szSectBuf, countof(szSectBuf), g_szCustCif );
  297. pCifRWComponent_t->SetDescription(szSectBuf);
  298. GetPrivateProfileString( CUSTCMSECT, TEXT("GUID"), TEXT(""), szSectBuf, countof(szSectBuf), g_szCustCif );
  299. pCifRWComponent_t->SetGUID(szSectBuf);
  300. GetPrivateProfileString( CUSTCMSECT, TEXT("Command1"), TEXT(""), szSectBuf, countof(szSectBuf),g_szCustCif );
  301. GetPrivateProfileString( CUSTCMSECT, TEXT("Switches1"), TEXT(""), szTempBuf, countof(szTempBuf), g_szCustCif );
  302. pCifRWComponent_t->SetCommand(0, szSectBuf, szTempBuf, 2);
  303. GetPrivateProfileString( CUSTCMSECT, TEXT("URL1"), TEXT(""), szSectBuf, countof(szSectBuf), g_szCustCif );
  304. pCifRWComponent_t->SetUrl(0, szSectBuf, 2);
  305. pCifRWComponent_t->SetGroup(TEXT("BASEIE4"));
  306. pCifRWComponent_t->SetPriority(1);
  307. GetPrivateProfileString( CUSTCMSECT, VERSION, g_szJobVersion, szTempBuf, countof(szTempBuf), g_szCustCif );
  308. pCifRWComponent_t->SetVersion(szTempBuf);
  309. pCifRWComponent_t->SetUIVisible(FALSE);
  310. WriteModesToCif(pCifRWComponent_t, g_szAllModes);
  311. delete pCifRWComponent_t;
  312. }
  313. else
  314. {
  315. g_lpCifRWFileDest->DeleteComponent(CUSTCMSECT);
  316. }
  317. WritePrivateProfileString(NULL, NULL, NULL, g_szCustIns);
  318. WritePrivateProfileString( TEXT("SourceFiles"), TEXT("SourceFiles0"), TEXT(".\\"), szCDF );
  319. WritePrivateProfileString(NULL, NULL, NULL, szCDF);
  320. for (pComp = g_aCustComponents, i = 0; i < g_nCustComp ; pComp++, i++)
  321. {
  322. ICifRWComponent * pCifRWComponent;
  323. CCifRWComponent_t * pCifRWComponent_t;
  324. g_lpCifRWFileDest->CreateComponent(pComp->szSection, &pCifRWComponent);
  325. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  326. pCifRWComponent_t->SetDescription(pComp->szDisplayName);
  327. if (pComp->iInstallType != 2)
  328. {
  329. pCifRWComponent_t->SetUrl(0, pComp->szUrl, (pComp->iType != INST_CAB) ? 2 : 3);
  330. pCifRWComponent_t->SetCommand(0, pComp->szCommand, pComp->szSwitches, pComp->iType);
  331. }
  332. else
  333. {
  334. TCHAR szCmd[MAX_PATH * 2];
  335. TCHAR szCabName[64];
  336. TCHAR szInf[MAX_PATH];
  337. wnsprintf(szCabName, countof(szCabName), TEXT("%s.cab"), pComp->szSection);
  338. PathCombine(szInf, g_szBuildTemp, TEXT("postinst.inf"));
  339. wnsprintf(szCmd, countof(szCmd), TEXT("%03d"), 2*i+1);
  340. InsWriteString(IS_STRINGS, TEXT("JobNumber"), szCmd, szInf);
  341. wnsprintf(szCmd, countof(szCmd), TEXT("%03d"), 2*i);
  342. InsWriteString(IS_STRINGS, TEXT("JobNumberMinusOne"), szCmd, szInf);
  343. WritePrivateProfileString(IS_STRINGS, TEXT("CustomFile"), PathFindFileName(pComp->szPath), szInf);
  344. if (pComp->iType != INST_CAB)
  345. {
  346. InsWriteString(DEFAULT_INSTALL, TEXT("AddReg"), TEXT("PostRebootExeJob.Add"), szInf);
  347. InsWriteString(DEFAULT_INSTALL, TEXT("RunPostSetupCommands"), NULL, szInf);
  348. }
  349. else
  350. {
  351. InsWriteString(DEFAULT_INSTALL, TEXT("AddReg"), TEXT("PostRebootCabJob.Add"), szInf);
  352. InsWriteString(DEFAULT_INSTALL, TEXT("RunPostSetupCommands"), TEXT("Cab.MoveFile"), szInf);
  353. }
  354. WritePrivateProfileString(IS_STRINGS, TEXT("Command"), pComp->szCommand, szInf);
  355. WritePrivateProfileString(IS_STRINGS, TEXT("Switches"), pComp->szSwitches, szInf);
  356. WritePrivateProfileString(NULL, NULL, NULL, szInf);
  357. pCifRWComponent_t->SetUrl(0, szCabName, 3);
  358. pCifRWComponent_t->SetCommand(0, TEXT("postinst.inf"), TEXT(""), 0);
  359. CopyFileToDir(pComp->szPath, g_szBuildTemp);
  360. wnsprintf(szCmd, countof(szCmd), TEXT("%s\\cabarc n %s postinst.inf \"%s\""), g_szBuildTemp, szCabName, PathFindFileName(pComp->szPath));
  361. RunAndWait(szCmd, g_szBuildTemp, SW_HIDE);
  362. DeleteFileInDir(pComp->szPath, g_szBuildTemp);
  363. SignFile(szCabName, g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  364. }
  365. pCifRWComponent_t->SetGUID(pComp->szGUID);
  366. pCifRWComponent_t->SetUninstallKey(pComp->szUninstall);
  367. pCifRWComponent_t->SetVersion(pComp->szVersion);
  368. pCifRWComponent_t->SetDownloadSize(pComp->dwSize);
  369. WriteModesToCif(pCifRWComponent_t, pComp->szModes);
  370. pCifRWComponent_t->SetDetails(pComp->szDesc);
  371. // BUGBUG: <oliverl> we should really have an inseng interface method for setting this
  372. if (pComp->fIEDependency)
  373. InsWriteString(pComp->szSection, TEXT("Dependencies"), TEXT("BASEIE40_Win:N"), g_szDestCif);
  374. if (pComp->iInstallType == 1)
  375. pCifRWComponent_t->SetGroup(TEXT("PreCustItems"));
  376. else
  377. {
  378. pCifRWComponent_t->SetGroup(TEXT("CustItems"));
  379. if (pComp->iInstallType == 2)
  380. pCifRWComponent_t->SetReboot(TRUE);
  381. }
  382. pCifRWComponent_t->SetPriority(500-i);
  383. delete pCifRWComponent_t;
  384. }
  385. if (i > 0)
  386. {
  387. if(ISNULL(g_szCustItems))
  388. LoadString(g_rvInfo.hInst, IDS_CUSTOMCOMPTITLE, g_szCustItems, MAX_PATH);
  389. ICifRWGroup * pCifRWGroup;
  390. CCifRWGroup_t * pCifRWGroup_t;
  391. g_lpCifRWFileDest->CreateGroup(TEXT("CustItems"), &pCifRWGroup);
  392. pCifRWGroup_t = new CCifRWGroup_t(pCifRWGroup);
  393. pCifRWGroup_t->SetDescription(g_szCustItems);
  394. pCifRWGroup_t->SetPriority(500);
  395. delete pCifRWGroup_t;
  396. g_lpCifRWFileDest->CreateGroup(TEXT("PreCustItems"), &pCifRWGroup);
  397. pCifRWGroup_t = new CCifRWGroup_t(pCifRWGroup);
  398. pCifRWGroup_t->SetDescription(g_szCustItems);
  399. pCifRWGroup_t->SetPriority(950);
  400. delete pCifRWGroup_t;
  401. }
  402. if (!g_fBatch)
  403. {
  404. PCOMPONENT pComp;
  405. ICifRWComponent * pCifRWComponent;
  406. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  407. {
  408. if (pComp->fCustomHide)
  409. {
  410. g_lpCifRWFileDest->CreateComponent(pComp->szSection, &pCifRWComponent);
  411. pCifRWComponent->SetUIVisible(FALSE);
  412. }
  413. }
  414. for (pComp = g_paComp; *pComp->szSection; pComp++)
  415. {
  416. if (pComp->fCustomHide)
  417. {
  418. g_lpCifRWFileDest->CreateComponent(pComp->szSection, &pCifRWComponent);
  419. pCifRWComponent->SetUIVisible(FALSE);
  420. }
  421. else
  422. {
  423. // aolsupp component is set invisible by default in the cif, but IEAK admins
  424. // can choose to make it visible
  425. if (StrCmpI(pComp->szSection, TEXT("AOLSUPP")) == 0)
  426. {
  427. g_lpCifRWFileDest->CreateComponent(pComp->szSection, &pCifRWComponent);
  428. pCifRWComponent->SetUIVisible(TRUE);
  429. }
  430. }
  431. }
  432. }
  433. if (InsGetBool(IS_HIDECUST, IK_URD_STR, FALSE, g_szCustIns))
  434. WriteURDComponent(g_lpCifRWFileDest, g_szAllModes);
  435. // -----------------------------------------
  436. // begin temporary copies to old locations
  437. if (ISNULL(g_szDeskTemp))
  438. {
  439. StrCpy(g_szDeskTemp, g_szBuildRoot);
  440. PathAppend(g_szDeskTemp, TEXT("Desktop"));
  441. CreateDirectory( g_szDeskTemp, NULL );
  442. }
  443. // connection settings files
  444. g_cmCabMappings.GetFeatureDir(FEATURE_CONNECT, szFrom);
  445. if (PathIsDirectory(szFrom))
  446. if (RemoveDirectory(szFrom))
  447. ; // asta la vista
  448. else
  449. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  450. // desktop files
  451. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  452. PathCombine(szTemp, szFrom, TEXT("desktop.inf"));
  453. if (PathFileExists(szTemp))
  454. CopyFilesSrcToDest(szFrom, TEXT("desktop.inf"), g_szTempSign);
  455. g_cmCabMappings.GetFeatureDir(FEATURE_DESKTOPCOMPONENTS, szFrom);
  456. if (PathIsDirectory(szFrom) && !RemoveDirectory(szFrom))
  457. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szDeskTemp);
  458. // toolbar files
  459. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  460. PathCombine(szTemp, szFrom, TEXT("toolbar.inf"));
  461. if (PathFileExists(szTemp))
  462. CopyFilesSrcToDest(szFrom, TEXT("toolbar.inf"), g_szTempSign);
  463. g_cmCabMappings.GetFeatureDir(FEATURE_TOOLBAR, szFrom);
  464. if (PathIsDirectory(szFrom) && !RemoveDirectory(szFrom))
  465. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szDeskTemp);
  466. // favorites/quick links files
  467. g_cmCabMappings.GetFeatureDir(FEATURE_FAVORITES, szFrom);
  468. if (PathIsDirectory(szFrom))
  469. if (RemoveDirectory(szFrom))
  470. ; // asta la vista
  471. else
  472. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  473. // ISP Root Cert
  474. if (GetPrivateProfileString(IS_ISPSECURITY, IK_ROOTCERT, TEXT(""),
  475. szTemp, countof(szTemp), g_szCustIns))
  476. {
  477. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  478. CopyFilesSrcToDest(szFrom, PathFindFileName(szTemp), g_szTempSign);
  479. }
  480. // browser toolbar buttons
  481. if (GetPrivateProfileString(IS_BTOOLBARS, IK_BTCAPTION TEXT("0"), TEXT(""),
  482. szTemp, countof(szTemp), g_szCustIns))
  483. {
  484. g_cmCabMappings.GetFeatureDir(FEATURE_BTOOLBAR, szFrom);
  485. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  486. }
  487. // My Computer files
  488. if (ISNONNULL(g_szMyCptrPath))
  489. {
  490. g_cmCabMappings.GetFeatureDir(FEATURE_MYCPTR, szFrom);
  491. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szDeskTemp);
  492. }
  493. // Control Panel files
  494. if (ISNONNULL(g_szCtlPanelPath))
  495. {
  496. g_cmCabMappings.GetFeatureDir(FEATURE_CTLPANEL, szFrom);
  497. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szDeskTemp);
  498. }
  499. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  500. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  501. g_cmCabMappings.GetFeatureDir(FEATURE_WALLPAPER, szFrom);
  502. if (PathIsDirectory(szFrom) && !RemoveDirectory(szFrom))
  503. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szDeskTemp);
  504. // sitecert files
  505. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  506. PathCombine(szTemp, szFrom, TEXT("sitecert.inf"));
  507. if (PathFileExists(szTemp))
  508. CopyFilesSrcToDest(szFrom, TEXT("sitecert.inf"), g_szTempSign);
  509. PathCombine(szTemp, szFrom, TEXT("root.str"));
  510. if (PathFileExists(szTemp))
  511. CopyFilesSrcToDest(szFrom, TEXT("root.str"), g_szTempSign);
  512. PathCombine(szTemp, szFrom, TEXT("root.dis"));
  513. if (PathFileExists(szTemp))
  514. CopyFilesSrcToDest(szFrom, TEXT("root.dis"), g_szTempSign);
  515. PathCombine(szTemp, szFrom, TEXT("ca.str"));
  516. if (PathFileExists(szTemp))
  517. CopyFilesSrcToDest(szFrom, TEXT("ca.str"), g_szTempSign);
  518. // authcode files
  519. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  520. PathCombine(szTemp, szFrom, TEXT("authcode.inf"));
  521. if (PathFileExists(szTemp))
  522. CopyFilesSrcToDest(szFrom, TEXT("authcode.inf"), g_szTempSign);
  523. // seczones files
  524. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  525. PathCombine(szTemp, szFrom, TEXT("seczones.inf"));
  526. if (PathFileExists(szTemp))
  527. CopyFilesSrcToDest(szFrom, TEXT("seczones.inf"), g_szTempSign);
  528. // ratings files
  529. g_cmCabMappings.GetFeatureDir(FEATURE_BRAND, szFrom);
  530. PathCombine(szTemp, szFrom, TEXT("ratings.inf"));
  531. if (PathFileExists(szTemp))
  532. CopyFilesSrcToDest(szFrom, TEXT("ratings.inf"), g_szTempSign);
  533. // LDAP component
  534. g_cmCabMappings.GetFeatureDir(FEATURE_LDAP, szFrom);
  535. if (PathIsDirectory(szFrom))
  536. if (RemoveDirectory(szFrom))
  537. ; // asta la vista
  538. else
  539. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  540. // OE component
  541. g_cmCabMappings.GetFeatureDir(FEATURE_OE, szFrom);
  542. if (PathIsDirectory(szFrom))
  543. if (RemoveDirectory(szFrom))
  544. ; // asta la vista
  545. else
  546. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  547. if (g_fBatch)
  548. {
  549. StrCpy(szFrom, g_szWizPath);
  550. PathAppend(szFrom, TEXT("Branding"));
  551. CopyFilesSrcToDest(szFrom, TEXT("*.*"), g_szTempSign);
  552. }
  553. return(0);
  554. }
  555. void DeleteUnusedComps(LPCTSTR pcszCompDir)
  556. {
  557. PCOMPONENT pComp;
  558. UINT uiIndex;
  559. DWORD dwFlags;
  560. TCHAR szUrl[INTERNET_MAX_URL_LENGTH];
  561. LPTSTR pszCab;
  562. ICifComponent * pCifComponent;
  563. DeleteFileInDir(TEXT("install.ins"), pcszCompDir);
  564. DeleteFileInDir(TEXT("iesetup.cif"), pcszCompDir);
  565. DeleteFileInDir(TEXT("iesetup.inf"), pcszCompDir);
  566. if (g_fBatch)
  567. return;
  568. for (pComp = g_paComp; *pComp->szSection; pComp++)
  569. {
  570. if ((pComp->iCompType != COMP_OPTIONAL) || (pComp->iImage == RED) ||
  571. AnySelection(pComp) || !pComp->fCustomHide || !pComp->fNoCopy || pComp->fAVSDupe)
  572. {
  573. if ((pComp->iCompType == COMP_OPTIONAL) && !pComp->fVisible)
  574. {
  575. PCOMPONENT pCompDep;
  576. int i;
  577. for (pCompDep = pComp->paCompRevDeps[0], i = 0; pCompDep; pCompDep = pComp->paCompRevDeps[++i])
  578. {
  579. if (AnySelection(pCompDep) || ((!pCompDep->fCustomHide || !pCompDep->fNoCopy) && pCompDep->fVisible))
  580. break;
  581. }
  582. if (pCompDep)
  583. continue;
  584. }
  585. else
  586. continue;
  587. if (pComp->fAVSDupe)
  588. continue;
  589. }
  590. if (SUCCEEDED(g_lpCifRWFileDest->FindComponent(pComp->szSection, &pCifComponent)))
  591. {
  592. CCifComponent_t * pCifComponent_t =
  593. new CCifComponent_t((ICifRWComponent *)pCifComponent);
  594. uiIndex = 0;
  595. while (SUCCEEDED(pCifComponent_t->GetUrl(uiIndex, szUrl, countof(szUrl), &dwFlags)))
  596. {
  597. if (dwFlags & URLF_RELATIVEURL)
  598. pszCab = szUrl;
  599. else
  600. {
  601. pszCab = StrRChr(szUrl, NULL, TEXT('/'));
  602. if (pszCab)
  603. pszCab++;
  604. else
  605. pszCab = szUrl;
  606. }
  607. DeleteFileInDir(pszCab, pcszCompDir);
  608. uiIndex++;
  609. }
  610. delete pCifComponent_t;
  611. }
  612. }
  613. for (pComp = g_aCustComponents; *pComp->szSection; pComp++)
  614. {
  615. if (!AnySelection(pComp) && pComp->fCustomHide && pComp->fNoCopy)
  616. {
  617. pszCab = PathFindFileName(pComp->szPath);
  618. DeleteFileInDir(pszCab, pcszCompDir);
  619. }
  620. }
  621. }
  622. BOOL BuildLAN(DWORD dwTicks)
  623. {
  624. TCHAR szIE4SetupTo[MAX_PATH];
  625. LPTSTR pszFileName;
  626. TCHAR szLANFrom[MAX_PATH * 10];
  627. TCHAR szLANTo[MAX_PATH];
  628. TCHAR szBuildLAN[MAX_PATH];
  629. PCOMPONENT pComp;
  630. SHELLEXECUTEINFO shInfo;
  631. int res;
  632. ZeroMemory(&shInfo, sizeof(shInfo));
  633. shInfo.cbSize = sizeof(shInfo);
  634. shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  635. g_shfStruc.wFunc = FO_COPY;
  636. StrCpy(szBuildLAN, g_szBuildRoot);
  637. if (!g_fOCW)
  638. {
  639. PathAppend(szBuildLAN, TEXT("FLAT"));
  640. PathAppend(szBuildLAN, GetOutputPlatformDir());
  641. }
  642. PathAppend(szBuildLAN, g_szLanguage);
  643. PathCreatePath(szBuildLAN);
  644. res = CopyFilesSrcToDest(g_szIEAKProg, TEXT("*.*"), szBuildLAN, dwTicks);
  645. if (res)
  646. return FALSE;
  647. pszFileName = StrRChr(s_szIE4SetupDir, NULL, TEXT('\\'));
  648. if (pszFileName)
  649. pszFileName++;
  650. PathCombine(szIE4SetupTo, szBuildLAN, pszFileName);
  651. CopyFile(s_szIE4SetupDir,szIE4SetupTo,FALSE);
  652. // copy custom cabs
  653. res = CopyFilesSrcToDest(g_szBuildTemp, TEXT("*.CAB"), szBuildLAN);
  654. if (res)
  655. return FALSE;
  656. // copy custom components
  657. ZeroMemory(szLANFrom, sizeof(szLANFrom));
  658. for (pComp = g_aCustComponents, pszFileName = szLANFrom; ; pComp++ )
  659. {
  660. if (!(*pComp->szSection)) break;
  661. if (pComp->iInstallType == 2)
  662. continue;
  663. StrCpy(pszFileName, pComp->szPath);
  664. pszFileName += lstrlen(pszFileName) + 1;
  665. }
  666. if (ISNONNULL(szLANFrom))
  667. {
  668. g_shfStruc.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
  669. g_shfStruc.pFrom = szLANFrom;
  670. g_shfStruc.pTo = szBuildLAN;
  671. res = SHFileOperation(&g_shfStruc);
  672. if (res)
  673. return FALSE;
  674. }
  675. // copy URD component
  676. if (InsGetBool(IS_HIDECUST, IK_URD_STR, FALSE, g_szCustIns))
  677. {
  678. TCHAR szURDPath[MAX_PATH];
  679. PathCombine(szURDPath, g_szBuildTemp, IE55URD_EXE);
  680. CopyFileToDir(szURDPath, szBuildLAN);
  681. }
  682. // copy iesetup.ini
  683. PathCombine(szLANTo, szBuildLAN, TEXT("iesetup.ini"));
  684. PathCombine(szLANFrom, g_szBuildTemp, TEXT("iesetup.ini"));
  685. CopyFile(szLANFrom, szLANTo, FALSE);
  686. // copy ICM profile
  687. if (g_fCustomICMPro)
  688. {
  689. PathCombine(szLANTo, szBuildLAN, PathFindFileName(g_szCustIcmPro));
  690. CopyFile(g_szCustIcmPro, szLANTo, FALSE);
  691. }
  692. DeleteUnusedComps(szBuildLAN);
  693. return TRUE;
  694. }
  695. void SetCompSize(LPTSTR szCab, LPTSTR szSect, DWORD dwInstallSize)
  696. {
  697. DWORD dwDownloadSize, dwTolerance, dwsHi, dwLowSize, dwHighSize;
  698. HANDLE hCab = CreateFile(szCab, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL);
  699. TCHAR szSize[32];
  700. if (hCab == INVALID_HANDLE_VALUE)
  701. return;
  702. dwDownloadSize = GetFileSize( hCab, &dwsHi ) >> 10;
  703. if (dwInstallSize ==0)
  704. dwInstallSize = dwDownloadSize << 1;
  705. CloseHandle(hCab);
  706. wnsprintf(szSize, countof(szSize), TEXT("%i,%i"), dwDownloadSize, dwInstallSize);
  707. ICifRWComponent * pCifRWComponent;
  708. if (SUCCEEDED(g_lpCifRWFileDest->CreateComponent(szSect, &pCifRWComponent)))
  709. {
  710. pCifRWComponent->SetDownloadSize(dwDownloadSize);
  711. pCifRWComponent->SetExtractSize(dwInstallSize);
  712. pCifRWComponent->SetInstalledSize(0, dwInstallSize);
  713. return;
  714. }
  715. if (dwDownloadSize <= 7)
  716. dwTolerance = 100;
  717. else
  718. {
  719. if (dwDownloadSize > 60)
  720. dwTolerance = 10;
  721. else
  722. dwTolerance = (600 / dwDownloadSize);
  723. }
  724. wnsprintf(szSize, countof(szSize), TEXT("0,%i"), dwInstallSize);
  725. WritePrivateProfileString( szSect, TEXT("InstalledSize"), szSize, g_szDestCif );
  726. dwTolerance = (dwDownloadSize * dwTolerance) / 100;
  727. dwLowSize = dwDownloadSize - dwTolerance;
  728. dwHighSize = dwDownloadSize + dwTolerance;
  729. wnsprintf(szSize, countof(szSize), TEXT("%i,%i"), dwLowSize, dwHighSize);
  730. WritePrivateProfileString( szSect, TEXT("Size1"), szSize, g_szDestCif );
  731. }
  732. BOOL BuildBrandingOnly(DWORD dwTicks)
  733. {
  734. HANDLE hFile;
  735. LPSTR lpszBuf;
  736. DWORD dwBytesToWrite, dwBytesWritten;
  737. CCifRWFile_t *pCifRWFile;
  738. ICifRWGroup *pCifRWGroup;
  739. CCifRWGroup_t * pCifRWGroup_t;
  740. ICifRWComponent *pCifRWComponent;
  741. CCifRWComponent_t * pCifRWComponent_t;
  742. ICifComponent *pCifComponent;
  743. TCHAR szDesc[MAX_PATH];
  744. DWORD dwPriority;
  745. TCHAR szSrc[MAX_PATH], szDst[MAX_PATH];
  746. TCHAR szBrndOnlyPath[MAX_PATH];
  747. TCHAR szCDF[MAX_PATH];
  748. SHELLEXECUTEINFO shInfo;
  749. // create a cif that has only the custom sections (branding, desktop, etc.)
  750. PathCombine(szSrc, g_szBuildTemp, TEXT("iesetup.cif"));
  751. PathCombine(szDst, g_szBuildTemp, TEXT("brndonly.cif"));
  752. if ((hFile = CreateFile(szDst, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
  753. return FALSE;
  754. lpszBuf = "[Version]\r\nSignature=$Chicago$\r\n";
  755. dwBytesToWrite = lstrlenA(lpszBuf);
  756. WriteFile(hFile, (LPCVOID) lpszBuf, dwBytesToWrite, &dwBytesWritten, NULL);
  757. CloseHandle(hFile);
  758. if (dwBytesToWrite != dwBytesWritten)
  759. return FALSE;
  760. GetICifRWFileFromFile_t(&pCifRWFile, szDst);
  761. if (pCifRWFile == NULL)
  762. return FALSE;
  763. // g_lpCifRWFileDest points to iesetup.cif
  764. g_lpCifRWFileDest->GetDescription(szDesc, countof(szDesc));
  765. pCifRWFile->SetDescription(szDesc);
  766. // read Description and Priority for BASEIE4 Group from iesetup.cif and set them in brndonly.cif
  767. g_lpCifRWFileDest->CreateGroup(TEXT("BASEIE4"), &pCifRWGroup); // iesetup.cif
  768. pCifRWGroup_t = new CCifRWGroup_t(pCifRWGroup);
  769. pCifRWGroup_t->GetDescription(szDesc, countof(szDesc));
  770. dwPriority = pCifRWGroup_t->GetPriority();
  771. delete pCifRWGroup_t;
  772. pCifRWFile->CreateGroup(TEXT("BASEIE4"), &pCifRWGroup); // brndonly.cif
  773. pCifRWGroup_t = new CCifRWGroup_t(pCifRWGroup);
  774. pCifRWGroup_t->SetDescription(szDesc);
  775. pCifRWGroup_t->SetPriority(dwPriority);
  776. delete pCifRWGroup_t;
  777. if (SUCCEEDED(g_lpCifRWFileDest->FindComponent(TEXT("BRANDING.CAB"), &pCifComponent)))
  778. {
  779. pCifRWFile->CreateComponent(TEXT("BRANDING.CAB"), &pCifRWComponent);
  780. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  781. pCifRWComponent_t->CopyComponent(szSrc);
  782. pCifRWComponent_t->SetReboot(TRUE);
  783. pCifRWComponent_t->DeleteDependency(NULL, TEXT('\0'));
  784. delete pCifRWComponent_t;
  785. }
  786. if (SUCCEEDED(g_lpCifRWFileDest->FindComponent(TEXT("DESKTOP.CAB"), &pCifComponent)))
  787. {
  788. pCifRWFile->CreateComponent(TEXT("DESKTOP.CAB"), &pCifRWComponent);
  789. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  790. pCifRWComponent_t->CopyComponent(szSrc);
  791. pCifRWComponent_t->SetReboot(TRUE);
  792. pCifRWComponent_t->DeleteDependency(NULL, TEXT('\0'));
  793. delete pCifRWComponent_t;
  794. }
  795. pCifRWFile->Flush();
  796. delete pCifRWFile;
  797. // copy brndonly.cif to iesetup.cif
  798. if (!CopyFile(szDst, szSrc, FALSE))
  799. return FALSE;
  800. // write LocalInstall = 1 in iesetup.ini
  801. // write MultiFloppy = 1 so JIT is handled properly as download install
  802. PathCombine(szDst, g_szBuildTemp, TEXT("iesetup.ini"));
  803. WritePrivateProfileString(TEXT("Options"), TEXT("LocalInstall"), TEXT("1"), szDst);
  804. WritePrivateProfileString(OPTIONS, TEXT("MultiFloppy"), TEXT("1"), szDst);
  805. WritePrivateProfileString(NULL, NULL, NULL, szDst);
  806. PathCombine(szDst, g_szBuildTemp, TEXT("iesetup.inf"));
  807. #if 0
  808. /***
  809. // pritobla: since we decided to do a reboot for single disk branding,
  810. // there's no need to call rundll32 on iedkcs32.dll and launch iexplore.exe.
  811. // I'm keeping the following code commented out for now (just in case we change our minds).
  812. // write some sections specific to single disk branding in iesetup.inf
  813. WritePrivateProfileString(TEXT("IE4Setup.Success.Win"), TEXT("RunPostSetupCommands"),
  814. TEXT("RunPostSetupCommands1.Success,RunPostSetupCommands2.Success:2"), szDst);
  815. WritePrivateProfileString(TEXT("IE4Setup.Success.NTx86"), TEXT("RunPostSetupCommands"),
  816. TEXT("RunPostSetupCommands1.Success,RunPostSetupCommands2.Success:2"), szDst);
  817. WritePrivateProfileString(TEXT("IE4Setup.Success.NTAlpha"), TEXT("RunPostSetupCommands"),
  818. TEXT("RunPostSetupCommands1.Success,RunPostSetupCommands2.Success:2"), szDst);
  819. ZeroMemory(szSrc, sizeof(szSrc));
  820. StrCpy(szSrc, TEXT("rundll32.exe iedkcs32.dll,BrandIE4 "));
  821. StrCat(szSrc, g_fIntranet ? TEXT("CUSTOM") : TEXT("SIGNUP"));
  822. // (!g_fIntranet && g_fBranded) ==> ISP
  823. if (!g_fIntranet && g_fBranded && !g_fNoSignup)
  824. {
  825. TCHAR szSrc2[MAX_PATH];
  826. // launch iexplore.exe so that the signup process happens automatically
  827. // custom ldid for the ie path in iesetup.inf is %50000%
  828. ZeroMemory(szSrc2, sizeof(szSrc2));
  829. StrCpy(szSrc2, TEXT("%50000%\\iexplore.exe"));
  830. WritePrivateProfileSection(TEXT("RunPostSetupCommands2.Success"), szSrc2, szDst);
  831. // write the custom ldid for the extracted files path
  832. WritePrivateProfileString(TEXT("CustInstDestSection2"), TEXT("40000"), TEXT("SourceDir,5"), szDst);
  833. StrCpy(szSrc + StrLen(szSrc) + 1, TEXT("rundll32.exe advpack.dll,LaunchINFSection %40000%\\iesetup.inf,IEAK.Signup.CleanUp"));
  834. // for single disk branding we spawn the iexplorer.exe when the iesetup.inf is processed (for down level compatibility).
  835. // So we do not want to spawn iexplore.exe from the branding dll automatically.
  836. AppendValueToKey(TEXT("IE4Setup.Success.Win"), TEXT("AddReg"), TEXT(",IEAK.Signup.reg"), szDst);
  837. AppendValueToKey(TEXT("IE4Setup.Success.NTx86"), TEXT("AddReg"), TEXT(",IEAK.Signup.reg"), szDst);
  838. AppendValueToKey(TEXT("IE4Setup.Success.NTAlpha"), TEXT("AddReg"), TEXT(",IEAK.Signup.reg"), szDst);
  839. WritePrivateProfileString(TEXT("IEAK.Signup.CleanUp"), TEXT("DelReg"), TEXT("IEAK.Signup.reg"), szDst);
  840. ZeroMemory(szSrc2, sizeof(szSrc2));
  841. StrCpy(szSrc2, TEXT("HKCU,\"Software\\Microsoft\\IEAK\",\"NoAutomaticSignup\",,\"1\""));
  842. WritePrivateProfileSection(TEXT("IEAK.Signup.reg"), szSrc2, szDst);
  843. }
  844. WritePrivateProfileSection(TEXT("RunPostSetupCommands1.Success"), szSrc, szDst);
  845. ***/
  846. #endif
  847. // delete sections that are not relevant to single disk branding from iesetup.inf
  848. WritePrivateProfileString(TEXT("Company.reg"), NULL, NULL, szDst);
  849. WritePrivateProfileString(TEXT("MSIE4Setup.File"), NULL, NULL, szDst);
  850. WritePrivateProfileString(TEXT("Ani.File"), NULL, NULL, szDst);
  851. WritePrivateProfileString(TEXT("ie40cif.copy"), NULL, NULL, szDst);
  852. WritePrivateProfileString(TEXT("AddonPages.Reg"), NULL, NULL, szDst);
  853. WritePrivateProfileString(NULL, NULL, NULL, szDst);
  854. // write the appropriate entries in the batch file for ie6wzd.exe
  855. PathCombine(szDst, g_szBuildTemp, TEXT("iebatch.txt"));
  856. WritePrivateProfileString(TEXT("SetupChoice"), TEXT("Display"), TEXT("0"), szDst);
  857. WritePrivateProfileString(TEXT("SetupChoice"), TEXT("SetupChoice"), TEXT("0"), szDst);
  858. WritePrivateProfileString(TEXT("PrepareSetup"), TEXT("Display"), TEXT("0"), szDst);
  859. WritePrivateProfileString(NULL, NULL, NULL, szDst);
  860. // include iebatch.txt in ie6setup.exe, i.e., add iebatch.txt to bootie42.cdf
  861. PathCombine(szCDF, g_szBuildTemp, TEXT("bootie42.cdf"));
  862. InsWriteQuotedString(STRINGS, TEXT("FILE100"), TEXT("iebatch.txt"), szCDF);
  863. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE100%"), TEXT(""), szCDF);
  864. // delete the files we don't need from bootie42.cdf
  865. /***
  866. [Strings]
  867. FILE1="Wininet.dll" // don't need
  868. FILE2="Urlmon.dll" // don't need
  869. FILE3="ie5wzd.exe"
  870. FILE4="advpack.dll"
  871. FILE5="iesetup.inf"
  872. FILE6="inseng.dll"
  873. FILE7="iesetup.cif"
  874. FILE8="globe.ani"
  875. FILE9="homepage.inf"
  876. FILE10="content.inf" // don't need
  877. FILE11="iesetup.hlp"
  878. FILE12="w95inf16.dll"
  879. FILE13="w95inf32.dll"
  880. FILE14="license.txt"
  881. FILE17="this.txt" // don't need
  882. FILE19="iedetect.dll" // don't need
  883. FILE20="pidgen.dll"
  884. ***/
  885. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE1%"), NULL, szCDF);
  886. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE2%"), NULL, szCDF);
  887. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE10%"), NULL, szCDF);
  888. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE17%"), NULL, szCDF);
  889. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE19%"), NULL, szCDF);
  890. // clear out any possible special custom command line flags
  891. InsWriteQuotedString(OPTIONS, APP_LAUNCHED, TEXT("ie6wzd.exe /S:\"#e\""), szCDF);
  892. WritePrivateProfileString(NULL, NULL, NULL, szCDF);
  893. // build the slim down version of ie6setup.exe
  894. SetCurrentDirectory(g_szBuildTemp);
  895. ZeroMemory(&shInfo, sizeof(shInfo));
  896. shInfo.cbSize = sizeof(shInfo);
  897. shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  898. shInfo.hwnd = g_hWizard;
  899. shInfo.lpVerb = TEXT("open");
  900. shInfo.lpFile = TEXT("iexpress.exe");
  901. shInfo.lpParameters =TEXT("/n bootie42.cdf /m");
  902. shInfo.lpDirectory = g_szBuildTemp;
  903. shInfo.nShow = SW_MINIMIZE;
  904. SetWindowPos(g_hStatusDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  905. ShellExecAndWait(shInfo);
  906. // find out which cabs are present and delete the ones that don't exist from brndonly.cdf
  907. /***
  908. [Strings]
  909. FILE2="branding.cab"
  910. FILE3="desktop.cab"
  911. ***/
  912. PathCombine(szDst, g_szBuildTemp, TEXT("brndonly.cdf"));
  913. PathCombine(szSrc, g_szBuildTemp, TEXT("BRANDING.CAB"));
  914. if (!PathFileExists(szSrc))
  915. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE2%"), NULL, szDst);
  916. PathCombine(szSrc, g_szBuildTemp, TEXT("DESKTOP.CAB"));
  917. if (!PathFileExists(szSrc))
  918. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE3%"), NULL, szDst);
  919. // nuke the ICW check in the cdf if this is a corp or no signup/ICP package
  920. if (g_fIntranet || g_fNoSignup || !g_fBranded)
  921. WritePrivateProfileString(TEXT("FileSectionList"), TEXT("2"), NULL, szDst);
  922. WritePrivateProfileString(NULL, NULL, NULL, szDst);
  923. // build the mongo setup.exe that includes ie6setup.exe, iesetup.ini and the cabs
  924. ZeroMemory(&shInfo, sizeof(shInfo));
  925. shInfo.cbSize = sizeof(shInfo);
  926. shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  927. shInfo.hwnd = g_hWizard;
  928. shInfo.lpVerb = TEXT("open");
  929. shInfo.lpFile = TEXT("iexpress.exe");
  930. shInfo.lpParameters =TEXT("/n brndonly.cdf /m");
  931. shInfo.lpDirectory = g_szBuildTemp;
  932. shInfo.nShow = SW_MINIMIZE;
  933. SetWindowPos(g_hStatusDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  934. ShellExecAndWait(shInfo);
  935. // sign the mongo setup.exe
  936. SignFile(TEXT("setup.exe"), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  937. // create the output dir structure for brndonly, e.g., brndonly\win32\en
  938. PathCombine(szBrndOnlyPath, g_szBuildRoot, TEXT("BrndOnly"));
  939. PathAppend(szBrndOnlyPath, GetOutputPlatformDir());
  940. PathAppend(szBrndOnlyPath, g_szLanguage);
  941. PathCreatePath(szBrndOnlyPath);
  942. // copy the mongo setup.exe to the brndonly path
  943. if (CopyFilesSrcToDest(g_szBuildTemp, TEXT("setup.exe"), szBrndOnlyPath))
  944. return FALSE;
  945. UpdateProgress(dwTicks);
  946. return TRUE;
  947. }
  948. #define NUMDEFINST 3
  949. static TCHAR s_aszDefInstSect[NUMDEFINST][32] =
  950. {
  951. DEFAULT_INSTALL, DEFAULT_INSTALL_NT, DEFAULT_INSTALL_ALPHA
  952. };
  953. DWORD BuildCDandMflop(LPVOID pParam)
  954. {
  955. SHELLEXECUTEINFO shInfo;
  956. TCHAR szDest[MAX_PATH];
  957. HWND hWnd;
  958. int res;
  959. hWnd=(HWND) pParam;
  960. ZeroMemory(&shInfo, sizeof(shInfo));
  961. shInfo.cbSize = sizeof(shInfo);
  962. shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  963. CoInitialize(NULL);
  964. if (g_fCD || g_fLAN)
  965. {
  966. PathCombine(szDest, g_szBuildTemp, TEXT("iesetup.ini"));
  967. WritePrivateProfileString(OPTIONS, TEXT("LocalInstall"), TEXT("1"), szDest);
  968. InsWriteBool(OPTIONS, TEXT("Shell_Integration"), g_fInteg, szDest);
  969. InsFlushChanges(szDest);
  970. }
  971. if(g_fCD)
  972. {
  973. TCHAR szIE4SetupTo[MAX_PATH];
  974. LPTSTR pszFileName;
  975. TCHAR szCDFrom[MAX_PATH * 10];
  976. TCHAR szCDTo[MAX_PATH];
  977. TCHAR szBuildCD[MAX_PATH];
  978. PCOMPONENT pComp;
  979. g_shfStruc.wFunc = FO_COPY;
  980. PathCombine(szBuildCD, g_szBuildRoot, TEXT("CD"));
  981. PathAppend(szBuildCD, GetOutputPlatformDir());
  982. PathCreatePath(szBuildCD);
  983. PathAppend(szBuildCD, g_szActLang);
  984. CreateDirectory(szBuildCD, NULL);
  985. PathCombine(szIE4SetupTo, szBuildCD, TEXT("bin"));
  986. PathCreatePath(szIE4SetupTo);
  987. PathAppend(szIE4SetupTo, TEXT("INSTALL.INS"));
  988. CopyFile(g_szCustIns, szIE4SetupTo, FALSE);
  989. StrCpy(szCDFrom, g_szMastInf);
  990. PathRemoveFileSpec(szCDFrom);
  991. PathAppend(szCDFrom, TEXT("welc.exe"));
  992. PathCombine(szCDTo, szBuildCD, TEXT("bin"));
  993. PathAppend(szCDTo, TEXT("welc.exe"));
  994. CopyFile(szCDFrom, szCDTo, FALSE);
  995. res = CopyFilesSrcToDest(g_szIEAKProg, TEXT("*.*"), szBuildCD, s_dwTicksPerUnit*2);
  996. if (res)
  997. {
  998. TCHAR szMsg[MAX_PATH];
  999. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1000. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1001. DoCancel();
  1002. CoUninitialize();
  1003. return FALSE;
  1004. }
  1005. pszFileName = StrRChr(s_szIE4SetupDir, NULL, TEXT('\\'));
  1006. if (pszFileName)
  1007. pszFileName++;
  1008. PathCombine(szIE4SetupTo, szBuildCD, pszFileName);
  1009. CopyFile(s_szIE4SetupDir,szIE4SetupTo,FALSE);
  1010. // copy custom cabs
  1011. res = CopyFilesSrcToDest(g_szBuildTemp, TEXT("*.CAB"), szBuildCD);
  1012. if (res)
  1013. {
  1014. TCHAR szMsg[MAX_PATH];
  1015. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1016. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1017. DoCancel();
  1018. CoUninitialize();
  1019. return FALSE;
  1020. }
  1021. // copy custom components
  1022. ZeroMemory(szCDFrom, sizeof(szCDFrom));
  1023. for (pComp = g_aCustComponents, pszFileName = szCDFrom; ; pComp++ )
  1024. {
  1025. if (!(*pComp->szSection)) break;
  1026. if (pComp->iInstallType == 2)
  1027. continue;
  1028. StrCpy(pszFileName, pComp->szPath);
  1029. pszFileName += lstrlen(pszFileName) + 1;
  1030. }
  1031. if (ISNONNULL(szCDFrom))
  1032. {
  1033. g_shfStruc.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
  1034. g_shfStruc.pFrom = szCDFrom;
  1035. g_shfStruc.pTo = szBuildCD;
  1036. res = SHFileOperation(&g_shfStruc);
  1037. if (res)
  1038. {
  1039. TCHAR szMsg[MAX_PATH];
  1040. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1041. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1042. DoCancel();
  1043. CoUninitialize();
  1044. return FALSE;
  1045. }
  1046. }
  1047. // copy iesetup.ini
  1048. PathCombine(szCDTo, szBuildCD, TEXT("iesetup.ini"));
  1049. PathCombine(szCDFrom, g_szBuildTemp, TEXT("iesetup.ini"));
  1050. CopyFile(szCDFrom, szCDTo, FALSE);
  1051. // copy ICM profile
  1052. if (g_fCustomICMPro)
  1053. {
  1054. PathCombine(szCDTo, szBuildCD, PathFindFileName(g_szCustIcmPro));
  1055. CopyFile(g_szCustIcmPro, szCDTo, FALSE);
  1056. }
  1057. DeleteUnusedComps(szBuildCD);
  1058. PathCombine(szBuildCD, g_szBuildRoot, TEXT("CD"));
  1059. CopyISK(szBuildCD, g_szBuildTemp);
  1060. }
  1061. if (g_fLAN)
  1062. {
  1063. if(!BuildLAN(s_dwTicksPerUnit*2))
  1064. {
  1065. TCHAR szMsg[MAX_PATH];
  1066. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1067. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1068. CoUninitialize();
  1069. DoCancel();
  1070. return FALSE;
  1071. }
  1072. }
  1073. CoUninitialize();
  1074. return(TRUE);
  1075. }
  1076. DWORD BuildIE4(LPVOID pParam)
  1077. {
  1078. DWORD res, erc;
  1079. TCHAR szSource[MAX_PATH];
  1080. TCHAR szDest[MAX_PATH];
  1081. TCHAR szNulls[8];
  1082. SHELLEXECUTEINFO shInfo;
  1083. SECURITY_ATTRIBUTES sa;
  1084. int i;
  1085. HANDLE hSiteDat, hFind, hThread;
  1086. WIN32_FIND_DATA fd;
  1087. PSITEDATA psd;
  1088. LPVOID pBuf;
  1089. DWORD dwsSiteDat = 0;
  1090. DWORD dwsSDH, sBuf;
  1091. TCHAR szSiteData[MAX_PATH];
  1092. TCHAR szCompBuf[10 * MAX_PATH];
  1093. LPTSTR pCompBuf;
  1094. PCOMPONENT pComp;
  1095. TCHAR szUrl[MAX_URL];
  1096. TCHAR szCustName[MAX_PATH], szBrandGuid[128] = TEXT(""), szOrderGuid[129];
  1097. TCHAR szHomeInf[MAX_PATH];
  1098. TCHAR szHomeUrl[MAX_URL];
  1099. TCHAR szBootieFile[MAX_PATH];
  1100. TCHAR szIE4ExeName[MAX_PATH];
  1101. TCHAR szSelMode[4] = TEXT("0");
  1102. LPTSTR pIE4ExeName = NULL;
  1103. TCHAR szSiteDest[MAX_PATH];
  1104. TCHAR szSiteRoot[MAX_PATH];
  1105. TCHAR szCDF[MAX_PATH];
  1106. DWORD dwTotalUnits;
  1107. DWORD dwTid;
  1108. HWND hWnd = (HWND)pParam;
  1109. GUID guid;
  1110. g_hWizard = hWnd;
  1111. g_hStatusDlg = hWnd;
  1112. g_hProgress = GetDlgItem(hWnd, IDC_PROGRESS);
  1113. StatusDialog( SD_STEP1 );
  1114. g_fDone = TRUE;
  1115. SetEvent(g_hDownloadEvent);
  1116. SetAttribAllEx(g_szBuildTemp, TEXT("*.*"), FILE_ATTRIBUTE_NORMAL, TRUE);
  1117. SetAttribAllEx(g_szBuildRoot, TEXT("*.*"), FILE_ATTRIBUTE_NORMAL, TRUE);
  1118. // figure out costing metrics. Two units is roughly the time required to create all custom
  1119. // cabs(iecif.cab, branding.cab, desktop.cab, ie6setup.exe) which we assume is
  1120. // approximately equal to the time required to copy all files for a standard media type
  1121. // (CD, LAN, download) as well. Single branding takes
  1122. // one unit. Ticks represent one percent on the status bar. The number of ticks per unit
  1123. // depend on how many media types are being built. The two units for the custom cabs will be
  1124. // split as follows: 1/3 after desktop.cab, 2/3 after ie6setup.exe, and
  1125. // 2/3 after branding.cab. For standard media, all the progress updates will be made when
  1126. // copying the base cabs.
  1127. dwTotalUnits = 2 + (g_fDownload ? 2 : 0) + (g_fLAN ? 2 : 0) + (g_fCD ? 2 : 0) + (g_fBrandingOnly ? 1 : 0);
  1128. s_dwTicksPerUnit = 100 / dwTotalUnits;
  1129. *szUrl = TEXT('\0');
  1130. if (g_fBatch)
  1131. {
  1132. if (GetPrivateProfileString(TEXT("BatchMode"), IK_URL, TEXT(""), szUrl, countof(szUrl), g_szCustIns))
  1133. InsWriteQuotedString( IS_STRINGS, IK_URL, szUrl, g_szCustInf);
  1134. if (GetPrivateProfileString(TEXT("BatchMode"), TEXT("URL2"), TEXT(""), szUrl, countof(szUrl), g_szCustIns))
  1135. InsWriteQuotedString( IS_STRINGS, TEXT("URL2"), szUrl, g_szCustInf);
  1136. }
  1137. else
  1138. {
  1139. TCHAR szSitePath[INTERNET_MAX_URL_LENGTH];
  1140. ICifRWComponent * pCifRWComponent;
  1141. CCifRWComponent_t * pCifRWComponent_t;
  1142. StrCpy(szSitePath, g_aCustSites->szUrl);
  1143. StrCat(szSitePath, TEXT("/IE6SITES.DAT"));
  1144. // if g_aCustSites->szUrl is NULL we're in a single disk branding only case so
  1145. // we shouldn't write out this entry and nuke the default sites location needed
  1146. // for JIT
  1147. if (ISNONNULL(g_aCustSites->szUrl))
  1148. InsWriteQuotedString( IS_STRINGS, TEXT("URL2"), szSitePath, g_szCustInf );
  1149. if (GetPrivateProfileInt(BRANDING, TEXT("NoIELite"), 0, g_szCustIns))
  1150. WritePrivateProfileString(OPTIONS, TEXT("IELiteModes"), NULL, g_szCustInf);
  1151. else
  1152. {
  1153. TCHAR szIELiteModes[16];
  1154. GetPrivateProfileString(OPTIONS, TEXT("IELiteModes"), TEXT(""), szIELiteModes,
  1155. countof(szIELiteModes), g_szMastInf);
  1156. WritePrivateProfileString(OPTIONS, TEXT("IELiteModes"), szIELiteModes, g_szCustInf);
  1157. }
  1158. if (g_fNoSignup || g_fIntranet || !g_fBranded)
  1159. {
  1160. if (SUCCEEDED(g_lpCifRWFile->CreateComponent(TEXT("ICW"), &pCifRWComponent)))
  1161. {
  1162. pCifRWComponent->DeleteFromModes(NULL);
  1163. pCifRWComponent->SetUIVisible(FALSE);
  1164. }
  1165. if (SUCCEEDED(g_lpCifRWFile->CreateComponent(TEXT("ICW_NTx86"), &pCifRWComponent)))
  1166. {
  1167. pCifRWComponent->DeleteFromModes(NULL);
  1168. pCifRWComponent->SetUIVisible(FALSE);
  1169. }
  1170. }
  1171. else
  1172. {
  1173. if (SUCCEEDED(g_lpCifRWFile->CreateComponent(TEXT("ICW"), &pCifRWComponent)))
  1174. {
  1175. TCHAR szGuid[128] = TEXT("");
  1176. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1177. pCifRWComponent_t->GetGUID(szGuid, countof(szGuid));
  1178. pCifRWComponent_t->SetUIVisible(FALSE);
  1179. if (ISNONNULL(szGuid))
  1180. WritePrivateProfileString(TEXT("IELITE"), szGuid, NULL, g_szCustInf);
  1181. delete pCifRWComponent_t;
  1182. }
  1183. if (SUCCEEDED(g_lpCifRWFile->CreateComponent(TEXT("ICW_NTx86"), &pCifRWComponent)))
  1184. {
  1185. TCHAR szGuid[128] = TEXT("");
  1186. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1187. pCifRWComponent_t->GetGUID(szGuid, countof(szGuid));
  1188. pCifRWComponent_t->SetUIVisible(FALSE);
  1189. if (ISNONNULL(szGuid))
  1190. WritePrivateProfileString(TEXT("IELITE"), szGuid, NULL, g_szCustInf);
  1191. delete pCifRWComponent_t;
  1192. }
  1193. }
  1194. if (SUCCEEDED(g_lpCifRWFile->CreateComponent(TEXT("MobilePk"), &pCifRWComponent)))
  1195. {
  1196. TCHAR szGuid[128] = TEXT("");
  1197. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1198. pCifRWComponent_t->GetGUID(szGuid, countof(szGuid));
  1199. if (ISNONNULL(szGuid))
  1200. WritePrivateProfileString(TEXT("IELITE"), szGuid, NULL, g_szCustInf);
  1201. delete pCifRWComponent_t;
  1202. }
  1203. }
  1204. g_shfStruc.hwnd = hWnd;
  1205. g_shfStruc.wFunc = FO_COPY;
  1206. if (!g_fBatch && !g_fBatch2)
  1207. {
  1208. TCHAR szDefaultMode[2];
  1209. BOOL bDefaultPresent = FALSE;
  1210. GetPrivateProfileString(STRINGS, INSTALLMODE, TEXT("1"), szDefaultMode, countof(szDefaultMode), g_szCustInf);
  1211. for (i=0; g_szAllModes[i]; i++)
  1212. {
  1213. if (g_szAllModes[i] == szDefaultMode[0])
  1214. bDefaultPresent = TRUE;
  1215. }
  1216. if (!bDefaultPresent)
  1217. {
  1218. szDefaultMode[0] = g_szAllModes[0];
  1219. szDefaultMode[1] = TEXT('\0');
  1220. }
  1221. WritePrivateProfileString(OPTIONS_WIN, INSTALLMODE, szDefaultMode, g_szCustInf);
  1222. WritePrivateProfileString(OPTIONS_WIN, TEXT("CustomMode"), szDefaultMode, g_szCustInf);
  1223. WritePrivateProfileString(OPTIONS_NTX86, INSTALLMODE, szDefaultMode, g_szCustInf);
  1224. WritePrivateProfileString(OPTIONS_NTX86, TEXT("CustomMode"), szDefaultMode, g_szCustInf);
  1225. WritePrivateProfileString(OPTIONS_NTALPHA, INSTALLMODE, szDefaultMode, g_szCustInf);
  1226. }
  1227. res = CopyIE4Files();
  1228. UpdateProgress(s_dwTicksPerUnit / 3);
  1229. if (res)
  1230. {
  1231. TCHAR szMsg[MAX_PATH];
  1232. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1233. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1234. DoCancel();
  1235. return (DWORD)-1;
  1236. }
  1237. BuildIE4Folders(hWnd);
  1238. UpdateProgress(s_dwTicksPerUnit / 3);
  1239. PathCombine(szDest, g_szBuildTemp, PathFindFileName(g_szCustIns));
  1240. CopyFile( g_szCustIns, szDest, FALSE );
  1241. PathCombine(szCDF, g_szBuildTemp, TEXT("bootie42.cdf"));
  1242. PathCombine( szSource, g_szBuildTemp, TEXT("ie6setup.exe"));
  1243. SetFileAttributes(szSource, FILE_ATTRIBUTE_NORMAL);
  1244. DeleteFile(szSource);
  1245. if (g_fIntranet)
  1246. {
  1247. TCHAR szInstallPath[MAX_PATH];
  1248. TCHAR szInstallDest[MAX_PATH];
  1249. TCHAR szCmd[MAX_PATH];
  1250. TCHAR szBatchFile[MAX_PATH];
  1251. int iDefaultBrowserCheck;
  1252. szSelMode[0] = (TCHAR)(g_iSelOpt + TEXT('0'));
  1253. PathCombine(szBatchFile, g_szBuildTemp, TEXT("iebatch.txt"));
  1254. DeleteFile(szBatchFile);
  1255. if (g_fSilent || g_fStealth)
  1256. {
  1257. TCHAR szDownloadSite[INTERNET_MAX_URL_LENGTH];
  1258. wnsprintf(szDownloadSite, countof(szDownloadSite), TEXT("%s/%s"), g_aCustSites[g_iSelSite].szUrl, g_szActLang);
  1259. WritePrivateProfileString(TEXT("Options"), TEXT("Quiet"), g_fStealth ? TEXT("A") : TEXT("C"), szBatchFile);
  1260. WritePrivateProfileString(TEXT("DownloadSite"), TEXT("Display"), TEXT("0"), szBatchFile);
  1261. WritePrivateProfileString(TEXT("DownloadSite"), TEXT("DownloadLocation"), szDownloadSite, szBatchFile);
  1262. WritePrivateProfileString(TEXT("Upgrade"), TEXT("ReinstallAll"), TEXT("1"), szBatchFile);
  1263. WritePrivateProfileString(NULL, NULL, NULL, szBatchFile);
  1264. wnsprintf(szCmd, countof(szCmd), TEXT("ie6wzd.exe /S:\"#e\" /m:%s /i:%s"),
  1265. szSelMode, g_fInteg ? TEXT("Y") : TEXT("N"));
  1266. InsWriteQuotedString( OPTIONS, APP_LAUNCHED, szCmd, szCDF );
  1267. }
  1268. else
  1269. {
  1270. wnsprintf(szCmd, countof(szCmd), TEXT("ie6wzd.exe /S:\"#e\" /i:%s"), g_fInteg ? TEXT("Y") : TEXT("N"));
  1271. InsWriteQuotedString( OPTIONS, APP_LAUNCHED, szCmd, szCDF );
  1272. if (GetPrivateProfileInt(IS_BRANDING, TEXT("HideCustom"), 0, g_szCustIns))
  1273. {
  1274. WritePrivateProfileString(TEXT("SetupChoice"), TEXT("Display"), TEXT("0"), szBatchFile);
  1275. WritePrivateProfileString(TEXT("SetupChoice"), TEXT("SetupChoice"), TEXT("0"), szBatchFile);
  1276. }
  1277. if (GetPrivateProfileInt(IS_BRANDING, TEXT("HideCompat"), 0, g_szCustIns))
  1278. WritePrivateProfileString(TEXT("Custom"), TEXT("IECompatShow"), TEXT("0"), szBatchFile);
  1279. }
  1280. if (GetPrivateProfileInt(IS_BRANDING, TEXT("NoBackup"), 0, g_szCustIns))
  1281. WritePrivateProfileString(TEXT("Options"), TEXT("SaveUninstallInfo"), TEXT("0"), szBatchFile);
  1282. if ((iDefaultBrowserCheck = GetPrivateProfileInt(IS_BRANDING, TEXT("BrowserDefault"), 2, g_szCustIns)) != 2)
  1283. {
  1284. WritePrivateProfileString(TEXT("Custom"), TEXT("IEDefaultRO"), TEXT("1"), szBatchFile);
  1285. WritePrivateProfileString(TEXT("Custom"), TEXT("IEDefault"),
  1286. iDefaultBrowserCheck ? TEXT("0") : TEXT("1"), szBatchFile);
  1287. }
  1288. WritePrivateProfileString(TEXT("Custom"), TEXT("UseInfInstallDir"), TEXT("1"), szBatchFile);
  1289. if(!GetPrivateProfileInt(IS_BRANDING, TEXT("AllowInstallDir"), 0, g_szCustIns))
  1290. WritePrivateProfileString(TEXT("Custom"), TEXT("InstallDirRO"), TEXT("1"), szBatchFile);
  1291. WritePrivateProfileString(NULL, NULL, NULL, szBatchFile);
  1292. if (PathFileExists(szBatchFile))
  1293. {
  1294. // package up batch file into ie6setup exe in file100 position
  1295. InsWriteQuotedString(IS_STRINGS, TEXT("FILE100"), TEXT("iebatch.txt"), szCDF);
  1296. WritePrivateProfileString(TEXT("SourceFiles0"), TEXT("%FILE100%"), TEXT(""), szCDF);
  1297. }
  1298. InsWriteQuotedString( STRINGS, DEFAULT_EXPLORER_PATH, g_szInstallFolder, g_szCustInf );
  1299. WritePrivateProfileString( OPTIONS, DISPLAY_LICENSE, TEXT(""), szCDF);
  1300. switch (g_iInstallOpt)
  1301. {
  1302. case INSTALL_OPT_PROG:
  1303. default:
  1304. wnsprintf(szInstallPath, countof(szInstallPath), TEXT("%%49001%%\\%%%s%%"), DEFAULT_EXPLORER_PATH);
  1305. wnsprintf(szInstallDest, countof(szInstallDest), TEXT("49001,%%%s%%"), DEFAULT_EXPLORER_PATH);
  1306. break;
  1307. case INSTALL_OPT_FULL:
  1308. wnsprintf(szInstallPath, countof(szInstallPath), TEXT("%%%s%%"), DEFAULT_EXPLORER_PATH);
  1309. wnsprintf(szInstallDest, countof(szInstallDest), TEXT("%%%s%%"), DEFAULT_EXPLORER_PATH);
  1310. break;
  1311. }
  1312. WritePrivateProfileString( OPTIONS_WIN, INSTALL_DIR, szInstallPath, g_szCustInf );
  1313. WritePrivateProfileString( DESTINATION_DIRS, OPTIONS_WIN, szInstallDest, g_szCustInf);
  1314. WritePrivateProfileString( OPTIONS_NTX86, INSTALL_DIR, szInstallPath, g_szCustInf );
  1315. WritePrivateProfileString( DESTINATION_DIRS, OPTIONS_NTX86, szInstallDest, g_szCustInf);
  1316. WritePrivateProfileString( OPTIONS_NTALPHA, INSTALL_DIR, szInstallPath, g_szCustInf );
  1317. WritePrivateProfileString( DESTINATION_DIRS, OPTIONS_NTALPHA, szInstallDest, g_szCustInf);
  1318. WritePrivateProfileString( NULL, NULL, NULL, g_szCustInf);
  1319. }
  1320. GetPrivateProfileString(IS_STRINGS, TEXT("CustomName"), TEXT(""), szCustName, countof(szCustName), g_szDefInf);
  1321. if (ISNULL(szCustName)) LoadString( g_rvInfo.hInst, IDS_CUSTNAME, szCustName, MAX_PATH );
  1322. // for batch mode builds, always used the old branding guid
  1323. if (!g_fBatch)
  1324. {
  1325. if (CoCreateGuid(&guid) == NOERROR)
  1326. CoStringFromGUID(guid, szBrandGuid, countof(szBrandGuid));
  1327. }
  1328. if (ISNULL(szBrandGuid))
  1329. CoStringFromGUID(GUID_BRANDING, szBrandGuid, countof(szBrandGuid));
  1330. StrNCat(szBrandGuid, g_szKey, 7);
  1331. wnsprintf(szOrderGuid, countof(szOrderGuid), TEXT("%s%s"), TEXT(">"), szBrandGuid);
  1332. res = CabUpFolder(NULL, g_szTempSign, g_fIntranet ? TEXT("49100,CUSTOM") : TEXT("49100,SIGNUP"),
  1333. TEXT("BRANDING.CAB"), szCustName, szOrderGuid, g_fIntranet ?
  1334. TEXT("\"RunDLL32 IEDKCS32.DLL,BrandIE4 CUSTOM\"") : TEXT("\"RunDLL32 IEDKCS32.DLL,BrandIE4 SIGNUP\"") );
  1335. UpdateProgress(s_dwTicksPerUnit * 2 / 3);
  1336. if (res)
  1337. {
  1338. TCHAR szMsg[MAX_PATH];
  1339. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1340. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1341. DoCancel();
  1342. return (DWORD)-1;
  1343. }
  1344. SignFile(TEXT("BRANDING.CAB"), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1345. // NOTE: Copying of signup files to the output folder should happen after branding.cab has been built.
  1346. // for server-based signup, if specified, copy branding.cab to the signup folder.
  1347. // copy *.ins and *.cab from the signup folder to the output dir; e.g., <output dir>\ispserv\win32\en\kiosk
  1348. if (ISNONNULL(g_szSignup) && (g_fServerICW || g_fServerKiosk))
  1349. {
  1350. TCHAR szOutDir[MAX_PATH];
  1351. // first, copy branding.cab to the signup folder
  1352. // NOTE: szOutDir is used as a temp buffer
  1353. PathCombine(szOutDir, g_szBuildTemp, TEXT("BRANDING.CAB"));
  1354. CopyCabFiles(g_szSignup, szOutDir);
  1355. PathCombine(szOutDir, g_szBuildRoot, TEXT("ispserv"));
  1356. PathAppend(szOutDir, GetOutputPlatformDir());
  1357. PathAppend(szOutDir, g_szLanguage);
  1358. // get the sub-dir based on signup mode from g_szSignup
  1359. PathAppend(szOutDir, PathFindFileName(g_szSignup));
  1360. // clean-up the content in the output folder before copying
  1361. PathRemovePath(szOutDir);
  1362. CopyINSFiles(g_szSignup, szOutDir);
  1363. CopyFilesSrcToDest(g_szSignup, TEXT("*.cab"), szOutDir);
  1364. }
  1365. PathCombine( szDest, g_szBuildTemp, TEXT("IESETUP.INF") );
  1366. CopyFile( g_szCustInf, szDest, FALSE );
  1367. ZeroMemory(&shInfo, sizeof(shInfo));
  1368. shInfo.cbSize = sizeof(shInfo);
  1369. shInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  1370. SetCurrentDirectory(g_szBuildTemp);
  1371. if (!g_fUseIEWelcomePage)
  1372. {
  1373. TCHAR szHomepageRegSect[80];
  1374. *szNulls = szNulls[1] = TEXT('\0');
  1375. PathCombine(szHomeInf, g_szBuildTemp, TEXT("Homepage.inf"));
  1376. GetPrivateProfileString( DEFAULT_INSTALL, ADDREG, INITHOMEPAGE,
  1377. szHomepageRegSect, countof(szHomepageRegSect), szHomeInf );
  1378. GetPrivateProfileString(IS_URL, IK_FIRSTHOMEPAGE, TEXT(""), szHomeUrl, countof(szHomeUrl), g_szCustIns);
  1379. InsWriteQuotedString( STRINGS, INITHOMEPAGE, szHomeUrl, szHomeInf );
  1380. if (ISNULL(szHomeUrl))
  1381. {
  1382. int i;
  1383. for (i = 0; i < NUMDEFINST; i++ )
  1384. {
  1385. WritePrivateProfileString(s_aszDefInstSect[i], ADDREG, NULL, szHomeInf );
  1386. WritePrivateProfileString(s_aszDefInstSect[i], DELREG, INIT_HOME_DEL, szHomeInf );
  1387. }
  1388. }
  1389. }
  1390. if (g_fCustomICMPro)
  1391. SetCompSize(g_szCustIcmPro, CUSTCMSECT, 0);
  1392. g_lpCifRWFileDest->Flush();
  1393. InsFlushChanges(g_szCustInf);
  1394. shInfo.hwnd = hWnd;
  1395. shInfo.lpVerb = TEXT("open");
  1396. shInfo.lpFile = TEXT("IEXPRESS.EXE");
  1397. shInfo.lpDirectory = g_szBuildTemp;
  1398. shInfo.nShow = SW_MINIMIZE;
  1399. shInfo.lpParameters = TEXT("/n bootie42.CDF /m");
  1400. shInfo.nShow = SW_MINIMIZE;
  1401. SetWindowPos(g_hStatusDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  1402. ShellExecAndWait(shInfo);
  1403. PathCombine( szSource, g_szBuildTemp, TEXT("IECIF.CAB") );
  1404. SetFileAttributes(szSource, FILE_ATTRIBUTE_NORMAL);
  1405. DeleteFile(szSource);
  1406. shInfo.lpParameters = TEXT("/n ie40cif.CDF /m");
  1407. SetWindowPos(g_hStatusDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  1408. ShellExecAndWait(shInfo);
  1409. SetWindowPos(g_hStatusDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  1410. SignFile(PathFindFileName(szSource), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1411. UpdateProgress(s_dwTicksPerUnit * 2 / 3);
  1412. ZeroMemory(szDest, sizeof(szDest));
  1413. StrCpy( szDest, g_szBuildRoot );
  1414. if(!g_fOCW)
  1415. {
  1416. PathAppend( szDest, TEXT("DOWNLOAD") );
  1417. PathAppend(szDest, GetOutputPlatformDir());
  1418. PathAppend(szDest, g_szLanguage);
  1419. if (g_fDownload)
  1420. {
  1421. erc = PathCreatePath(szDest);
  1422. SetAttribAllEx(szDest, TEXT("*.*"), FILE_ATTRIBUTE_NORMAL, TRUE);
  1423. }
  1424. }
  1425. else
  1426. {
  1427. TCHAR szIniFile[MAX_PATH];
  1428. TCHAR szDestIniFile[MAX_PATH];
  1429. TCHAR szFileName[MAX_PATH];
  1430. // write office data to HKCU\Software\Microsoft\IEAK registry branch since office
  1431. // reads/writes data from/to this location.
  1432. SHSetValue(HKEY_CURRENT_USER, RK_IEAK, TEXT("TargetDir"), REG_SZ, (LPBYTE)szDest,
  1433. (StrLen(szDest)+1)*sizeof(TCHAR));
  1434. SHSetValue(HKEY_CURRENT_USER, RK_IEAK, TEXT("LangFolder"), REG_SZ, (LPBYTE)g_szActLang,
  1435. (StrLen(g_szActLang)+1)*sizeof(TCHAR));
  1436. StrCpy(szFileName, TEXT("ie6setup.exe"));
  1437. SHSetValue(HKEY_CURRENT_USER, RK_IEAK, TEXT("FileName"), REG_SZ, (LPBYTE)szFileName,
  1438. (StrLen(szFileName)+1)*sizeof(TCHAR));
  1439. PathAppend(szDest, g_szLanguage);
  1440. erc = PathCreatePath( szDest );
  1441. PathCombine(szIniFile, g_szBuildTemp, TEXT("iesetup.ini"));
  1442. PathCombine(szDestIniFile, szDest, TEXT("iesetup.ini"));
  1443. WritePrivateProfileString(OPTIONS, TEXT("LocalInstall"), TEXT("1"), szIniFile);
  1444. WritePrivateProfileString(NULL, NULL, NULL, szIniFile);
  1445. CopyFile(szIniFile, szDestIniFile, FALSE);
  1446. }
  1447. TCHAR szTo[MAX_PATH];
  1448. ZeroMemory(szIE4ExeName, sizeof(szIE4ExeName));
  1449. PathCombine(szBootieFile, g_szBuildTemp, TEXT("bootie42.cdf"));
  1450. GetPrivateProfileString(OPTIONS, TEXT("TargetName"), TEXT(""), szIE4ExeName, countof(szIE4ExeName), szBootieFile);
  1451. if(ISNONNULL(szIE4ExeName))
  1452. {
  1453. pIE4ExeName = StrRChr(szIE4ExeName, NULL, TEXT('\\'));
  1454. if(pIE4ExeName)
  1455. pIE4ExeName = pIE4ExeName + 1;
  1456. else
  1457. pIE4ExeName = szIE4ExeName;
  1458. }
  1459. else
  1460. pIE4ExeName = TEXT("IE6Setup.exe\0\0");
  1461. SignFile(pIE4ExeName, g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1462. PathCombine(s_szIE4SetupDir, g_szBuildTemp, pIE4ExeName);
  1463. TCHAR szSignLoc[MAX_PATH];
  1464. DWORD dwAttrib;
  1465. if (g_fCustomICMPro)
  1466. {
  1467. PathCombine(szSignLoc, g_szBuildTemp, PathFindFileName(g_szCustIcmPro));
  1468. CopyFile(g_szCustIcmPro, szSignLoc, FALSE);
  1469. StrCpy(g_szCustIcmPro, szSignLoc);
  1470. dwAttrib = GetFileAttributes(g_szCustIcmPro);
  1471. SetFileAttributes(g_szCustIcmPro, FILE_ATTRIBUTE_NORMAL);
  1472. SignFile(PathFindFileName(g_szCustIcmPro), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1473. SetFileAttributes(g_szCustIcmPro, dwAttrib);
  1474. }
  1475. for (pComp = g_aCustComponents; ; pComp++ )
  1476. {
  1477. if (!(*pComp->szSection)) break;
  1478. if (pComp->iInstallType == 2)
  1479. continue;
  1480. PathCombine(szSignLoc, g_szBuildTemp, PathFindFileName(pComp->szPath));
  1481. CopyFile(pComp->szPath, szSignLoc, FALSE);
  1482. StrCpy(pComp->szPath, szSignLoc);
  1483. dwAttrib = GetFileAttributes(pComp->szPath);
  1484. SetFileAttributes(pComp->szPath, FILE_ATTRIBUTE_NORMAL);
  1485. SignFile(PathFindFileName(pComp->szPath), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1486. SetFileAttributes(pComp->szPath, dwAttrib);
  1487. }
  1488. // Copy URDComponent
  1489. if (InsGetBool(IS_HIDECUST, IK_URD_STR, FALSE, g_szCustIns))
  1490. {
  1491. TCHAR szURDPath[MAX_PATH];
  1492. // IE55URD.EXE is under iebin\<lang>\optional
  1493. StrCpy(szURDPath, g_szMastInf);
  1494. PathRemoveFileSpec(szURDPath);
  1495. PathAppend(szURDPath, IE55URD_EXE);
  1496. CopyFileToDir(szURDPath, g_szBuildTemp);
  1497. PathCombine(szURDPath, g_szBuildTemp, IE55URD_EXE);
  1498. dwAttrib = GetFileAttributes(szURDPath);
  1499. SetFileAttributes(szURDPath, FILE_ATTRIBUTE_NORMAL);
  1500. SignFile(IE55URD_EXE, g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  1501. SetFileAttributes(szURDPath, dwAttrib);
  1502. }
  1503. StatusDialog( SD_STEP2 );
  1504. ZeroMemory(szDest, sizeof(szDest));
  1505. sa.nLength=sizeof(SECURITY_ATTRIBUTES);
  1506. sa.lpSecurityDescriptor=NULL;
  1507. sa.bInheritHandle=TRUE;
  1508. hThread=CreateThread(&sa, 4096, BuildCDandMflop, hWnd, 0, &dwTid);
  1509. while (MsgWaitForMultipleObjects(1, &hThread, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
  1510. {
  1511. MSG msg;
  1512. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  1513. {
  1514. TranslateMessage(&msg);
  1515. DispatchMessage(&msg);
  1516. }
  1517. }
  1518. if (hThread != NULL) CloseHandle(hThread);
  1519. StrCpy( szDest, g_szBuildRoot );
  1520. if(!g_fOCW)
  1521. {
  1522. PathAppend( szDest, TEXT("INS") );
  1523. PathAppend(szDest, GetOutputPlatformDir());
  1524. StrCpy(szSiteRoot, szDest);
  1525. PathAppend(szDest, g_szLanguage);
  1526. PathCombine(szSiteDest, g_szBuildRoot, TEXT("DOWNLOAD"));
  1527. PathAppend(szSiteDest, GetOutputPlatformDir());
  1528. }
  1529. if (g_fDownload)
  1530. {
  1531. PathAppend(szDest, TEXT("IE6SITES.DAT"));
  1532. SetFileAttributes(szDest, FILE_ATTRIBUTE_NORMAL);
  1533. DeleteFile( szDest );
  1534. hSiteDat = CreateFile(szDest, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  1535. for (i = 0, psd=g_aCustSites; i < g_nDownloadUrls ; i++, psd++ )
  1536. {
  1537. SITEDATA sd;
  1538. TCHAR szSite[2 * MAX_URL];
  1539. ZeroMemory(szSite, sizeof(szSite));
  1540. ZeroMemory((void *) &sd, sizeof(sd));
  1541. if (g_fBatch)
  1542. {
  1543. TCHAR szBaseUrlParm[32];
  1544. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteName%i"), i);
  1545. GetPrivateProfileString(TEXT("BatchMode"), szBaseUrlParm, TEXT(""), sd.szName, 80, g_szCustIns );
  1546. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteUrl%i"), i);
  1547. GetPrivateProfileString(TEXT("BatchMode"), szBaseUrlParm, TEXT(""), sd.szUrl, MAX_URL, g_szCustIns );
  1548. wnsprintf(szBaseUrlParm, countof(szBaseUrlParm), TEXT("SiteRegion%i"), i);
  1549. GetPrivateProfileString(TEXT("BatchMode"), szBaseUrlParm, TEXT(""), sd.szRegion, 80, g_szCustIns );
  1550. if (*sd.szName && *sd.szUrl && *sd.szRegion)
  1551. wnsprintf(szSite, countof(szSite), TEXT("\"%s\",\"%s\",\"%s\",\"%s\"\r\n"), sd.szUrl, sd.szName, g_szActLang, sd.szRegion);
  1552. }
  1553. if (*szSite == TEXT('\0'))
  1554. {
  1555. if(!g_fOCW)
  1556. {
  1557. wnsprintf(szSite, countof(szSite), TEXT("\"%s/%s\",\"%s\",\"%s\",\"%s\"\r\n"), psd->szUrl, g_szActLang, psd->szName,
  1558. g_szActLang, psd->szRegion);
  1559. }
  1560. else
  1561. {
  1562. wnsprintf(szSite, countof(szSite), TEXT("\"%s\",\"%s\",\"%s\",\"%s\"\r\n"), psd->szUrl, psd->szName,
  1563. g_szActLang, psd->szRegion);
  1564. }
  1565. }
  1566. WriteStringToFile( hSiteDat, szSite, StrLen(szSite) );
  1567. }
  1568. dwsSiteDat = GetFileSize( hSiteDat, &dwsSDH );
  1569. CloseHandle(hSiteDat);
  1570. }
  1571. if(!g_fOCW && g_fDownload)
  1572. {
  1573. PathCombine(szDest, szSiteRoot, TEXT("*."));
  1574. PathCombine(szSiteData, szSiteDest, TEXT("IE6SITES.DAT"));
  1575. SetFileAttributes(szSiteData, FILE_ATTRIBUTE_NORMAL);
  1576. DeleteFile (szSiteData);
  1577. hSiteDat = CreateFile(szSiteData, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  1578. sBuf = 2 * dwsSiteDat;
  1579. pBuf = LocalAlloc(LPTR, sBuf );
  1580. hFind = FindFirstFile( szDest, &fd );
  1581. while (hFind != INVALID_HANDLE_VALUE)
  1582. {
  1583. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
  1584. (lstrlen(fd.cFileName) == 2))
  1585. {
  1586. TCHAR szLangSiteDat[MAX_PATH];
  1587. HANDLE hLangSiteDat;
  1588. DWORD dwsLangSite;
  1589. PathCombine(szLangSiteDat, szSiteRoot, fd.cFileName);
  1590. PathAppend(szLangSiteDat, TEXT("IE6SITES.DAT"));
  1591. hLangSiteDat = CreateFile(szLangSiteDat, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  1592. if (hLangSiteDat != INVALID_HANDLE_VALUE)
  1593. {
  1594. DWORD dwsRead;
  1595. dwsLangSite = GetFileSize( hLangSiteDat, &dwsSDH );
  1596. if (dwsLangSite > sBuf)
  1597. {
  1598. LocalFree(pBuf);
  1599. sBuf = 2 * dwsLangSite;
  1600. pBuf = LocalAlloc(LPTR, sBuf);
  1601. }
  1602. ReadFile( hLangSiteDat, pBuf, dwsLangSite, &dwsRead, NULL );
  1603. WriteFile( hSiteDat, pBuf, dwsLangSite, &dwsRead, NULL );
  1604. CloseHandle(hLangSiteDat);
  1605. }
  1606. }
  1607. if (!FindNextFile( hFind, &fd ))
  1608. {
  1609. FindClose(hFind);
  1610. break;
  1611. }
  1612. }
  1613. CloseHandle(hSiteDat);
  1614. LocalFree(pBuf);
  1615. }
  1616. SetCurrentDirectory(g_szIEAKProg);
  1617. PathCombine(szCompBuf, g_szIEAKProg, TEXT("new"));
  1618. PathRemovePath(szCompBuf);
  1619. ZeroMemory(szCompBuf, sizeof(szCompBuf));
  1620. if(g_fOCW)
  1621. PathCombine(szDest, g_szBuildRoot, g_szActLang);
  1622. else
  1623. {
  1624. PathCombine(szDest, g_szBuildRoot, TEXT("DOWNLOAD"));
  1625. PathAppend(szDest, GetOutputPlatformDir());
  1626. PathAppend(szDest, g_szActLang);
  1627. }
  1628. TCHAR szSourceDir[MAX_PATH];
  1629. TCHAR szTargetDir[MAX_PATH];
  1630. StrCpy(szSourceDir, g_szIEAKProg);
  1631. StrCpy(szTargetDir, g_szBuildRoot);
  1632. PathRemoveBackslash(szSourceDir);
  1633. PathRemoveBackslash(szTargetDir);
  1634. if((!g_fOCW && g_fDownload) || (g_fOCW && StrCmpI(szSourceDir, szTargetDir)))
  1635. res = CopyFilesSrcToDest(g_szIEAKProg, TEXT("*.*"), szDest, s_dwTicksPerUnit*2);
  1636. if (g_fDownload || g_fOCW)
  1637. {
  1638. res |= CopyFilesSrcToDest(g_szBuildTemp, TEXT("*.CAB"), szDest);
  1639. PathCombine(szTo, szDest, pIE4ExeName);
  1640. SetFileAttributes(szTo, FILE_ATTRIBUTE_NORMAL);
  1641. DeleteFile(szTo);
  1642. CopyFile(s_szIE4SetupDir, szTo, FALSE);
  1643. if (res)
  1644. {
  1645. TCHAR szMsg[MAX_PATH];
  1646. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1647. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1648. DoCancel();
  1649. return (DWORD)-1;
  1650. }
  1651. }
  1652. // remove the .cif file that was copied from the download\optional directory
  1653. TCHAR szCifFile[MAX_PATH];
  1654. PathCombine(szCifFile, szDest, TEXT("IESetup.cif"));
  1655. DeleteFile(szCifFile);
  1656. if (g_fOCW || g_fDownload)
  1657. {
  1658. if (g_fCustomICMPro)
  1659. {
  1660. ZeroMemory(szSource, sizeof(szSource));
  1661. StrCpy(szSource, g_szCustIcmPro);
  1662. g_shfStruc.pFrom = szSource;
  1663. g_shfStruc.pTo = szDest;
  1664. g_shfStruc.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
  1665. res |= SHFileOperation(&g_shfStruc);
  1666. }
  1667. }
  1668. if (res)
  1669. {
  1670. TCHAR szMsg[MAX_PATH];
  1671. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1672. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1673. DoCancel();
  1674. return (DWORD)-1;
  1675. }
  1676. if (g_fOCW || g_fDownload)
  1677. {
  1678. ZeroMemory(szCompBuf, sizeof(szCompBuf));
  1679. for (pComp = g_aCustComponents, pCompBuf = szCompBuf; ; pComp++ )
  1680. {
  1681. if (!(*pComp->szSection)) break;
  1682. if (pComp->iInstallType == 2)
  1683. continue;
  1684. StrCpy(pCompBuf, pComp->szPath);
  1685. pCompBuf += lstrlen(pCompBuf) + 1;
  1686. }
  1687. }
  1688. if (g_fOCW || g_fDownload)
  1689. {
  1690. if (*szCompBuf)
  1691. {
  1692. g_shfStruc.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
  1693. g_shfStruc.pFrom = szCompBuf;
  1694. g_shfStruc.pTo = szDest;
  1695. res = SHFileOperation(&g_shfStruc);
  1696. if (res)
  1697. {
  1698. TCHAR szMsg[MAX_PATH];
  1699. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1700. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1701. DoCancel();
  1702. return (DWORD)-1;
  1703. }
  1704. }
  1705. DeleteUnusedComps(szDest);
  1706. }
  1707. // copy custom cab files to ins directory for IEAKLite
  1708. if (!g_fBatch)
  1709. {
  1710. StrCpy(szDest, g_szCustIns);
  1711. PathRemoveFileSpec(szDest);
  1712. CopyFilesSrcToDest(g_szBuildTemp, TEXT("*.CAB"), szDest);
  1713. CopyFilesSrcToDest(g_szBuildTemp, TEXT("IE6SETUP.EXE"), szDest);
  1714. // clear out the deleteadms flags if it's there so adms can be disabled in IEAKLite
  1715. WritePrivateProfileString(IS_BRANDING, TEXT("DeleteAdms"), NULL, g_szCustIns);
  1716. }
  1717. // NOTE: BuildBrandingOnly should be the last one because it munges
  1718. // iesetup.inf, iesetup.cif, bootie42.cdf, etc.
  1719. if (g_fBrandingOnly)
  1720. {
  1721. if(!BuildBrandingOnly(s_dwTicksPerUnit))
  1722. {
  1723. TCHAR szMsg[MAX_PATH];
  1724. LoadString( g_rvInfo.hInst, IDS_ERROREXIT, szMsg, countof(szMsg) );
  1725. MessageBox(hWnd, szMsg, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1726. DoCancel();
  1727. return (DWORD)-1;
  1728. }
  1729. }
  1730. UpdateProgress(-1);
  1731. StrCpy( szDest, g_szBuildTemp );
  1732. SetCurrentDirectory(g_szWizPath);
  1733. #ifndef DBG
  1734. PathRemovePath(szDest);
  1735. #endif
  1736. if (ISNONNULL(g_szUnsignedFiles))
  1737. {
  1738. TCHAR szMessage[MAX_BUF];
  1739. TCHAR szMsg[512];
  1740. LoadString(g_rvInfo.hInst, IDS_CABSIGN_ERROR, szMsg, countof(szMsg));
  1741. wnsprintf(szMessage, countof(szMessage), szMsg, g_szUnsignedFiles);
  1742. MessageBox(hWnd, szMessage, g_szTitle, MB_OK | MB_SETFOREGROUND);
  1743. }
  1744. if (!g_fBatch && !g_fBatch2)
  1745. {
  1746. SetFocus(hWnd);
  1747. SetCurrentDirectory( g_szWizRoot );
  1748. }
  1749. return 0;
  1750. }
  1751. DWORD ProcessINSFiles(LPCTSTR pcszDir, DWORD dwFlags, LPCTSTR pcszOutDir)
  1752. // Except the .INS files that have Cancel=Yes in the [Entry] section, do this:
  1753. // return the number of INS files found in pcszDir;
  1754. // if (HasFlag(dwFlags, PINSF_DELETE)), delete them from pcszDir;
  1755. // else if (HasFlag(dwFlags, PINSF_COPY)), copy them to pcszOutDir;
  1756. // else if (HasFlag(dwFlags, PINSF_APPLY)), append pcszOutDir (actually points to INSTALL.INS) to them;
  1757. // else if (HasFlag(dwFlags, PINSF_COPYCAB)), copy pcszOutDir (actually points to BRANDING.CAB) to pcszDir;
  1758. // else if (HasFlag(dwFlags, PINSF_FIXINS)), write Serverless=1 to the [Branding] section;
  1759. // else if (HasFlag(dwFlags, PINSF_NOCLEAR)), write NoClear=1 to the [Branding] section.
  1760. {
  1761. DWORD nFiles = 0;
  1762. TCHAR szFile[MAX_PATH], szCabName[MAX_PATH];
  1763. WIN32_FIND_DATA fd;
  1764. HANDLE hFind;
  1765. LPTSTR pszFile, pszCabName = NULL;
  1766. if (pcszDir == NULL || ISNULL(pcszDir))
  1767. return 0;
  1768. if (HasFlag(dwFlags, PINSF_COPY) || HasFlag(dwFlags, PINSF_APPLY) || HasFlag(dwFlags, PINSF_COPYCAB))
  1769. if (pcszOutDir == NULL || ISNULL(pcszOutDir))
  1770. return 0;
  1771. StrCpy(szFile, pcszDir);
  1772. pszFile = PathAddBackslash(szFile);
  1773. StrCpy(pszFile, TEXT("*.ins"));
  1774. if (HasFlag(dwFlags, PINSF_COPYCAB))
  1775. {
  1776. StrCpy(szCabName, pcszDir);
  1777. pszCabName = PathAddBackslash(szCabName);
  1778. }
  1779. if ((hFind = FindFirstFile(szFile, &fd)) != INVALID_HANDLE_VALUE)
  1780. {
  1781. do
  1782. {
  1783. if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  1784. continue;
  1785. StrCpy(pszFile, fd.cFileName);
  1786. if (!InsGetYesNo(TEXT("Entry"), TEXT("Cancel"), 0, szFile))
  1787. {
  1788. nFiles++;
  1789. if (HasFlag(dwFlags, PINSF_DELETE))
  1790. {
  1791. SetFileAttributes(szFile, FILE_ATTRIBUTE_NORMAL);
  1792. DeleteFile(szFile);
  1793. }
  1794. else if (HasFlag(dwFlags, PINSF_COPY))
  1795. {
  1796. CopyFileToDir(szFile, pcszOutDir);
  1797. }
  1798. else if (HasFlag(dwFlags, PINSF_APPLY))
  1799. {
  1800. // append install.ins only if ApplyIns is TRUE
  1801. if (InsGetBool(IS_APPLYINS, IK_APPLYINS, 0, szFile))
  1802. {
  1803. // IMPORTANT: (pritobla) On Win9x, should flush the content before
  1804. // mixing file operations (CreateFile, ReadFile, WriteFile, DeleteFile, etc)
  1805. // with PrivateProfile function calls.
  1806. WritePrivateProfileString(NULL, NULL, NULL, szFile);
  1807. AppendFile(pcszOutDir, szFile); // pcszOutDir actually points to INSTALL.INS
  1808. if (g_fServerICW || g_fServerKiosk)
  1809. {
  1810. TCHAR szCabURL[MAX_URL];
  1811. LPTSTR pszCabName;
  1812. // for server-based signup, write the following entries so that ICW doesn't
  1813. // close the RAS connection after downloading the INS file
  1814. WritePrivateProfileString(TEXT("Custom"), TEXT("Keep_Connection"), TEXT("Yes"), szFile);
  1815. WritePrivateProfileString(TEXT("Custom"), TEXT("Run"), TEXT("rundll32.exe"), szFile);
  1816. WritePrivateProfileString(TEXT("Custom"), TEXT("Argument"), TEXT("IEDKCS32.DLL,CloseRASConnections"), szFile);
  1817. // write the URL to the branding cab
  1818. // BUGBUG: should probably use InternetComineUrl()
  1819. GetPrivateProfileString(IS_APPLYINS, IK_BRAND_URL, TEXT(""), szCabURL, countof(szCabURL), szFile);
  1820. ASSERT(ISNONNULL(szCabURL));
  1821. pszCabName = szCabURL + StrLen(szCabURL);
  1822. if (*CharPrev(szCabURL, pszCabName) != TEXT('/'))
  1823. *pszCabName++ = TEXT('/');
  1824. GetPrivateProfileString(IS_APPLYINS, IK_BRAND_NAME, TEXT(""), pszCabName,
  1825. countof(szCabURL) - (DWORD) (pszCabName - szCabURL), szFile);
  1826. ASSERT(ISNONNULL(pszCabName));
  1827. WritePrivateProfileString(IS_CUSTOMBRANDING, IK_BRANDING, szCabURL, szFile);
  1828. WritePrivateProfileString(NULL, NULL, NULL, szFile);
  1829. }
  1830. }
  1831. }
  1832. else if (HasFlag(dwFlags, PINSF_COPYCAB))
  1833. {
  1834. // for server-based signup, copy branding.cab only if ApplyIns is TRUE
  1835. if ((g_fServerICW || g_fServerKiosk) &&
  1836. InsGetBool(IS_APPLYINS, IK_APPLYINS, 0, szFile))
  1837. {
  1838. GetPrivateProfileString(IS_APPLYINS, IK_BRAND_NAME, TEXT(""), pszCabName,
  1839. countof(szCabName) - (DWORD) (pszCabName - szCabName), szFile);
  1840. ASSERT(ISNONNULL(pszCabName));
  1841. CopyFile(pcszOutDir, szCabName, FALSE); // pcszOutDir actually points to BRANDING.CAB
  1842. }
  1843. }
  1844. else if (HasFlag(dwFlags, PINSF_FIXINS))
  1845. {
  1846. InsWriteBool(IS_BRANDING, IK_SERVERLESS, TRUE, szFile);
  1847. WritePrivateProfileString(NULL, NULL, NULL, szFile);
  1848. }
  1849. else if (HasFlag(dwFlags, PINSF_NOCLEAR))
  1850. {
  1851. InsWriteBool(IS_BRANDING, TEXT("NoClear"), TRUE, szFile);
  1852. WritePrivateProfileString(NULL, NULL, NULL, szFile);
  1853. }
  1854. }
  1855. } while (FindNextFile(hFind, &fd));
  1856. FindClose(hFind);
  1857. }
  1858. return nFiles;
  1859. }
  1860. /////////////////////////////////////////////////////////////////////////////
  1861. // Implementation helpers routines (private)
  1862. static void WritePIDValues(LPCTSTR pcszInsFile, LPCTSTR pcszSetupInf)
  1863. {
  1864. TCHAR szValue[32];
  1865. // MS1 is the MPC code and MS2 is the 6-8 position chars that are replaced in the PID
  1866. // we check to see if there are custom values in the INS file and make sure these are
  1867. // cleared before cabbing into the branding cab.
  1868. // the values are writen to the iesetup.inf that goes into ie6setup.exe with the default
  1869. // MS2 value always being OEM
  1870. if (GetPrivateProfileString(IS_BRANDING, TEXT("MS1"), TEXT(""), szValue, countof(szValue), pcszInsFile))
  1871. {
  1872. WritePrivateProfileString(IS_BRANDING, TEXT("MS1"), szValue, pcszSetupInf);
  1873. WritePrivateProfileString(IS_BRANDING, TEXT("MS1"), NULL, pcszInsFile);
  1874. }
  1875. // pass size as 4 since MS2 can only be 3 chars long
  1876. if (GetPrivateProfileString(IS_BRANDING, TEXT("MS2"), TEXT(""), szValue, 4, pcszInsFile))
  1877. {
  1878. WritePrivateProfileString(IS_BRANDING, TEXT("MS2"), szValue, pcszSetupInf);
  1879. WritePrivateProfileString(IS_BRANDING, TEXT("MS2"), NULL, pcszInsFile);
  1880. }
  1881. else
  1882. WritePrivateProfileString(IS_BRANDING, TEXT("MS2"), TEXT("OEM"), pcszSetupInf);
  1883. WritePrivateProfileString(NULL, NULL, NULL, pcszInsFile);
  1884. }
  1885. static void WriteURDComponent(CCifRWFile_t *lpCifRWFileDest, LPCTSTR pcszModes)
  1886. {
  1887. ICifRWGroup * pCifRWGroup = NULL;
  1888. CCifRWGroup_t * pCifRWGroup_t = NULL;
  1889. ICifRWComponent * pCifRWComponent = NULL;
  1890. CCifRWComponent_t * pCifRWComponent_t = NULL;
  1891. BOOL fGroup = FALSE;
  1892. if (lpCifRWFileDest == NULL)
  1893. return;
  1894. lpCifRWFileDest->CreateGroup(POSTCUSTITEMS, &pCifRWGroup);
  1895. if (pCifRWGroup != NULL)
  1896. {
  1897. pCifRWGroup_t = new CCifRWGroup_t(pCifRWGroup);
  1898. if (pCifRWGroup_t != NULL)
  1899. {
  1900. TCHAR szCustDesc[MAX_PATH];
  1901. LoadString(g_rvInfo.hInst, IDS_CUSTOMCOMPTITLE, szCustDesc, countof(szCustDesc));
  1902. pCifRWGroup_t->SetDescription(szCustDesc);
  1903. pCifRWGroup_t->SetPriority(1);
  1904. delete pCifRWGroup_t;
  1905. fGroup = TRUE;
  1906. }
  1907. }
  1908. if (fGroup)
  1909. {
  1910. lpCifRWFileDest->CreateComponent(URDCOMP, &pCifRWComponent);
  1911. if (pCifRWComponent != NULL)
  1912. {
  1913. pCifRWComponent_t = new CCifRWComponent_t(pCifRWComponent);
  1914. if (pCifRWComponent_t != NULL)
  1915. {
  1916. DWORD dwSize = 0;
  1917. HANDLE hFile;
  1918. TCHAR szURDPath[MAX_PATH];
  1919. pCifRWComponent_t->SetGroup(POSTCUSTITEMS);
  1920. pCifRWComponent_t->SetGUID(URD_GUID_STR);
  1921. pCifRWComponent_t->SetDescription(TEXT("URD Component"));
  1922. pCifRWComponent_t->SetDetails(TEXT(""));
  1923. pCifRWComponent_t->SetCommand(0, IE55URD_EXE, TEXT("/s"), INST_EXE);
  1924. pCifRWComponent_t->SetUrl(0, IE55URD_EXE, 2);
  1925. pCifRWComponent_t->SetPriority(1);
  1926. pCifRWComponent_t->SetVersion(TEXT(""));
  1927. pCifRWComponent_t->SetUninstallKey(TEXT(""));
  1928. pCifRWComponent_t->SetUIVisible(FALSE);
  1929. StrCpy(szURDPath, g_szMastInf);
  1930. PathRemoveFileSpec(szURDPath);
  1931. PathAppend(szURDPath, IE55URD_EXE);
  1932. if ((hFile = CreateFile(szURDPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
  1933. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
  1934. {
  1935. dwSize = ((dwSize = GetFileSize(hFile, NULL)) != 0xffffffff) ? (dwSize >> 10) : 0;
  1936. CloseHandle(hFile);
  1937. }
  1938. pCifRWComponent_t->SetDownloadSize(dwSize);
  1939. WriteModesToCif(pCifRWComponent_t, pcszModes);
  1940. delete pCifRWComponent_t;
  1941. }
  1942. }
  1943. }
  1944. }