Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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