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.

221 lines
6.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998.
  5. //
  6. // File: apmupgrd.cpp
  7. //
  8. // Contents: DllMain
  9. //
  10. // Notes: copied from net\config\upgrade\netupgrd\netupgrd.cpp by kumarp
  11. //
  12. // Author: t-sdey 19 June 98
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <winnt32.h>
  16. #include "apmupgrd.h"
  17. #include "apmrsrc.h"
  18. // ----------------------------------------------------------------------
  19. // variables
  20. HINSTANCE g_hinst;
  21. TCHAR g_APM_ERROR_HTML_FILE[] = TEXT("compdata\\apmerror.htm");
  22. TCHAR g_APM_ERROR_TEXT_FILE[] = TEXT("compdata\\apmerror.txt");
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Function: DllMain
  26. //
  27. // Purpose: constructor
  28. //
  29. // Arguments: Standard DLL entry point arguments
  30. //
  31. // Author: t-sdey 19 June 98
  32. //
  33. // Notes: from kumarp 12 April 97
  34. //
  35. extern "C"
  36. BOOL WINAPI DllMain(HINSTANCE hInstance,
  37. DWORD dwReasonForCall,
  38. LPVOID lpReserved)
  39. {
  40. BOOL status = TRUE;
  41. switch( dwReasonForCall )
  42. {
  43. case DLL_PROCESS_ATTACH:
  44. {
  45. g_hinst = hInstance;
  46. DisableThreadLibraryCalls(hInstance);
  47. }
  48. break;
  49. case DLL_PROCESS_DETACH:
  50. case DLL_THREAD_ATTACH:
  51. case DLL_THREAD_DETACH:
  52. break;
  53. }
  54. return status;
  55. }
  56. //+----------------------------------------------------------------------
  57. //
  58. // Function: ApmUpgradeCompatibilityCheck
  59. //
  60. // Purpose: This function is called by winnt32.exe so that we
  61. // can scan the system to find any potential upgrade problems.
  62. //
  63. // NOTE: we do not call CompatibilityCallback to report
  64. // conflicts to winnt32 unless there was a problem removing them
  65. // or the user cancels removal.
  66. //
  67. // Arguments:
  68. // CompatibilityCallback [in] pointer to COMPATIBILITYCALLBACK fn
  69. // Context [in] pointer to compatibility context
  70. //
  71. // Returns: FALSE if successful (no conflicts remaining)
  72. // TRUE if unsuccessful (conflicts still exist -- cancel setup)
  73. //
  74. // Author: t-sdey 1 July 98
  75. //
  76. // Notes:
  77. //
  78. BOOL WINAPI ApmUpgradeCompatibilityCheck(
  79. IN PCOMPAIBILITYCALLBACK CompatibilityCallback,
  80. IN LPVOID Context)
  81. {
  82. if (HrDetectAPMConflicts() == S_OK)
  83. return FALSE;
  84. // Signal to the user that there was a problem.
  85. // Prepare the warning message
  86. TCHAR szDescription[5000];
  87. if(!LoadString(g_hinst, APM_STR_CONFLICT_DESCRIPTION, szDescription, 5000)) {
  88. szDescription[0] = 0;
  89. }
  90. // Use the callback function to send the signal
  91. COMPATIBILITY_ENTRY ce;
  92. ZeroMemory((PVOID)&ce, sizeof(COMPATIBILITY_ENTRY));
  93. ce.Description = szDescription;
  94. ce.HtmlName = g_APM_ERROR_HTML_FILE; // defined above
  95. ce.TextName = g_APM_ERROR_TEXT_FILE; // defined above
  96. ce.RegKeyName = NULL;
  97. ce.RegValName = NULL;
  98. ce.RegValDataSize = 0;
  99. ce.RegValData = NULL;
  100. ce.SaveValue = NULL;
  101. ce.Flags = 0;
  102. CompatibilityCallback(&ce, Context);
  103. return TRUE;
  104. }
  105. //+---------------------------------------------------------------------------
  106. //
  107. // Function: ApmUpgradeHandleHaveDisk
  108. //
  109. // Purpose: This callback function is called by winnt32.exe
  110. // if user clicks HaveDisk button on the compatibility
  111. // report page. However, that situation *should* never
  112. // arise, so this function does nothing.
  113. //
  114. // Arguments:
  115. // hwndParent [in] handle of parent window
  116. // SaveValue [in] pointer to private data
  117. // (we store CNetComponent* in this pointer)
  118. //
  119. // Returns: ERROR_SUCCESS
  120. //
  121. // Author: t-sdey 1 July 98
  122. //
  123. // Notes:
  124. //
  125. DWORD WINAPI ApmUpgradeHandleHaveDisk(IN HWND hwndParent,
  126. IN LPVOID SaveValue)
  127. {
  128. return ERROR_SUCCESS;
  129. }
  130. //+---------------------------------------------------------------------------
  131. //
  132. // Function: HrDetectAPMConflicts
  133. //
  134. // Purpose: Detect and disable any APM drivers which will not work under
  135. // NT 5.0.
  136. //
  137. // Arguments:
  138. //
  139. // Returns: S_OK if conflict detect/disable was successful
  140. // S_FALSE if unsuccessful/cancelled -- must ABORT SETUP!
  141. //
  142. // Author: t-sdey 29 June 98
  143. //
  144. // Notes:
  145. //
  146. HRESULT HrDetectAPMConflicts()
  147. {
  148. HRESULT hrStatus = S_OK;
  149. // Check each company's drivers individually
  150. hrStatus = HrDetectAndDisableSystemSoftAPMDrivers();
  151. if (hrStatus == S_OK)
  152. hrStatus = HrDetectAndDisableAwardAPMDrivers();
  153. if (hrStatus == S_OK)
  154. hrStatus = HrDetectAndDisableSoftexAPMDrivers();
  155. if (hrStatus == S_OK)
  156. hrStatus = HrDetectAndDisableIBMAPMDrivers();
  157. return hrStatus;
  158. }
  159. //+---------------------------------------------------------------------------
  160. //
  161. // Function: DisplayAPMDisableWarningDialog
  162. //
  163. // Purpose: Display a popup informing the user of APM services about to be
  164. // disabled.
  165. //
  166. // Arguments: dwCaptionID [in] the ID of the caption for the window
  167. // dwMessageID [in] the ID of the message to display
  168. //
  169. // Returns: integer flag - IDOK if the user clicked "OK"
  170. // IDCANCEL if the user clicked "Cancel" or some other
  171. // error occurred -- Must exit setup
  172. //
  173. // Author: t-sdey 29 June 98
  174. //
  175. // Notes:
  176. //
  177. int DisplayAPMDisableWarningDialog(IN DWORD dwCaptionID,
  178. IN DWORD dwMessageID)
  179. {
  180. // Prepare the strings
  181. TCHAR szCaption[512];
  182. TCHAR szMessage[5000];
  183. if(!LoadString(g_hinst, dwCaptionID, szCaption, 512)) {
  184. szCaption[0] = 0;
  185. }
  186. if(!LoadString(g_hinst, dwMessageID, szMessage, 5000)) {
  187. szMessage[0] = 0;
  188. }
  189. // Create the dialog box
  190. int button = MessageBox(NULL, szMessage, szCaption, MB_OKCANCEL);
  191. // Check which button the user pushed
  192. if (button == IDOK) // The user clicked "OK"
  193. return (IDOK);
  194. else // The user clicked "Cancel" or an error occurred
  195. return (IDCANCEL);
  196. }