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.

244 lines
8.7 KiB

  1. // SvcProp.h : header file
  2. //
  3. // Data object used to display service properties.
  4. //
  5. //
  6. #ifndef __SVCPROP_H__
  7. #define __SVCPROP_H__
  8. /////////////////////////////////////////////////////////////////////
  9. // Structure used by the hardware profile listbox. One of these
  10. // structure is allocated per listbox item.
  11. //
  12. // Typically the listbox has very few entries.
  13. //
  14. class CHardwareProfileEntry // hpe
  15. {
  16. public:
  17. CHardwareProfileEntry * m_pNext; // Next item of the linked-list
  18. HWPROFILEINFO m_hpi; // Hardware profile info returned by CM_Get_Hardware_Profile_Info_Ex()
  19. ULONG m_uHwFlags; // Hardware profile flags for the given device instance
  20. CString m_strDeviceName;
  21. CString m_strDeviceNameFriendly;
  22. BOOL m_fReadOnly; // TRUE => Cannot disable this hardware profile entry
  23. BOOL m_fEnabled; // TRUE => Given hardware profile entry is enabled.
  24. public:
  25. CHardwareProfileEntry(
  26. IN CONST HWPROFILEINFO * phpi,
  27. IN ULONG uHwFlags,
  28. TCHAR * pszDeviceName,
  29. CString * pstrDeviceNameFriendly);
  30. ~CHardwareProfileEntry();
  31. BOOL FWriteHardwareProfile(HMACHINE hMachine);
  32. }; // CHardwareProfileEntry
  33. #define SERVICE_cchDisplayNameMax 256
  34. #define SERVICE_cchDescriptionMax 2048 // Maximum number of character in the description
  35. #define SERVICE_cbQueryServiceConfigMax 4096 // Maximum number of bytes required by QueryServiceConfig()
  36. #define SERVICE_cchRebootMessageMax 2048 // Longest length of the reboot message
  37. #define cActionsMax 3 // Maximum number of failure/actions supported
  38. // Macros to convert one time unit to another
  39. #define CvtMillisecondsIntoMinutes(dwMilliseconds) ((dwMilliseconds) / (1000 * 60))
  40. #define CvtSecondsIntoDays(dwSeconds) ((dwSeconds) / (60 * 60 * 24))
  41. #define CvtMinutesIntoMilliseconds(dwMinutes) ((dwMinutes) * 60 * 1000)
  42. #define CvtDaysIntoSeconds(dwDays) ((dwDays) * 60 * 60 * 24)
  43. /////////////////////////////////////////////////////////////////////
  44. // class CDlgPropService - Service dialog properties
  45. //
  46. // This object is created only to display the service properties
  47. // of a given service.
  48. //
  49. class CServicePropertyData
  50. {
  51. friend class CServicePageGeneral;
  52. friend class CServicePageHwProfile;
  53. friend class CServicePageRecovery;
  54. friend class CServicePageRecovery2;
  55. friend class CServiceDlgRebootComputer;
  56. protected:
  57. enum _DIRTYFLAGS
  58. {
  59. mskzValidNone = 0x00000000, // None of the fields are valid
  60. mskfValidSS = 0x00000001, // Content of m_SS is valid
  61. mskfValidQSC = 0x00000002, // Content of m_paQSC is valid
  62. mskfValidSFA = 0x00000004, // Content of m_SFA is valid
  63. mskfValidDescr = 0x00000008, // Service description is valid
  64. mskfSystemProcess = 0x00000010, // Service runs in system process
  65. //mskfValidAll = 0x00000080, // All the fields are valid
  66. mskfErrorBAADF00D = 0x00008000, // Workaround for the error code returned by CM_Get_Hardware_Profile_Info_Ex()
  67. // General
  68. #ifdef EDIT_DISPLAY_NAME_373025
  69. mskfDirtyDisplayName = 0x00010000, // Service display name has been modified
  70. mskfDirtyDescription = 0x00020000, // Service description has been modified
  71. #endif // EDIT_DISPLAY_NAME_373025
  72. mskfDirtyStartupType = 0x00040000, // Startup type has been modified
  73. // mskfDirtyStartupParam = 0x00080000, // IGNORED: Startup parameters are not persistent
  74. // Log On
  75. mskfDirtyAccountName = 0x01000000,
  76. mskfDirtyPassword = 0x02000000,
  77. mskfDirtySvcType = 0x04000000,
  78. // Recovery
  79. mskfDirtySFA = 0x10000000, // Content of m_SFA has been modified
  80. mskfDirtyRunFile = 0x20000000, // Command to run a file has been modified
  81. mskfDirtyRebootMessage = 0x40000000, // Reboot message has been modified
  82. mskfDirtyActionType = 0x80000000, // Only the action type has been changed
  83. mskmDirtyAll = 0xFFFF0000, // Mask to check if one of the field has been modified
  84. } DIRTYFLAGS;
  85. protected:
  86. IDataObjectPtr m_spDataObject; // Used for MMCPropertyChangeNotify
  87. LONG_PTR m_lNotifyHandle; // Handle used to notify SnapIn parent when properties are modified
  88. HMACHINE m_hMachine; // Handle of computer for Configuration Manager.
  89. SC_HANDLE m_hScManager; // Handle to service control manager database
  90. CString m_strMachineName; // Name of the computer. Empty for 'local machine'.
  91. CString m_strUiMachineName; // Name of the computer in a friendly way (should not be used with the APIs)
  92. CString m_strServiceName; // Name of the service
  93. CONST TCHAR * m_pszServiceName; // Pointer to service name (pointing to m_strServiceName)
  94. CString m_strServiceDisplayName; // Display name of the service
  95. BOOL m_fQueryServiceConfig2; // TRUE => Machine support QueryServiceConfig2() API
  96. UINT m_uFlags; // Flags about which fields are dirty
  97. //
  98. // General Dialog
  99. //
  100. // JonN 4/21/01 348163
  101. // Note that this structure may not be initialized, or only the
  102. // SERVICE_STATUS field may be initialized
  103. SERVICE_STATUS_PROCESS m_SS; // Service Status structure
  104. QUERY_SERVICE_CONFIG * m_paQSC; // Pointer to allocated QSC structure
  105. CString m_strDescription; // Description of service
  106. //
  107. // Logon As Dialog
  108. //
  109. CString m_strLogOnAccountName;
  110. CString m_strPassword;
  111. //
  112. // Hardware profile
  113. //
  114. CHardwareProfileEntry * m_paHardwareProfileEntryList; // Pointer to linked list of entries
  115. BOOL m_fShowHwProfileInstances; // TRUE => Show the device instances
  116. INT m_iSubItemHwProfileStatus; // Always 1 or 2 (computed from 1 + m_fShowHwProfileInstance)
  117. //
  118. // Recovery Dialog
  119. //
  120. SERVICE_FAILURE_ACTIONS * m_paSFA; // Pointer to allocated SFA structure
  121. SERVICE_FAILURE_ACTIONS m_SFA; // Output SFA structure
  122. SC_ACTION m_rgSA[cActionsMax]; // Array to hold first, second and subsequent failures
  123. BOOL m_fAllSfaTakeNoAction; // TRUE => All SFA recovery attemps do take no actions
  124. // JonN 3/28/00 28975
  125. // IIS 5.0 Reliability : SCM Snap-in :
  126. // The snap-in is changing the failure action delay value
  127. //
  128. // We remember the initial value and what we initially displayed.
  129. // if the user does not change the value of DelayAbendCount,
  130. // DelayRestartService, or DelayRebootComputer.
  131. UINT m_secOriginalAbendCount;
  132. UINT m_daysOriginalAbendCount;
  133. UINT m_daysDisplayAbendCount;
  134. UINT m_msecOriginalRestartService;
  135. UINT m_minOriginalRestartService;
  136. UINT m_minDisplayRestartService;
  137. UINT m_msecOriginalRebootComputer;
  138. UINT m_minOriginalRebootComputer;
  139. UINT m_minDisplayRebootComputer;
  140. CString m_strRunFileCommand; // Command line with arguments and abend number (if any)
  141. CString m_strRebootMessage; // Reboot message
  142. HWND m_hwndPropertySheet; // Handle of the property sheet
  143. CServicePageGeneral * m_pPageGeneral;
  144. CServicePageHwProfile * m_pPageHwProfile;
  145. CServicePageRecovery * m_pPageRecovery;
  146. CServicePageRecovery2 * m_pPageRecovery2; // JonN 4/20/01 348163
  147. public:
  148. CServicePropertyData();
  149. ~CServicePropertyData();
  150. BOOL FInit(
  151. LPDATAOBJECT lpDataObject,
  152. CONST TCHAR pszMachineName[],
  153. CONST TCHAR pszServiceName[],
  154. CONST TCHAR pszServiceDisplayName[],
  155. LONG_PTR lNotifyHandle);
  156. BOOL CreatePropertyPages(LPPROPERTYSHEETCALLBACK pCallback);
  157. BOOL FOpenScManager();
  158. BOOL FQueryServiceInfo();
  159. BOOL FUpdateServiceInfo();
  160. void FCheckLSAAccount();
  161. BOOL FOnApply();
  162. void NotifySnapInParent();
  163. void UpdateCaption();
  164. void FlushHardwareProfileEntries();
  165. BOOL FQueryHardwareProfileEntries();
  166. BOOL FChangeHardwareProfileEntries();
  167. void SetDirty(enum CServicePropertyData::_DIRTYFLAGS uDirtyFlag)
  168. {
  169. Assert((uDirtyFlag & ~mskmDirtyAll) == 0);
  170. m_uFlags |= uDirtyFlag;
  171. }
  172. UINT GetDelayForActionType(SC_ACTION_TYPE actionType, BOOL * pfDelayFound);
  173. void SetDelayForActionType(SC_ACTION_TYPE actionType, UINT uDelay);
  174. UINT QueryUsesActionType(SC_ACTION_TYPE actionType);
  175. BOOL FAllSfaTakeNoAction();
  176. }; // CServicePropertyData
  177. /*
  178. These functions call through to the appropriate ADVAPI32 calls
  179. and set the last parameter to FALSE
  180. */
  181. /* ISSUE-2002/03/06-JonN not used
  182. BOOL MyChangeServiceConfig2(
  183. BOOL* pfDllPresentLocally, // will set to FALSE if new ADVAPI32 not present
  184. SC_HANDLE hService, // handle to service
  185. DWORD dwInfoLevel, // which configuration information to change
  186. LPVOID lpInfo // pointer to configuration information
  187. );
  188. */
  189. BOOL MyQueryServiceConfig2(
  190. BOOL* pfDllPresentLocally, // will set to FALSE if new ADVAPI32 not present
  191. SC_HANDLE hService, // handle of service
  192. DWORD dwInfoLevel, // which configuration data is requested
  193. LPBYTE lpBuffer, // pointer to service configuration buffer
  194. DWORD cbBufSize, // size of service configuration buffer
  195. LPDWORD pcbBytesNeeded // address of variable for bytes needed
  196. );
  197. #endif // ~__SVCPROP_H__