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.

189 lines
3.3 KiB

  1. /*
  2. File upgrade.c
  3. Implementation of functions to update the registry when an
  4. NT 4.0 to NT 5.0 upgrade takes place.
  5. Paul Mayfield, 8/11/97
  6. Copyright 1997 Microsoft.
  7. */
  8. #include "upgrade.h"
  9. static const WCHAR szSteelheadKey[] = L"PreUpgradeRouter";
  10. static const WCHAR szSapKey[] = L"Sap.Parameters";
  11. static const WCHAR szIpRipKey[] = L"IpRip.Parameters";
  12. static const WCHAR szDhcpKey[] = L"RelayAgent.Parameters";
  13. static const WCHAR szRadiusKey[] = L"Radius.Parameters";
  14. static const WCHAR szIpxRipKey[] = L"IpxRip";
  15. // Dll entry
  16. BOOL
  17. WINAPI
  18. RtrUpgradeDllEntry (
  19. IN HINSTANCE hInstDll,
  20. IN DWORD fdwReason,
  21. IN LPVOID pReserved)
  22. {
  23. switch (fdwReason)
  24. {
  25. case DLL_PROCESS_ATTACH:
  26. DisableThreadLibraryCalls(hInstDll);
  27. break;
  28. }
  29. return TRUE;
  30. }
  31. //
  32. // Performs the various router upgrade scenarios
  33. //
  34. DWORD
  35. DispatchSetupWork(
  36. IN PWCHAR szAnswerFileName,
  37. IN PWCHAR szSectionName)
  38. {
  39. HINF hInf = NULL;
  40. BOOL DoUpgrade;
  41. WCHAR szBuf[1024];
  42. DWORD dwSize = 1024;
  43. DWORD dwErr, dwRet = NO_ERROR;
  44. // Open the answer file
  45. hInf = SetupOpenInfFileW(
  46. szAnswerFileName,
  47. NULL,
  48. INF_STYLE_OLDNT,
  49. NULL);
  50. if (hInf == INVALID_HANDLE_VALUE)
  51. {
  52. return GetLastError();
  53. }
  54. // Perform a steelhead upgrade
  55. //
  56. dwSize = sizeof(szBuf) / sizeof(WCHAR);
  57. if (SetupGetLineTextW(
  58. NULL,
  59. hInf,
  60. szSectionName,
  61. szSteelheadKey,
  62. szBuf,
  63. dwSize,
  64. &dwSize))
  65. {
  66. dwErr = SteelheadToNt5Upgrade(szBuf);
  67. if (dwErr != NO_ERROR)
  68. {
  69. dwRet = dwErr;
  70. }
  71. }
  72. // Perform an ipx sap upgrade
  73. //
  74. dwSize = sizeof(szBuf) / sizeof(WCHAR);
  75. if (SetupGetLineTextW(
  76. NULL,
  77. hInf,
  78. szSectionName,
  79. szSapKey,
  80. szBuf,
  81. dwSize,
  82. &dwSize))
  83. {
  84. dwErr = SapToRouterUpgrade(szBuf);
  85. if (dwErr != NO_ERROR)
  86. {
  87. dwRet = dwErr;
  88. }
  89. }
  90. // Perform an ip rip upgrade
  91. //
  92. dwSize = sizeof(szBuf) / sizeof(WCHAR);
  93. if (SetupGetLineTextW(
  94. NULL,
  95. hInf,
  96. szSectionName,
  97. szIpRipKey,
  98. szBuf,
  99. dwSize,
  100. &dwSize))
  101. {
  102. dwErr = IpRipToRouterUpgrade(szBuf);
  103. if (dwErr != NO_ERROR)
  104. {
  105. dwRet = dwErr;
  106. }
  107. }
  108. // Perform a dhcp relay agent upgrade
  109. //
  110. dwSize = sizeof(szBuf) / sizeof(WCHAR);
  111. if (SetupGetLineTextW(
  112. NULL,
  113. hInf,
  114. szSectionName,
  115. szDhcpKey,
  116. szBuf,
  117. dwSize,
  118. &dwSize))
  119. {
  120. dwErr = DhcpToRouterUpgrade(szBuf);
  121. if (dwErr != NO_ERROR)
  122. {
  123. dwRet = dwErr;
  124. }
  125. }
  126. // Perform a radius upgrade
  127. //
  128. dwSize = sizeof(szBuf) / sizeof(WCHAR);
  129. if (SetupGetLineTextW(
  130. NULL,
  131. hInf,
  132. szSectionName,
  133. szRadiusKey,
  134. szBuf,
  135. dwSize,
  136. &dwSize))
  137. {
  138. dwErr = RadiusToRouterUpgrade(szBuf);
  139. if (dwErr != NO_ERROR)
  140. {
  141. dwRet = dwErr;
  142. }
  143. }
  144. SetupCloseInfFile(hInf);
  145. return dwRet;
  146. }
  147. //
  148. // This is the entry point to upgrade mpr v1 and steelhead to
  149. // NT 5.0.
  150. //
  151. HRESULT
  152. WINAPI
  153. RouterUpgrade (
  154. IN DWORD dwUpgradeFlag,
  155. IN DWORD dwUpgradeFromBuildNumber,
  156. IN PWCHAR szAnswerFileName,
  157. IN PWCHAR szSectionName)
  158. {
  159. DWORD dwErr;
  160. dwErr = DispatchSetupWork(szAnswerFileName, szSectionName);
  161. if (dwErr == NO_ERROR)
  162. {
  163. return S_OK;
  164. }
  165. UtlPrintErr(dwErr);
  166. return dwErr;
  167. }