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.

173 lines
6.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: wmihooks.h
  7. //
  8. // Contents: definition of CWMIRsop
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef WMIHOOKS_H
  12. #define WMIHOOKS_H
  13. using namespace std;
  14. #define MAX_REG_VALUE_NUM 100
  15. typedef struct _RSOP_INFO
  16. {
  17. ULONG precedence;
  18. ULONG status;
  19. ULONG error;
  20. LPWSTR pszGPOID;
  21. }RSOP_INFO, *PRSOP_INFO;
  22. VOID FreeRI(PRSOP_INFO ptr);
  23. typedef struct _WMI_SCE_PROFILE_INFO: public SCE_PROFILE_INFO
  24. {
  25. PRSOP_INFO pInfo;
  26. PRSOP_INFO pRIMinimumPasswordAge;
  27. PRSOP_INFO pRIMaximumPasswordAge;
  28. PRSOP_INFO pRIMinimumPasswordLength;
  29. PRSOP_INFO pRIPasswordComplexity;
  30. PRSOP_INFO pRIPasswordHistorySize;
  31. PRSOP_INFO pRILockoutBadCount;
  32. PRSOP_INFO pRIResetLockoutCount;
  33. PRSOP_INFO pRILockoutDuration;
  34. PRSOP_INFO pRIRequireLogonToChangePassword;
  35. PRSOP_INFO pRIForceLogoffWhenHourExpire;
  36. PRSOP_INFO pRIEnableAdminAccount;
  37. PRSOP_INFO pRIEnableGuestAccount;
  38. PRSOP_INFO pRILSAAnonymousNameLookup;
  39. PRSOP_INFO pRINewAdministratorName;
  40. PRSOP_INFO pRINewGuestName;
  41. PRSOP_INFO pRISecureSystemPartition;
  42. PRSOP_INFO pRIClearTextPassword;
  43. //RSOPINFO for pKerberosInfo
  44. PRSOP_INFO pRIMaxTicketAge;
  45. PRSOP_INFO pRIMaxRenewAge;
  46. PRSOP_INFO pRIMaxServiceAge;
  47. PRSOP_INFO pRIMaxClockSkew;
  48. PRSOP_INFO pRITicketValidateClient;
  49. //This is a link list. corresponding to pInfPrivilegeAssignedTo
  50. //in otherinfo
  51. list<PRSOP_INFO> listRIInfPrivilegeAssignedTo;
  52. list<PRSOP_INFO> listRIGroupMemebership;
  53. list<PRSOP_INFO> listRIServices;
  54. vector<PRSOP_INFO> vecRIFiles;
  55. vector<PRSOP_INFO> vecRIReg;
  56. PRSOP_INFO pRIAuditSystemEvents;
  57. PRSOP_INFO pRIAuditLogonEvents;
  58. PRSOP_INFO pRIAuditObjectAccess;
  59. PRSOP_INFO pRIAuditPrivilegeUse;
  60. PRSOP_INFO pRIAuditPolicyChange;
  61. PRSOP_INFO pRIAuditAccountManage;
  62. PRSOP_INFO pRIAuditProcessTracking;
  63. PRSOP_INFO pRIAuditDSAccess;
  64. PRSOP_INFO pRIAuditAccountLogon;
  65. PRSOP_INFO pRICrashOnAuditFull;
  66. vector<PRSOP_INFO> vecRIRegValues;
  67. // Event Log Numeric
  68. PRSOP_INFO pRIMaximumLogSize[3];
  69. PRSOP_INFO pRIAuditLogRetentionPeriod[3];
  70. PRSOP_INFO pRIRetentionDays[3];
  71. // Event Log Boolean
  72. PRSOP_INFO pRIRestrictGuestAccess[3];
  73. }WMI_SCE_PROFILE_INFO, *PWMI_SCE_PROFILE_INFO;
  74. VOID InitWMI_SEC_PROFILE_INFO(PWMI_SCE_PROFILE_INFO pProfileInfo);
  75. VOID FreeList(list<PRSOP_INFO> * li);
  76. VOID FreeVector(vector<PRSOP_INFO> * li);
  77. VOID FreeWMI_SCE_PROFILE_INFO(PWMI_SCE_PROFILE_INFO pProfileInfo);
  78. class CWMIRsop
  79. {
  80. public:
  81. CWMIRsop(LPRSOPINFORMATION pRSOP):
  82. m_cRegValueSize(MAX_REG_VALUE_NUM),
  83. m_cFileSize(MAX_REG_VALUE_NUM),
  84. m_cRegArrayCount(MAX_REG_VALUE_NUM),
  85. m_pSvc(NULL),
  86. m_vecAllRSOPCache(NULL),
  87. m_pRSOPInformation(pRSOP)
  88. {};
  89. virtual ~CWMIRsop();
  90. HRESULT GetPrecedenceOneRSOPInfo(PWMI_SCE_PROFILE_INFO* ppProfileInfo);
  91. HRESULT GetAllRSOPInfo(vector<PWMI_SCE_PROFILE_INFO> *vecInfo);
  92. HRESULT GetGPOFriendlyName (LPTSTR lpGPOID, PWSTR *pGPOName);
  93. private:
  94. IWbemServices *m_pSvc;
  95. LPRSOPINFORMATION m_pRSOPInformation;
  96. vector<PWMI_SCE_PROFILE_INFO> *m_vecAllRSOPCache;
  97. ULONG m_cRegValueSize; //current capacity of array aRegValues
  98. ULONG m_cFileSize; //current capacity of array in pFiles
  99. ULONG m_cRegArrayCount; //current capacity of array in pRegistryKeys
  100. //Connect to WMI and Get IWbemServices
  101. HRESULT Initialize();
  102. HRESULT EnumeratePrecedenceOne(IEnumWbemClassObject **ppEnum);
  103. HRESULT EnumerateAll(IEnumWbemClassObject **ppEnum);
  104. HRESULT GetNextInstance(IEnumWbemClassObject *pEnum,
  105. IWbemClassObject** rsopInstance);
  106. HRESULT GetRSOPInfo(IWbemClassObject *rsopInstance,
  107. PRSOP_INFO pInfo);
  108. HRESULT GetClass(IWbemClassObject* rsopInstance,
  109. LPWSTR *ppClass);
  110. HRESULT AddInstance(IWbemClassObject *rsopInstance,
  111. PRSOP_INFO pInfo,
  112. PWMI_SCE_PROFILE_INFO pProfileInfo);
  113. HRESULT AddNumericSetting(IWbemClassObject *rsopInstance,
  114. PRSOP_INFO pInfo,
  115. PWMI_SCE_PROFILE_INFO pProfileInfo);
  116. HRESULT AddEventLogNumericSetting(IWbemClassObject *rsopInstance,
  117. PRSOP_INFO pInfo,
  118. PWMI_SCE_PROFILE_INFO pProfileInfo);
  119. HRESULT AddBooleanSetting(IWbemClassObject *rsopInstance,
  120. PRSOP_INFO pInfo,
  121. PWMI_SCE_PROFILE_INFO pProfileInfo);
  122. HRESULT AddEventLogBooleanSetting(IWbemClassObject *rsopInstance,
  123. PRSOP_INFO pInfo,
  124. PWMI_SCE_PROFILE_INFO pProfileInfo);
  125. HRESULT AddAuditSetting(IWbemClassObject *rsopInstance,
  126. PRSOP_INFO pInfo,
  127. PWMI_SCE_PROFILE_INFO pProfileInfo);
  128. HRESULT AddUserRightSetting(IWbemClassObject *rsopInstance,
  129. PRSOP_INFO pInfo,
  130. PWMI_SCE_PROFILE_INFO pProfileInfo);
  131. HRESULT AddRegValSetting(IWbemClassObject *rsopInstance,
  132. PRSOP_INFO pInfo,
  133. PWMI_SCE_PROFILE_INFO pProfileInfo);
  134. HRESULT AddRestrictedGroupSetting(IWbemClassObject *rsopInstance,
  135. PRSOP_INFO pInfo,
  136. PWMI_SCE_PROFILE_INFO pProfileInfo);
  137. HRESULT AddServiceSetting(IWbemClassObject *rsopInstance,
  138. PRSOP_INFO pInfo,
  139. PWMI_SCE_PROFILE_INFO pProfileInfo);
  140. HRESULT AddFileSetting(IWbemClassObject *rsopInstance,
  141. PRSOP_INFO pInfo,
  142. PWMI_SCE_PROFILE_INFO pProfileInfo);
  143. HRESULT AddRegSetting(IWbemClassObject *rsopInstance,
  144. PRSOP_INFO pInfo,
  145. PWMI_SCE_PROFILE_INFO pProfileInfo);
  146. HRESULT AddStringSetting (IWbemClassObject *rsopInstance,
  147. PRSOP_INFO pInfo,
  148. PWMI_SCE_PROFILE_INFO pProfileInfo);
  149. };
  150. #endif // WMIHOOKS_H