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

369 lines
12 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CTaskUpgradeWin2k.cpp
  7. //
  8. // Description:
  9. // Implementation file for the CTaskUpgradeWin2k class.
  10. //
  11. // Header File:
  12. // CTaskUpgradeWin2k.h
  13. //
  14. // Maintained By:
  15. // Vij Vasu (Vvasu) 18-APR-2000
  16. // Created this file.
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. //////////////////////////////////////////////////////////////////////////////
  20. // Include Files
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Precompiled header for this DLL.
  23. #include "pch.h"
  24. // The header file for this module.
  25. #include "CTaskUpgradeWin2k.h"
  26. //////////////////////////////////////////////////////////////////////////////
  27. // Macro Definitions
  28. //////////////////////////////////////////////////////////////////////////////
  29. // Needed for tracing.
  30. DEFINE_THISCLASS( "CTaskUpgradeWin2k" )
  31. /////////////////////////////////////////////////////////////////////////////
  32. //++
  33. //
  34. // CTaskUpgradeWin2k::CTaskUpgradeWin2k
  35. //
  36. // Description:
  37. // Constructor of the CTaskUpgradeWin2k class.
  38. //
  39. // Arguments:
  40. // const CClusOCMApp & rAppIn
  41. // Reference to the CClusOCMApp object that is hosting this task.
  42. //
  43. // Return Value:
  44. // None.
  45. //
  46. //--
  47. /////////////////////////////////////////////////////////////////////////////
  48. CTaskUpgradeWin2k::CTaskUpgradeWin2k( const CClusOCMApp & rAppIn )
  49. : BaseClass( rAppIn )
  50. {
  51. TraceFunc( "" );
  52. TraceFuncExit();
  53. } //*** CTaskUpgradeWin2k::CTaskUpgradeWin2k()
  54. /////////////////////////////////////////////////////////////////////////////
  55. //++
  56. //
  57. // CTaskUpgradeWin2k::~CTaskUpgradeWin2k
  58. //
  59. // Description:
  60. // Destructor of the CTaskUpgradeWin2k class.
  61. //
  62. // Arguments:
  63. // None.
  64. //
  65. // Return Value:
  66. // None.
  67. //
  68. //--
  69. /////////////////////////////////////////////////////////////////////////////
  70. CTaskUpgradeWin2k::~CTaskUpgradeWin2k( void )
  71. {
  72. TraceFunc( "" );
  73. TraceFuncExit();
  74. } //*** CTaskUpgradeWin2k::~CTaskUpgradeWin2k()
  75. /////////////////////////////////////////////////////////////////////////////
  76. //++
  77. //
  78. // DWORD
  79. // CTaskUpgradeWin2k::DwOcQueueFileOps
  80. //
  81. // Description:
  82. // This function handles the OC_QUEUE_FILE_OPS messages from the Optional
  83. // Components Manager. It installs the files needed for an upgrade from
  84. // Windows 2000.
  85. //
  86. // Arguments:
  87. // HSPFILEQ hSetupFileQueueIn
  88. // Handle to the file queue to operate upon.
  89. //
  90. // Return Value:
  91. // NO_ERROR if all went well.
  92. // Other Win32 error codes on failure.
  93. //
  94. //--
  95. /////////////////////////////////////////////////////////////////////////////
  96. DWORD
  97. CTaskUpgradeWin2k::DwOcQueueFileOps( HSPFILEQ hSetupFileQueueIn )
  98. {
  99. TraceFunc( "" );
  100. LogMsg( "Entering " __FUNCTION__ "()" );
  101. DWORD dwReturnValue = NO_ERROR;
  102. // Do different things based on whether this node is already part of a cluster or not.
  103. if ( RGetApp().CisGetClusterInstallState() == eClusterInstallStateFilesCopied )
  104. {
  105. TraceFlow( "The cluster binaries are installed, but this node is not part of a cluster." );
  106. LogMsg( "The cluster binaries are installed, but this node is not part of a cluster." );
  107. // The base class helper function does everything that we need to do here.
  108. // So, just call it.
  109. dwReturnValue = TW32( BaseClass::DwOcQueueFileOps( hSetupFileQueueIn, INF_SECTION_WIN2K_UPGRADE_UNCLUSTERED_NODE ) );
  110. } // if: the node is not part of a cluster
  111. else
  112. {
  113. TraceFlow( "This node is part of a cluster." );
  114. LogMsg( "This node is part of a cluster." );
  115. // The base class helper function does everything that we need to do here.
  116. // So, just call it.
  117. dwReturnValue = TW32( BaseClass::DwOcQueueFileOps( hSetupFileQueueIn, INF_SECTION_WIN2K_UPGRADE ) );
  118. } // else: the node is part of a cluster
  119. TraceFlow1( "Return Value is %#x.", dwReturnValue );
  120. LogMsg( "Return Value is %#x.", dwReturnValue );
  121. RETURN( dwReturnValue );
  122. } //*** CTaskUpgradeWin2k::DwOcQueueFileOps()
  123. /////////////////////////////////////////////////////////////////////////////
  124. //++
  125. //
  126. // DWORD
  127. // CTaskUpgradeWin2k::DwOcCompleteInstallation
  128. //
  129. // Description:
  130. // This function handles the OC_COMPLETE_INSTALLATION messages from the
  131. // Optional Components Manager during an upgrade from Windows 2000.
  132. //
  133. // Registry operations, COM component registrations, creation of servies
  134. // etc. are performed in this function.
  135. //
  136. // Arguments:
  137. // None.
  138. //
  139. // Return Value:
  140. // NO_ERROR if all went well.
  141. // Other Win32 error codes on failure.
  142. //
  143. //--
  144. /////////////////////////////////////////////////////////////////////////////
  145. DWORD
  146. CTaskUpgradeWin2k::DwOcCompleteInstallation( void )
  147. {
  148. TraceFunc( "" );
  149. LogMsg( "Entering " __FUNCTION__ "()" );
  150. DWORD dwReturnValue = NO_ERROR;
  151. // Do different things based on whether this node is already part of a cluster or not.
  152. if ( RGetApp().CisGetClusterInstallState() == eClusterInstallStateFilesCopied )
  153. {
  154. TraceFlow( "The cluster binaries are installed, but this node is not part of a cluster." );
  155. LogMsg( "The cluster binaries are installed, but this node is not part of a cluster." );
  156. // The base class helper function does everything that we need to do here.
  157. // So, just call it.
  158. dwReturnValue = TW32( BaseClass::DwOcCompleteInstallation( INF_SECTION_WIN2K_UPGRADE_UNCLUSTERED_NODE ) );
  159. } // if: the node is not part of a cluster
  160. else
  161. {
  162. TraceFlow( "This node is part of a cluster." );
  163. LogMsg( "This node is part of a cluster." );
  164. // The base class helper function does everything that we need to do here.
  165. // So, just call it.
  166. dwReturnValue = TW32( BaseClass::DwOcCompleteInstallation( INF_SECTION_WIN2K_UPGRADE ) );
  167. } // else: the node is part of a cluster
  168. TraceFlow1( "Return Value is %#x.", dwReturnValue );
  169. LogMsg( "Return Value is %#x.", dwReturnValue );
  170. RETURN( dwReturnValue );
  171. } //*** CTaskUpgradeWin2k::DwOcCompleteInstallation()
  172. /////////////////////////////////////////////////////////////////////////////
  173. //++
  174. //
  175. // DWORD
  176. // CTaskUpgradeWin2k::DwOcCleanup
  177. //
  178. // Description:
  179. // This function handles the OC_CLEANUP messages from the
  180. // Optional Components Manager during an upgrade from Windows 2000.
  181. //
  182. // If an error has previously occurred during this task, cleanup operations
  183. // are performed. Otherwise nothing is done by this function.
  184. //
  185. // Arguments:
  186. // None.
  187. //
  188. // Return Value:
  189. // NO_ERROR if all went well.
  190. // Other Win32 error codes on failure.
  191. //
  192. //--
  193. /////////////////////////////////////////////////////////////////////////////
  194. DWORD
  195. CTaskUpgradeWin2k::DwOcCleanup( void )
  196. {
  197. TraceFunc( "" );
  198. LogMsg( "Entering " __FUNCTION__ "()" );
  199. DWORD dwReturnValue = NO_ERROR;
  200. // Do different things based on whether this node is already part of a cluster or not.
  201. if ( RGetApp().CisGetClusterInstallState() == eClusterInstallStateFilesCopied )
  202. {
  203. TraceFlow( "The cluster binaries are installed, but this node is not part of a cluster." );
  204. LogMsg( "The cluster binaries are installed, but this node is not part of a cluster." );
  205. // The base class helper function does everything that we need to do here.
  206. // So, just call it.
  207. dwReturnValue = TW32( BaseClass::DwOcCleanup( INF_SECTION_WIN2K_UPGRADE_UNCLUSTERED_NODE_CLEANUP ) );
  208. } // if: the node is not part of a cluster
  209. else
  210. {
  211. TraceFlow( "This node is part of a cluster." );
  212. LogMsg( "This node is part of a cluster." );
  213. // The base class helper function does everything that we need to do here.
  214. // So, just call it.
  215. dwReturnValue = TW32( BaseClass::DwOcCleanup( INF_SECTION_WIN2K_UPGRADE_CLEANUP ) );
  216. } // else: the node is part of a cluster
  217. TraceFlow1( "Return Value is %#x.", dwReturnValue );
  218. LogMsg( "Return Value is %#x.", dwReturnValue );
  219. RETURN( dwReturnValue );
  220. } //*** CTaskUpgradeWin2k::DwOcCleanup()
  221. /////////////////////////////////////////////////////////////////////////////
  222. //++
  223. //
  224. // DWORD
  225. // CTaskUpgradeWin2k::DwSetDirectoryIds
  226. //
  227. // Description:
  228. // This function maps ids specified in the INF file to directories.
  229. // The behavior of this function is different for different cluster
  230. // installation states.
  231. //
  232. // If the cluster binaries are installed, but the node is not part
  233. // of a cluster, the cluster installation directory is set to the
  234. // default value.
  235. //
  236. // If the node is already a part of a cluster, the cluster installation
  237. // directory is got from the service control manager, since it is possible
  238. // the the cluster binaries are installed in a non-default location if
  239. // this node was upgraded from NT4 previously.
  240. //
  241. // Arguments:
  242. // None.
  243. //
  244. // Return Value:
  245. // NO_ERROR if all went well.
  246. // Other Win32 error codes on failure.
  247. //
  248. //--
  249. /////////////////////////////////////////////////////////////////////////////
  250. DWORD
  251. CTaskUpgradeWin2k::DwSetDirectoryIds( void )
  252. {
  253. TraceFunc( "" );
  254. LogMsg( "Entering " __FUNCTION__ "()" );
  255. DWORD dwReturnValue = NO_ERROR;
  256. do
  257. {
  258. const WCHAR * pcszInstallDir = NULL;
  259. if ( RGetApp().CisGetClusterInstallState() == eClusterInstallStateFilesCopied )
  260. {
  261. // If the cluster binaries have been install previously, and the node is
  262. // not part of a cluster, the binaries have to be installed in the default
  263. // location. This is because the binaries were always installed in the
  264. // default location in Win2k and it is not possible to be in this state
  265. // on a Win2k node by upgrading from NT4.
  266. // The base class helper function does everything that we need to do here.
  267. // So, just call it.
  268. TraceFlow( "This node is not part of a cluster. Upgrading files in the default directory." );
  269. LogMsg( "This node is not part of a cluster. Upgrading files in the default directory." );
  270. dwReturnValue = TW32( BaseClass::DwSetDirectoryIds() );
  271. // We are done.
  272. break;
  273. } // if: the node is not part of a cluster
  274. // If we are here, the this node is already a part of a cluster. So, get the
  275. // installation directory from SCM.
  276. TraceFlow( "This node is part of a cluster. Trying to determine the installation directory." );
  277. LogMsg( "This node is part of a cluster. Trying to determine the installation directory." );
  278. // Do not free the pointer returned by this call.
  279. dwReturnValue = TW32( DwGetClusterServiceDirectory( pcszInstallDir ) );
  280. if ( dwReturnValue != NO_ERROR )
  281. {
  282. TraceFlow1( "Error %#x occurred trying to determine the directory in which the cluster binaries are installed.", dwReturnValue );
  283. LogMsg( "Error %#x occurred trying to determine the directory in which the cluster binaries are installed.", dwReturnValue );
  284. break;
  285. } // if: we could not get the cluster service installation directory
  286. TraceFlow1( "The cluster binaries are installed in the directory '%ws'.", pcszInstallDir );
  287. LogMsg( "The cluster binaries are installed in the directory '%ws'.", pcszInstallDir );
  288. // Create the mapping between the directory id and the path
  289. if ( SetupSetDirectoryId(
  290. RGetApp().RsicGetSetupInitComponent().ComponentInfHandle
  291. , CLUSTER_DEFAULT_INSTALL_DIRID
  292. , pcszInstallDir
  293. )
  294. == FALSE
  295. )
  296. {
  297. dwReturnValue = TW32( GetLastError() );
  298. TraceFlow1( "Error %#x occurred trying set the cluster install directory id.", dwReturnValue );
  299. LogMsg( "Error %#x occurred trying set the cluster install directory id.", dwReturnValue );
  300. break;
  301. } // if: SetupSetDirectoryId() failed
  302. TraceFlow2( "The id %d maps to '%ws'.", CLUSTER_DEFAULT_INSTALL_DIRID, pcszInstallDir );
  303. LogMsg( "The id %d maps to '%ws'.", CLUSTER_DEFAULT_INSTALL_DIRID, pcszInstallDir );
  304. }
  305. while ( false ); // dummy do-while loop to avoid gotos
  306. TraceFlow1( "Return Value is %#x.", dwReturnValue );
  307. LogMsg( "Return Value is %#x.", dwReturnValue );
  308. RETURN( dwReturnValue );
  309. } //*** CTaskUpgradeWin2k::DwSetDirectoryIds()