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.

345 lines
11 KiB

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