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.

4562 lines
174 KiB

  1. #include "stdafx.h"
  2. #include <afxinet.h>
  3. #include <ole2.h>
  4. #include "iadmw.h"
  5. #include "iiscnfg.h"
  6. #include "mdkey.h"
  7. #include "massupdt.h"
  8. #include "setupapi.h"
  9. #include "ocmanage.h"
  10. #include "browsedi.h"
  11. #include "log.h"
  12. #include "other.h"
  13. #include "mtxadmii.c"
  14. #include "mtxadmin.h"
  15. #include "mdentry.h"
  16. #include "depends.h"
  17. #include "kill.h"
  18. #include "svc.h"
  19. #include "wolfpack.h"
  20. #include "dllmain.h"
  21. #include "ocpages.h"
  22. #pragma hdrstop
  23. int g_GlobalTickValue = 1;
  24. int g_GlobalGuiOverRide = 0;
  25. int g_GlobalTotalTickGaugeCount = 0;
  26. int g_GlobalTickTotal_iis_common = 0;
  27. int g_GlobalTickTotal_iis_inetmgr = 0;
  28. int g_GlobalTickTotal_iis_www = 0;
  29. int g_GlobalTickTotal_iis_pwmgr = 0;
  30. int g_GlobalTickTotal_iis_doc = 0;
  31. int g_GlobalTickTotal_iis_htmla = 0;
  32. int g_GlobalTickTotal_iis_ftp = 0;
  33. TCHAR g_szCurrentSubComponent[20];
  34. // OcManage globals
  35. OCMANAGER_ROUTINES gHelperRoutines;
  36. HANDLE g_MyModuleHandle = NULL;
  37. const TCHAR OC_MANAGER_SETUP_KEY[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Setup\\OC Manager\\Subcomponents");
  38. const TCHAR OCM_OptionalComponents_Section[] = _T("Optional Components");
  39. const TCHAR STRING_iis_ftp[] = _T("iis_ftp");
  40. const TCHAR STRING_iis_htmla[] = _T("iis_htmla");
  41. const TCHAR STRING_iis_doc[] = _T("iis_doc");
  42. const TCHAR STRING_iis_pwmgr[] = _T("iis_pwmgr");
  43. const TCHAR STRING_iis_www[] = _T("iis_www");
  44. const TCHAR STRING_iis_inetmgr[] = _T("iis_inetmgr");
  45. const TCHAR STRING_iis_core[] = _T("iis_core");
  46. const TCHAR STRING_iis_common[] = _T("iis_common");
  47. const TCHAR STRING_iis_www_parent[] = _T("iis_www_parent");
  48. const TCHAR STRING_iis_www_vdir_scripts[] = _T("iis_www_vdir_scripts");
  49. const TCHAR STRING_iis_www_vdir_printers[] = _T("iis_www_vdir_printers");
  50. int g_iOC_WIZARD_CREATED_Called = FALSE;
  51. int g_iOC_FILE_BUSY_Called = FALSE;
  52. int g_iOC_PREINITIALIZE_Called = FALSE;
  53. int g_iOC_INIT_COMPONENT_Called = FALSE;
  54. int g_iOC_SET_LANGUAGE_Called = FALSE;
  55. int g_iOC_QUERY_IMAGE_Called = FALSE;
  56. int g_iOC_REQUEST_PAGES_Called = FALSE;
  57. int g_iOC_QUERY_STATE_Called = FALSE;
  58. int g_iOC_QUERY_CHANGE_SEL_STATE_Called = FALSE;
  59. int g_iOC_QUERY_SKIP_PAGE_Called = FALSE;
  60. int g_iOC_CALC_DISK_SPACE_Called = FALSE;
  61. int g_iOC_QUEUE_FILE_OPS_Called = FALSE;
  62. int g_iOC_NEED_MEDIA_Called = FALSE;
  63. int g_iOC_NOTIFICATION_FROM_QUEUE_Called = FALSE;
  64. int g_iOC_QUERY_STEP_COUNT_Called = FALSE;
  65. int g_iOC_ABOUT_TO_COMMIT_QUEUE_Called = FALSE;
  66. int g_iOC_COMPLETE_INSTALLATION_Called = FALSE;
  67. int g_iOC_CLEANUP_Called = FALSE;
  68. int g_iOC_DEFAULT_Called = FALSE;
  69. int g_Please_Call_Register_iis_inetmgr = FALSE;
  70. HSPFILEQ g_GlobalFileQueueHandle = NULL;
  71. int g_GlobalFileQueueHandle_ReturnError = 0;
  72. CInitApp *g_pTheApp;
  73. BOOL g_bGlobalWriteUnSecuredIfFailed_All = FALSE;
  74. // 0 = log errors only
  75. // 1 = log warnings
  76. // 2 = trace
  77. // 3 = trace win32 stuff
  78. int g_GlobalDebugLevelFlag = 3;
  79. int g_GlobalDebugLevelFlag_WasSetByUnattendFile = FALSE;
  80. int g_GlobalDebugCallValidateHeap = 1;
  81. int g_GlobalDebugCrypto = 0;
  82. int g_GlobalFastLoad = 0;
  83. TCHAR g_szLastSectionToGetCalled[50];
  84. // Logging class
  85. MyLogFile g_MyLogFile;
  86. int CheckInfInstead(int iPrevious)
  87. {
  88. INFCONTEXT Context;
  89. int iTempFlag = 0;
  90. TCHAR szPersonalFlag[20] = _T("");
  91. iTempFlag = iPrevious;
  92. if (SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, _T("SetupInfo"), _T("Personal"), &Context) )
  93. {
  94. SetupGetStringField(&Context, 1, szPersonalFlag, 50, NULL);
  95. if (IsValidNumber((LPCTSTR)szPersonalFlag))
  96. {
  97. iTempFlag = _ttoi(szPersonalFlag);
  98. iTempFlag++;
  99. }
  100. }
  101. return (iTempFlag);
  102. }
  103. BOOL IsWhistlerPersonal(void)
  104. {
  105. static int PersonalSKU = 0;
  106. if (0 == PersonalSKU)
  107. {
  108. OSVERSIONINFOEX osvi;
  109. //
  110. // Determine if we are installing Personal SKU
  111. //
  112. ZeroMemory( &osvi, sizeof( OSVERSIONINFOEX ) );
  113. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  114. GetVersionEx((OSVERSIONINFO *) &osvi);
  115. if (osvi.wProductType == VER_NT_WORKSTATION && (osvi.wSuiteMask & VER_SUITE_PERSONAL))
  116. {
  117. PersonalSKU = 2;
  118. }
  119. else
  120. {
  121. PersonalSKU = 1;
  122. }
  123. PersonalSKU = CheckInfInstead(PersonalSKU);
  124. }
  125. return (PersonalSKU - 1);
  126. }
  127. void WINAPI ProcessInfSection(CHAR *pszSectionName)
  128. {
  129. BOOL bPleaseCloseInfHandle = FALSE;
  130. TCHAR szWindowsDir[_MAX_PATH];
  131. TCHAR szFullPath[_MAX_PATH];
  132. TCHAR wszWideString[MAX_PATH];
  133. int MySavedDebugLevel = 0;
  134. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("ProcessInfSection:"));
  135. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  136. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("ProcessInfSection: Start.\n")));
  137. if (!pszSectionName)
  138. {goto ProcessInfSection_Exit;}
  139. if (!g_pTheApp->m_hInfHandle || g_pTheApp->m_hInfHandle == INVALID_HANDLE_VALUE)
  140. {
  141. g_pTheApp->m_hInfHandle = INVALID_HANDLE_VALUE;
  142. // get the c:\winnt dir
  143. if (0 == GetWindowsDirectory(szWindowsDir, _MAX_PATH))
  144. {goto ProcessInfSection_Exit;}
  145. // Tack on the inf\iis.inf subdir and filename
  146. _stprintf(szFullPath, _T("%s\\inf\\iis.inf"),szWindowsDir);
  147. // Check if the file exists
  148. if (TRUE != IsFileExist(szFullPath))
  149. {
  150. iisDebugOut((LOG_TYPE_WARN, _T("ProcessInfSection: %s does not exist!\n"),szFullPath));
  151. goto ProcessInfSection_Exit;
  152. }
  153. // Get a handle to it.
  154. g_pTheApp->m_hInfHandle = SetupOpenInfFile(szFullPath, NULL, INF_STYLE_WIN4, NULL);
  155. if (!g_pTheApp->m_hInfHandle || g_pTheApp->m_hInfHandle == INVALID_HANDLE_VALUE)
  156. {
  157. iisDebugOut((LOG_TYPE_WARN, _T("ProcessInfSection: SetupOpenInfFile failed on file: %s.\n"),szFullPath));
  158. goto ProcessInfSection_Exit;
  159. }
  160. bPleaseCloseInfHandle = TRUE;
  161. }
  162. // get the debug level from the iis.inf
  163. GetDebugLevelFromInf(g_pTheApp->m_hInfHandle);
  164. MySavedDebugLevel = g_GlobalDebugLevelFlag;
  165. // reset global debug level only most of the time
  166. if (LOG_TYPE_TRACE_WIN32_API < g_GlobalDebugLevelFlag)
  167. {g_GlobalDebugLevelFlag = LOG_TYPE_ERROR;}
  168. // Read .inf file and set some globals from the information in there.
  169. ReadGlobalsFromInf(g_pTheApp->m_hInfHandle);
  170. g_pTheApp->InitApplication();
  171. SetDIRIDforThisInf(g_pTheApp->m_hInfHandle);
  172. //g_pTheApp->DumpAppVars();
  173. g_GlobalDebugLevelFlag = MySavedDebugLevel;
  174. // See if user configured anything
  175. ReadUserConfigurable(g_pTheApp->m_hInfHandle);
  176. // Convert the input to a wide char if ProcessSection() takes wide type.
  177. #if defined(UNICODE) || defined(_UNICODE)
  178. MultiByteToWideChar( CP_ACP, 0, pszSectionName, -1, wszWideString, MAX_PATH);
  179. #else
  180. _tcscpy(wszWideString, pszSectionName);
  181. #endif
  182. ProcessSection(g_pTheApp->m_hInfHandle, wszWideString);
  183. ProcessInfSection_Exit:
  184. if (TRUE == bPleaseCloseInfHandle)
  185. {if(g_pTheApp->m_hInfHandle != INVALID_HANDLE_VALUE) {SetupCloseInfFile(g_pTheApp->m_hInfHandle);g_pTheApp->m_hInfHandle = INVALID_HANDLE_VALUE;}}
  186. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("ProcessInfSection: End.\n")));
  187. return;
  188. }
  189. void WINAPI IIS5Log(int iLogType, TCHAR *pszfmt)
  190. {
  191. iisDebugOut((iLogType, pszfmt));
  192. }
  193. void WINAPI IIS5LogParmString(int iLogType, TCHAR *pszfmt, TCHAR *pszString)
  194. {
  195. if ( _tcsstr(pszfmt, _T("%s")) || _tcsstr(pszfmt, _T("%S")))
  196. {
  197. iisDebugOut((iLogType, pszfmt, pszString));
  198. }
  199. else
  200. {
  201. iisDebugOut((iLogType, pszfmt));
  202. iisDebugOut((iLogType, pszString));
  203. }
  204. }
  205. void WINAPI IIS5LogParmDword(int iLogType, TCHAR *pszfmt, DWORD dwErrorCode)
  206. {
  207. if ( _tcsstr(pszfmt, _T("%x")) || _tcsstr(pszfmt, _T("%X")) || _tcsstr(pszfmt, _T("%d")) || _tcsstr(pszfmt, _T("%D")))
  208. {
  209. iisDebugOut((iLogType, pszfmt, dwErrorCode));
  210. }
  211. else
  212. {
  213. iisDebugOut((iLogType, pszfmt));
  214. iisDebugOut((iLogType, _T("%d"), dwErrorCode));
  215. }
  216. }
  217. void TestAfterInitApp(void)
  218. {
  219. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("...... Start\n")));
  220. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("...... End\n")));
  221. return;
  222. }
  223. extern "C" void InitializeIISRTL2();
  224. extern "C" void TerminateIISRTL2();
  225. //
  226. // Standard Win32 DLL Entry point
  227. //
  228. BOOL WINAPI DllMain(IN HANDLE DllHandle,IN DWORD Reason,IN LPVOID Reserved)
  229. {
  230. BOOL bReturn = TRUE;
  231. UNREFERENCED_PARAMETER(Reserved);
  232. bReturn = TRUE;
  233. CString csTempPath;
  234. switch(Reason)
  235. {
  236. case DLL_PROCESS_ATTACH:
  237. InitializeIISRTL2();
  238. // Because Heap problems with IISRTL, we must make sure that anything that
  239. // uses stuff from iisrtl, must NOT live beyond the scope of
  240. // InitializeIISRTL2 and TerminateIISRTL2!!!
  241. g_pTheApp = new (CInitApp);
  242. if ( !g_pTheApp )
  243. {
  244. bReturn = FALSE;
  245. }
  246. if (!g_MyModuleHandle)
  247. {
  248. srand(GetTickCount());
  249. g_MyModuleHandle = DllHandle;
  250. // open the log file.
  251. #ifdef IIS60
  252. g_MyLogFile.LogFileCreate(_T("iis6.log"));
  253. #else
  254. g_MyLogFile.LogFileCreate(_T("iis5.log"));
  255. #endif
  256. gHelperRoutines.OcManagerContext = NULL;
  257. }
  258. break;
  259. case DLL_THREAD_ATTACH:
  260. bReturn = TRUE;
  261. break;
  262. case DLL_PROCESS_DETACH:
  263. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("Final Check:"));
  264. // only do the final check if we are actually run from sysocmgr.exe!
  265. // and the first thing that sysocmgr.exe does is call preinitialize, so let's check for that!
  266. if (g_iOC_PREINITIALIZE_Called)
  267. {
  268. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("=======================\n")));
  269. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_PREINITIALIZE Called=%d\n"), g_iOC_PREINITIALIZE_Called));
  270. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_INIT_COMPONENT Called=%d\n"), g_iOC_INIT_COMPONENT_Called));
  271. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_SET_LANGUAGE Called=%d\n"), g_iOC_SET_LANGUAGE_Called));
  272. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUERY_IMAGE Called=%d\n"), g_iOC_QUERY_IMAGE_Called));
  273. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_REQUEST_PAGES Called=%d\n"), g_iOC_REQUEST_PAGES_Called));
  274. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_WIZARD_CREATED Called=%d\n"), g_iOC_WIZARD_CREATED_Called));
  275. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUERY_STATE Called=%d\n"), g_iOC_QUERY_STATE_Called));
  276. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUERY_CHANGE_SEL_STATE Called=%d\n"), g_iOC_QUERY_CHANGE_SEL_STATE_Called));
  277. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUERY_SKIP_PAGE Called=%d\n"), g_iOC_QUERY_SKIP_PAGE_Called));
  278. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_CALC_DISK_SPACE Called=%d\n"), g_iOC_CALC_DISK_SPACE_Called));
  279. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUEUE_FILE_OPS Called=%d\n"), g_iOC_QUEUE_FILE_OPS_Called));
  280. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_NEED_MEDIA Called=%d\n"), g_iOC_NEED_MEDIA_Called));
  281. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_NOTIFICATION_FROM_QUEUE Called=%d\n"), g_iOC_NOTIFICATION_FROM_QUEUE_Called));
  282. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_QUERY_STEP_COUNT Called=%d\n"), g_iOC_QUERY_STEP_COUNT_Called));
  283. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_ABOUT_TO_COMMIT_QUEUE Called=%d\n"), g_iOC_ABOUT_TO_COMMIT_QUEUE_Called));
  284. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_FILE_BUSY Called=%d\n"), g_iOC_FILE_BUSY_Called));
  285. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_COMPLETE_INSTALLATION Called=%d\n"), g_iOC_COMPLETE_INSTALLATION_Called));
  286. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("OC_CLEANUP Called=%d\n"), g_iOC_CLEANUP_Called));
  287. iisDebugOut((LOG_TYPE_TRACE, _T("OC_DEFAULT Called=%d\n"), g_iOC_DEFAULT_Called));
  288. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("Final Check:"));
  289. // Check if g_iOC_COMPLETE_INSTALLATION_Called was called!!!!!
  290. if (!g_iOC_COMPLETE_INSTALLATION_Called)
  291. {
  292. if (g_pTheApp->m_fNTGuiMode)
  293. {
  294. iisDebugOut((LOG_TYPE_ERROR, _T("WARNING.FAILURE: OC_COMPLETE_INSTALLATION was not called (by ocmanage.dll) for this component. IIS was not installed or configured!! This will be a problem for other ocm installed components as well.\n")));
  295. }
  296. }
  297. }
  298. // log the heap state
  299. LogHeapState(TRUE, __FILE__, __LINE__);
  300. // free some memory
  301. FreeTaskListMem();
  302. UnInit_Lib_PSAPI();
  303. // Close the log file
  304. g_MyLogFile.LogFileClose();
  305. ASSERT(g_pTheApp);
  306. delete (g_pTheApp);
  307. g_pTheApp = NULL;
  308. TerminateIISRTL2();
  309. break;
  310. case DLL_THREAD_DETACH:
  311. break;
  312. }
  313. return(bReturn);
  314. }
  315. BOOL g_fFranceHackAttempted = FALSE;
  316. LCID g_TrueThreadLocale;
  317. DWORD WINAPI FranceFixThread(LPVOID lpParameter)
  318. {
  319. g_TrueThreadLocale = GetThreadLocale ();
  320. return 0;
  321. }
  322. // -----------------------------------------------
  323. // OcEntry is the main entry point (After DllMain)
  324. // -----------------------------------------------
  325. DWORD_PTR OcEntry(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  326. {
  327. DWORD_PTR dwOcEntryReturn = 0;
  328. _tcscpy(g_szCurrentSubComponent, _T(""));
  329. if (SubcomponentId) {_tcscpy(g_szCurrentSubComponent, SubcomponentId);}
  330. if (!g_fFranceHackAttempted)
  331. {
  332. g_fFranceHackAttempted = TRUE;
  333. LCID InitialThreadLocale;
  334. DWORD thid;
  335. InitialThreadLocale = GetThreadLocale ();
  336. iisDebugOut((LOG_TYPE_TRACE, _T("Initial thread locale=%0x\n"),InitialThreadLocale));
  337. HANDLE hHackThread = CreateThread (NULL,0,FranceFixThread,NULL,0,&thid);
  338. if (hHackThread)
  339. {
  340. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("Starting to wait On France fix thread\n")));
  341. // wait for 10 secs only
  342. DWORD res = WaitForSingleObject (hHackThread,10*1000);
  343. if (res==WAIT_TIMEOUT)
  344. {
  345. iisDebugOut((LOG_TYPE_ERROR, _T("ERROR France fix thread never finished...\n")));
  346. }
  347. else
  348. {
  349. iisDebugOut((LOG_TYPE_TRACE, _T("returned from France fix with locale %0x \n"),g_TrueThreadLocale));
  350. CloseHandle (hHackThread);
  351. // do that only if locales are different and another one is France
  352. if (g_TrueThreadLocale !=InitialThreadLocale && g_TrueThreadLocale==0x40c)
  353. {
  354. BOOL ret = SetThreadLocale (g_TrueThreadLocale);
  355. iisDebugOut((LOG_TYPE_TRACE, _T("SetThreadLocale returned %d\n"),ret));
  356. g_TrueThreadLocale = GetThreadLocale ();
  357. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("France fix succeed=%0x\n"),g_TrueThreadLocale));
  358. }
  359. }
  360. }
  361. else
  362. {
  363. iisDebugOut((LOG_TYPE_ERROR, _T("Failed to start France fix thread. error =%0x\n"),GetLastError()));
  364. }
  365. }
  366. switch(Function)
  367. {
  368. case OC_WIZARD_CREATED:
  369. g_iOC_WIZARD_CREATED_Called = TRUE;
  370. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_WIZARD_CREATED:"));
  371. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  372. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  373. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  374. break;
  375. case OC_FILE_BUSY:
  376. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_FILE_BUSY:"));
  377. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  378. // if the first time this function was
  379. // called then show all running services
  380. LogHeapState(FALSE, __FILE__, __LINE__);
  381. if (g_iOC_FILE_BUSY_Called != TRUE)
  382. {
  383. // display locked dlls by setup
  384. // This seems to thru exceptions on build nt5 build 1980.
  385. // comment this out since it's not crucial.
  386. //LogThisProcessesDLLs();
  387. // display running services
  388. LogEnumServicesStatus();
  389. }
  390. g_iOC_FILE_BUSY_Called = TRUE;
  391. dwOcEntryReturn = OC_FILE_BUSY_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  392. LogHeapState(FALSE, __FILE__, __LINE__);
  393. break;
  394. case OC_PREINITIALIZE:
  395. g_iOC_PREINITIALIZE_Called = TRUE;
  396. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_PREINITIALIZE:"));
  397. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  398. dwOcEntryReturn = OC_PREINITIALIZE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  399. break;
  400. case OC_INIT_COMPONENT:
  401. g_iOC_INIT_COMPONENT_Called = TRUE;
  402. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_INIT_COMPONENT:"));
  403. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  404. dwOcEntryReturn = OC_INIT_COMPONENT_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  405. break;
  406. case OC_SET_LANGUAGE:
  407. g_iOC_SET_LANGUAGE_Called = TRUE;
  408. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_SET_LANGUAGE:"));
  409. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  410. dwOcEntryReturn = OC_SET_LANGUAGE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  411. break;
  412. #ifdef _WIN64
  413. case OC_QUERY_IMAGE_EX:
  414. g_iOC_QUERY_IMAGE_Called = TRUE;
  415. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_IMAGE_EX:"));
  416. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  417. dwOcEntryReturn = OC_QUERY_IMAGE_EX_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  418. break;
  419. #endif
  420. case OC_QUERY_IMAGE:
  421. g_iOC_QUERY_IMAGE_Called = TRUE;
  422. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_IMAGE:"));
  423. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  424. dwOcEntryReturn = OC_QUERY_IMAGE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  425. break;
  426. case OC_REQUEST_PAGES:
  427. g_iOC_REQUEST_PAGES_Called = TRUE;
  428. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_REQUEST_PAGES:"));
  429. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  430. dwOcEntryReturn = OC_REQUEST_PAGES_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  431. break;
  432. case OC_QUERY_STATE:
  433. g_iOC_QUERY_STATE_Called = TRUE;
  434. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_STATE:"));
  435. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  436. dwOcEntryReturn = OC_QUERY_STATE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  437. break;
  438. case OC_QUERY_CHANGE_SEL_STATE:
  439. g_iOC_QUERY_CHANGE_SEL_STATE_Called = TRUE;
  440. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_CHANGE_SEL_STATE:"));
  441. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  442. dwOcEntryReturn = OC_QUERY_CHANGE_SEL_STATE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  443. break;
  444. case OC_QUERY_SKIP_PAGE:
  445. g_iOC_QUERY_SKIP_PAGE_Called = TRUE;
  446. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_SKIP_PAGE:"));
  447. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  448. dwOcEntryReturn = OC_QUERY_SKIP_PAGE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  449. break;
  450. case OC_CALC_DISK_SPACE:
  451. g_iOC_CALC_DISK_SPACE_Called = TRUE;
  452. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_CALC_DISK_SPACE:"));
  453. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  454. dwOcEntryReturn = OC_CALC_DISK_SPACE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  455. break;
  456. case OC_QUEUE_FILE_OPS:
  457. ProgressBarTextStack_Set(IDS_IIS_ALL_FILEOPS);
  458. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUEUE_FILE_OPS:"));
  459. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  460. if (g_iOC_QUEUE_FILE_OPS_Called != TRUE)
  461. {
  462. // turn logging back on if we need to
  463. // get the debug level from the iis.inf
  464. if (g_GlobalFastLoad)
  465. {
  466. GetDebugLevelFromInf(g_pTheApp->m_hInfHandle);
  467. // output stuff that we missed during init
  468. g_pTheApp->DumpAppVars();
  469. }
  470. }
  471. g_iOC_QUEUE_FILE_OPS_Called = TRUE;
  472. dwOcEntryReturn = OC_QUEUE_FILE_OPS_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  473. ProgressBarTextStack_Pop();
  474. break;
  475. case OC_NEED_MEDIA:
  476. g_iOC_NEED_MEDIA_Called = TRUE;
  477. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_NEED_MEDIA:"));
  478. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  479. dwOcEntryReturn = OC_NEED_MEDIA_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  480. break;
  481. case OC_NOTIFICATION_FROM_QUEUE:
  482. g_iOC_NOTIFICATION_FROM_QUEUE_Called = TRUE;
  483. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_NOTIFICATION_FROM_QUEUE:"));
  484. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  485. dwOcEntryReturn = OC_NOTIFICATION_FROM_QUEUE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  486. break;
  487. case OC_QUERY_STEP_COUNT:
  488. g_iOC_QUERY_STEP_COUNT_Called = TRUE;
  489. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_QUERY_STEP_COUNT:"));
  490. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  491. dwOcEntryReturn = OC_QUERY_STEP_COUNT_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  492. break;
  493. case OC_ABOUT_TO_COMMIT_QUEUE:
  494. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_ABOUT_TO_COMMIT_QUEUE:"));
  495. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  496. LogHeapState(FALSE, __FILE__, __LINE__);
  497. if (g_iOC_ABOUT_TO_COMMIT_QUEUE_Called != TRUE)
  498. {
  499. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  500. {
  501. // display running processes
  502. LogCurrentProcessIDs();
  503. // display running services
  504. LogEnumServicesStatus();
  505. // log file versions
  506. LogImportantFiles();
  507. // display locked dlls by setup
  508. //LogThisProcessesDLLs();
  509. // check if temp dir is writeable
  510. LogCheckIfTempDirWriteable();
  511. }
  512. }
  513. g_iOC_ABOUT_TO_COMMIT_QUEUE_Called = TRUE;
  514. dwOcEntryReturn = OC_ABOUT_TO_COMMIT_QUEUE_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  515. LogHeapState(FALSE, __FILE__, __LINE__);
  516. break;
  517. case OC_COMPLETE_INSTALLATION:
  518. g_iOC_COMPLETE_INSTALLATION_Called = TRUE;
  519. //ProgressBarTextStack_Set(IDS_IIS_ALL_COMPLETE);
  520. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_COMPLETE_INSTALLATION:"));
  521. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  522. LogHeapState(FALSE, __FILE__, __LINE__);
  523. // no need to do this, just slows things down
  524. //g_MyLogFile.m_bFlushLogToDisk = TRUE;
  525. if (g_iOC_COMPLETE_INSTALLATION_Called != TRUE)
  526. {
  527. // Get the debug level, incase we changed it during setup...
  528. GetDebugLevelFromInf(g_pTheApp->m_hInfHandle);
  529. }
  530. dwOcEntryReturn = OC_COMPLETE_INSTALLATION_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  531. LogHeapState(FALSE, __FILE__, __LINE__);
  532. g_MyLogFile.m_bFlushLogToDisk = FALSE;
  533. //ProgressBarTextStack_Pop();
  534. break;
  535. case OC_CLEANUP:
  536. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_CLEANUP:"));
  537. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  538. LogHeapState(FALSE, __FILE__, __LINE__);
  539. if (g_iOC_CLEANUP_Called != TRUE)
  540. {
  541. // turn logging back on if we need to
  542. // get the debug level from the iis.inf
  543. if (g_GlobalFastLoad)
  544. {
  545. GetDebugLevelFromInf(g_pTheApp->m_hInfHandle);
  546. }
  547. }
  548. g_iOC_CLEANUP_Called = TRUE;
  549. dwOcEntryReturn = OC_CLEANUP_Func(ComponentId,SubcomponentId,Function,Param1,Param2);
  550. LogHeapState(FALSE, __FILE__, __LINE__);
  551. break;
  552. default:
  553. g_iOC_DEFAULT_Called = TRUE;
  554. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_(DEFAULT):"));
  555. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  556. dwOcEntryReturn = 0;
  557. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Type=0x%x. Return=%d\n"), ComponentId, SubcomponentId, Function, dwOcEntryReturn));
  558. break;
  559. }
  560. return(dwOcEntryReturn);
  561. }
  562. // -----------------------------------------------------
  563. // Retrive the original state of the subcomponent
  564. // -----------------------------------------------------
  565. STATUS_TYPE GetSubcompInitStatus(LPCTSTR SubcomponentId)
  566. {
  567. STATUS_TYPE nStatus = ST_UNINSTALLED;
  568. BOOL OriginalState;
  569. #ifdef _CHICAGO_
  570. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0)
  571. {return nStatus;}
  572. #endif //_CHICAGO_
  573. // Get the original state from the Helper Routines (which get it from the registry)
  574. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  575. if (OriginalState == 1) {nStatus = ST_INSTALLED;}
  576. if (OriginalState == 0) {nStatus = ST_UNINSTALLED;}
  577. return nStatus;
  578. }
  579. void DebugOutAction(LPCTSTR SubcomponentId, ACTION_TYPE nAction)
  580. {
  581. switch (nAction)
  582. {
  583. case AT_DO_NOTHING:
  584. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= AT_DO_NOTHING.\n"), SubcomponentId));
  585. break;
  586. case AT_REMOVE:
  587. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= AT_REMOVE.\n"), SubcomponentId));
  588. break;
  589. case AT_INSTALL_FRESH:
  590. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= AT_INSTALL_FRESH.\n"), SubcomponentId));
  591. break;
  592. case AT_INSTALL_UPGRADE:
  593. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= AT_INSTALL_UPGRADE.\n"), SubcomponentId));
  594. break;
  595. case AT_INSTALL_REINSTALL:
  596. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= AT_INSTALL_REINSTALL.\n"), SubcomponentId));
  597. break;
  598. default:
  599. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= UN_DEFINED.\n"), SubcomponentId));
  600. break;
  601. }
  602. return;
  603. }
  604. // ---------------------------------------------------------
  605. // OriginalState = 1 (means that it was previously installed and exists on the computer)
  606. // OriginalState = 0 (means that it does not exist on the computer)
  607. //
  608. // CurrentState = 1 (means please install the subcomponent)
  609. // CurrentState = 0 (means please remove the subcomponent)
  610. // ---------------------------------------------------------
  611. ACTION_TYPE GetSubcompAction(LPCTSTR SubcomponentId, int iLogResult)
  612. {
  613. ACTION_TYPE nReturn = AT_DO_NOTHING;
  614. BOOL CurrentState,OriginalState;
  615. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  616. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  617. // if already installed and we want to remove it, then remove it
  618. if (OriginalState == 1 && CurrentState == 0) {nReturn = AT_REMOVE;}
  619. // if not installed and we want to install it, then install it.
  620. if (OriginalState == 0 && CurrentState == 1) {nReturn = AT_INSTALL_FRESH;}
  621. // if already installed and we want to install it, then Gee i dunno.
  622. // it could be a bunch of things
  623. if (OriginalState == 1 && CurrentState == 1)
  624. {
  625. if (g_pTheApp->m_eInstallMode == IM_UPGRADE) {nReturn = AT_INSTALL_UPGRADE;}
  626. if (g_pTheApp->m_dwSetupMode == SETUPMODE_REINSTALL) {nReturn = AT_INSTALL_REINSTALL;}
  627. if (g_pTheApp->m_dwSetupMode == SETUPMODE_ADDREMOVE) {nReturn = AT_DO_NOTHING;}
  628. }
  629. if (iLogResult)
  630. {
  631. TCHAR szTempString[50];
  632. _tcscpy(szTempString, _T("UN_DEFINED"));
  633. switch (nReturn)
  634. {
  635. case AT_DO_NOTHING:
  636. _tcscpy(szTempString, _T("AT_DO_NOTHING"));
  637. break;
  638. case AT_REMOVE:
  639. _tcscpy(szTempString, _T("AT_REMOVE"));
  640. break;
  641. case AT_INSTALL_FRESH:
  642. _tcscpy(szTempString, _T("AT_INSTALL_FRESH"));
  643. break;
  644. case AT_INSTALL_UPGRADE:
  645. _tcscpy(szTempString, _T("AT_INSTALL_UPGRADE"));
  646. break;
  647. case AT_INSTALL_REINSTALL:
  648. _tcscpy(szTempString, _T("AT_INSTALL_REINSTALL"));
  649. break;
  650. default:
  651. _tcscpy(szTempString, _T("UN_DEFINED"));
  652. break;
  653. }
  654. if (_tcsicmp(SubcomponentId, _T("iis")) == 0)
  655. {
  656. // use two tabs
  657. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t\t= %s. Original=%d, Current=%d.\n"), SubcomponentId, szTempString, OriginalState, CurrentState));
  658. }
  659. else
  660. {
  661. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Action of [%s]\t= %s. Original=%d, Current=%d.\n"), SubcomponentId, szTempString, OriginalState, CurrentState));
  662. }
  663. }
  664. return nReturn;
  665. }
  666. BOOL GetDataFromMetabase(LPCTSTR szPath, int nID, LPBYTE Buffer, int BufSize)
  667. {
  668. BOOL bFound = FALSE;
  669. DWORD attr, uType, dType, cbLen;
  670. CMDKey cmdKey;
  671. cmdKey.OpenNode(szPath);
  672. if ( (METADATA_HANDLE)cmdKey )
  673. {
  674. bFound = cmdKey.GetData(nID, &attr, &uType, &dType, &cbLen, (PBYTE)Buffer, BufSize);
  675. cmdKey.Close();
  676. }
  677. else
  678. {
  679. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("GetDataFromMetabase():%s:ID=%d.Could not open node.\n"),szPath,nID));
  680. }
  681. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("GetDataFromMetabase():%s:ID=%d.ret=%d.\n"),szPath,nID,bFound));
  682. return (bFound);
  683. }
  684. void SetIISSetupMode(DWORD dwSetupMode)
  685. {
  686. if (g_pTheApp->m_fInvokedByNT)
  687. {
  688. g_pTheApp->DefineSetupModeOnNT();
  689. }
  690. else
  691. {
  692. g_pTheApp->m_dwSetupMode = dwSetupMode;
  693. }
  694. if (g_pTheApp->m_dwSetupMode & SETUPMODE_UPGRADE){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_UPGRADE\n")));}
  695. if (g_pTheApp->m_dwSetupMode == SETUPMODE_UPGRADEONLY){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_UPGRADE | SETUPMODE_UPGRADEONLY\n")));}
  696. if (g_pTheApp->m_dwSetupMode == SETUPMODE_ADDEXTRACOMPS){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_UPGRADE | SETUPMODE_ADDEXTRACOMPS\n")));}
  697. if (g_pTheApp->m_dwSetupMode & SETUPMODE_MAINTENANCE){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_MAINTENANCE\n")));}
  698. if (g_pTheApp->m_dwSetupMode == SETUPMODE_ADDREMOVE){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_ADDREMOVE\n")));}
  699. if (g_pTheApp->m_dwSetupMode == SETUPMODE_REINSTALL){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_REINSTALL\n")));}
  700. if (g_pTheApp->m_dwSetupMode == SETUPMODE_REMOVEALL){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_REMOVEALL\n")));}
  701. if (g_pTheApp->m_dwSetupMode & SETUPMODE_FRESH){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_FRESH\n")));}
  702. if (g_pTheApp->m_dwSetupMode == SETUPMODE_MINIMAL){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_MINIMAL\n")));}
  703. if (g_pTheApp->m_dwSetupMode == SETUPMODE_TYPICAL){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_TYPICAL\n")));}
  704. if (g_pTheApp->m_dwSetupMode == SETUPMODE_CUSTOM){iisDebugOut((LOG_TYPE_TRACE, _T("SetIISSetupMode() m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_CUSTOM\n")));}
  705. gHelperRoutines.SetSetupMode(gHelperRoutines.OcManagerContext, g_pTheApp->m_dwSetupMode);
  706. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("IISSetupMode"),(PVOID)&(g_pTheApp->m_dwSetupMode),sizeof(DWORD),REG_DWORD);
  707. return;
  708. }
  709. BOOL ToBeInstalled(LPCTSTR ComponentId, LPCTSTR SubcomponentId)
  710. {
  711. BOOL fReturn = FALSE;
  712. if ( SubcomponentId )
  713. {
  714. BOOL CurrentState,OriginalState;
  715. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  716. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  717. if (OriginalState == 0 && CurrentState == 1)
  718. {fReturn = TRUE;}
  719. }
  720. return fReturn;
  721. }
  722. void CustomFTPRoot(LPCTSTR szFTPRoot)
  723. {
  724. g_pTheApp->m_csPathFTPRoot = szFTPRoot;
  725. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32769, g_pTheApp->m_csPathFTPRoot);
  726. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathFTPRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathFTPRoot,(g_pTheApp->m_csPathFTPRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  727. return;
  728. }
  729. void CustomWWWRoot(LPCTSTR szWWWRoot)
  730. {
  731. TCHAR szParentDir[_MAX_PATH], szDir[_MAX_PATH];
  732. g_pTheApp->m_csPathWWWRoot = szWWWRoot;
  733. InetGetFilePath(szWWWRoot, szParentDir);
  734. g_pTheApp->m_csPathInetpub = szParentDir;
  735. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32773, szParentDir);
  736. AppendDir(szParentDir, _T("iissamples"), szDir);
  737. g_pTheApp->m_csPathIISSamples = szDir;
  738. AppendDir(szParentDir, _T("webpub"), szDir);
  739. g_pTheApp->m_csPathWebPub = szDir;
  740. AppendDir(szParentDir, _T("scripts"), szDir);
  741. g_pTheApp->m_csPathScripts = szDir;
  742. AppendDir(szParentDir, _T("ASPSamp"), szDir);
  743. g_pTheApp->m_csPathASPSamp = szDir;
  744. g_pTheApp->m_csPathAdvWorks = g_pTheApp->m_csPathASPSamp + _T("\\AdvWorks");
  745. CString csPathScripts = g_pTheApp->m_csPathIISSamples + _T("\\Scripts");
  746. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathScripts"),(PVOID)(LPCTSTR)csPathScripts,(csPathScripts.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  747. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathWWWRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathWWWRoot,(g_pTheApp->m_csPathWWWRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  748. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISSamples"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathIISSamples,(g_pTheApp->m_csPathIISSamples.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  749. // Set inf file dir id's
  750. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32770, g_pTheApp->m_csPathWWWRoot);
  751. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32771, g_pTheApp->m_csPathIISSamples);
  752. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32772, g_pTheApp->m_csPathScripts);
  753. SetupSetDirectoryId_Wrapper(g_pTheApp->m_hInfHandle, 32779, g_pTheApp->m_csPathWebPub);
  754. return;
  755. }
  756. void StartInstalledServices(void)
  757. {
  758. ACTION_TYPE atWWW = GetSubcompAction(STRING_iis_www, FALSE);
  759. ACTION_TYPE atFTP = GetSubcompAction(STRING_iis_ftp, FALSE);
  760. STATUS_TYPE stFTP = GetSubcompInitStatus(STRING_iis_ftp);
  761. STATUS_TYPE stWWW = GetSubcompInitStatus(STRING_iis_www);
  762. iisDebugOut_Start(_T("StartInstalledServices()"), LOG_TYPE_TRACE);
  763. if (atWWW == AT_INSTALL_FRESH || atWWW == AT_INSTALL_UPGRADE || atWWW == AT_INSTALL_REINSTALL || (stWWW == ST_INSTALLED && atWWW != AT_REMOVE))
  764. {
  765. #ifndef _CHICAGO_
  766. InetStartService(_T("W3SVC"));
  767. #else
  768. W95StartW3SVC();
  769. #endif // _CHICAGO_
  770. }
  771. #ifndef _CHICAGO_
  772. if (atFTP == AT_INSTALL_FRESH || atFTP == AT_INSTALL_UPGRADE || atFTP == AT_INSTALL_REINSTALL || (stFTP == ST_INSTALLED && atFTP != AT_REMOVE))
  773. {
  774. InetStartService(_T("MSFTPSVC"));
  775. }
  776. #endif // _CHICAGO_
  777. if (g_pTheApp->m_eOS == OS_W95 || g_pTheApp->m_eNTOSType == OT_NTW)
  778. {
  779. ACTION_TYPE atPWMGR = GetSubcompAction(STRING_iis_pwmgr, FALSE);
  780. if (atPWMGR == AT_INSTALL_FRESH ||
  781. atPWMGR == AT_INSTALL_UPGRADE ||
  782. atPWMGR == AT_INSTALL_REINSTALL)
  783. {
  784. CString csProgram;
  785. csProgram = g_pTheApp->m_csSysDir + _T("\\pwstray.exe");
  786. if (IsFileExist(csProgram))
  787. {
  788. STARTUPINFO si;
  789. PROCESS_INFORMATION pi;
  790. ZeroMemory(&si, sizeof(STARTUPINFO));
  791. si.cb = sizeof( STARTUPINFO );
  792. CreateProcess( csProgram, NULL, NULL, NULL,FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi );
  793. }
  794. }
  795. }
  796. return;
  797. }
  798. void GetShortDesc(LPCTSTR SubcomponentId, LPTSTR szShortDesc)
  799. {
  800. INFCONTEXT Context;
  801. TCHAR szSection[_MAX_PATH] = _T("Strings");
  802. TCHAR szKey[_MAX_PATH] = _T("SDESC_");
  803. TCHAR szString[_MAX_PATH] = _T("");
  804. int nLen=0;
  805. _tcscat(szKey, SubcomponentId);
  806. *szShortDesc = _T('\0');
  807. if (SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, szSection, szKey, &Context))
  808. {
  809. SetupGetStringField(&Context, 1, szString, _MAX_PATH, NULL);
  810. nLen = _tcslen(szString);
  811. if (*szString == _T('"') && *_tcsninc(szString, nLen-1) == _T('"'))
  812. {_tcsncpy(szShortDesc, _tcsinc(szString), nLen-2);}
  813. else
  814. {_tcscpy(szShortDesc, szString);}
  815. }
  816. return;
  817. }
  818. void ParseCmdLine(void)
  819. {
  820. TCHAR szCmdLine[_MAX_PATH];
  821. _tcscpy(szCmdLine, GetCommandLine());
  822. _tcslwr(szCmdLine);
  823. if (_tcsstr(szCmdLine, _T("sysoc.inf")))
  824. {g_pTheApp->m_fInvokedByNT = TRUE;}
  825. return;
  826. }
  827. // -----------------------------
  828. // handles the OC_INIT_COMPONENT call from ocmanager
  829. //
  830. // The OC Manager passes us some information that we want to save,
  831. // such as an open handle to our per-component INF. As long as we have
  832. // a per-component INF, append-open any layout file that is
  833. // associated with it, in preparation for later inf-based file
  834. // queuing operations.
  835. //
  836. // We save away certain other stuff that gets passed to us now,
  837. // since OC Manager doesn't guarantee that the SETUP_INIT_COMPONENT
  838. // will persist beyond processing of this one interface routine.
  839. //
  840. //
  841. // Param1 = unused
  842. // Param2 = points to SETUP_INIT_COMPONENT structure
  843. // Return code = is Win32 error indicating outcome.
  844. //
  845. // -----------------------------
  846. DWORD_PTR OC_INIT_COMPONENT_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  847. {
  848. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start.\n"), ComponentId, SubcomponentId));
  849. DWORD_PTR dwOcEntryReturn = 0;
  850. INFCONTEXT Context;
  851. PSETUP_INIT_COMPONENT InitComponent = (PSETUP_INIT_COMPONENT)Param2;
  852. TCHAR szCmdLine1[_MAX_PATH];
  853. // set flag if running as admin
  854. BOOL g_fAdministrator = RunningAsAdministrator();
  855. // Parse The Command line and set global Variables.
  856. ParseCmdLine();
  857. // first of all display iis.dll to avoid any confusion!
  858. DisplayVerOnCurrentModule();
  859. g_pTheApp->m_hInfHandle = InitComponent->ComponentInfHandle;
  860. if (InitComponent->ComponentInfHandle == INVALID_HANDLE_VALUE)
  861. {
  862. MessageBox(NULL, _T("Invalid inf handle."), _T("IIS Setup"), MB_OK | MB_SETFOREGROUND);
  863. iisDebugOut((LOG_TYPE_ERROR, _T("InitComponent->ComponentInfHandle FAILED")));
  864. dwOcEntryReturn = ERROR_CANCELLED;
  865. goto OC_INIT_COMPONENT_Func_Exit;
  866. }
  867. g_pTheApp->m_fNTOperationFlags = InitComponent->SetupData.OperationFlags;
  868. g_pTheApp->m_fNtWorkstation = InitComponent->SetupData.ProductType == PRODUCT_WORKSTATION;
  869. if (InitComponent->SetupData.OperationFlags & SETUPOP_STANDALONE)
  870. {
  871. g_pTheApp->m_fNTGuiMode = FALSE;
  872. }
  873. else
  874. {
  875. g_pTheApp->m_fNTGuiMode = TRUE;
  876. }
  877. g_pTheApp->m_csPathSource = InitComponent->SetupData.SourcePath;
  878. gHelperRoutines = InitComponent->HelperRoutines;
  879. g_pTheApp->m_fInvokedByNT = g_pTheApp->m_fNTGuiMode;
  880. // get the handle to the unattended file (the answer file)
  881. // if this is a migration from win95, then there will be
  882. // a section in here called [InternetServer] which will
  883. // point to the win95 migration.dat file.
  884. g_pTheApp->m_hUnattendFile = gHelperRoutines.GetInfHandle(INFINDEX_UNATTENDED, gHelperRoutines.OcManagerContext);
  885. if (_tcsicmp(InitComponent->SetupData.UnattendFile,_T("")) != 0 && InitComponent->SetupData.UnattendFile != NULL)
  886. {
  887. g_pTheApp->m_csUnattendFile = InitComponent->SetupData.UnattendFile;
  888. }
  889. g_pTheApp->m_fUnattended = (((DWORD)InitComponent->SetupData.OperationFlags) & SETUPOP_BATCH);
  890. if (g_pTheApp->m_fUnattended)
  891. {
  892. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Set UnAttendFlag:ON (File='%s')\n"), g_pTheApp->m_csUnattendFile));
  893. if (g_pTheApp->m_hUnattendFile == INVALID_HANDLE_VALUE || g_pTheApp->m_hUnattendFile == NULL)
  894. {iisDebugOut((LOG_TYPE_WARN, _T("WARNING: There should have been an unattended file but there is none.\n")));}
  895. }
  896. else
  897. {iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Set UnAttendFlag:OFF (File='%s')\n"), g_pTheApp->m_csUnattendFile));}
  898. // if ran from sysoc.inf then set m_fInvokedByNT (for control panel add/remove)
  899. _tcscpy(szCmdLine1, GetCommandLine());
  900. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("CmdLine=%s"), szCmdLine1));
  901. _tcslwr(szCmdLine1);
  902. if (_tcsstr(szCmdLine1, _T("sysoc.inf")))
  903. {g_pTheApp->m_fInvokedByNT = TRUE;}
  904. // make sure that this is always set -- so that
  905. // you never get the iis welcome, min\typ\custom, dir selection, End pages.
  906. g_pTheApp->m_fInvokedByNT = TRUE;
  907. if (g_pTheApp->m_fInvokedByNT) {g_pTheApp->m_bAllowMessageBoxPopups = FALSE;}
  908. //if (g_SpecialFlagForDebug) {g_pTheApp->m_bAllowMessageBoxPopups = TRUE;}
  909. // get the debug level from the iis.inf
  910. GetDebugLevelFromInf(g_pTheApp->m_hInfHandle);
  911. if (!g_pTheApp->m_fNTGuiMode)
  912. {
  913. if (g_GlobalFastLoad)
  914. {
  915. // change it so that there is no logging during the load process.
  916. // so that the iis.dll loads up faster.
  917. // g_pTheApp->m_fNTGuiMode
  918. g_GlobalDebugLevelFlag = LOG_TYPE_WARN;
  919. }
  920. }
  921. // Read .inf file
  922. // and set some globals from the informatin in there.
  923. ReadGlobalsFromInf(g_pTheApp->m_hInfHandle);
  924. if (g_GlobalGuiOverRide)
  925. {
  926. g_pTheApp->m_fNTGuiMode = TRUE;
  927. SetIISSetupMode(SETUPMODE_UPGRADEONLY);
  928. }
  929. // ----------------------------------
  930. // handle win95 migration
  931. //
  932. // win95 migration is handled this way.
  933. // 1. on the win95 side a file is generated. it is a actually a
  934. // setupapi type .inf fie.
  935. // 2. win95 migration dll creates the file and sticks the path to where
  936. // it is in the answerfile.txt file. should look like this
  937. // [InternetServer]
  938. // Win95MigrateDll=d:\winnt\system32\setup\????\something.dat
  939. //
  940. // 3. so we should, open the answer file,
  941. // find the [InternetServer] section
  942. // have setupapi install it
  943. //
  944. // 4. that will put appropriate registry values into the registry.
  945. //
  946. // ----------------------------------
  947. HandleWin95MigrateDll();
  948. if (!g_fAdministrator)
  949. {
  950. g_pTheApp->MsgBox(NULL, IDS_NOT_ADMINISTRATOR, MB_OK, TRUE);
  951. dwOcEntryReturn = ERROR_CANCELLED;
  952. goto OC_INIT_COMPONENT_Func_Exit;
  953. }
  954. // Call this stuff after setting m_fNTGuiMode and m_fNtWorkstation and m_fInvokedByNT
  955. // since it maybe used in InitApplication().
  956. if ( FALSE == g_pTheApp->InitApplication() )
  957. {
  958. g_pTheApp->DumpAppVars();
  959. iisDebugOut((LOG_TYPE_ERROR, _T("FAILED")));
  960. // setup should be terminated.
  961. dwOcEntryReturn = ERROR_CANCELLED;
  962. goto OC_INIT_COMPONENT_Func_Exit;
  963. }
  964. if ( g_pTheApp->m_eInstallMode == IM_MAINTENANCE )
  965. {g_pTheApp->m_fEULA = TRUE;}
  966. // check if the .inf we are looking at is the right inf for what the machine is running as
  967. //if (FALSE == CheckIfPlatformMatchesInf(g_pTheApp->m_hInfHandle))
  968. //{
  969. // dwOcEntryReturn = ERROR_CANCELLED;
  970. // goto OC_INIT_COMPONENT_Func_Exit;
  971. //}
  972. // something like "this build requires nt build 1899 or something"
  973. CheckSpecificBuildinInf(g_pTheApp->m_hInfHandle);
  974. // Check for old gopher!
  975. if (FALSE == CheckForOldGopher(g_pTheApp->m_hInfHandle))
  976. {
  977. dwOcEntryReturn = ERROR_CANCELLED;
  978. goto OC_INIT_COMPONENT_Func_Exit;
  979. }
  980. // See if user configured anything
  981. // must happen after g_pTheApp->InitApplication
  982. // but before SetDIRIDforThisInf!
  983. ReadUserConfigurable(g_pTheApp->m_hInfHandle);
  984. //
  985. // Set up the DIRIDs for our .inf file
  986. // these are very very important and can get changed throughout the program
  987. //
  988. SetDIRIDforThisInf(g_pTheApp->m_hInfHandle);
  989. //
  990. // Set global ocm private data for other components to find out
  991. // (during installation) where our inetpub or inetsrv dir is located..
  992. SetOCGlobalPrivateData();
  993. dwOcEntryReturn = NO_ERROR;
  994. // Check if There are pending reboot operations...
  995. if (LogPendingReBootOperations() != ERROR_SUCCESS)
  996. {dwOcEntryReturn = ERROR_CANCELLED;}
  997. // if we already did some win95 stuff then don't need to do this
  998. // do this only in gui mode
  999. if (g_pTheApp->m_fNTGuiMode)
  1000. {
  1001. if (!g_pTheApp->m_bWin95Migration){CheckIfWeNeedToMoveMetabaseBin();}
  1002. }
  1003. // Get the last section to be called.
  1004. _tcscpy(g_szLastSectionToGetCalled, _T(""));
  1005. GetLastSectionToBeCalled();
  1006. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_INIT_COMPONENT"));
  1007. Check_For_DebugServiceFlag();
  1008. TestAfterInitApp();
  1009. OC_INIT_COMPONENT_Func_Exit:
  1010. g_pTheApp->DumpAppVars();
  1011. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d \n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1012. return dwOcEntryReturn;
  1013. }
  1014. DWORD_PTR OC_QUERY_CHANGE_SEL_STATE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1015. {
  1016. // Make these static, so we can query the value on the next call
  1017. static BOOL bFtp_IgnoreNextSet = FALSE;
  1018. static BOOL bVdirScripts_IgnoreNextSet = FALSE;
  1019. DWORD dwOcEntryReturn = 0;
  1020. DWORD dwCurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  1021. dwOcEntryReturn = 1;
  1022. if (SubcomponentId)
  1023. {
  1024. BOOL OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  1025. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Param1=%d, Param2=%d, Original=%d, Current=%d\n"), ComponentId, SubcomponentId, Param1, Param2,OriginalState,CurrentState));
  1026. if (OriginalState == 1)
  1027. {
  1028. if ((BOOL)Param1)
  1029. {
  1030. dwOcEntryReturn = 1;
  1031. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0 || _tcsicmp(SubcomponentId, STRING_iis_www) == 0 || _tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0 )
  1032. {
  1033. // check if tcpip is installed
  1034. g_pTheApp->IsTCPIPInstalled();
  1035. if (g_pTheApp->m_fTCPIP == FALSE)
  1036. {
  1037. g_pTheApp->MsgBox(NULL, IDS_TCPIP_NEEDED_ON_OPTION, MB_OK, TRUE);
  1038. dwOcEntryReturn = 0;
  1039. }
  1040. }
  1041. }
  1042. else
  1043. {
  1044. // In upgrade case, we don't allow user to uncheck previously installed components
  1045. if (g_pTheApp->m_eInstallMode == IM_UPGRADE)
  1046. {dwOcEntryReturn = 0;}
  1047. }
  1048. }
  1049. else
  1050. {
  1051. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0 || _tcsicmp(SubcomponentId, STRING_iis_www) == 0 || _tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0 )
  1052. {
  1053. if ((BOOL)Param1)
  1054. {
  1055. //
  1056. // if we are turning ON then we NEED TCPIP
  1057. //
  1058. // check if tcpip is installed
  1059. g_pTheApp->IsTCPIPInstalled();
  1060. if (g_pTheApp->m_fTCPIP == FALSE)
  1061. {
  1062. g_pTheApp->MsgBox(NULL, IDS_TCPIP_NEEDED_ON_OPTION, MB_OK, TRUE);
  1063. dwOcEntryReturn = 0;
  1064. }
  1065. }
  1066. }
  1067. }
  1068. }
  1069. // If we are turning the component on
  1070. if ( Param1 != 0 )
  1071. {
  1072. if ( _tcscmp(SubcomponentId, _T("iis") ) == 0 )
  1073. {
  1074. // This is going to cause a chain reaction of selections, so make sure
  1075. // that when the ftp one comes around, we ignore it
  1076. bFtp_IgnoreNextSet = TRUE;
  1077. }
  1078. else if ( _tcscmp(SubcomponentId, _T("iis_www_parent") ) == 0 )
  1079. {
  1080. // This is going to cause a chain reaction of selections, so make sure
  1081. // that when the vdirs_scripts one comes around, we ignore it
  1082. bVdirScripts_IgnoreNextSet = TRUE;
  1083. }
  1084. else if ( ( _tcscmp(SubcomponentId, _T("iis_ftp") ) == 0 ) && (bFtp_IgnoreNextSet) )
  1085. {
  1086. bFtp_IgnoreNextSet = FALSE;
  1087. return 0;
  1088. }
  1089. else if ( ( _tcscmp(SubcomponentId, _T("iis_www_vdir_scripts") ) == 0 ) && (bVdirScripts_IgnoreNextSet) )
  1090. {
  1091. bVdirScripts_IgnoreNextSet = FALSE;
  1092. return 0;
  1093. }
  1094. }
  1095. //
  1096. // if we are running on Whistler personal, then return denied.
  1097. // so that no other component can turn us on! or think that they're going to turn us on.
  1098. //
  1099. if (IsWhistlerPersonal())
  1100. {
  1101. dwOcEntryReturn = 0;
  1102. }
  1103. if (dwOcEntryReturn == 0)
  1104. {
  1105. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d (denied) \n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1106. }
  1107. else
  1108. {
  1109. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d (approved)\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1110. }
  1111. return dwOcEntryReturn;
  1112. }
  1113. //
  1114. // gets called right before we show your page!
  1115. //
  1116. DWORD_PTR OC_QUERY_SKIP_PAGE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1117. {
  1118. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start.\n"), ComponentId, SubcomponentId));
  1119. DWORD_PTR dwOcEntryReturn = 0;
  1120. TCHAR szTempString[50];
  1121. _tcscpy(szTempString, _T(""));
  1122. switch (g_pTheApp->m_dwSetupMode)
  1123. {
  1124. case SETUPMODE_UPGRADEONLY:
  1125. _tcscpy(szTempString, _T("SETUPMODE_UPGRADEONLY"));
  1126. dwOcEntryReturn = 1;
  1127. break;
  1128. case SETUPMODE_REINSTALL:
  1129. _tcscpy(szTempString, _T("SETUPMODE_REINSTALL"));
  1130. dwOcEntryReturn = 1;
  1131. break;
  1132. case SETUPMODE_REMOVEALL:
  1133. _tcscpy(szTempString, _T("SETUPMODE_REMOVEALL"));
  1134. dwOcEntryReturn = 1;
  1135. break;
  1136. case SETUPMODE_MINIMAL:
  1137. _tcscpy(szTempString, _T("SETUPMODE_MINIMAL"));
  1138. dwOcEntryReturn = 1;
  1139. break;
  1140. case SETUPMODE_TYPICAL:
  1141. _tcscpy(szTempString, _T("SETUPMODE_TYPICAL"));
  1142. dwOcEntryReturn = 1;
  1143. break;
  1144. case SETUPMODE_ADDEXTRACOMPS:
  1145. _tcscpy(szTempString, _T("SETUPMODE_ADDEXTRACOMPS"));
  1146. dwOcEntryReturn = 0;
  1147. break;
  1148. case SETUPMODE_ADDREMOVE:
  1149. _tcscpy(szTempString, _T("SETUPMODE_ADDREMOVE"));
  1150. dwOcEntryReturn = 0;
  1151. break;
  1152. case SETUPMODE_CUSTOM:
  1153. _tcscpy(szTempString, _T("SETUPMODE_CUSTOM"));
  1154. dwOcEntryReturn = 0;
  1155. break;
  1156. }
  1157. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. g_pTheApp->m_dwSetupMode=%x (%s), dwOcEntryReturn=%d\n"), ComponentId, SubcomponentId, g_pTheApp->m_dwSetupMode, szTempString, dwOcEntryReturn));
  1158. return dwOcEntryReturn;
  1159. }
  1160. // ----------------------------------------
  1161. // Param1 = 0 if for removing component or non-0 if for adding component
  1162. // Param2 = HDSKSPC to operate on
  1163. //
  1164. // Return value is Win32 error code indicating outcome.
  1165. //
  1166. // In our case the private section for this component/subcomponent pair
  1167. // is a simple standard inf install section, so we can use the high-level
  1168. // disk space list api to do what we want.
  1169. // Logic is not correct here !!!
  1170. // ----------------------------------------
  1171. DWORD_PTR OC_CALC_DISK_SPACE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1172. {
  1173. DWORD_PTR dwOcEntryReturn = 0;
  1174. BOOL bTempFlag = FALSE;
  1175. TCHAR SectionName[128];
  1176. dwOcEntryReturn = NO_ERROR;
  1177. if (SubcomponentId)
  1178. {
  1179. bTempFlag = TRUE;
  1180. if ( Param1 )
  1181. {
  1182. // add component
  1183. _stprintf(SectionName,TEXT("%s_%s"),SubcomponentId, _T("install"));
  1184. bTempFlag = SetupAddInstallSectionToDiskSpaceList(Param2,g_pTheApp->m_hInfHandle,NULL,SectionName,0,0);
  1185. }
  1186. else
  1187. {
  1188. // removing component
  1189. // Comment this out per PatSt, 3/5/97, and change it to the install list
  1190. //_stprintf(SectionName,TEXT("%s_%s"),SubcomponentId, _T("uninstall"));
  1191. _stprintf(SectionName,TEXT("%s_%s"),SubcomponentId, _T("install"));
  1192. bTempFlag = SetupRemoveInstallSectionFromDiskSpaceList(Param2,g_pTheApp->m_hInfHandle,NULL,SectionName,0,0);
  1193. //
  1194. // check if it's something we need to warn user about
  1195. //
  1196. // in add remove case, if the user is removing w3svc or msftpsvc
  1197. // then check if clustering is installed. if clustering is installed
  1198. // then check if there are any cluster resources which have w3svc or msftpsvc as a
  1199. // resouce, if there are any, then warn the user that they must remove these cluster resources!
  1200. #ifndef _CHICAGO_
  1201. if (g_pTheApp->m_eInstallMode == IM_MAINTENANCE)
  1202. {
  1203. BOOL CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  1204. BOOL OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  1205. if (OriginalState == 1 && CurrentState == 0)
  1206. {
  1207. if (TRUE == DoesClusterServiceExist())
  1208. {
  1209. TCHAR * szClusterName = NULL;
  1210. WCHAR szServiceLookingFor[20];
  1211. CString MyReturnString;
  1212. CLUSTER_SVC_INFO_FILL_STRUCT MyStructOfInfo;
  1213. // check if they are trying to
  1214. // remove the W3SVC service!
  1215. if (_tcsicmp(SubcomponentId, STRING_iis_www) == 0 || _tcsicmp(SubcomponentId, STRING_iis_ftp) == 0)
  1216. {
  1217. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0)
  1218. {
  1219. wcscpy(szServiceLookingFor,L"MSFTPSVC");
  1220. // check for msftpsvc resource
  1221. MyStructOfInfo.szTheClusterName = szClusterName;
  1222. MyStructOfInfo.pszTheServiceType = szServiceLookingFor;
  1223. MyStructOfInfo.csTheReturnServiceResName = &MyReturnString;
  1224. MyStructOfInfo.dwReturnStatus = 0;
  1225. if (TRUE == DoClusterServiceCheck(&MyStructOfInfo))
  1226. {
  1227. g_pTheApp->MsgBox2(NULL, IDS_REMOVE_CLUS_MSFTPSVC_FIRST, *MyStructOfInfo.csTheReturnServiceResName, MB_OK | MB_SETFOREGROUND);
  1228. }
  1229. }
  1230. else
  1231. {
  1232. wcscpy(szServiceLookingFor,L"W3SVC");
  1233. // check for w3svc resource
  1234. MyStructOfInfo.szTheClusterName = szClusterName;
  1235. MyStructOfInfo.pszTheServiceType = szServiceLookingFor;
  1236. MyStructOfInfo.csTheReturnServiceResName = &MyReturnString;
  1237. MyStructOfInfo.dwReturnStatus = 0;
  1238. if (TRUE == DoClusterServiceCheck(&MyStructOfInfo))
  1239. {
  1240. g_pTheApp->MsgBox2(NULL, IDS_REMOVE_CLUS_W3SVC_FIRST, *MyStructOfInfo.csTheReturnServiceResName, MB_OK | MB_SETFOREGROUND);
  1241. }
  1242. else
  1243. {
  1244. // check for smtp resources
  1245. wcscpy(szServiceLookingFor,L"SMTPSVC");
  1246. if (TRUE == DoClusterServiceCheck(&MyStructOfInfo))
  1247. {
  1248. g_pTheApp->MsgBox2(NULL, IDS_REMOVE_CLUS_W3SVC_FIRST, *MyStructOfInfo.csTheReturnServiceResName, MB_OK | MB_SETFOREGROUND);
  1249. }
  1250. else
  1251. {
  1252. // check for nntp resources
  1253. wcscpy(szServiceLookingFor,L"NNTPSVC");
  1254. if (TRUE == DoClusterServiceCheck(&MyStructOfInfo))
  1255. {
  1256. g_pTheApp->MsgBox2(NULL, IDS_REMOVE_CLUS_W3SVC_FIRST, *MyStructOfInfo.csTheReturnServiceResName, MB_OK | MB_SETFOREGROUND);
  1257. }
  1258. }
  1259. }
  1260. }
  1261. }
  1262. }
  1263. }
  1264. }
  1265. #endif
  1266. }
  1267. dwOcEntryReturn = bTempFlag ? NO_ERROR : GetLastError();
  1268. }
  1269. // Display the new state of this component
  1270. if (SubcomponentId)
  1271. {
  1272. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0 || _tcsicmp(SubcomponentId, STRING_iis_www) == 0)
  1273. {
  1274. GetIISCoreAction(TRUE);
  1275. }
  1276. else
  1277. {
  1278. GetSubcompAction(SubcomponentId, TRUE);
  1279. }
  1280. }
  1281. if (dwOcEntryReturn == NO_ERROR)
  1282. {
  1283. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=NO_ERROR\n"), ComponentId, SubcomponentId));
  1284. }
  1285. else
  1286. {
  1287. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return='0x%x'\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1288. }
  1289. return dwOcEntryReturn;
  1290. }
  1291. DWORD_PTR OC_NEED_MEDIA_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1292. {
  1293. DWORD_PTR dwOcEntryReturn = 0;
  1294. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("[%1!s!,%2!s!] Start. Param1=0x%3!x!,Param2=0x%4!x!\n"), ComponentId, SubcomponentId, Param1, Param2));
  1295. dwOcEntryReturn = NO_ERROR;
  1296. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1297. return dwOcEntryReturn;
  1298. }
  1299. // -------------------------------
  1300. // Param1 = unused
  1301. // Param2 = HSPFILEQ to operate on
  1302. //
  1303. // Return value is Win32 error code indicating outcome.
  1304. //
  1305. // OC Manager calls this routine when it is ready for files to be copied
  1306. // to effect the changes the user requested. The component DLL must figure out
  1307. // whether it is being installed or uninstalled and take appropriate action.
  1308. // For this sample, we look in the private data section for this component/
  1309. // subcomponent pair, and get the name of an uninstall section for the
  1310. // uninstall case.
  1311. //
  1312. // Note that OC Manager calls us once for the *entire* component
  1313. // and then once per subcomponent. We ignore the first call.
  1314. // -------------------------------
  1315. DWORD_PTR OC_QUEUE_FILE_OPS_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1316. {
  1317. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start.\n"), ComponentId, SubcomponentId));
  1318. DWORD_PTR dwOcEntryReturn = NO_ERROR;
  1319. g_GlobalFileQueueHandle = Param2;
  1320. g_GlobalFileQueueHandle_ReturnError = NO_ERROR;
  1321. g_GlobalTotalTickGaugeCount = 0;
  1322. if (!SubcomponentId)
  1323. {
  1324. if (g_pTheApp->m_fNTGuiMode)
  1325. {
  1326. // no need to do anyof this anymore since nt will be installing %windir%\Help\iis.chm
  1327. /*
  1328. BOOL iHelpFileExists = FALSE;
  1329. // on install NT copies file iisnts.chm or iisntw.chm to the %windir%\help dir.
  1330. // during guimode install we need to make sure it get's renamed to %windir%\help\iis.chm
  1331. CString csIISHelpCopiedAlways;
  1332. csIISHelpCopiedAlways = g_pTheApp->m_csWinDir + _T("\\Help\\iisnts.chm");
  1333. if (IsFileExist(csIISHelpCopiedAlways))
  1334. {iHelpFileExists = TRUE;}
  1335. if (!iHelpFileExists)
  1336. {
  1337. csIISHelpCopiedAlways = g_pTheApp->m_csWinDir + _T("\\Help\\iisntw.chm");
  1338. if (IsFileExist(csIISHelpCopiedAlways))
  1339. {iHelpFileExists = TRUE;}
  1340. }
  1341. if (iHelpFileExists)
  1342. {
  1343. CString csTempDelFile;
  1344. // Delete any existing iis.chm that's already there
  1345. csTempDelFile = g_pTheApp->m_csWinDir + _T("\\Help\\iis.chm");
  1346. DeleteFile(csTempDelFile);
  1347. // Rename iisnts.chm to iis.chm
  1348. MoveFileEx( csIISHelpCopiedAlways, csTempDelFile, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING);
  1349. //rename((csIISHelpCopiedAlways, csTempDelFile);
  1350. }
  1351. */
  1352. }
  1353. }
  1354. // -----------------------
  1355. // handle all removes here = the file operations only
  1356. // -----------------------
  1357. //
  1358. // Check to see if the user has chosen to "remove-all"
  1359. //
  1360. // handle all removes here.
  1361. // we need to handle it in or special order
  1362. // because we want to make sure that removeal happens in the right order.
  1363. // right order means =(considering the 'needs' relationship - since ocmanage does not handle it).
  1364. //
  1365. if (!SubcomponentId)
  1366. {
  1367. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  1368. if (g_pTheApp->m_eInstallMode != IM_UPGRADE)
  1369. {
  1370. // make sure they can't mistakenly
  1371. // do these remove's during guimode!
  1372. if (!g_pTheApp->m_fNTGuiMode)
  1373. {
  1374. // if the user has chosen to remove any iis component...
  1375. // then we must make sure that they get removed in the correct order since
  1376. // ocmanage will not remove based on the .inf 'Needs' relationships.
  1377. //iis
  1378. //iis_common (Needs = iis)
  1379. //iis_core (Needs = iis_core)
  1380. //iis_inetmgr (Needs = iis_common)
  1381. //iis_www (Needs = iis_inetmgr, com
  1382. //iis_pwmgr (Needs = iis_www)
  1383. //iis_doc (Needs = iis_www)
  1384. //iis_htmla (Needs = iis_www)
  1385. //iis_www_vdir_scripts (Needs = iis_www)
  1386. //iis_ftp (Needs = iis_inetmgr)
  1387. _tcscpy(g_szCurrentSubComponent, STRING_iis_ftp);
  1388. RemoveComponent(STRING_iis_ftp,1);
  1389. _tcscpy(g_szCurrentSubComponent, STRING_iis_www_vdir_scripts);
  1390. RemoveComponent(STRING_iis_www_vdir_scripts,1);
  1391. _tcscpy(g_szCurrentSubComponent, STRING_iis_www_vdir_printers);
  1392. RemoveComponent(STRING_iis_www_vdir_printers,1);
  1393. _tcscpy(g_szCurrentSubComponent, STRING_iis_htmla);
  1394. RemoveComponent(STRING_iis_htmla,1);
  1395. _tcscpy(g_szCurrentSubComponent, STRING_iis_doc);
  1396. RemoveComponent(STRING_iis_doc,1);
  1397. _tcscpy(g_szCurrentSubComponent, STRING_iis_pwmgr);
  1398. RemoveComponent(STRING_iis_pwmgr,1);
  1399. _tcscpy(g_szCurrentSubComponent, STRING_iis_www);
  1400. RemoveComponent(STRING_iis_www,1);
  1401. _tcscpy(g_szCurrentSubComponent, STRING_iis_inetmgr);
  1402. RemoveComponent(STRING_iis_inetmgr,1);
  1403. _tcscpy(g_szCurrentSubComponent, STRING_iis_common);
  1404. RemoveComponent(STRING_iis_core,1);
  1405. RemoveComponent(STRING_iis_common,1);
  1406. _tcscpy(g_szCurrentSubComponent, _T(""));
  1407. RemoveComponent(_T("iis"),1);
  1408. if (SubcomponentId)
  1409. {_tcscpy(g_szCurrentSubComponent, SubcomponentId);}
  1410. // check to make sure that we haven't overlooked something.
  1411. // if iis_core is to be not there, then make sure it is not there.
  1412. }
  1413. }
  1414. }
  1415. // ------------------------
  1416. // handle fresh and upgrade
  1417. // ------------------------
  1418. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  1419. if (!SubcomponentId)
  1420. {
  1421. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_QUEUE_FILE_OPS"));
  1422. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  1423. if (atCORE == AT_INSTALL_FRESH || atCORE == AT_INSTALL_UPGRADE || atCORE == AT_INSTALL_REINSTALL)
  1424. {
  1425. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_QUEUE_FILE_OPS_install.iis_core"));
  1426. dwOcEntryReturn = g_GlobalFileQueueHandle_ReturnError ? NO_ERROR : GetLastError();
  1427. }
  1428. }
  1429. else
  1430. {
  1431. ACTION_TYPE atComp = GetSubcompAction(SubcomponentId, FALSE);
  1432. if (atComp == AT_INSTALL_FRESH ||atComp == AT_INSTALL_UPGRADE || atComp == AT_INSTALL_REINSTALL)
  1433. {
  1434. TCHAR szTheSectionToDo[100];
  1435. _stprintf(szTheSectionToDo,_T("OC_QUEUE_FILE_OPS_install.%s"),SubcomponentId);
  1436. if (GetSectionNameToDo(g_pTheApp->m_hInfHandle, (CString) szTheSectionToDo))
  1437. {
  1438. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1439. dwOcEntryReturn = g_GlobalFileQueueHandle_ReturnError ? NO_ERROR : GetLastError();
  1440. }
  1441. else
  1442. {
  1443. dwOcEntryReturn = NO_ERROR;
  1444. }
  1445. }
  1446. }
  1447. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1448. return dwOcEntryReturn;
  1449. }
  1450. DWORD_PTR OC_ABOUT_TO_COMMIT_QUEUE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1451. {
  1452. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start. 0x%x,0x%x\n"), ComponentId, SubcomponentId, Param1, Param2));
  1453. DWORD_PTR dwOcEntryReturn = 0;
  1454. BOOL bTempFlag = FALSE;
  1455. g_GlobalTotalTickGaugeCount = 0;
  1456. // OCM will send this notification to each components by using the order
  1457. // of bottom==>top of the dependency tree.
  1458. // You should handle un-installation in this notification.
  1459. dwOcEntryReturn = NO_ERROR;
  1460. SetCurrentDirectory(g_pTheApp->m_csPathInetsrv);
  1461. if (!SubcomponentId)
  1462. {
  1463. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  1464. // set the machinename
  1465. g_pTheApp->ReGetMachineAndAccountNames();
  1466. CString csMachineName = g_pTheApp->m_csMachineName.Right(g_pTheApp->m_csMachineName.GetLength() - 2);
  1467. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle, 32800, csMachineName);
  1468. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_ABOUT_TO_COMMIT_QUEUE"));
  1469. }
  1470. else
  1471. {
  1472. TCHAR szTheSectionToDo[100];
  1473. _stprintf(szTheSectionToDo,_T("OC_ABOUT_TO_COMMIT_QUEUE.%s"),SubcomponentId);
  1474. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1475. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  1476. ACTION_TYPE atComp = GetSubcompAction(SubcomponentId, FALSE);
  1477. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1478. }
  1479. // ------------------------------------
  1480. // Stop any services that we need to...
  1481. // ------------------------------------
  1482. if (!SubcomponentId)
  1483. {
  1484. if (g_pTheApp->m_fNTGuiMode)
  1485. {
  1486. // In any type of case, either fresh,upgrade, reinstall, whatevers,
  1487. // the services must be stopped at this point!!!!
  1488. StopAllServicesRegardless(FALSE);
  1489. // handle the metabase file appropriately,
  1490. // in order to work correctly with NT5 GUI mode setup re-startable
  1491. HandleMetabaseBeforeSetupStarts();
  1492. //AfterRemoveAll_SaveMetabase();
  1493. }
  1494. else
  1495. {
  1496. // add\remove, so only stop services that will be affected
  1497. StopAllServicesThatAreRelevant(FALSE);
  1498. }
  1499. }
  1500. // -----------------------
  1501. // handle all removes here
  1502. // -----------------------
  1503. //
  1504. // Check to see if the user has chosen to "remove-all"
  1505. //
  1506. // handle all removes here.
  1507. // we need to handle it in or special order
  1508. // because we want to make sure that removeal happens in the right order.
  1509. // right order means =(considering the 'needs' relationship - since ocmanage does not handle it).
  1510. //
  1511. if (!SubcomponentId)
  1512. {
  1513. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  1514. if (g_pTheApp->m_eInstallMode != IM_UPGRADE)
  1515. {
  1516. // if the user has chosen to remove any iis component...
  1517. // then we must make sure that they get removed in the correct order since
  1518. // ocmanage will not remove based on the .inf 'Needs' relationships.
  1519. //iis
  1520. //iis_common (Needs = iis)
  1521. //iis_core (Needs = iis_core)
  1522. //iis_inetmgr (Needs = iis_common)
  1523. //iis_www (Needs = iis_inetmgr, com
  1524. //iis_pwmgr (Needs = iis_www)
  1525. //iis_doc (Needs = iis_www)
  1526. //iis_htmla (Needs = iis_www)
  1527. //iis_www_vdir_scripts (Needs = iis_www)
  1528. //iis_ftp (Needs = iis_inetmgr)
  1529. _tcscpy(g_szCurrentSubComponent, STRING_iis_ftp);
  1530. RemoveComponent(STRING_iis_ftp,2);
  1531. _tcscpy(g_szCurrentSubComponent, STRING_iis_www_vdir_scripts);
  1532. RemoveComponent(STRING_iis_www_vdir_scripts,2);
  1533. _tcscpy(g_szCurrentSubComponent, STRING_iis_www_vdir_printers);
  1534. RemoveComponent(STRING_iis_www_vdir_printers,2);
  1535. _tcscpy(g_szCurrentSubComponent, STRING_iis_htmla);
  1536. RemoveComponent(STRING_iis_htmla,2);
  1537. _tcscpy(g_szCurrentSubComponent, STRING_iis_doc);
  1538. RemoveComponent(STRING_iis_doc,2);
  1539. _tcscpy(g_szCurrentSubComponent, STRING_iis_pwmgr);
  1540. RemoveComponent(STRING_iis_pwmgr,2);
  1541. _tcscpy(g_szCurrentSubComponent, STRING_iis_www);
  1542. RemoveComponent(STRING_iis_www,2);
  1543. _tcscpy(g_szCurrentSubComponent, STRING_iis_inetmgr);
  1544. RemoveComponent(STRING_iis_inetmgr,2);
  1545. _tcscpy(g_szCurrentSubComponent, STRING_iis_core);
  1546. RemoveComponent(STRING_iis_core,2);
  1547. _tcscpy(g_szCurrentSubComponent, STRING_iis_common);
  1548. RemoveComponent(STRING_iis_common,2);
  1549. _tcscpy(g_szCurrentSubComponent, _T(""));
  1550. RemoveComponent(_T("iis"),2);
  1551. }
  1552. }
  1553. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoFreeUnusedLibraries().Start.")));
  1554. CoFreeUnusedLibraries();
  1555. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoFreeUnusedLibraries().End.")));
  1556. // ------------------------------------
  1557. // Make sure that all possible services are stopped before anytype of copyfiles!
  1558. // ------------------------------------
  1559. if (g_pTheApp->m_fNTGuiMode)
  1560. {
  1561. // In any type of case, either fresh,upgrade, reinstall, whatevers,
  1562. // the services must be stopped at this point!!!!
  1563. StopAllServicesRegardless(TRUE);
  1564. }
  1565. else
  1566. {
  1567. // add\remove, so only stop services that will be affected
  1568. StopAllServicesThatAreRelevant(TRUE);
  1569. }
  1570. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1571. return dwOcEntryReturn;
  1572. }
  1573. DWORD_PTR OC_COMPLETE_INSTALLATION_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1574. {
  1575. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start. 0x%x,0x%x\n"), ComponentId, SubcomponentId, Param1, Param2));
  1576. // OCM will send this notification to each components by using the order
  1577. // of top==>bottom of the dependency tree.
  1578. // You should handle installation in this notification.
  1579. DWORD_PTR dwOcEntryReturn = 0;
  1580. BOOL bTempFlag = FALSE;
  1581. TCHAR SectionName[128];
  1582. TCHAR szShortDesc[_MAX_PATH];
  1583. TCHAR szTheSectionToDo[100];
  1584. g_GlobalTotalTickGaugeCount = 0;
  1585. if (!SubcomponentId)
  1586. {
  1587. if (g_pTheApp->m_fNTGuiMode)
  1588. {
  1589. g_pTheApp->ReGetMachineAndAccountNames();
  1590. CString csMachineName = g_pTheApp->m_csMachineName.Right(g_pTheApp->m_csMachineName.GetLength() - 2);
  1591. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle, 32800, csMachineName);
  1592. }
  1593. _stprintf(szTheSectionToDo,_T("OC_COMPLETE_INSTALLATION_install.%s"),ComponentId);
  1594. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1595. }
  1596. dwOcEntryReturn = NO_ERROR;
  1597. SetCurrentDirectory(g_pTheApp->m_csPathInetsrv);
  1598. if (SubcomponentId)
  1599. {
  1600. ACTION_TYPE atComp = GetSubcompAction(SubcomponentId, FALSE);
  1601. // Should get called in this order
  1602. // ===============================
  1603. // [Optional Components]
  1604. // iis
  1605. // iis_common
  1606. // iis_inetmgr
  1607. // iis_www
  1608. // iis_doc
  1609. // iis_htmla
  1610. // iis_www_vdir_scripts
  1611. // iis_ftp
  1612. // ===============================
  1613. //
  1614. // iis_common should be the first call....
  1615. //
  1616. // ===============================
  1617. if (_tcsicmp(SubcomponentId, STRING_iis_common) == 0)
  1618. {
  1619. //
  1620. // install the iis_common section
  1621. //
  1622. if (atComp == AT_INSTALL_FRESH || atComp == AT_INSTALL_UPGRADE || (atComp == AT_INSTALL_REINSTALL))
  1623. {
  1624. _stprintf(g_MyLogFile.m_szLogPreLineInfo2,_T("%s:"),SubcomponentId);
  1625. if (atComp == AT_INSTALL_UPGRADE){ProgressBarTextStack_Set(IDS_IIS_ALL_UPGRADE);}
  1626. else{ProgressBarTextStack_Set(IDS_IIS_ALL_INSTALL);}
  1627. _stprintf(szTheSectionToDo,_T("OC_COMPLETE_INSTALLATION_install.%s"),SubcomponentId);
  1628. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1629. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  1630. ProgressBarTextStack_Pop();
  1631. }
  1632. //
  1633. // If we just processed iis_common,
  1634. // but now we should install iis_core
  1635. //
  1636. if (atComp == AT_INSTALL_FRESH || atComp == AT_INSTALL_UPGRADE || (atComp == AT_INSTALL_REINSTALL) || atComp == AT_DO_NOTHING)
  1637. {
  1638. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  1639. if (atCORE == AT_INSTALL_FRESH || atCORE == AT_INSTALL_UPGRADE || (atCORE == AT_INSTALL_REINSTALL))
  1640. {
  1641. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("iis_core:"));
  1642. if (atComp != AT_DO_NOTHING)
  1643. {
  1644. if (atCORE == AT_INSTALL_UPGRADE){ProgressBarTextStack_Set(IDS_IIS_ALL_UPGRADE);}
  1645. else{ProgressBarTextStack_Set(IDS_IIS_ALL_INSTALL);}
  1646. }
  1647. _stprintf(szTheSectionToDo,_T("OC_COMPLETE_INSTALLATION_install.%s"),STRING_iis_core);
  1648. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1649. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  1650. if (atComp != AT_DO_NOTHING)
  1651. {
  1652. ProgressBarTextStack_Pop();
  1653. }
  1654. }
  1655. }
  1656. }
  1657. else
  1658. {
  1659. // ===============================
  1660. //
  1661. // Handle the Registration of all other components...
  1662. //
  1663. // ===============================
  1664. if (atComp == AT_INSTALL_FRESH || atComp == AT_INSTALL_UPGRADE || (atComp == AT_INSTALL_REINSTALL))
  1665. {
  1666. _stprintf(g_MyLogFile.m_szLogPreLineInfo2,_T("%s:"),SubcomponentId);
  1667. if (atComp == AT_INSTALL_UPGRADE){ProgressBarTextStack_Set(IDS_IIS_ALL_UPGRADE);}
  1668. else{ProgressBarTextStack_Set(IDS_IIS_ALL_INSTALL);}
  1669. // Call the sections registration stuff.
  1670. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0)
  1671. {
  1672. // Do this at the end of setup since things that it needs may not happen yet (mmc)
  1673. g_Please_Call_Register_iis_inetmgr = TRUE;
  1674. // Register_iis_inetmgr();
  1675. }
  1676. _stprintf(szTheSectionToDo,_T("OC_COMPLETE_INSTALLATION_install.%s"),SubcomponentId);
  1677. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1678. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  1679. ProgressBarTextStack_Pop();
  1680. }
  1681. }
  1682. //
  1683. // If we are removing something, then remove the directories
  1684. //
  1685. if (atComp == AT_REMOVE)
  1686. {
  1687. ProgressBarTextStack_Set(IDS_IIS_ALL_REMOVE);
  1688. _stprintf(szTheSectionToDo,_T("OC_COMPLETE_INSTALLATION_remove.%s"),SubcomponentId);
  1689. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  1690. ProgressBarTextStack_Pop();
  1691. }
  1692. }
  1693. AdvanceProgressBarTickGauge();
  1694. SumUpProgressBarTickGauge(SubcomponentId);
  1695. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1696. // check if this is the last section to get called!!!
  1697. if (SubcomponentId)
  1698. {
  1699. // Yes this is the last section to get called! So, let's say sooooo....
  1700. if (_tcsicmp(SubcomponentId, g_szLastSectionToGetCalled) == 0)
  1701. {
  1702. // Enforce max connections
  1703. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  1704. {
  1705. //EnforceMaxConnections();
  1706. }
  1707. // free some memory
  1708. FreeTaskListMem();
  1709. UnInit_Lib_PSAPI();
  1710. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("....All OC_COMPLETE_INSTALLATION for all 'IIS' sections have been completed.....\n")));
  1711. // if there were errors then popup message box.
  1712. MesssageBoxErrors_IIS();
  1713. }
  1714. }
  1715. return dwOcEntryReturn;
  1716. }
  1717. DWORD_PTR OC_CLEANUP_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1718. {
  1719. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start. 0x%x,0x%x\n"), ComponentId, SubcomponentId, Param1, Param2));
  1720. // OCM send out this notification after the "Finish" button on
  1721. // the End Page has been clicked.
  1722. //
  1723. // remove the files we downloaded from the web in this session
  1724. DWORD_PTR dwOcEntryReturn = 0;
  1725. // display running services in case our services
  1726. // need other services to be running!
  1727. ShowStateOfTheseServices(g_pTheApp->m_hInfHandle);
  1728. // Install inetmgr after gui mode setup is done because
  1729. // it may require other things that were setup in guimode.
  1730. if (TRUE == g_Please_Call_Register_iis_inetmgr) {Register_iis_inetmgr();}
  1731. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_CLEANUP"));
  1732. // restart services that we stopped
  1733. ServicesRestartList_RestartServices();
  1734. #ifndef _CHICAGO_
  1735. // restart cluster resources that we had stopped
  1736. if (!g_pTheApp->m_fNTGuiMode)
  1737. {
  1738. BringALLIISClusterResourcesOnline();
  1739. }
  1740. #endif
  1741. //--------------------------------------------------------------------
  1742. // For Migrations we need to scan the entire metabase and look for the old
  1743. // system directory (e.g. "C:\\Windows\\System\\") and replace
  1744. // with the new system directory (e.g. "C:\\WINNT.1\\System32\\")
  1745. //
  1746. // Does the iisadmin service exist?
  1747. // Does the metabase exist???
  1748. if (g_pTheApp->m_eInstallMode == IM_UPGRADE)
  1749. {
  1750. if (g_pTheApp->m_fMoveInetsrv)
  1751. {
  1752. // Check if the iisadmin service exists...
  1753. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  1754. {
  1755. CMDKey cmdKey;
  1756. cmdKey.OpenNode(_T("LM"));
  1757. if ( (METADATA_HANDLE)cmdKey )
  1758. {
  1759. HRESULT hr;
  1760. cmdKey.Close();
  1761. CString cOldWinSysPath;
  1762. CString cNewWinSysPath;
  1763. // Change all "c:\windows\system\inetsrv" to "c:\windows\system32\inetsrv"
  1764. cOldWinSysPath = g_pTheApp->m_csPathOldInetsrv;
  1765. cOldWinSysPath += _T("\\"); // add a trailing backslash
  1766. cNewWinSysPath = g_pTheApp->m_csPathInetsrv;
  1767. cNewWinSysPath += _T("\\"); // add a trailing backslash
  1768. iisDebugOut((LOG_TYPE_TRACE, _T("CPhysicalPathFixer: please change %s to %s.\n"),cOldWinSysPath, cNewWinSysPath));
  1769. CPhysicalPathFixer cmdKeySpecial(cOldWinSysPath, cNewWinSysPath);
  1770. hr = cmdKeySpecial.Update(_T("LM"), TRUE);
  1771. if (FAILED(hr)) {iisDebugOut((LOG_TYPE_ERROR, _T("CPhysicalPathFixer failed return HR:%#lx\n"), hr));}
  1772. // Change all "%WinDir%\System" to "%windir%\System32"
  1773. cOldWinSysPath = _T("%WinDir%\\System");
  1774. cNewWinSysPath = _T("%WinDir%\\System32");
  1775. CPhysicalPathFixer cmdKeySpecial2(cOldWinSysPath, cNewWinSysPath);
  1776. hr = cmdKeySpecial2.Update(_T("LM"), TRUE);
  1777. if (FAILED(hr)) {iisDebugOut((LOG_TYPE_ERROR, _T("CPhysicalPathFixer failed return HR:%#lx\n"), hr));}
  1778. }
  1779. }
  1780. }
  1781. }
  1782. // if iis is installed, then check if Tcp/ip is installed.
  1783. // if it is not installed... then output some error message to the log saying
  1784. // a big warning that they must install tcp/ip inorder for iis to work.
  1785. //IDS_TCPIP_ERROR
  1786. if (CheckifServiceExist(_T("TCPIP")) == ERROR_SERVICE_DOES_NOT_EXIST)
  1787. {
  1788. int IISInstalled = FALSE;
  1789. if (CheckifServiceExist(_T("W3SVC")) == 0 )
  1790. {IISInstalled=TRUE;}
  1791. if (CheckifServiceExist(_T("MSFTPSVC")) == 0 )
  1792. {IISInstalled=TRUE;}
  1793. if (IISInstalled)
  1794. {
  1795. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T(""));
  1796. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("FAIL:"));
  1797. CString csTemp;
  1798. MyLoadString(IDS_TCPIP_ERROR, csTemp);
  1799. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("================================\n")));
  1800. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("%s\n"), csTemp));
  1801. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("================================\n")));
  1802. _tcscpy(g_MyLogFile.m_szLogPreLineInfo, _T("OC_CLEANUP:"));
  1803. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  1804. //LogSevInformation 0x00000000
  1805. //LogSevWarning 0x00000001
  1806. //LogSevError 0x00000002
  1807. //LogSevFatalError 0x00000003
  1808. //LogSevMaximum 0x00000004
  1809. // Write it to the setupapi log file!
  1810. SetupLogError(csTemp, LogSevWarning);
  1811. }
  1812. }
  1813. else
  1814. {
  1815. // The tcpip service exists, but is it running???
  1816. }
  1817. // Write the uninstall info for this session out to the registry
  1818. g_pTheApp->UnInstallList_RegWrite();
  1819. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP);
  1820. if ((HKEY) regINetStp){regINetStp.DeleteValue(_T("MetabaseUnSecuredRead"));}
  1821. dwOcEntryReturn = 0;
  1822. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  1823. return dwOcEntryReturn;
  1824. }
  1825. //
  1826. // Param1 = char width flags
  1827. // Param2 = unused
  1828. //
  1829. // Return value is a flag indicating to OC Manager
  1830. // which char width we want to run in. Run in "native"
  1831. // char width.
  1832. //
  1833. DWORD_PTR OC_PREINITIALIZE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1834. {
  1835. DWORD_PTR dwOcEntryReturn = 0;
  1836. #ifdef UNICODE
  1837. dwOcEntryReturn = OCFLAG_UNICODE;
  1838. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s] End. Return=%d (OCFLAG_UNICODE)\n"), ComponentId, dwOcEntryReturn));
  1839. #else
  1840. dwOcEntryReturn = OCFLAG_ANSI;
  1841. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s] End. Return=%d (OCFLAG_ANSI)\n"), ComponentId, dwOcEntryReturn));
  1842. #endif
  1843. return dwOcEntryReturn;
  1844. }
  1845. //
  1846. // Param1 = low 16 bits specify Win32 LANGID
  1847. // Param2 = unused
  1848. //
  1849. // Return code is a boolean indicating whether we think we
  1850. // support the requested language. We remember the language id
  1851. // and say we support the language. A more exact check might involve
  1852. // looking through our resources via EnumResourcesLnguages() for
  1853. // example, or checking our inf to see whether there is a matching
  1854. // or closely matching [strings] section. We don't bother with
  1855. // any of that here.
  1856. //
  1857. // Locate the component and remember the language id for later use.
  1858. //
  1859. DWORD_PTR OC_SET_LANGUAGE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1860. {
  1861. DWORD_PTR dwOcEntryReturn = 0;
  1862. dwOcEntryReturn = TRUE;
  1863. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Win32LANGID=0x%x, Return=%d\n"), ComponentId, SubcomponentId, Param1, dwOcEntryReturn));
  1864. return dwOcEntryReturn;
  1865. }
  1866. #ifdef _WIN64
  1867. DWORD_PTR OC_QUERY_IMAGE_EX_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1868. {
  1869. BOOL bReturn = FALSE;
  1870. HBITMAP hBitMap = NULL;
  1871. HBITMAP * phBitMapInput = NULL;
  1872. OC_QUERY_IMAGE_INFO * MyQueryInfo = NULL;
  1873. MyQueryInfo = (OC_QUERY_IMAGE_INFO *) Param1;
  1874. phBitMapInput = (HBITMAP *) Param2;
  1875. if(MyQueryInfo->ComponentInfo == SubCompInfoSmallIcon)
  1876. {
  1877. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle,MAKEINTRESOURCE(IDB_FTP));}
  1878. if (_tcsicmp(SubcomponentId, STRING_iis_www) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW));}
  1879. if (_tcsicmp(SubcomponentId, STRING_iis_www_parent) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW));}
  1880. if (_tcsicmp(SubcomponentId, STRING_iis_www_vdir_scripts) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW_VDIR));}
  1881. if (_tcsicmp(SubcomponentId, STRING_iis_www_vdir_printers) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW_VDIR));}
  1882. if (_tcsicmp(SubcomponentId, STRING_iis_htmla) == 0 || _tcsicmp(SubcomponentId, STRING_iis_doc) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_HTMLA));}
  1883. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_INETMGR));}
  1884. if (_tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_PWS));}
  1885. if (_tcsicmp(SubcomponentId, _T("iis")) == 0) {hBitMap = LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_TOPLEVEL_IIS));}
  1886. if (hBitMap)
  1887. {
  1888. *phBitMapInput = (HBITMAP) hBitMap;
  1889. bReturn = TRUE;
  1890. }
  1891. }
  1892. if (phBitMapInput != NULL)
  1893. {
  1894. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End.Return=0x%x.\n"), ComponentId, SubcomponentId,phBitMapInput));
  1895. }
  1896. else
  1897. {
  1898. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End.Return=0x%x.\n"), ComponentId, SubcomponentId,phBitMapInput));
  1899. }
  1900. MyQueryInfo = NULL;
  1901. return bReturn;
  1902. }
  1903. #endif
  1904. DWORD_PTR OC_QUERY_IMAGE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1905. {
  1906. DWORD_PTR dwOcEntryReturn = 0;
  1907. dwOcEntryReturn = (DWORD)NULL;
  1908. if(LOWORD(Param1) == SubCompInfoSmallIcon)
  1909. {
  1910. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle,MAKEINTRESOURCE(IDB_FTP));}
  1911. if (_tcsicmp(SubcomponentId, STRING_iis_www) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW));}
  1912. if (_tcsicmp(SubcomponentId, STRING_iis_www_parent) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW));}
  1913. if (_tcsicmp(SubcomponentId, STRING_iis_www_vdir_scripts) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW_VDIR));}
  1914. if (_tcsicmp(SubcomponentId, STRING_iis_www_vdir_printers) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_WWW_VDIR));}
  1915. if (_tcsicmp(SubcomponentId, STRING_iis_htmla) == 0 || _tcsicmp(SubcomponentId, STRING_iis_doc) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_HTMLA));}
  1916. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_INETMGR));}
  1917. if (_tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_PWS));}
  1918. if (_tcsicmp(SubcomponentId, _T("iis")) == 0) {dwOcEntryReturn = (DWORD_PTR) LoadBitmap((HINSTANCE) g_MyModuleHandle, MAKEINTRESOURCE(IDB_TOPLEVEL_IIS));}
  1919. }
  1920. if (dwOcEntryReturn != NULL)
  1921. {
  1922. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End.Return=0x%x.\n"), ComponentId, SubcomponentId,dwOcEntryReturn));
  1923. }
  1924. else
  1925. {
  1926. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End.Return=NULL.\n"), ComponentId, SubcomponentId));
  1927. }
  1928. return dwOcEntryReturn;
  1929. }
  1930. int GetTotalTickGaugeFromINF(IN LPCTSTR SubcomponentId, IN int GimmieForInstall)
  1931. {
  1932. int nReturn = 0;
  1933. INFCONTEXT Context;
  1934. TCHAR szTempString[20];
  1935. TCHAR szTempString2[20];
  1936. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("TotalTicks"), &Context) )
  1937. {
  1938. SetupGetStringField(&Context, 1, szTempString, 20, NULL);
  1939. if (!SetupGetStringField(&Context, 2, szTempString2, 20, NULL))
  1940. {_tcscpy(szTempString2,szTempString);}
  1941. //iisDebugOut((LOG_TYPE_TRACE, _T("GetTotalTickGaugeFromINF:%s,%s\n"),szTempString,szTempString2));
  1942. if (GimmieForInstall)
  1943. {
  1944. nReturn = _ttoi(szTempString);
  1945. }
  1946. else
  1947. {
  1948. nReturn = _ttoi(szTempString2);
  1949. }
  1950. }
  1951. return nReturn;
  1952. }
  1953. //
  1954. // Param1 = unused
  1955. // Param2 = unused
  1956. //
  1957. // Return value is an arbitrary 'step' count or -1 if error.
  1958. //
  1959. // OC Manager calls this routine when it wants to find out how much
  1960. // work the component wants to perform for nonfile operations to
  1961. // install/uninstall a component/subcomponent.
  1962. // It is called once for the *entire* component and then once for
  1963. // each subcomponent in the component.
  1964. //
  1965. // One could get arbitrarily fancy here but we simply return 2 step
  1966. // per subcomponent. We ignore the "entire component" case.
  1967. //
  1968. DWORD_PTR OC_QUERY_STEP_COUNT_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  1969. {
  1970. DWORD_PTR dwOcEntryReturn = 0;
  1971. // iis
  1972. // iis_common
  1973. // iis_inetmgr
  1974. // iis_www
  1975. // iis_doc
  1976. // iis_htmla
  1977. // iis_ftp
  1978. //AT_DO_NOTHING AT_REMOVE AT_INSTALL_FRESH AT_INSTALL_UPGRADE AT_INSTALL_REINSTALL
  1979. if (SubcomponentId)
  1980. {
  1981. ACTION_TYPE atComp = GetSubcompAction(SubcomponentId, FALSE);
  1982. // Set the Tick Total value for iis_common (which includes iis_core)
  1983. if (_tcsicmp(SubcomponentId, STRING_iis_common) == 0)
  1984. {
  1985. // Get the operations for Core instead since this is bigger.
  1986. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  1987. if (atCORE == AT_REMOVE)
  1988. {dwOcEntryReturn = GetTotalTickGaugeFromINF(SubcomponentId, FALSE);}
  1989. else
  1990. {dwOcEntryReturn = GetTotalTickGaugeFromINF(SubcomponentId, TRUE);}
  1991. if (atCORE == AT_DO_NOTHING)
  1992. {dwOcEntryReturn = 0;}
  1993. }
  1994. else
  1995. {
  1996. if (atComp == AT_REMOVE)
  1997. {dwOcEntryReturn = GetTotalTickGaugeFromINF(SubcomponentId, FALSE);}
  1998. else
  1999. {dwOcEntryReturn = GetTotalTickGaugeFromINF(SubcomponentId, TRUE);}
  2000. if (atComp == AT_DO_NOTHING)
  2001. {dwOcEntryReturn = 0;}
  2002. }
  2003. }
  2004. else
  2005. {
  2006. //
  2007. // "Entire component" case, which we ignore.
  2008. //
  2009. dwOcEntryReturn = 0;
  2010. }
  2011. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  2012. return dwOcEntryReturn;
  2013. }
  2014. //
  2015. // This is a fake notification. You'll never receive this notification from OCM.
  2016. //
  2017. DWORD_PTR OC_NOTIFICATION_FROM_QUEUE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  2018. {
  2019. DWORD_PTR dwOcEntryReturn = 0;
  2020. dwOcEntryReturn = 0;
  2021. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  2022. return dwOcEntryReturn;
  2023. }
  2024. void StopAllServicesThatAreRelevant(int iShowErrorsFlag)
  2025. {
  2026. int iPleaseStopTheService = FALSE;
  2027. #ifndef _CHICAGO_
  2028. ACTION_TYPE atTheComponent_core = GetIISCoreAction(FALSE);
  2029. ACTION_TYPE atTheComponent_ftp = GetSubcompAction(STRING_iis_ftp, FALSE);
  2030. ACTION_TYPE atTheComponent_www = GetSubcompAction(STRING_iis_www, FALSE);
  2031. int BringALLIISClusterResourcesOffline_WasCalled = FALSE;
  2032. //ACTION_TYPE atTheComponent_common = GetSubcompAction(STRING_iis_common, FALSE);
  2033. //ACTION_TYPE atTheComponent_inetmgr = GetSubcompAction(STRING_iis_inetmgr, FALSE);
  2034. //ACTION_TYPE atTheComponent_pwmgr = GetSubcompAction(STRING_iis_pwmgr, FALSE);
  2035. //ACTION_TYPE atTheComponent_doc = GetSubcompAction(STRING_iis_doc, FALSE);
  2036. //ACTION_TYPE atTheComponent_htmla = GetSubcompAction(STRING_iis_htmla, FALSE);
  2037. // ----------------------
  2038. // Handle the MSFTPSVC service...
  2039. // ----------------------
  2040. // Check if we are going to remove something...
  2041. iPleaseStopTheService = FALSE;
  2042. if (atTheComponent_ftp != AT_DO_NOTHING){iPleaseStopTheService = TRUE;}
  2043. if (iPleaseStopTheService)
  2044. {
  2045. // important: you must take iis clusters off line before doing anykind of upgrade\installs...
  2046. // but incase the user didn't do this... try to take them off line for the user
  2047. if (FALSE == BringALLIISClusterResourcesOffline_WasCalled)
  2048. {
  2049. DWORD dwResult = ERROR_SUCCESS;
  2050. dwResult = BringALLIISClusterResourcesOffline();
  2051. BringALLIISClusterResourcesOffline_WasCalled = TRUE;
  2052. }
  2053. if (StopServiceAndDependencies(_T("MSFTPSVC"), FALSE) == FALSE)
  2054. {
  2055. if (iShowErrorsFlag)
  2056. {
  2057. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("MSFTPSVC"), MB_OK | MB_SETFOREGROUND);
  2058. }
  2059. }
  2060. }
  2061. // ----------------------
  2062. // Handle the W3SVC service...
  2063. // ----------------------
  2064. iPleaseStopTheService = FALSE;
  2065. if (atTheComponent_www != AT_DO_NOTHING){iPleaseStopTheService = TRUE;}
  2066. if (iPleaseStopTheService)
  2067. {
  2068. // important: you must take iis clusters off line before doing anykind of upgrade\installs...
  2069. // but incase the user didn't do this... try to take them off line for the user
  2070. if (FALSE == BringALLIISClusterResourcesOffline_WasCalled)
  2071. {
  2072. DWORD dwResult = ERROR_SUCCESS;
  2073. dwResult = BringALLIISClusterResourcesOffline();
  2074. BringALLIISClusterResourcesOffline_WasCalled = TRUE;
  2075. }
  2076. if (StopServiceAndDependencies(_T("W3SVC"), FALSE) == FALSE)
  2077. {
  2078. if (iShowErrorsFlag)
  2079. {
  2080. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("W3SVC"), MB_OK | MB_SETFOREGROUND);
  2081. }
  2082. }
  2083. }
  2084. // ----------------------
  2085. // Handle the IISADMIN service...
  2086. // ----------------------
  2087. iPleaseStopTheService = FALSE;
  2088. if (atTheComponent_core != AT_DO_NOTHING){iPleaseStopTheService = TRUE;}
  2089. // if they are adding msftpsvc or w3svc, then we'll have to stop this iisadmin service as well!
  2090. // why? because the iisadmin serivce (inetinfo.exe) can be locking some files that we want to copy in.
  2091. // and if we can't copy them in, things could get hosed -- especially w3svc.
  2092. // actually if you think about it all the services (msftp,w3svc,smtp, etc..) area all running in the same process (inetinfo.exe)
  2093. // so it kinda makes sense that we have to stop this service when add\removing.
  2094. // let's say i removed msftpsvc -- and the services are still running,
  2095. // then i go and re-add msftpsvc -- well because we didn't reboot some of those ftp files are still
  2096. // locked -- so well have to do the old "slip it in on reboot" trick or something
  2097. // which still may have problems. Bottom line here is -- we have to stop iisadmin service when adding\readding
  2098. // msftpsvc or w3svc
  2099. // when i tested this -- it looks like the wam*.dll's get locked by the inetinfo.exe process
  2100. // so i have to stop the iisadmin service to unload those.
  2101. // if we they are trying to remove ftp then we don't have to stop the iisadmin service.
  2102. // but if we are trying to add, then stop the iisadmin service
  2103. if (atTheComponent_ftp != AT_DO_NOTHING && atTheComponent_ftp != AT_REMOVE)
  2104. {iPleaseStopTheService = TRUE;}
  2105. // if we they are trying to remove w3svc then we don't have to stop the iisadmin service.
  2106. // but if we are trying to add, then stop the iisadmin service
  2107. if (atTheComponent_www != AT_DO_NOTHING && atTheComponent_www != AT_REMOVE)
  2108. {iPleaseStopTheService = TRUE;}
  2109. if (iPleaseStopTheService)
  2110. {
  2111. // important: you must take iis clusters off line before doing anykind of upgrade\installs...
  2112. // but incase the user didn't do this... try to take them off line for the user
  2113. if (FALSE == BringALLIISClusterResourcesOffline_WasCalled)
  2114. {
  2115. DWORD dwResult = ERROR_SUCCESS;
  2116. dwResult = BringALLIISClusterResourcesOffline();
  2117. BringALLIISClusterResourcesOffline_WasCalled = TRUE;
  2118. }
  2119. if (StopServiceAndDependencies(_T("IISADMIN"), TRUE) == FALSE)
  2120. {
  2121. if (iShowErrorsFlag)
  2122. {
  2123. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("IISADMIN"), MB_OK | MB_SETFOREGROUND);
  2124. }
  2125. }
  2126. }
  2127. #endif
  2128. return;
  2129. }
  2130. DWORD_PTR OC_FILE_BUSY_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  2131. {
  2132. DWORD_PTR dwOcEntryReturn = 0;
  2133. //dwOcEntryReturn = TRUE;
  2134. PFILEPATHS pTheBusyFile;
  2135. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start.\n"), ComponentId, SubcomponentId));
  2136. pTheBusyFile = (PFILEPATHS) Param1;
  2137. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("Target=%1!s!, Source=%2!s!\n"), pTheBusyFile->Target, pTheBusyFile->Source));
  2138. ProcessSection(g_pTheApp->m_hInfHandle, _T("OC_FILE_BUSY"));
  2139. // display the file version information
  2140. LogFileVersion(pTheBusyFile->Target, TRUE);
  2141. // handle the file busy stuff ourselves.
  2142. // either - 1. findout who is locking this file -- which process or services and stop it.
  2143. // 2. or try to rename the locked file and copy in the new one.
  2144. // will set the reboot flag if we did #2
  2145. HandleFileBusyOurSelf(pTheBusyFile);
  2146. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. Return=%d\n"), ComponentId, SubcomponentId, dwOcEntryReturn));
  2147. return dwOcEntryReturn;
  2148. }
  2149. #define HandleMetabaseBeforeSetupStarts_log _T("HandleMetabaseBeforeSetupStarts")
  2150. void HandleMetabaseBeforeSetupStarts()
  2151. /*++
  2152. Routine Description:
  2153. This function handles the metabase file in various installation scenario before iis setup really starts.
  2154. It is developed in order to handle NT5 GUI mode setup re-startable.
  2155. This function should be called exactly after we have stopped all running iis services,
  2156. such that nobody is locking the metabase file.
  2157. Arguments:
  2158. None
  2159. Return Value:
  2160. void
  2161. --*/
  2162. {
  2163. CString csMetabaseFile;
  2164. csMetabaseFile = g_pTheApp->m_csPathInetsrv + _T("\\metabase.bin");
  2165. switch (g_pTheApp->m_eInstallMode) {
  2166. case IM_UPGRADE:
  2167. {
  2168. if (g_pTheApp->m_bUpgradeTypeHasMetabaseFlag)
  2169. {
  2170. CString csBackupFile;
  2171. csBackupFile = g_pTheApp->m_csPathInetsrv + _T("\\upg45b2.bin");
  2172. if (IsFileExist(csBackupFile)) {
  2173. //
  2174. // restore it back to be the current metabase.bin
  2175. //
  2176. iisDebugOut((LOG_TYPE_TRACE, _T("%s:IM_UPGRADE:restore upg45b2.bin to metabase.bin\n"),HandleMetabaseBeforeSetupStarts_log));
  2177. InetCopyFile(csBackupFile, csMetabaseFile);
  2178. } else {
  2179. //
  2180. // backup the current metabase.bin to upg45b2.bin
  2181. //
  2182. if (IsFileExist(csMetabaseFile))
  2183. {
  2184. iisDebugOut((LOG_TYPE_TRACE, _T("%s:IM_UPGRADE:backup metabase.bin to upg45b2.bin\n"),HandleMetabaseBeforeSetupStarts_log));
  2185. InetCopyFile(csMetabaseFile, csBackupFile);
  2186. }
  2187. else
  2188. {
  2189. iisDebugOut((LOG_TYPE_TRACE, _T("%s:IM_UPGRADE:backup metabase.bin to upg45b2.bin. metabase.bin not found WARNING.\n"),HandleMetabaseBeforeSetupStarts_log));
  2190. }
  2191. }
  2192. //
  2193. // delete the backup file on reboot
  2194. //
  2195. iisDebugOut((LOG_TYPE_TRACE, _T("%s:IM_UPGRADE:mark upg45b2.bin as delete-on-reboot\n"),HandleMetabaseBeforeSetupStarts_log));
  2196. MoveFileEx( (LPCTSTR)csBackupFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT );
  2197. break;
  2198. }
  2199. // for all the other upgrades, fall through
  2200. // to blow away the existing metabase.bin
  2201. }
  2202. case IM_FRESH:
  2203. {
  2204. //
  2205. // blow away the existing metabase.bin
  2206. //
  2207. iisDebugOut((LOG_TYPE_TRACE, _T("%s:IM_FRESH.Delete metabase.bin for NTsetup restartable mode case.\n"),HandleMetabaseBeforeSetupStarts_log));
  2208. InetDeleteFile(csMetabaseFile);
  2209. break;
  2210. }
  2211. default:
  2212. {
  2213. break;
  2214. }
  2215. }
  2216. return;
  2217. }
  2218. void SetRebootFlag(void)
  2219. {
  2220. gHelperRoutines.SetReboot(gHelperRoutines.OcManagerContext, TRUE);
  2221. }
  2222. #define GetStateFromUnattendFile_log _T("GetStateFromUnattendFile")
  2223. int GetStateFromUnattendFile(LPCTSTR SubcomponentId)
  2224. /*++
  2225. Routine Description:
  2226. This function determines the current state of SubcomponentId
  2227. according to values specified in the unattend text file.
  2228. Arguments:
  2229. SubcomponentId: the name of the component, e.g., iis_www
  2230. Return Value:
  2231. SubcompOn/SubcompOff/SubcompUseOcManagerDefault
  2232. This function returns SubcompUseOcManagerDefault in case the value of SubcomponentId
  2233. is neither specified as ON nor OFF.
  2234. --*/
  2235. {
  2236. int nReturn = SubcompUseOcManagerDefault;
  2237. INFCONTEXT Context;
  2238. TCHAR szSectionName[_MAX_PATH];
  2239. TCHAR szValue[_MAX_PATH] = _T("");
  2240. _tcscpy(szSectionName, _T("InternetServer"));
  2241. if (g_pTheApp->m_hUnattendFile == INVALID_HANDLE_VALUE || g_pTheApp->m_hUnattendFile == NULL)
  2242. {return SubcompUseOcManagerDefault;}
  2243. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, szSectionName, SubcomponentId, &Context) )
  2244. {SetupGetStringField(&Context, 1, szValue, _MAX_PATH, NULL);}
  2245. if (_tcsicmp(szValue, _T("ON")) == 0)
  2246. {nReturn = SubcompOn;}
  2247. else if (_tcsicmp(szValue, _T("OFF")) == 0)
  2248. {nReturn = SubcompOff;}
  2249. else
  2250. {nReturn = SubcompUseOcManagerDefault;}
  2251. if (SubcompOn)
  2252. {iisDebugOut((LOG_TYPE_TRACE, _T("%s() on %s returns SubcompOn\n"), GetStateFromUnattendFile_log, SubcomponentId));}
  2253. if (SubcompOff)
  2254. {iisDebugOut((LOG_TYPE_TRACE, _T("%s() on %s returns SubcompOff\n"), GetStateFromUnattendFile_log, SubcomponentId));}
  2255. if (SubcompUseOcManagerDefault)
  2256. {iisDebugOut((LOG_TYPE_TRACE, _T("%s() on %s returns SubcompUseOcManagerDefault\n"), GetStateFromUnattendFile_log, SubcomponentId));}
  2257. return nReturn;
  2258. }
  2259. int GetStateFromModesLine(LPCTSTR SubcomponentId, int nModes)
  2260. /*++
  2261. Routine Description:
  2262. This function determines the current state of SubcomponentId
  2263. according to the Modes= line specified in the inf file.
  2264. Arguments:
  2265. SubcomponentId: the name of the component, e.g., iis_www
  2266. Return Value:
  2267. SubcompOn/SubcompOff only
  2268. --*/
  2269. {
  2270. int nReturn = SubcompOff;
  2271. BOOL bFound = FALSE;
  2272. INFCONTEXT Context;
  2273. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("Modes"), &Context) )
  2274. {
  2275. int n, i, nValue;
  2276. n = SetupGetFieldCount(&Context);
  2277. for(i=0; i<n; i++) {
  2278. if(SetupGetIntField(&Context,i+1,&nValue) && ((DWORD)nValue < 32)) {
  2279. if (nValue == nModes) {
  2280. bFound = TRUE;
  2281. break;
  2282. }
  2283. }
  2284. }
  2285. }
  2286. if (bFound)
  2287. nReturn = SubcompOn;
  2288. else
  2289. nReturn = SubcompOff;
  2290. iisDebugOut((LOG_TYPE_TRACE, _T("%s() on %s for mode %d returns %d\n"), GetStateFromUnattendFile_log, SubcomponentId, nModes, nReturn));
  2291. return nReturn;
  2292. }
  2293. int GetStateFromRegistry(LPCTSTR SubcomponentId)
  2294. /*++
  2295. Routine Description:
  2296. This function determines the original state of SubcomponentId
  2297. according to the registry value.
  2298. Arguments:
  2299. SubcomponentId: the name of the component, e.g., iis_www
  2300. Return Value:
  2301. SubcompOn/SubcompOff only
  2302. --*/
  2303. {
  2304. int nReturn = SubcompOff;
  2305. CRegKey regKey(HKEY_LOCAL_MACHINE,OC_MANAGER_SETUP_KEY,KEY_READ);
  2306. if ((HKEY)regKey)
  2307. {
  2308. DWORD dwValue = 0xffffffff;
  2309. regKey.m_iDisplayWarnings = TRUE;
  2310. if (regKey.QueryValue(SubcomponentId, dwValue) == ERROR_SUCCESS)
  2311. {
  2312. if (dwValue == 0x0)
  2313. nReturn = SubcompOff;
  2314. else
  2315. nReturn = SubcompOn;
  2316. }
  2317. }
  2318. iisDebugOut((LOG_TYPE_TRACE, _T("GetStateFromRegistry() on %s returns %d\n"), SubcomponentId, nReturn));
  2319. return nReturn;
  2320. }
  2321. int IsThisSubCompNeededByOthers(LPCTSTR SubcomponentId)
  2322. {
  2323. int iReturn = FALSE;
  2324. // search thru our inf to see if another component needs it
  2325. return iReturn;
  2326. }
  2327. int DoesOCManagerKeyExist(LPCTSTR SubcomponentId)
  2328. {
  2329. int iReturn = FALSE;
  2330. CRegKey regKey(HKEY_LOCAL_MACHINE,OC_MANAGER_SETUP_KEY,KEY_READ);
  2331. if ((HKEY)regKey)
  2332. {
  2333. DWORD dwValue = 0xffffffff;
  2334. regKey.m_iDisplayWarnings = FALSE;
  2335. if (regKey.QueryValue(SubcomponentId, dwValue) == ERROR_SUCCESS)
  2336. {iReturn = TRUE;}
  2337. }
  2338. return iReturn;
  2339. }
  2340. int GetStateFromUpgRegLines(LPCTSTR SubcomponentId)
  2341. /*++
  2342. Routine Description:
  2343. This function determines the original state of SubcomponentId
  2344. according to the UpgReg= line specified in the inf file.
  2345. Arguments:
  2346. SubcomponentId: the name of the component, e.g., iis_www
  2347. Return Value:
  2348. SubcompOn/SubcompOff only
  2349. --*/
  2350. {
  2351. int nReturn = SubcompOff;
  2352. INFCONTEXT Context;
  2353. TCHAR szPath[_MAX_PATH];
  2354. TCHAR szUpgradeInfKeyToUse[30];
  2355. _tcscpy(szUpgradeInfKeyToUse, _T("None"));
  2356. // Check for special NT4 upgrade
  2357. if (g_pTheApp->m_eUpgradeType == UT_40)
  2358. {
  2359. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg4"), &Context) )
  2360. {
  2361. _tcscpy(szUpgradeInfKeyToUse, _T("UpgReg4"));
  2362. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("GetStateFromUpgRegLines() use: UpgReg4.\n")));
  2363. SetupGetStringField(&Context, 1, szPath, _MAX_PATH, NULL);
  2364. CRegKey regKey(HKEY_LOCAL_MACHINE, szPath, KEY_READ);
  2365. if ((HKEY)regKey)
  2366. {
  2367. TCHAR szCompId[_MAX_PATH];
  2368. int iValue = 0;
  2369. DWORD dwValue = 0xffffffff;
  2370. SetupGetStringField(&Context, 2, szCompId, _MAX_PATH, NULL);
  2371. SetupGetIntField(&Context, 3, &iValue);
  2372. regKey.m_iDisplayWarnings = TRUE;
  2373. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2374. {
  2375. if (dwValue == (DWORD)iValue)
  2376. nReturn = SubcompOn;
  2377. }
  2378. }
  2379. }
  2380. goto GetStateFromUpgRegLines_Exit;
  2381. }
  2382. // Check for special NT60 upgrade
  2383. if (g_pTheApp->m_eUpgradeType == UT_60)
  2384. {
  2385. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg60"), &Context) )
  2386. {
  2387. _tcscpy(szUpgradeInfKeyToUse, _T("UpgReg60"));
  2388. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("GetStateFromUpgRegLines() use: UpgReg60.\n")));
  2389. SetupGetStringField(&Context, 1, szPath, _MAX_PATH, NULL);
  2390. CRegKey regKey(HKEY_LOCAL_MACHINE, szPath, KEY_READ);
  2391. if ((HKEY)regKey)
  2392. {
  2393. TCHAR szCompId[_MAX_PATH];
  2394. int iValue = 0;
  2395. DWORD dwValue = 0xffffffff;
  2396. SetupGetStringField(&Context, 2, szCompId, _MAX_PATH, NULL);
  2397. SetupGetIntField(&Context, 3, &iValue);
  2398. regKey.m_iDisplayWarnings = TRUE;
  2399. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2400. {
  2401. if (dwValue == (DWORD)iValue)
  2402. nReturn = SubcompOn;
  2403. }
  2404. }
  2405. }
  2406. goto GetStateFromUpgRegLines_Exit;
  2407. }
  2408. // Check for special NT5 upgrade
  2409. if (g_pTheApp->m_eUpgradeType == UT_51)
  2410. {
  2411. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg51"), &Context) )
  2412. {
  2413. _tcscpy(szUpgradeInfKeyToUse, _T("UpgReg51"));
  2414. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("GetStateFromUpgRegLines() use: UpgReg51.\n")));
  2415. SetupGetStringField(&Context, 1, szPath, _MAX_PATH, NULL);
  2416. CRegKey regKey(HKEY_LOCAL_MACHINE, szPath, KEY_READ);
  2417. if ((HKEY)regKey)
  2418. {
  2419. TCHAR szCompId[_MAX_PATH];
  2420. int iValue = 0;
  2421. DWORD dwValue = 0xffffffff;
  2422. SetupGetStringField(&Context, 2, szCompId, _MAX_PATH, NULL);
  2423. SetupGetIntField(&Context, 3, &iValue);
  2424. regKey.m_iDisplayWarnings = TRUE;
  2425. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2426. {
  2427. if (dwValue == (DWORD)iValue)
  2428. nReturn = SubcompOn;
  2429. }
  2430. }
  2431. }
  2432. goto GetStateFromUpgRegLines_Exit;
  2433. }
  2434. // Check for special NT5 upgrade
  2435. if (g_pTheApp->m_eUpgradeType == UT_50)
  2436. {
  2437. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg5"), &Context) )
  2438. {
  2439. _tcscpy(szUpgradeInfKeyToUse, _T("UpgReg5"));
  2440. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("GetStateFromUpgRegLines() use: UpgReg5.\n")));
  2441. SetupGetStringField(&Context, 1, szPath, _MAX_PATH, NULL);
  2442. CRegKey regKey(HKEY_LOCAL_MACHINE, szPath, KEY_READ);
  2443. if ((HKEY)regKey)
  2444. {
  2445. TCHAR szCompId[_MAX_PATH];
  2446. int iValue = 0;
  2447. DWORD dwValue = 0xffffffff;
  2448. SetupGetStringField(&Context, 2, szCompId, _MAX_PATH, NULL);
  2449. SetupGetIntField(&Context, 3, &iValue);
  2450. regKey.m_iDisplayWarnings = TRUE;
  2451. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2452. {
  2453. if (dwValue == (DWORD)iValue)
  2454. nReturn = SubcompOn;
  2455. }
  2456. }
  2457. }
  2458. goto GetStateFromUpgRegLines_Exit;
  2459. }
  2460. // Check if there is a specific one for our special upgrade type.
  2461. _tcscpy(szUpgradeInfKeyToUse, _T("UpgReg"));
  2462. if (g_pTheApp->m_eUpgradeType == UT_351)
  2463. {
  2464. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg351"), &Context) )
  2465. {_tcscpy(szUpgradeInfKeyToUse, _T("UpgReg351"));}
  2466. }
  2467. if (g_pTheApp->m_eUpgradeType == UT_10)
  2468. {
  2469. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg1"), &Context) )
  2470. {_tcscpy(szUpgradeInfKeyToUse, _T("UpgReg1"));}
  2471. }
  2472. if (g_pTheApp->m_eUpgradeType == UT_20)
  2473. {
  2474. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg2"), &Context) )
  2475. {_tcscpy(szUpgradeInfKeyToUse, _T("UpgReg2"));}
  2476. }
  2477. if (g_pTheApp->m_eUpgradeType == UT_30)
  2478. {
  2479. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg3"), &Context) )
  2480. {_tcscpy(szUpgradeInfKeyToUse, _T("UpgReg3"));}
  2481. }
  2482. if (g_pTheApp->m_eUpgradeType == UT_10_W95)
  2483. {
  2484. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, _T("UpgReg1_w95"), &Context) )
  2485. {_tcscpy(szUpgradeInfKeyToUse, _T("UpgReg1_w95"));}
  2486. }
  2487. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, SubcomponentId, szUpgradeInfKeyToUse, &Context) )
  2488. {
  2489. SetupGetStringField(&Context, 1, szPath, _MAX_PATH, NULL);
  2490. CRegKey regKey(HKEY_LOCAL_MACHINE, szPath, KEY_READ);
  2491. if ((HKEY)regKey)
  2492. {
  2493. TCHAR szCompId[_MAX_PATH];
  2494. int iValue = 0;
  2495. DWORD dwValue = 0xffffffff;
  2496. // check if there is a parameter specified
  2497. if (SetupGetStringField(&Context, 2, szCompId, _MAX_PATH, NULL))
  2498. {
  2499. if (SetupGetIntField(&Context, 3, &iValue))
  2500. {
  2501. // check if the dword matches what we specified.
  2502. regKey.m_iDisplayWarnings = FALSE;
  2503. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2504. {
  2505. if (dwValue == (DWORD)iValue)
  2506. {nReturn = SubcompOn;}
  2507. }
  2508. }
  2509. else
  2510. {
  2511. // just check for existence.
  2512. regKey.m_iDisplayWarnings = FALSE;
  2513. if (regKey.QueryValue(szCompId, dwValue) == ERROR_SUCCESS)
  2514. {
  2515. nReturn = SubcompOn;
  2516. }
  2517. }
  2518. }
  2519. else
  2520. {
  2521. nReturn = SubcompOn;
  2522. }
  2523. }
  2524. }
  2525. GetStateFromUpgRegLines_Exit:
  2526. iisDebugOut((LOG_TYPE_TRACE, _T("GetStateFromUpgRegLines() %s:%s returns %d\n"), szUpgradeInfKeyToUse, SubcomponentId, nReturn));
  2527. return nReturn;
  2528. }
  2529. void InCaseNoTCPIP(LPCTSTR SubcomponentId, int nNewStateValue, int *pnState)
  2530. /*++
  2531. Routine Description:
  2532. This function overwrites current state with nNewStateValue
  2533. in case that TCPIP is not present.
  2534. Arguments:
  2535. LPCTSTR SubcomponentId: e.g., iis_www, etc.
  2536. int nNewStateValue: SubcompOn/SubcompOff/SubcompUseOcManagerDefault
  2537. int *pnState: pointer to the state which will be overwritten if condition is met.
  2538. Return Value:
  2539. void
  2540. --*/
  2541. {
  2542. // check if tcpip is installed
  2543. g_pTheApp->IsTCPIPInstalled();
  2544. if (g_pTheApp->m_fTCPIP == FALSE)
  2545. {
  2546. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0 ||
  2547. _tcsicmp(SubcomponentId, STRING_iis_www) == 0 ||
  2548. _tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0 )
  2549. {
  2550. *pnState = nNewStateValue;
  2551. }
  2552. }
  2553. return;
  2554. }
  2555. DWORD_PTR OC_QUERY_STATE_Func(IN LPCTSTR ComponentId,IN LPCTSTR SubcomponentId,IN UINT Function,IN UINT_PTR Param1,IN OUT PVOID Param2)
  2556. /*++
  2557. Routine Description:
  2558. This function handles OC_QUERY_STATE notification.
  2559. IIS 4.0 SETUP NOTE (LinanT):
  2560. ============================
  2561. This function returns SubcompOn/SubcompOff explicitly.
  2562. It does NOT return SubcompUseOcManagerDefault, because
  2563. OCM sometimes behaves strangely when SubcompUseOcManagerDefault is returned.
  2564. The above comments were valid for iis4 but in iis5 ocmanage has been fixed so
  2565. that SubcompUseOcManagerDefault is valid
  2566. IIS 5.0 SETUP NOTE (AaronL):
  2567. ============================
  2568. Well okay. iis5.0 shipped with Win2000, Patst and then AndrewR took over the ocmanager.
  2569. They made a bunch of changes to ocmanager to appropriately handle the "needs" relationship stuff in the .inf files.
  2570. Anyway, that stuffs all kool, however things had to be changed in order for this oc_query_state stuff to work.
  2571. Here is basic description of how this works:
  2572. OCSELSTATETYPE_ORIGINAL
  2573. -----------------------
  2574. During setup ocmanage will ask each of the components for they're original state (OCSELSTATETYPE_ORIGINAL).
  2575. In this call each component can return back the state of that certain component -- such as "yes, a previous inetmgr 1.0,2.0,3.0,4.0 or 5.0 is already installed".
  2576. If this is a fresh\maintenance installation, the component should return back SubcompUseOcManagerDefault. Meaning, ocmanage will look in the registry for this component
  2577. probably at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents;SubcomponentId=1 or 0.
  2578. if the component value is 0, then ocmanage will figure your component is off. if it's 1 then it's on. however if it's not there, then ocmanage will use whatever
  2579. the component has specified for for it's Modes= line in the .inf file.
  2580. During an upgrade installation, well, since older installations of inetmgr maybe located at a different registry key than at:
  2581. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents;iis_inetmgr=1 or 0.
  2582. we have to let ocmanage know, what the original state is by manually returning on/off/default.
  2583. Okay so what's the deal here? Why do we even need to use default? That's because something in ocmanage isn't working quite right and AndrewR doesn't want to destabilize
  2584. setup by making such a drastic this late in win2000 ship cycle. Here is the story. If iis_inetmgr returns on during this call -- kool, everything is fine and no problems.
  2585. however if i find that iis_inetmgr was not previously installed, then naturally i would want to return "off", but in fact this is wrong and will hose other things. how you say?
  2586. well because if i return "off" here, that means other components which need iis_inetmgr will not be able to turn it "on" thru needs (since the ocmanage has a screwy bug with this).
  2587. But if i return here "SubcompUseOcManagerDefault", then the other components will be able to turn it on iff they need it. the catch here is that -- ocmanage will use SubcompUseOcManagerDefault
  2588. which means that it will lookup in the registry:
  2589. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents;iis_inetmgr=1 or 0.
  2590. and determine for itself if it should be on or off, however on the upgrade iis_inetmgr won't be there so it will want to default to the "Modes=" line. however if iis is installed by default -- as
  2591. specified in the modes= lines -- then iis_inetmgr would be turned on wrongly!
  2592. How to work around this problem? Well, if the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents;iis_inetmgr=1 or 0
  2593. key was there then ocmanage wouldn't have to consult the Modes= line. so the workaround was for AndrewR, on an upgrade case to crate the
  2594. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents;iis_inetmgr key if it wasn't already there.
  2595. OCSELSTATETYPE_CURRENT
  2596. -----------------------
  2597. on a fresh just returns SubcompUseOcManagerDefault. in this case ocmanage should open the .inf file and read my Modes= line to determine if this component should be on or off.
  2598. on a maintenance mode add\remove (there is no removeall or reinstall in win2000 add\remove ocmanage) just returns SubcompUseOcManagerDefault. in which ocmanage will just read the registry again.
  2599. on upgrade the code will return either on or usedefault. we don't ever want to return off here because that would prevent other components which need us from turing us on.
  2600. --*/
  2601. {
  2602. int nReturn = SubcompUseOcManagerDefault;
  2603. TCHAR szTempStringInstallMode[40];
  2604. _tcscpy(szTempStringInstallMode, _T("NONE"));
  2605. if (!SubcomponentId)
  2606. {goto OC_QUERY_STATE_Func_Exit;}
  2607. switch (g_pTheApp->m_eInstallMode)
  2608. {
  2609. case IM_FRESH:
  2610. _tcscpy(szTempStringInstallMode, _T("IM_FRESH"));
  2611. break;
  2612. case IM_MAINTENANCE:
  2613. _tcscpy(szTempStringInstallMode, _T("IM_MAINTENANCE"));
  2614. break;
  2615. case IM_UPGRADE:
  2616. _tcscpy(szTempStringInstallMode, _T("IM_UPGRADE"));
  2617. break;
  2618. }
  2619. if (Param1 == OCSELSTATETYPE_ORIGINAL)
  2620. {
  2621. switch (g_pTheApp->m_eInstallMode)
  2622. {
  2623. case IM_FRESH:
  2624. nReturn = SubcompUseOcManagerDefault;
  2625. break;
  2626. case IM_MAINTENANCE:
  2627. nReturn = SubcompUseOcManagerDefault;
  2628. break;
  2629. case IM_UPGRADE:
  2630. nReturn = GetStateFromUpgRegLines(SubcomponentId);
  2631. if (SubcompOff == nReturn)
  2632. {
  2633. if (g_pTheApp->m_eUpgradeType != UT_NONE)
  2634. {
  2635. // Dont' return back SubCompOff because ocmanage won't be able to turn it on from they're screwy needs logic.
  2636. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_ORIGINAL. %s. Return=SubcompUseOcManagerDefault (But really it was SubCompOff)\n"), ComponentId, SubcomponentId, szTempStringInstallMode));
  2637. nReturn = SubcompUseOcManagerDefault;
  2638. }
  2639. }
  2640. break;
  2641. default:
  2642. break;
  2643. }
  2644. goto OC_QUERY_STATE_Func_Exit;
  2645. } // OCSELSTATETYPE_ORIGINAL
  2646. if (Param1 == OCSELSTATETYPE_CURRENT)
  2647. {
  2648. // This should overide everything...
  2649. if (g_pTheApp->m_bPleaseDoNotInstallByDefault == TRUE)
  2650. {
  2651. _tcscpy(szTempStringInstallMode, _T("IM_NO_IIS_TO_UPGRADE"));
  2652. // change for AndrewR to make sure that during an upgrade, our component is set to default (which will be "off" by default since the modes= line will be set [if not there] at the beginning of guimode setup)
  2653. nReturn = SubcompUseOcManagerDefault;
  2654. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] Start. OCSELSTATETYPE_CURRENT.m_bPleaseDoNotInstallByDefault=TRUE,so setting to SubcompUseOcManagerDefault by default.\n"), ComponentId, SubcomponentId));
  2655. goto OC_QUERY_STATE_Func_Exit;
  2656. }
  2657. if (g_pTheApp->m_eInstallMode == IM_FRESH)
  2658. {
  2659. nReturn = SubcompUseOcManagerDefault;
  2660. goto OC_QUERY_STATE_Func_Exit;
  2661. }
  2662. if (g_pTheApp->m_eInstallMode == IM_MAINTENANCE)
  2663. {
  2664. int nOriginal = (gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL)) ? SubcompOn : SubcompOff;
  2665. switch (g_pTheApp->m_dwSetupMode)
  2666. {
  2667. case SETUPMODE_ADDREMOVE:
  2668. nReturn = SubcompUseOcManagerDefault;
  2669. break;
  2670. case SETUPMODE_REINSTALL:
  2671. nReturn = nOriginal;
  2672. break;
  2673. case SETUPMODE_REMOVEALL:
  2674. nReturn = SubcompOff;
  2675. break;
  2676. }
  2677. goto OC_QUERY_STATE_Func_Exit;
  2678. }
  2679. if (g_pTheApp->m_eInstallMode == IM_UPGRADE)
  2680. {
  2681. int nOriginal = (gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL)) ? SubcompOn : SubcompOff;
  2682. switch (g_pTheApp->m_dwSetupMode)
  2683. {
  2684. case SETUPMODE_UPGRADEONLY:
  2685. nReturn = nOriginal;
  2686. break;
  2687. case SETUPMODE_ADDEXTRACOMPS:
  2688. nReturn = nOriginal;
  2689. break;
  2690. }
  2691. // ocmanager work around.
  2692. // check the ocmanage setup key to see if this entry
  2693. // exists -- in an upgrade ocmanage is assuming that it does exist
  2694. // when in fact -- it may not (since they ocmanage key could have been introduced in this new OS version
  2695. // if the key is in the registry then set this to subcompuseocmanagedefault, otherwise, set it to off
  2696. //if (TRUE == DoesOCManagerKeyExist(SubcomponentId))
  2697. {
  2698. if (SubcompOff == nReturn)
  2699. {
  2700. nReturn = SubcompUseOcManagerDefault;
  2701. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_CURRENT. %s. Return=SubcompUseOcManagerDefault (But really it was SubCompOff)\n"), ComponentId, SubcomponentId, szTempStringInstallMode));
  2702. }
  2703. }
  2704. /*
  2705. else
  2706. {
  2707. // however if the key does not exist
  2708. // we want to set this to off (since ocmanage will take the default from the modes line -- which is probably on)
  2709. // however if this component is needed by another component, then this component won't be able to be turned on
  2710. // since it was set to off.
  2711. // so before we go and set this component to be off, check to see if it has any needs dependencies (like it's needed by someone else)
  2712. // if it's needed by someone else then we set it to be SubcompUseOcManagerDefault
  2713. if (TRUE == IsThisSubCompNeededByOthers(SubcomponentId))
  2714. {
  2715. if (SubcompOff == nReturn)
  2716. {
  2717. nReturn = SubcompUseOcManagerDefault;
  2718. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_CURRENT. %s. Return=SubcompUseOcManagerDefault (But really it was SubCompOff)\n"), ComponentId, SubcomponentId, szTempStringInstallMode));
  2719. }
  2720. }
  2721. }
  2722. */
  2723. //
  2724. // if we are running on Whistler personal, then
  2725. // return back OFF! -- so that we will remove ourselves!
  2726. //
  2727. if (TRUE == IsWhistlerPersonal())
  2728. {
  2729. nReturn = SubcompOff;
  2730. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_CURRENT. %s. Return=SubCompOff (always on personal)\n"), ComponentId, SubcomponentId, szTempStringInstallMode));
  2731. }
  2732. }
  2733. goto OC_QUERY_STATE_Func_Exit;
  2734. } // OCSELSTATETYPE_CURRENT
  2735. if (Param1 == OCSELSTATETYPE_FINAL)
  2736. {
  2737. nReturn = SubcompUseOcManagerDefault;
  2738. if (!g_iOC_COMPLETE_INSTALLATION_Called)
  2739. {
  2740. // user could have cancelled setup
  2741. // so only do this in guimode fresh or upgrade scenario.
  2742. if (g_pTheApp->m_fNTGuiMode)
  2743. {
  2744. nReturn = SubcompOff;
  2745. }
  2746. }
  2747. goto OC_QUERY_STATE_Func_Exit;
  2748. } // OCSELSTATETYPE_FINAL
  2749. OC_QUERY_STATE_Func_Exit:
  2750. TCHAR szTempStringMode[40];
  2751. if (nReturn == SubcompOn)
  2752. {_tcscpy(szTempStringMode, _T("SubcompOn"));}
  2753. if (nReturn == SubcompOff)
  2754. {_tcscpy(szTempStringMode, _T("SubcompOff"));}
  2755. if (nReturn == SubcompUseOcManagerDefault)
  2756. {_tcscpy(szTempStringMode, _T("SubcompUseOcManagerDefault"));}
  2757. if (Param1 == OCSELSTATETYPE_ORIGINAL)
  2758. {iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_ORIGINAL. %s. Return=%s\n"), ComponentId, SubcomponentId, szTempStringInstallMode, szTempStringMode));}
  2759. if (Param1 == OCSELSTATETYPE_CURRENT)
  2760. {iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_CURRENT. %s. Return=%s\n"), ComponentId, SubcomponentId, szTempStringInstallMode, szTempStringMode));}
  2761. if (Param1 == OCSELSTATETYPE_FINAL)
  2762. {iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("[%s,%s] End. OCSELSTATETYPE_FINAL. %s. Return=%s\n"), ComponentId, SubcomponentId, szTempStringInstallMode, szTempStringMode));}
  2763. return nReturn;
  2764. }
  2765. DWORD TryToSlipInFile(PFILEPATHS pFilePath)
  2766. {
  2767. DWORD dwReturn = FALSE;
  2768. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("TryToSlipInFile:Replacing critical setup file %1!s!.\n"), pFilePath->Target));
  2769. BOOL bOK = FALSE;
  2770. DWORD dwSourceAttrib = 0;
  2771. DWORD dwTargetAttrib = 0;
  2772. TCHAR tszTempFileName[MAX_PATH+1];
  2773. TCHAR tszTempDir[MAX_PATH+1];
  2774. _tcscpy(tszTempDir, pFilePath->Target);
  2775. LPTSTR ptszTemp = _tcsrchr(tszTempDir, _T('\\'));
  2776. if (ptszTemp)
  2777. {
  2778. *ptszTemp = _T('\0');
  2779. }
  2780. GetTempFileName(tszTempDir, _T("IIS"), 0, tszTempFileName);
  2781. DeleteFile(tszTempFileName);
  2782. //Save file attributes so they can be restored after we are done.
  2783. dwSourceAttrib = GetFileAttributes(pFilePath->Source);
  2784. dwTargetAttrib = GetFileAttributes(pFilePath->Target);
  2785. //Now set the file attributes to normal to ensure file ops succeed.
  2786. SetFileAttributes(pFilePath->Source, FILE_ATTRIBUTE_NORMAL);
  2787. SetFileAttributes(pFilePath->Target, FILE_ATTRIBUTE_NORMAL);
  2788. // Try to rename the filename.dll file!
  2789. bOK = MoveFile(pFilePath->Target, tszTempFileName);
  2790. if (bOK) {iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Rename %1!s! to %2!s!. Successfull.\n"), pFilePath->Target, tszTempFileName));}
  2791. else{iisDebugOutSafeParams((LOG_TYPE_WARN, _T("Rename %1!s! to %2!s!. Failed.\n"), pFilePath->Target, tszTempFileName));}
  2792. bOK = CopyFile(pFilePath->Source, pFilePath->Target, FALSE);
  2793. if (bOK) {iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Copy %1!s! to %2!s!. Successfull.\n"), pFilePath->Source, pFilePath->Target));}
  2794. else{iisDebugOutSafeParams((LOG_TYPE_WARN, _T("Copy %1!s! to %2!s!. Failed, Replace on reboot.\n"), pFilePath->Source, pFilePath->Target));}
  2795. #ifdef _CHICAGO_
  2796. if(!DeleteFile(tszTempFileName))
  2797. {
  2798. TCHAR tszWinInitFile[MAX_PATH+1];
  2799. GetWindowsDirectory(tszWinInitFile, MAX_PATH);
  2800. AddPath(tszWinInitFile, _T("WININIT.INI"));
  2801. WritePrivateProfileString(_T("Rename"), _T("NUL"), tszTempFileName, tszWinInitFile);
  2802. }
  2803. #else
  2804. MoveFileEx(tszTempFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  2805. #endif
  2806. SetFileAttributes(pFilePath->Source, dwSourceAttrib);
  2807. SetFileAttributes(pFilePath->Target, dwTargetAttrib);
  2808. SetRebootFlag();
  2809. dwReturn = TRUE;
  2810. return dwReturn;
  2811. }
  2812. DWORD HandleFileBusyOurSelf(PFILEPATHS pFilePath)
  2813. {
  2814. // ----------------------------
  2815. // Why would we want to handle the file busy ourself?
  2816. //
  2817. // When setupapi/ocmanage handles it:
  2818. // it will keep the old filename.dll and create a new randomename.tmp for the new file.
  2819. //
  2820. // The result is that our files will link with the old filename.dll when it does
  2821. // all of it's regsvr32 stuff -- this is bad and can produce very confusing results.
  2822. //
  2823. //
  2824. // What We will want to do is:
  2825. // 1. try to rename filename.dll to something else. and copy over filename.dll
  2826. // 2. if we can't do it then at least log it.
  2827. // ----------------------------
  2828. DWORD dwRetVal = 0;
  2829. TCHAR szDrive_only[_MAX_DRIVE];
  2830. TCHAR szPath_only[_MAX_PATH];
  2831. TCHAR szDrive_and_Path[_MAX_DRIVE + _MAX_PATH];
  2832. TCHAR szFilename_only[_MAX_FNAME];
  2833. TCHAR szFilename_ext_only[_MAX_EXT];
  2834. TCHAR szFilename_and_ext[_MAX_FNAME + _MAX_EXT];
  2835. BOOL bOK = FALSE;
  2836. BOOL bFileFound = FALSE;
  2837. //Critical Setup files
  2838. TCHAR * szFileList[] = {
  2839. _T("admexs.dll"),
  2840. _T("admwprox.dll"),
  2841. _T("admxprox.dll"),
  2842. _T("ADROT.dll"),
  2843. _T("adsiis.dll"),
  2844. _T("adsiis51.dll"),
  2845. _T("AppConf.dll"),
  2846. _T("asp.dll"),
  2847. _T("asp51.dll"),
  2848. _T("aspperf.dll"),
  2849. _T("asptxn.dll"),
  2850. _T("authfilt.dll"),
  2851. _T("axctrnm.h2"),
  2852. _T("axperf.ini"),
  2853. _T("browscap.dll"),
  2854. _T("browscap.ini"),
  2855. _T("catmeta.xms"),
  2856. _T("CertMap.ocx"),
  2857. _T("certobj.dll"),
  2858. _T("CertWiz.ocx"),
  2859. _T("Cnfgprts.ocx"),
  2860. _T("coadmin.dll"),
  2861. _T("compfilt.dll"),
  2862. _T("ContRot.dll"),
  2863. _T("convlog.exe"),
  2864. _T("counters.dll"),
  2865. _T("davcdata.exe"),
  2866. _T("exstrace.dll"),
  2867. _T("fortutil.exe"),
  2868. _T("ftpctrs.h2"),
  2869. _T("ftpctrs.ini"),
  2870. _T("ftpctrs2.dll"),
  2871. _T("ftpmib.dll"),
  2872. _T("ftpsapi2.dll"),
  2873. _T("ftpsvc2.dll"),
  2874. _T("gzip.dll"),
  2875. _T("http.sys"),
  2876. _T("httpapi.dll"),
  2877. _T("httpext.dll"),
  2878. _T("httpmb51.dll"),
  2879. _T("httpmib.dll"),
  2880. _T("httpod51.dll"),
  2881. _T("httpodbc.dll"),
  2882. _T("iis.dll"),
  2883. _T("iis.msc"),
  2884. _T("iisadmin.dll"),
  2885. _T("IIsApp.vbs"),
  2886. _T("iisback.vbs"),
  2887. _T("iiscfg.dll"),
  2888. _T("iische51.dll"),
  2889. _T("iisclex4.dll"),
  2890. _T("IIsCnfg.vbs"),
  2891. _T("iiscrmap.dll"),
  2892. _T("iisext.dll"),
  2893. _T("iisext51.dll"),
  2894. _T("iisfecnv.dll"),
  2895. _T("IIsFtp.vbs"),
  2896. _T("IIsFtpdr.vbs"),
  2897. _T("iislog.dll"),
  2898. _T("iislog51.dll"),
  2899. _T("iismap.dll"),
  2900. _T("iismui.dll"),
  2901. _T("iisperf.pmc"),
  2902. _T("iisreset.exe"),
  2903. _T("iisrstap.dll"),
  2904. _T("iisrstas.exe"),
  2905. _T("iisRtl.dll"),
  2906. _T("IIsScHlp.wsc"),
  2907. _T("iissync.exe"),
  2908. _T("iisui.dll"),
  2909. _T("iisutil.dll"),
  2910. _T("iisvdir.vbs"),
  2911. _T("iisw3adm.dll"),
  2912. _T("iisweb.vbs"),
  2913. _T("iiswmi.dll"),
  2914. _T("iiswmi.mfl"),
  2915. _T("iiswmi.mof"),
  2916. _T("inetin51.exe"),
  2917. _T("inetinfo.exe"),
  2918. _T("inetmgr.dll"),
  2919. _T("inetmgr.exe"),
  2920. _T("inetsloc.dll"),
  2921. _T("infoadmn.dll"),
  2922. _T("infocomm.dll"),
  2923. _T("infoctrs.dll"),
  2924. _T("infoctrs.h2"),
  2925. _T("infoctrs.ini"),
  2926. _T("ipm.dll"),
  2927. _T("isapips.dll"),
  2928. _T("isatq.dll"),
  2929. _T("iscomlog.dll"),
  2930. _T("iwrps.dll"),
  2931. _T("logscrpt.dll"),
  2932. _T("logtemp.sql"),
  2933. _T("logui.ocx"),
  2934. _T("lonsint.dll"),
  2935. _T("md5filt.dll"),
  2936. _T("mdsync.dll"),
  2937. _T("metada51.dll"),
  2938. _T("metadata.dll"),
  2939. _T("NEXTLINK.dll"),
  2940. _T("nsepm.dll"),
  2941. _T("PageCnt.dll"),
  2942. _T("PermChk.dll"),
  2943. _T("pwsdata.dll"),
  2944. _T("rpcref.dll"),
  2945. _T("spud.sys"),
  2946. _T("ssinc.dll"),
  2947. _T("ssinc51.dll"),
  2948. _T("sspifilt.dll"),
  2949. _T("status.dll"),
  2950. _T("staxmem.dll"),
  2951. _T("strmfilt.dll"),
  2952. _T("svcext.dll"),
  2953. _T("tools.dll"),
  2954. _T("uihelper.dll"),
  2955. _T("w3cache.dll"),
  2956. _T("w3comlog.dll"),
  2957. _T("w3core.dll"),
  2958. _T("w3ctrlps.dll"),
  2959. _T("w3ctrs.dll"),
  2960. _T("w3ctrs.h2"),
  2961. _T("w3ctrs.ini"),
  2962. _T("w3ctrs51.dll"),
  2963. _T("w3ctrs51.h2"),
  2964. _T("w3ctrs51.ini"),
  2965. _T("w3dt.dll"),
  2966. _T("w3ext.dll"),
  2967. _T("w3isapi.dll"),
  2968. _T("w3svapi.dll"),
  2969. _T("w3svc.dll"),
  2970. _T("w3tp.dll"),
  2971. _T("w3wp.exe"),
  2972. _T("wam.dll"),
  2973. _T("wam51.dll"),
  2974. _T("wamps.dll"),
  2975. _T("wamps51.dll"),
  2976. _T("wamreg.dll"),
  2977. _T("wamreg51.dll"),
  2978. _T("wamregps.dll"),
  2979. _T("clusiis4.dll"),
  2980. _T("iis.msc"),
  2981. _T("iissuba.dll"),
  2982. _T("regtrace.exe"),
  2983. NULL
  2984. };
  2985. // make sure we didn't get some bogus pointers
  2986. if(pFilePath->Target == NULL || pFilePath->Source == NULL) return dwRetVal;
  2987. // Check to make sure the file exists!
  2988. if(!IsFileExist(pFilePath->Source)) return dwRetVal;
  2989. _tsplitpath( pFilePath->Target, szDrive_only, szPath_only, szFilename_only, szFilename_ext_only);
  2990. _tcscpy(szFilename_and_ext, szFilename_only);
  2991. _tcscat(szFilename_and_ext, szFilename_ext_only);
  2992. _tcscpy(szDrive_and_Path, szDrive_only);
  2993. _tcscat(szDrive_and_Path, szPath_only);
  2994. //
  2995. // if this is a removal, then forget it, if it's locked!
  2996. //
  2997. if((g_pTheApp->m_eInstallMode == IM_MAINTENANCE) && (g_pTheApp->m_dwSetupMode == SETUPMODE_REMOVEALL))
  2998. {
  2999. return dwRetVal;
  3000. }
  3001. CString csInetsrvPath = g_pTheApp->m_csPathInetsrv;
  3002. // add extra '\' chracter
  3003. csInetsrvPath += _T('\\');
  3004. BOOL bAbleToCopyFileAfterStopingService = FALSE;
  3005. // Check if it's anything in the inetsrv directory.
  3006. if (_tcsicmp(csInetsrvPath, szFilename_and_ext) == 0) {bFileFound = TRUE;}
  3007. if (_tcsicmp(csInetsrvPath, szDrive_and_Path) == 0)
  3008. {
  3009. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("Check %1!s! against filename=%2!s!.Match!\n"),csInetsrvPath,szDrive_and_Path));
  3010. bFileFound = TRUE;
  3011. }
  3012. else
  3013. {
  3014. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("Check %1!s! against filename=%2!s!.no match.\n"),csInetsrvPath,szDrive_and_Path));
  3015. }
  3016. // loop thru our list of file which
  3017. // we care about (since this function will get called for every single
  3018. // ocmanage component <-- not just iiS.
  3019. if (bFileFound != TRUE)
  3020. {
  3021. for(int i = 0; !bFileFound && szFileList[i]; i++)
  3022. {if(szFilename_and_ext && _tcsicmp(szFileList[i], szFilename_and_ext) == 0) bFileFound = TRUE;}
  3023. }
  3024. // files on nt5 in the cab are stoed as iis_filename.
  3025. // check to see if this file starts with iis_
  3026. // if it does then it's a file that we care about..
  3027. if (bFileFound != TRUE)
  3028. {
  3029. }
  3030. // ah, do it for everyone.
  3031. // bFileFound = TRUE;
  3032. // Do we really need to replace this file???
  3033. // If the filesize is the same, then lets just save it for reboot!
  3034. if (_tcsicmp(_T("iissuba.dll"), szFilename_and_ext) == 0)
  3035. {
  3036. if (bFileFound)
  3037. {
  3038. DWORD dwSize1 = ReturnFileSize(pFilePath->Target);
  3039. DWORD dwSize2 = ReturnFileSize(pFilePath->Source);
  3040. if (dwSize1 == 0xFFFFFFFF || dwSize1 == 0xFFFFFFFF)
  3041. {
  3042. // unable to retrieve the size of one of those files!
  3043. }
  3044. else
  3045. {
  3046. // check if dwSize1 and dwSize2 are the same.
  3047. if (dwSize1 == dwSize2)
  3048. {
  3049. // They are the same, so we don't have to replace it till reboot! yah!
  3050. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("Files %1!s! and %2!s! are the same size, not replacing..\n"),pFilePath->Target, pFilePath->Source));
  3051. goto HandleFileBusyOurSelf_Exit;
  3052. }
  3053. }
  3054. }
  3055. }
  3056. // if this is one of the files that we care about, then
  3057. // let's try to see who is locking it and try to stop that service or kill the process
  3058. // and then try to move the file over!
  3059. bAbleToCopyFileAfterStopingService = FALSE;
  3060. if(bFileFound)
  3061. {
  3062. TCHAR szReturnedServiceName[MAX_PATH];
  3063. // display which process has it locked, so we can fix it in the future.
  3064. CStringList strList;
  3065. LogProcessesUsingThisModule(pFilePath->Target, strList);
  3066. if (strList.IsEmpty() == FALSE)
  3067. {
  3068. POSITION pos;
  3069. CString csExeName;
  3070. LPTSTR p;
  3071. int nLen = 0;
  3072. pos = strList.GetHeadPosition();
  3073. while (pos)
  3074. {
  3075. csExeName = strList.GetAt(pos);
  3076. nLen += csExeName.GetLength() + 1;
  3077. if (TRUE == InetIsThisExeAService(csExeName, szReturnedServiceName))
  3078. {
  3079. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is the %2!s! service and is locking %3!s!. Let's stop that service.\n"),csExeName,szReturnedServiceName, pFilePath->Target));
  3080. /*
  3081. // Check if it is the netlogon service, We no don't want to stop this service for sure!!!
  3082. if (_tcsicmp(szReturnedServiceName, _T("NetLogon")) == 0)
  3083. {
  3084. // no we do not want to stop this service!!!
  3085. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is the %2!s! service and is locking %3!s!. This service should not be stopped.\n"),csExeName,szReturnedServiceName, pFilePath->Target));
  3086. bAbleToCopyFileAfterStopingService = FALSE;
  3087. break;
  3088. }
  3089. if (_tcsicmp(szReturnedServiceName, _T("WinLogon")) == 0)
  3090. {
  3091. // no we do not want to stop this service!!!
  3092. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is the %2!s! service and is locking %3!s!. This service should not be stopped.\n"),csExeName,szReturnedServiceName, pFilePath->Target));
  3093. bAbleToCopyFileAfterStopingService = FALSE;
  3094. break;
  3095. }
  3096. */
  3097. // check list of services that we definetly do not want to stop!
  3098. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, szReturnedServiceName, TRUE))
  3099. {
  3100. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is the %2!s! service and is locking %3!s!. This service should not be stopped.\n"),csExeName,szReturnedServiceName, pFilePath->Target));
  3101. }
  3102. else
  3103. {
  3104. // add this service to the list of
  3105. // services we need to restart after setup is done!!
  3106. ServicesRestartList_Add(szReturnedServiceName);
  3107. // net stop it
  3108. InetStopService(szReturnedServiceName);
  3109. // if the service is stopped, then it should be okay if we kill it!
  3110. KillProcess_Wrap(csExeName);
  3111. // now try to copy over the file!
  3112. if (CopyFile(pFilePath->Source, pFilePath->Target, FALSE))
  3113. {
  3114. bAbleToCopyFileAfterStopingService = TRUE;
  3115. break;
  3116. }
  3117. }
  3118. // otherwise go on to the next .exe file
  3119. }
  3120. else
  3121. {
  3122. // This .exe file is not a Service....
  3123. // Should we kill it???????
  3124. // check list of services/processes that we definetly do not want to stop!
  3125. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, csExeName, FALSE))
  3126. {
  3127. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is locking it. This process should not be killed\n"),csExeName));
  3128. }
  3129. else
  3130. {
  3131. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is locking it. Let's kill that process.\n"),csExeName));
  3132. if (KillProcess_Wrap(csExeName) == 0)
  3133. {
  3134. // if we were able to kill the process.
  3135. // then let's try to copy over the file.
  3136. // now try to copy over the file!
  3137. if (CopyFile(pFilePath->Source, pFilePath->Target, FALSE))
  3138. {
  3139. bAbleToCopyFileAfterStopingService = TRUE;
  3140. break;
  3141. }
  3142. }
  3143. }
  3144. }
  3145. strList.GetNext(pos);
  3146. }
  3147. }
  3148. }
  3149. // if this is one of the files that we care about then, let's do the move
  3150. if (bAbleToCopyFileAfterStopingService == TRUE)
  3151. {
  3152. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("HandleFileBusyOurSelf:critical setup file %1!s!, was successfully copied over after stopping services or stopping processes which were locking it.\n"), pFilePath->Target));
  3153. }
  3154. else
  3155. {
  3156. if(bFileFound)
  3157. {
  3158. // make sure the services we know about are stopped.
  3159. StopAllServicesRegardless(FALSE);
  3160. TryToSlipInFile(pFilePath);
  3161. }
  3162. else
  3163. {
  3164. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("HandleFileBusyOurSelf:%1!s! busy, but not one of our files, so ignore.\n"), pFilePath->Target));
  3165. }
  3166. }
  3167. HandleFileBusyOurSelf_Exit:
  3168. return dwRetVal;
  3169. }
  3170. DWORD GetLastSectionToBeCalled(void)
  3171. {
  3172. DWORD dwReturn = ERROR_SUCCESS;
  3173. // Open up the .inf file and return the last section which will get called...
  3174. // [Optional Components]
  3175. // iis
  3176. // iis_common
  3177. // iis_inetmgr
  3178. // iis_www
  3179. // iis_doc
  3180. // iis_htmla
  3181. // iis_ftp <-------
  3182. //
  3183. LPTSTR szLine = NULL;
  3184. DWORD dwRequiredSize;
  3185. BOOL b = FALSE;
  3186. INFCONTEXT Context;
  3187. // go to the beginning of the section in the INF file
  3188. b = SetupFindFirstLine_Wrapped(g_pTheApp->m_hInfHandle, OCM_OptionalComponents_Section, NULL, &Context);
  3189. if (!b)
  3190. {
  3191. dwReturn = E_FAIL;
  3192. goto GetLastSectionToBeCalled_Exit;
  3193. }
  3194. // loop through the items in the section.
  3195. while (b)
  3196. {
  3197. // get the size of the memory we need for this
  3198. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  3199. // prepare the buffer to receive the line
  3200. szLine = (LPTSTR)GlobalAlloc( GPTR, dwRequiredSize * sizeof(TCHAR) );
  3201. if ( !szLine )
  3202. {
  3203. goto GetLastSectionToBeCalled_Exit;
  3204. }
  3205. // get the line from the inf file1
  3206. if (SetupGetLineText(&Context, NULL, NULL, NULL, szLine, dwRequiredSize, NULL) == FALSE)
  3207. {
  3208. goto GetLastSectionToBeCalled_Exit;
  3209. }
  3210. // overwrite our string
  3211. _tcscpy(g_szLastSectionToGetCalled, szLine);
  3212. // find the next line in the section. If there is no next line it should return false
  3213. b = SetupFindNextLine(&Context, &Context);
  3214. // free the temporary buffer
  3215. GlobalFree( szLine );
  3216. szLine = NULL;
  3217. }
  3218. if (szLine) {GlobalFree(szLine);szLine=NULL;}
  3219. GetLastSectionToBeCalled_Exit:
  3220. return dwReturn;
  3221. }
  3222. // should create a backup of the metabase on remove all....
  3223. #define AfterRemoveAll_SaveMetabase_log _T("AfterRemoveAll_SaveMetabase")
  3224. int AfterRemoveAll_SaveMetabase(void)
  3225. {
  3226. iisDebugOut_Start(AfterRemoveAll_SaveMetabase_log);
  3227. int iReturn = TRUE;
  3228. int iFileExist = FALSE;
  3229. CString csMetabaseFile;
  3230. csMetabaseFile = g_pTheApp->m_csPathInetsrv + _T("\\metabase.xml");
  3231. switch (g_pTheApp->m_eInstallMode)
  3232. {
  3233. case IM_MAINTENANCE:
  3234. {
  3235. iisDebugOut((LOG_TYPE_TRACE, _T("%s.End.Maintenance.\n"),AfterRemoveAll_SaveMetabase_log));
  3236. if ( g_pTheApp->m_dwSetupMode == SETUPMODE_ADDREMOVE || g_pTheApp->m_dwSetupMode == SETUPMODE_REMOVEALL)
  3237. {
  3238. iisDebugOut((LOG_TYPE_TRACE, _T("%s.End.Maintenance.addremoveorremoveall\n"),AfterRemoveAll_SaveMetabase_log));
  3239. // Check if we removed iis_core!!!
  3240. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  3241. if (atCORE == AT_REMOVE)
  3242. {
  3243. iisDebugOut((LOG_TYPE_TRACE, _T("%s.End.removing Core.\n"),AfterRemoveAll_SaveMetabase_log));
  3244. // Back up the file!
  3245. if (IsFileExist(csMetabaseFile))
  3246. {
  3247. CString csBackupFile;
  3248. SYSTEMTIME SystemTime;
  3249. GetLocalTime(&SystemTime);
  3250. TCHAR szDatedFileName[50];
  3251. csBackupFile = g_pTheApp->m_csPathInetsrv + _T("\\MetaBack");
  3252. CreateDirectory(csBackupFile, NULL);
  3253. _stprintf(szDatedFileName,_T("\\MetaBack\\Metabase.%d%d%d"),SystemTime.wYear,SystemTime.wMonth, SystemTime.wDay);
  3254. csBackupFile = g_pTheApp->m_csPathInetsrv + szDatedFileName;
  3255. // Get a new filename
  3256. csBackupFile = ReturnUniqueFileName(csBackupFile);
  3257. if (!IsFileExist(csBackupFile))
  3258. {
  3259. // backup the current metabase.bin to Metabase.bin.bak#
  3260. iisDebugOut((LOG_TYPE_TRACE, _T("backup metabase.bin to %s\n"), csBackupFile));
  3261. InetCopyFile(csMetabaseFile, csBackupFile);
  3262. }
  3263. }
  3264. }
  3265. }
  3266. break;
  3267. }
  3268. default:
  3269. {break;}
  3270. }
  3271. iisDebugOut_End(AfterRemoveAll_SaveMetabase_log);
  3272. return iReturn;
  3273. }
  3274. int CheckIfWeNeedToMoveMetabaseBin(void)
  3275. {
  3276. int iReturn = TRUE;
  3277. TCHAR szTempDir1[_MAX_PATH];
  3278. TCHAR szTempDir2[_MAX_PATH];
  3279. BOOL bOK = FALSE;
  3280. DWORD dwSourceAttrib = 0;
  3281. // check if the old inetsrv dir is different from the new inetsrv directory.
  3282. // if it's different then we need to move all the old inetsrv files to the new directory
  3283. // no. we just need to move the metabase.bin file.
  3284. // all those other files should get deleted in the iis.inf file.
  3285. if (!g_pTheApp->m_fMoveInetsrv)
  3286. {goto CheckIfWeNeedToMoveMetabaseBin_Exit;}
  3287. _tcscpy(szTempDir1, g_pTheApp->m_csPathOldInetsrv);
  3288. _tcscpy(szTempDir2, g_pTheApp->m_csPathInetsrv);
  3289. AddPath(szTempDir1, _T("Metabase.bin"));
  3290. AddPath(szTempDir2, _T("Metabase.bin"));
  3291. // Check if the old metabase.bin even exists first...
  3292. if (!IsFileExist(szTempDir1))
  3293. {goto CheckIfWeNeedToMoveMetabaseBin_Exit;}
  3294. // Check if there is a metabase.bin already in the new place
  3295. if (IsFileExist(szTempDir2))
  3296. {
  3297. iisDebugOut((LOG_TYPE_WARN, _T("CheckIfWeNeedToMoveMetabaseBin:Cannot copy %s to %s because already exists. WARNING.\n"), szTempDir1, szTempDir2));
  3298. goto CheckIfWeNeedToMoveMetabaseBin_Exit;
  3299. }
  3300. //
  3301. // Try to move over the entire dirs...
  3302. //
  3303. // Try to rename the system\inetsrv to system32\inetsrv
  3304. if (TRUE == MoveFileEx( g_pTheApp->m_csPathOldInetsrv, g_pTheApp->m_csPathInetsrv, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH ))
  3305. {
  3306. goto CheckIfWeNeedToMoveMetabaseBin_Exit;
  3307. }
  3308. // otherwise, we were not able to move the system\inetsrv dir to system32\inetsrv....
  3309. // let's see if we can do another type of dirmove.
  3310. //Save file attributes so they can be restored after we are done.
  3311. dwSourceAttrib = GetFileAttributes(szTempDir1);
  3312. //Now set the file attributes to normal to ensure file ops succeed.
  3313. SetFileAttributes(szTempDir1, FILE_ATTRIBUTE_NORMAL);
  3314. bOK = CopyFile(szTempDir1, szTempDir2, FALSE);
  3315. if (bOK) {iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("CheckIfWeNeedToMoveMetabaseBin: Copy %1!s! to %2!s!. Successfull.\n"), szTempDir1, szTempDir2));}
  3316. else{iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CheckIfWeNeedToMoveMetabaseBin: Copy %1!s! to %2!s!. FAILED. Metabase.bin will not be upgraded.\n"), szTempDir1, szTempDir2));}
  3317. if (bOK)
  3318. {
  3319. // remove the old one
  3320. DeleteFile(szTempDir1);
  3321. // set the file attributes back to what it was.
  3322. SetFileAttributes(szTempDir2, dwSourceAttrib);
  3323. }
  3324. else
  3325. {
  3326. // set the file attributes back to what it was.
  3327. SetFileAttributes(szTempDir1, dwSourceAttrib);
  3328. // set return flag to say we failed to move over old files.
  3329. // upgrade will not do an upgrade.
  3330. iReturn = FALSE;
  3331. }
  3332. CheckIfWeNeedToMoveMetabaseBin_Exit:
  3333. return iReturn;
  3334. }
  3335. //
  3336. // function will copy all the old c:\windows\system\inetsrv files
  3337. //
  3338. // over to c:\windows\system32\inetsrv
  3339. //
  3340. // keep a list of the files which we're copied and
  3341. // then after the files are copied, delete the files in the old location.
  3342. int MigrateAllWin95Files(void)
  3343. {
  3344. int iReturn = TRUE;
  3345. TCHAR szTempSysDir1[_MAX_PATH];
  3346. TCHAR szTempSysDir2[_MAX_PATH];
  3347. TCHAR szTempSysDir3[_MAX_PATH];
  3348. //
  3349. // Check if the old metabase.bin even exists first...
  3350. //
  3351. GimmieOriginalWin95MetabaseBin(szTempSysDir1);
  3352. GetSystemDirectory( szTempSysDir2, _MAX_PATH);
  3353. AddPath(szTempSysDir2, _T("inetsrv\\Metabase.bin"));
  3354. if (!IsFileExist(szTempSysDir1))
  3355. {
  3356. // Check if there is one in the new location...
  3357. if (!IsFileExist(szTempSysDir2))
  3358. {
  3359. // set return flag to say we failed to move over old files.
  3360. // upgrade will not do an upgrade.
  3361. iReturn = FALSE;
  3362. goto MigrateAllWin95Files_Exit;
  3363. }
  3364. else
  3365. {
  3366. iReturn = TRUE;
  3367. goto MigrateAllWin95Files_Exit;
  3368. }
  3369. }
  3370. //
  3371. // Try to move over the entire dirs...
  3372. //
  3373. // cut of the filename and just get the path
  3374. ReturnFilePathOnly(szTempSysDir1,szTempSysDir3);
  3375. GetSystemDirectory( szTempSysDir2, _MAX_PATH);
  3376. AddPath(szTempSysDir2, _T("inetsrv"));
  3377. // Try to rename the system\inetsrv to system32\inetsrv
  3378. RemoveDirectory( szTempSysDir2 ); // Delete the destination directory first, so the move will work.
  3379. if (TRUE == MoveFileEx( szTempSysDir3, szTempSysDir2, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH ))
  3380. {goto MigrateAllWin95Files_Exit;}
  3381. // otherwise, we were not able to move the system\inetsrv dir to system32\inetsrv....
  3382. // let's see if we can do another type of dirmove.
  3383. // looks like all the other types of copies failed...
  3384. // let's just try to move the metabase.bin file.
  3385. GetWindowsDirectory( szTempSysDir1, _MAX_PATH);
  3386. AddPath(szTempSysDir1, _T("System\\inetsrv\\Metabase.bin"));
  3387. GetSystemDirectory( szTempSysDir2, _MAX_PATH);
  3388. AddPath(szTempSysDir2, _T("inetsrv\\Metabase.bin"));
  3389. // then let's copy it over, if we don't already have one in system32\inetsrv
  3390. if (IsFileExist(szTempSysDir2))
  3391. {
  3392. iisDebugOut((LOG_TYPE_WARN, _T("Cannot copy %s to %s because already exists. WARNING.\n"), szTempSysDir1, szTempSysDir2));
  3393. }
  3394. else
  3395. {
  3396. BOOL bOK = FALSE;
  3397. DWORD dwSourceAttrib = 0;
  3398. //Save file attributes so they can be restored after we are done.
  3399. dwSourceAttrib = GetFileAttributes(szTempSysDir1);
  3400. //Now set the file attributes to normal to ensure file ops succeed.
  3401. SetFileAttributes(szTempSysDir1, FILE_ATTRIBUTE_NORMAL);
  3402. bOK = CopyFile(szTempSysDir1, szTempSysDir2, FALSE);
  3403. if (bOK) {iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("Copy %1!s! to %2!s!. Successfull.\n"), szTempSysDir1, szTempSysDir2));}
  3404. else{iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("Copy %1!s! to %2!s!. FAILED. Metabase.bin will not be upgraded.\n"), szTempSysDir1, szTempSysDir2));}
  3405. if (bOK)
  3406. {
  3407. // remove the old one
  3408. DeleteFile(szTempSysDir1);
  3409. // set the file attributes back to what it was.
  3410. SetFileAttributes(szTempSysDir2, dwSourceAttrib);
  3411. }
  3412. else
  3413. {
  3414. // set the file attributes back to what it was.
  3415. SetFileAttributes(szTempSysDir1, dwSourceAttrib);
  3416. // set return flag to say we failed to move over old files.
  3417. // upgrade will not do an upgrade.
  3418. iReturn = FALSE;
  3419. }
  3420. }
  3421. MigrateAllWin95Files_Exit:
  3422. return iReturn;
  3423. }
  3424. int GimmieOriginalWin95MetabaseBin(TCHAR * szReturnedFilePath)
  3425. {
  3426. int iReturn = FALSE;
  3427. INFCONTEXT Context;
  3428. int iFindSection = FALSE;
  3429. TCHAR szWin95MetabaseFile[_MAX_PATH] = _T("");
  3430. iFindSection = SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, _T("InternetServer"), _T("Win95MigrateDllMetabaseOrg"), &Context);
  3431. if (iFindSection)
  3432. {
  3433. SetupGetStringField(&Context, 1, szWin95MetabaseFile, _MAX_PATH, NULL);
  3434. iisDebugOut((LOG_TYPE_TRACE, _T("[InternetServer].Win95MigrateDllMetabaseOrg=%s.\n"), szWin95MetabaseFile));
  3435. // if there is an entry, check if the file exists...
  3436. if (IsFileExist(szWin95MetabaseFile))
  3437. {
  3438. _tcscpy(szReturnedFilePath, szWin95MetabaseFile);
  3439. iReturn = TRUE;
  3440. }
  3441. }
  3442. if (FALSE == iReturn)
  3443. {
  3444. // we were not able to get the metabase.dll from the answer file.
  3445. // assume that it's in %windir%\system\inetsrv\metabase.bin
  3446. TCHAR szTempSysDir1[_MAX_PATH];
  3447. // Check if the old metabase.bin even exists first...
  3448. GetWindowsDirectory(szTempSysDir1, _MAX_PATH);
  3449. AddPath(szTempSysDir1, _T("System\\inetsrv\\Metabase.bin"));
  3450. _tcscpy(szReturnedFilePath, szTempSysDir1);
  3451. if (IsFileExist(szTempSysDir1))
  3452. {
  3453. iReturn = TRUE;
  3454. }
  3455. else
  3456. {
  3457. iReturn = FALSE;
  3458. }
  3459. }
  3460. return iReturn;
  3461. }
  3462. int HandleWin95MigrateDll(void)
  3463. {
  3464. int iReturn = TRUE;
  3465. int iTempFlag = 0;
  3466. int iFindSection = FALSE;
  3467. TCHAR szMigrateFileName[_MAX_PATH] = _T("");
  3468. INFCONTEXT Context;
  3469. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("Win95Upgrate:"));
  3470. if (g_pTheApp->m_hUnattendFile == INVALID_HANDLE_VALUE || g_pTheApp->m_hUnattendFile == NULL)
  3471. {
  3472. goto HandleWin95MigrateDll_Exit;
  3473. }
  3474. if (g_pTheApp->m_csUnattendFile)
  3475. {
  3476. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("AnswerFile=%1!s!.\n"), g_pTheApp->m_csUnattendFile));
  3477. }
  3478. else
  3479. {
  3480. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("AnswerFile=(not found).exiting.\n")));
  3481. goto HandleWin95MigrateDll_Exit;
  3482. }
  3483. // Look for our entry
  3484. //iisDebugOut((LOG_TYPE_TRACE, _T("HandleWin95MigrateDll:looking for entry [InternetServer]:Win95MigrateDll.\n")));
  3485. iFindSection = SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, _T("InternetServer"), _T("Win95MigrateDll"), &Context);
  3486. if (iFindSection)
  3487. {
  3488. SetupGetStringField(&Context, 1, szMigrateFileName, _MAX_PATH, NULL);
  3489. iisDebugOut((LOG_TYPE_TRACE, _T("[InternetServer].Win95MigrateDll=%s.\n"), szMigrateFileName));
  3490. // if there is an entry
  3491. // check if the file exists...
  3492. if (!IsFileExist(szMigrateFileName))
  3493. {
  3494. iisDebugOut((LOG_TYPE_ERROR, _T("[InternetServer].Win95MigrateDll=%s. Does not exist!!!!! FAILURE.\n"), szMigrateFileName));
  3495. iReturn = FALSE;
  3496. goto HandleWin95MigrateDll_Exit;
  3497. }
  3498. // okay, the file exists.
  3499. // lets pass it off to setupapi.
  3500. //iisDebugOut((LOG_TYPE_TRACE, _T("%s\n"), szMigrateFileName));
  3501. iTempFlag = InstallInfSection(INVALID_HANDLE_VALUE,szMigrateFileName,_T("DefaultInstall"));
  3502. if (iTempFlag != TRUE)
  3503. {
  3504. iisDebugOut((LOG_TYPE_ERROR, _T("FAILED to install DefaultInstall Section.\n"), szMigrateFileName));
  3505. goto HandleWin95MigrateDll_Exit;
  3506. }
  3507. // During the win95 side of migrate.dll
  3508. // the metabase.bin file gets a bunch of stuff removed from it.
  3509. // then that metabase.bin file gets renamed to another file.
  3510. // then the original metabase.bin is put back -- just in case the user cancelled upgrading to win95 (to ensure that they're win95/98 pws still works the metabase.bin has to be kool)
  3511. // so what we need to do here is:
  3512. // 1.save the old metabase.bin to something in case we mess things up.
  3513. // 2.find out what the newlyhacked metabase.bin file is called by looking for the entry in the answerfile
  3514. // 3.rename whatever that filename is to metabase.bin
  3515. GetTheRightWin95MetabaseFile();
  3516. // set the flag to say that we did call win95 migration dll
  3517. if (TRUE == MigrateAllWin95Files())
  3518. {
  3519. // only set this flag if
  3520. // we can copy over the existing metabase.bin file!
  3521. g_pTheApp->m_bWin95Migration = TRUE;
  3522. }
  3523. iReturn = iTempFlag;
  3524. }
  3525. HandleWin95MigrateDll_Exit:
  3526. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  3527. return iReturn;
  3528. }
  3529. int GetTheRightWin95MetabaseFile(void)
  3530. {
  3531. int iReturn = TRUE;
  3532. int iFindSection = FALSE;
  3533. INFCONTEXT Context;
  3534. TCHAR szOriginalMetabaseBin[_MAX_PATH];
  3535. // Get the full path to the original metabase.bin file
  3536. GimmieOriginalWin95MetabaseBin(szOriginalMetabaseBin);
  3537. iFindSection = FALSE;
  3538. iFindSection = SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, _T("InternetServer"), _T("Win95MigrateDllMetabaseNew"), &Context);
  3539. if (iFindSection)
  3540. {
  3541. TCHAR szWin95FixedMetabaseFile[_MAX_PATH] = _T("");
  3542. SetupGetStringField(&Context, 1, szWin95FixedMetabaseFile, _MAX_PATH, NULL);
  3543. iisDebugOut((LOG_TYPE_TRACE, _T("[InternetServer].Win95MigrateDllMetabaseNew=%s.\n"), szWin95FixedMetabaseFile));
  3544. // if there is an entry, check if the file exists...
  3545. if (IsFileExist(szWin95FixedMetabaseFile))
  3546. {
  3547. // File is there.
  3548. // 1. save the old metabase.bin just in case.
  3549. TCHAR szTempDir[MAX_PATH+1];
  3550. TCHAR szTempFileName[MAX_PATH+1];
  3551. // delete the original metabase.bin file
  3552. if (DeleteFile(szOriginalMetabaseBin))
  3553. {
  3554. // copy in the fixed one.
  3555. if (0 == CopyFile(szWin95FixedMetabaseFile, szOriginalMetabaseBin, FALSE))
  3556. {
  3557. // unable to copy it, try to move it
  3558. // Try to rename the system\inetsrv to system32\inetsrv
  3559. if (FALSE == MoveFileEx( szWin95FixedMetabaseFile, szOriginalMetabaseBin, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH ))
  3560. {
  3561. // do nothing i guess were hosed.
  3562. // setup won't upgrade and will only do a clean install
  3563. iReturn = FALSE;
  3564. }
  3565. }
  3566. }
  3567. }
  3568. else
  3569. {
  3570. iisDebugOut((LOG_TYPE_ERROR, _T("[InternetServer].Win95MigrateDllMetabaseNew=%s. Does not exist!!!!! FAILURE.\n"), szWin95FixedMetabaseFile));
  3571. }
  3572. }
  3573. return iReturn;
  3574. }
  3575. DWORD RemoveComponent(IN LPCTSTR SubcomponentId, int iThePartToDo)
  3576. {
  3577. TCHAR szTheSectionToDo[100];
  3578. int iWeAreGoingToRemoveSomething = FALSE;
  3579. DWORD dwReturn = NO_ERROR;
  3580. ACTION_TYPE atTheComponent;
  3581. // Make sure there are not MyMessageBox popups!
  3582. //int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  3583. // g_pTheApp->m_bAllowMessageBoxPopups = FALSE;
  3584. if (g_pTheApp->m_eInstallMode == IM_UPGRADE) goto RemoveComponent_Exit;
  3585. // Check if we are going to remove something...
  3586. atTheComponent = GetSubcompAction(SubcomponentId, FALSE);
  3587. if (_tcsicmp(SubcomponentId, STRING_iis_core) == 0)
  3588. {
  3589. atTheComponent = GetIISCoreAction(TRUE);;
  3590. }
  3591. if (atTheComponent == AT_REMOVE)
  3592. {iWeAreGoingToRemoveSomething = TRUE;}
  3593. if (iThePartToDo == 1)
  3594. {
  3595. // Check if we are supposed to do nothing.
  3596. if (atTheComponent == AT_DO_NOTHING)
  3597. {
  3598. // ok, if we're supposed to do nothing
  3599. // and the files are not supposed to be there
  3600. // then just make sure they are not there by removing them!!!!!
  3601. BOOL CurrentState,OriginalState;
  3602. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  3603. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  3604. // if we think that the original state is uninstalled
  3605. // and the current state is not installed, then make sure that the files do not exist by
  3606. // removing the files!
  3607. if (_tcsicmp(SubcomponentId, STRING_iis_core) == 0)
  3608. {
  3609. // since we can't check the state of iis_core, then check the states of iis_www and iis_ftp
  3610. // if any one of these remains installed, then don't remove it.
  3611. int iSomethingIsOn = FALSE;
  3612. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,STRING_iis_www,OCSELSTATETYPE_CURRENT);
  3613. if (CurrentState == 1) {iSomethingIsOn = TRUE;}
  3614. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,STRING_iis_ftp,OCSELSTATETYPE_CURRENT);
  3615. if (CurrentState == 1) {iSomethingIsOn = TRUE;}
  3616. iWeAreGoingToRemoveSomething = TRUE;
  3617. if (iSomethingIsOn)
  3618. {
  3619. iWeAreGoingToRemoveSomething = FALSE;
  3620. }
  3621. }
  3622. else
  3623. {
  3624. if (OriginalState == 0 && CurrentState == 0)
  3625. {
  3626. // but don't do it for the iis_doc files because there are too many files in that one.
  3627. if ((_tcsicmp(SubcomponentId, STRING_iis_common) == 0) ||
  3628. (_tcsicmp(SubcomponentId, STRING_iis_www) == 0) ||
  3629. (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0))
  3630. {
  3631. iWeAreGoingToRemoveSomething = TRUE;
  3632. }
  3633. }
  3634. }
  3635. }
  3636. }
  3637. if (iThePartToDo == 2)
  3638. {
  3639. // Check if we are supposed to do nothing.
  3640. if (atTheComponent == AT_DO_NOTHING)
  3641. {
  3642. if (_tcsicmp(SubcomponentId, _T("iis")) == 0)
  3643. {
  3644. BOOL CurrentState,OriginalState;
  3645. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_ORIGINAL);
  3646. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,SubcomponentId,OCSELSTATETYPE_CURRENT);
  3647. // if we think that the original state is uninstalled
  3648. // and the current state is not installed, then make sure that the files do not exist by
  3649. // removing the files!
  3650. if (OriginalState == 0 && CurrentState == 0)
  3651. {
  3652. // but don't do it for the iis_doc files because there are too many files in that one.
  3653. // Special: if this is removing the iis section [all of iis] then, make sure to
  3654. // clean everything up.
  3655. iWeAreGoingToRemoveSomething = TRUE;
  3656. }
  3657. else
  3658. {
  3659. // check if every component is off
  3660. if (FALSE == AtLeastOneComponentIsTurnedOn(g_pTheApp->m_hInfHandle))
  3661. {
  3662. iWeAreGoingToRemoveSomething = TRUE;
  3663. }
  3664. }
  3665. }
  3666. }
  3667. }
  3668. // Do the actual removing
  3669. if (iWeAreGoingToRemoveSomething)
  3670. {
  3671. if (iThePartToDo == 1)
  3672. {
  3673. //
  3674. // Queue the deletion of the files
  3675. //
  3676. ProgressBarTextStack_Set(IDS_IIS_ALL_REMOVE);
  3677. _stprintf(szTheSectionToDo,_T("OC_QUEUE_FILE_OPS_remove.%s"),SubcomponentId);
  3678. if (GetSectionNameToDo(g_pTheApp->m_hInfHandle, (CString) szTheSectionToDo))
  3679. {
  3680. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  3681. dwReturn = g_GlobalFileQueueHandle_ReturnError ? NO_ERROR : GetLastError();
  3682. }
  3683. else
  3684. {
  3685. dwReturn = NO_ERROR;
  3686. }
  3687. ProgressBarTextStack_Pop();
  3688. }
  3689. else
  3690. {
  3691. ProgressBarTextStack_Set(IDS_IIS_ALL_REMOVE);
  3692. _stprintf(g_MyLogFile.m_szLogPreLineInfo2,_T("Unreg %s:"),SubcomponentId);
  3693. _stprintf(szTheSectionToDo,_T("OC_ABOUT_TO_COMMIT_QUEUE_remove.%s"),SubcomponentId);
  3694. ProcessSection(g_pTheApp->m_hInfHandle, szTheSectionToDo);
  3695. _tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  3696. ProgressBarTextStack_Pop();
  3697. }
  3698. }
  3699. RemoveComponent_Exit:
  3700. // Turn popups back on.
  3701. //g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  3702. return dwReturn;
  3703. }
  3704. int AtLeastOneComponentIsTurnedOn(IN HINF hInfFileHandle)
  3705. {
  3706. int iSomeIsOn = FALSE;
  3707. TCHAR szTempSubComp[50];
  3708. BOOL CurrentState,OriginalState;
  3709. CStringList strList;
  3710. CString csTheSection = OCM_OptionalComponents_Section;
  3711. if (GetSectionNameToDo(hInfFileHandle, csTheSection))
  3712. {
  3713. if (ERROR_SUCCESS == FillStrListWithListOfSections(hInfFileHandle, strList, csTheSection))
  3714. {
  3715. // loop thru the list returned back
  3716. if (strList.IsEmpty() == FALSE)
  3717. {
  3718. POSITION pos;
  3719. CString csEntry;
  3720. pos = strList.GetHeadPosition();
  3721. while (pos)
  3722. {
  3723. csEntry = _T("");
  3724. csEntry = strList.GetAt(pos);
  3725. // We now have the entry, send it to the function.
  3726. OriginalState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,csEntry,OCSELSTATETYPE_ORIGINAL);
  3727. CurrentState = gHelperRoutines.QuerySelectionState(gHelperRoutines.OcManagerContext,csEntry,OCSELSTATETYPE_CURRENT);
  3728. if (CurrentState == 1) {iSomeIsOn = TRUE;}
  3729. // Get the next one.
  3730. strList.GetNext(pos);
  3731. }
  3732. }
  3733. }
  3734. }
  3735. return iSomeIsOn;
  3736. }
  3737. void AdvanceProgressBarTickGauge(int iTicks)
  3738. {
  3739. // multiply the amount of ticks by our tick multiple
  3740. iTicks = g_GlobalTickValue * iTicks;
  3741. for(int i = 0; i < iTicks; i++)
  3742. {
  3743. gHelperRoutines.TickGauge(gHelperRoutines.OcManagerContext);
  3744. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("--- TickGauge ---\n")));
  3745. }
  3746. g_GlobalTotalTickGaugeCount=g_GlobalTotalTickGaugeCount+iTicks;
  3747. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_common) == 0)
  3748. {g_GlobalTickTotal_iis_common = g_GlobalTickTotal_iis_common + g_GlobalTotalTickGaugeCount;}
  3749. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_inetmgr) == 0)
  3750. {g_GlobalTickTotal_iis_inetmgr = g_GlobalTickTotal_iis_inetmgr + g_GlobalTotalTickGaugeCount;}
  3751. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_www) == 0)
  3752. {g_GlobalTickTotal_iis_www = g_GlobalTickTotal_iis_www + g_GlobalTotalTickGaugeCount;}
  3753. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_pwmgr) == 0)
  3754. {g_GlobalTickTotal_iis_pwmgr = g_GlobalTickTotal_iis_pwmgr + g_GlobalTotalTickGaugeCount;}
  3755. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_doc) == 0)
  3756. {g_GlobalTickTotal_iis_doc = g_GlobalTickTotal_iis_doc + g_GlobalTotalTickGaugeCount;}
  3757. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_htmla) == 0)
  3758. {g_GlobalTickTotal_iis_htmla = g_GlobalTickTotal_iis_htmla + g_GlobalTotalTickGaugeCount;}
  3759. if (_tcsicmp(g_szCurrentSubComponent, STRING_iis_ftp) == 0)
  3760. {g_GlobalTickTotal_iis_ftp = g_GlobalTickTotal_iis_ftp + g_GlobalTotalTickGaugeCount;}
  3761. }
  3762. void SumUpProgressBarTickGauge(IN LPCTSTR SubcomponentId)
  3763. {
  3764. int iTicksYetToDo = 0;
  3765. int iTicksSupposedToDo = 0;
  3766. if (SubcomponentId)
  3767. {
  3768. ACTION_TYPE atComp = GetSubcompAction(SubcomponentId, FALSE);
  3769. // Set the Tick Total value for iis_common (which includes iis_core)
  3770. if (_tcsicmp(SubcomponentId, STRING_iis_common) == 0)
  3771. {
  3772. // Get the operations for Core instead since this is bigger.
  3773. ACTION_TYPE atCORE = GetIISCoreAction(FALSE);
  3774. if (atCORE == AT_REMOVE)
  3775. {iTicksSupposedToDo = GetTotalTickGaugeFromINF(SubcomponentId, FALSE);}
  3776. else
  3777. {iTicksSupposedToDo = GetTotalTickGaugeFromINF(SubcomponentId, TRUE);}
  3778. if (atCORE == AT_DO_NOTHING)
  3779. {iTicksSupposedToDo = 0;}
  3780. }
  3781. else
  3782. {
  3783. if (atComp == AT_REMOVE)
  3784. {iTicksSupposedToDo = GetTotalTickGaugeFromINF(SubcomponentId, FALSE);}
  3785. else
  3786. {iTicksSupposedToDo = GetTotalTickGaugeFromINF(SubcomponentId, TRUE);}
  3787. if (atComp == AT_DO_NOTHING)
  3788. {iTicksSupposedToDo = 0;}
  3789. }
  3790. // 1. Take the amount that we're supposed to be finsihed with from the inf.
  3791. // 2. take the amount that we are actually done with.
  3792. // fill up the difference
  3793. if (iTicksSupposedToDo > g_GlobalTotalTickGaugeCount)
  3794. {
  3795. int iTempVal = 0;
  3796. if (_tcsicmp(SubcomponentId, STRING_iis_common) == 0)
  3797. {iTempVal = g_GlobalTickTotal_iis_common;}
  3798. if (_tcsicmp(SubcomponentId, STRING_iis_inetmgr) == 0)
  3799. {iTempVal = g_GlobalTickTotal_iis_inetmgr;}
  3800. if (_tcsicmp(SubcomponentId, STRING_iis_www) == 0)
  3801. {iTempVal = g_GlobalTickTotal_iis_www;}
  3802. if (_tcsicmp(SubcomponentId, STRING_iis_pwmgr) == 0)
  3803. {iTempVal = g_GlobalTickTotal_iis_pwmgr;}
  3804. if (_tcsicmp(SubcomponentId, STRING_iis_doc) == 0)
  3805. {iTempVal = g_GlobalTickTotal_iis_doc;}
  3806. if (_tcsicmp(SubcomponentId, STRING_iis_htmla) == 0)
  3807. {iTempVal = g_GlobalTickTotal_iis_htmla;}
  3808. if (_tcsicmp(SubcomponentId, STRING_iis_ftp) == 0)
  3809. {iTempVal = g_GlobalTickTotal_iis_ftp;}
  3810. //iTicksYetToDo = iTicksSupposedToDo - g_GlobalTotalTickGaugeCount;
  3811. iTicksYetToDo = iTicksSupposedToDo - iTempVal;
  3812. // divide by the tick multiple.
  3813. // multiply the amount of ticks by our tick multiple
  3814. if (iTicksYetToDo > 0)
  3815. {
  3816. iTicksYetToDo = iTicksYetToDo / g_GlobalTickValue;
  3817. }
  3818. AdvanceProgressBarTickGauge(iTicksYetToDo);
  3819. }
  3820. }
  3821. return;
  3822. }
  3823. // ===================================================================================================================
  3824. // service1 service2
  3825. //
  3826. // Upg Upg
  3827. // Fresh Fresh
  3828. // Remove Remove
  3829. // Noop-Yes Noop-Yes Yes means ST_INSTALLED, No means ST_UNINSTALLED
  3830. // Noop-No Noop-No
  3831. // Noop_Yes | Noop_No | Remove | Install_Fresh | Install_Upgrade | Install_Reinstall
  3832. // ------------------------------------------------------------------------------------------------
  3833. // Noop_Yes | Noop_Yes | Noop_Yes | Noop_Yes | Noop_Yes | x | x
  3834. // Noop_No | Noop_Yes | Noop_No* | Remove* | Install_Fresh | Install_Upgrade | Install_Reinstall
  3835. // Remove | Noop_Yes | Remove* | Remove* | Noop_Yes | x | x
  3836. // Install_Fresh | Noop_Yes | Install_Fresh | Noop_Yes | Install_Fresh | x | x
  3837. // Install_Upgrade | x | Install_Upgrade | x | x | Install_Upgrade | x
  3838. // Install_Reinstall | x | Install_Reinstall | x | x | x | Install_Reinstall
  3839. //
  3840. // *: if it is still needed by other groups (e.g., SMTP), then we shouldn't remove it
  3841. // ===================================================================================================================
  3842. ACTION_TYPE GetIISCoreAction(int iLogResult)
  3843. {
  3844. ACTION_TYPE atCORE = AT_DO_NOTHING;
  3845. ACTION_TYPE atFTP = GetSubcompAction(STRING_iis_ftp, iLogResult);
  3846. ACTION_TYPE atWWW = GetSubcompAction(STRING_iis_www, iLogResult);
  3847. STATUS_TYPE stFTP = GetSubcompInitStatus(STRING_iis_ftp);
  3848. STATUS_TYPE stWWW = GetSubcompInitStatus(STRING_iis_www);
  3849. do
  3850. {
  3851. if ((atFTP == AT_DO_NOTHING && stFTP == ST_INSTALLED) || (atWWW == AT_DO_NOTHING && stWWW == ST_INSTALLED) )
  3852. {
  3853. atCORE = AT_DO_NOTHING;
  3854. break;
  3855. }
  3856. if (atFTP == AT_INSTALL_UPGRADE || atWWW == AT_INSTALL_UPGRADE)
  3857. {
  3858. atCORE = AT_INSTALL_UPGRADE;
  3859. break;
  3860. }
  3861. if ((atFTP == AT_INSTALL_FRESH && atWWW == AT_INSTALL_FRESH) || (atFTP == AT_INSTALL_FRESH && atWWW == AT_DO_NOTHING && stWWW == ST_UNINSTALLED) || (atFTP == AT_DO_NOTHING && stFTP == ST_UNINSTALLED && atWWW == AT_INSTALL_FRESH) )
  3862. {
  3863. atCORE = AT_INSTALL_FRESH;
  3864. break;
  3865. }
  3866. if ((atFTP == AT_REMOVE && atWWW == AT_DO_NOTHING && stWWW == ST_UNINSTALLED) || (atFTP == AT_DO_NOTHING && stFTP == ST_UNINSTALLED && atWWW == AT_REMOVE) )
  3867. {
  3868. atCORE = AT_REMOVE;
  3869. break;
  3870. }
  3871. if ( atFTP == AT_REMOVE && atWWW == AT_REMOVE )
  3872. {
  3873. atCORE = AT_REMOVE;
  3874. break;
  3875. }
  3876. if ( atFTP == AT_INSTALL_REINSTALL || atWWW == AT_INSTALL_REINSTALL )
  3877. {
  3878. atCORE = AT_INSTALL_REINSTALL;
  3879. break;
  3880. }
  3881. atCORE = AT_DO_NOTHING;
  3882. } while (0);
  3883. if (iLogResult)
  3884. {
  3885. DebugOutAction(STRING_iis_core, atCORE);
  3886. }
  3887. return (atCORE);
  3888. }
  3889. void DisplayActionsForAllOurComponents(IN HINF hInfFileHandle)
  3890. {
  3891. CStringList strList;
  3892. ACTION_TYPE atTheComponent;
  3893. CString csTheSection = OCM_OptionalComponents_Section;
  3894. if (GetSectionNameToDo(hInfFileHandle, csTheSection))
  3895. {
  3896. if (ERROR_SUCCESS == FillStrListWithListOfSections(hInfFileHandle, strList, csTheSection))
  3897. {
  3898. // loop thru the list returned back
  3899. if (strList.IsEmpty() == FALSE)
  3900. {
  3901. POSITION pos;
  3902. CString csEntry;
  3903. pos = strList.GetHeadPosition();
  3904. while (pos)
  3905. {
  3906. csEntry = _T("");
  3907. csEntry = strList.GetAt(pos);
  3908. // We now have the entry, send it to the function.
  3909. atTheComponent = GetSubcompAction(csEntry, TRUE);
  3910. // Get the next one.
  3911. strList.GetNext(pos);
  3912. }
  3913. }
  3914. }
  3915. }
  3916. return;
  3917. }