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.

246 lines
5.2 KiB

  1. /*++
  2. Copyright (C) 2000 Microsoft Corporation
  3. Module Name:
  4. ftcomp.cpp
  5. Abstract:
  6. This compatibility dll is used by winnt32.exe in order to decide
  7. if the SIS groveler is running. If so it will stop the groveler
  8. and pop-up a dialog telling them we stopped it. It will then allow
  9. the installation to proceed.
  10. Author:
  11. Neal Christiansen (nealch) 02-May-2002
  12. Environment:
  13. compatibility dll for sis groveler
  14. Notes:
  15. Revision History:
  16. --*/
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <stdio.h>
  21. #include <windows.h>
  22. #include <comp.h>
  23. #include "siscomprc.h"
  24. #define LOCAL_DEBUG (DBG && 0)
  25. //
  26. // Control local debug display (by default we
  27. //
  28. #if LOCAL_DEBUG
  29. #define MyKdPrint( _string ) DbgPrint _string
  30. #else
  31. #define MyKdPrint( _string )
  32. #endif
  33. //
  34. // Global variables
  35. //
  36. SC_HANDLE scm = NULL; //service control manager handle
  37. HINSTANCE g_hinst = NULL;
  38. //
  39. // Function prototypes
  40. //
  41. BOOL WINAPI
  42. SisCompatibilityCheck(
  43. IN PCOMPAIBILITYCALLBACK CompatibilityCallback,
  44. IN LPVOID Context
  45. );
  46. BOOL
  47. StopGrovelerService(
  48. );
  49. DllMain(
  50. HINSTANCE hInstance,
  51. DWORD dwReasonForCall,
  52. LPVOID lpReserved
  53. )
  54. {
  55. BOOL status = TRUE;
  56. switch( dwReasonForCall )
  57. {
  58. case DLL_PROCESS_ATTACH:
  59. g_hinst = hInstance;
  60. DisableThreadLibraryCalls(hInstance);
  61. break;
  62. case DLL_PROCESS_DETACH:
  63. case DLL_THREAD_ATTACH:
  64. case DLL_THREAD_DETACH:
  65. break;
  66. }
  67. return status;
  68. }
  69. BOOL WINAPI
  70. SisCompatibilityCheck(
  71. IN PCOMPAIBILITYCALLBACK CompatibilityCallback,
  72. IN LPVOID Context
  73. )
  74. /*++
  75. Routine Description:
  76. This routine is called by winnt32.exe in order to decide whether the user
  77. should be warned about the presence of FT sets in a Windows NT 4.0 system
  78. Arguments:
  79. CompatibilityCallback - Supplies the winnt32 callback
  80. Context - Supplies the compatibility context
  81. Return Value:
  82. TRUE if the CompatibilityCallback was called
  83. FALSE if it was not
  84. --*/
  85. {
  86. COMPATIBILITY_ENTRY ce;
  87. BOOL retval = FALSE;
  88. WCHAR description[128];
  89. //
  90. // Obtain a handle to the service control manager requesting all access
  91. //
  92. scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  93. if (!scm) {
  94. //
  95. // If we can't access the service control manager, just let the
  96. // operation proceed
  97. //
  98. return FALSE;
  99. }
  100. try {
  101. if (StopGrovelerService()) {
  102. if (!LoadString(g_hinst, SISCOMP_STR_DESCRIPTION, description, sizeof(description)/sizeof(WCHAR))) {
  103. description[0] = 0;
  104. }
  105. MyKdPrint(("SisComp!SisCompatibilityCheck: Description=\"%S\"\n",description));
  106. //
  107. // The groveler was stopped, display the compatbility entry
  108. //
  109. ZeroMemory( &ce, sizeof(COMPATIBILITY_ENTRY) );
  110. ce.Description = description;
  111. ce.HtmlName = L"compdata\\groveler.htm";
  112. ce.TextName = L"compdata\\groveler.txt";
  113. CompatibilityCallback(&ce, Context);
  114. retval = TRUE; //mark we called compatibility routine
  115. }
  116. } finally {
  117. CloseServiceHandle(scm);
  118. }
  119. return retval;
  120. }
  121. BOOL
  122. StopGrovelerService(
  123. )
  124. /*++
  125. Routine Description:
  126. This routine will locate and try and STOP the groveler service. This
  127. returns TRUE if the service was stopped, else FALSE (which means it
  128. was not found or couldn't be stopped)
  129. Arguments:
  130. Return Value:
  131. TRUE If the service was stopped
  132. FALSE if it was not found/stopped
  133. --*/
  134. {
  135. SC_HANDLE hGroveler;
  136. SERVICE_STATUS grovelerStatus;
  137. BOOL retValue = FALSE;
  138. try {
  139. //
  140. // Open the groveler service, if it does not exists, just return
  141. //
  142. hGroveler = OpenService( scm,
  143. L"groveler",
  144. SERVICE_ALL_ACCESS );
  145. if (hGroveler == NULL) {
  146. MyKdPrint(("SisComp!StopGrovelerService: Groveler service not found, status=%d\n",GetLastError()));
  147. leave;
  148. }
  149. MyKdPrint(("SisComp!StopGrovelerService: Groveler service detected\n"));
  150. //
  151. // We opened the groveler service, tell the service to stop.
  152. //
  153. if (!ControlService( hGroveler, SERVICE_CONTROL_STOP, &grovelerStatus )) {
  154. MyKdPrint(("SisComp!StopGrovelerService: Groveler STOP request failed, status=%d\n",GetLastError()));
  155. leave;
  156. }
  157. //
  158. // It was successfully stopped, return correct value
  159. //
  160. MyKdPrint(("SisComp!StopGrovelerService: Groveler service stopped\n"));
  161. retValue = TRUE;
  162. } finally {
  163. //
  164. // Close the service handle
  165. //
  166. if (hGroveler) {
  167. CloseServiceHandle( hGroveler );
  168. }
  169. }
  170. return retValue;
  171. }