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.

166 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. cgenericlogger.h
  5. Abstract:
  6. This file contains base class prototypes for logging RSOP security extension data to WMI.
  7. Author:
  8. Vishnu Patankar (VishnuP) 7-April-2000
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // //
  15. // Includes //
  16. // //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #if !defined _generic_logger_
  19. #define _generic_logger_
  20. #include "headers.h"
  21. #include "smartptr.h"
  22. #include <cfgmgr32.h>
  23. #include <ole2.h>
  24. #include <wininet.h>
  25. #include <wbemidl.h>
  26. #ifndef Thread
  27. #define Thread __declspec( thread )
  28. #endif
  29. extern IWbemServices *tg_pWbemServices;
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // //
  32. // Private defines //
  33. // //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. #define SCEP_GUID_TO_STRING(guid, szValue )\
  36. wsprintf( szValue,\
  37. TEXT("{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}"),\
  38. guid.Data1,\
  39. guid.Data2,\
  40. guid.Data3,\
  41. guid.Data4[0], guid.Data4[1],\
  42. guid.Data4[2], guid.Data4[3],\
  43. guid.Data4[4], guid.Data4[5],\
  44. guid.Data4[6], guid.Data4[7] )
  45. #define SCEP_NULL_GUID(guid)\
  46. ((guid.Data1 == 0) &&\
  47. (guid.Data2 == 0) &&\
  48. (guid.Data3 == 0) &&\
  49. (guid.Data4[0] == 0) &&\
  50. (guid.Data4[1] == 0) &&\
  51. (guid.Data4[2] == 0) &&\
  52. (guid.Data4[3] == 0) &&\
  53. (guid.Data4[4] == 0) &&\
  54. (guid.Data4[5] == 0) &&\
  55. (guid.Data4[6] == 0) &&\
  56. (guid.Data4[7] == 0) )
  57. /////////////////////////////////////////////////////////////////////
  58. // Base logger class prototype
  59. //////////////////////////////////////////////////////////////////////
  60. class CGenericLogger
  61. {
  62. public:
  63. CGenericLogger(IWbemServices *pNamespace, PWSTR pwszGPOName, const PWSTR pwszSOMID);
  64. virtual ~CGenericLogger();
  65. IWbemClassObject *m_pObj;
  66. IEnumWbemClassObject * m_pEnum;
  67. //protected:
  68. HRESULT PutGenericProperties();
  69. HRESULT PutInstAndFreeObj();
  70. // Overloaded put methods
  71. HRESULT PutProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, WCHAR *wcValue);
  72. HRESULT PutProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, int iValue);
  73. HRESULT PutProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, bool bValue);
  74. HRESULT PutProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, PSCE_NAME_LIST strList);
  75. HRESULT PutProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, WCHAR *mszValue, CIMTYPE cimtype);
  76. // Overloaded get methods
  77. HRESULT GetProperty(IWbemClassObject *pObj, const WCHAR *wcProperty, int *piValue);
  78. // Method to get an instance to populate
  79. HRESULT SpawnAnInstance(IWbemClassObject **pObj);
  80. // Method to set/get error code
  81. void SetError(HRESULT hr);
  82. HRESULT GetError();
  83. // Data members unique to logger instance
  84. IWbemServices *m_pNamespace;
  85. IWbemClassObject *m_pClassForSpawning;
  86. // Generic schema property name placeholders
  87. // Use smart ptrs for implicit memory mgmt (even if exceptions thrown)
  88. XBStr m_xbstrClassName;
  89. XBStr m_xbstrId;
  90. XBStr m_xbstrPrecedence;
  91. XBStr m_xbstrGPO;
  92. XBStr m_xbstrSOM;
  93. XBStr m_xbstrStatus;
  94. XBStr m_xbstrErrorCode;
  95. // Value placeholders for generic schema properties
  96. XBStr m_xbstrCanonicalGPOName;
  97. XBStr m_xbstrSOMID;
  98. XBStr m_xbstrIdValue;
  99. // set to TRUE by highest derived class if all constructors completely constructed
  100. BOOL m_bInitialized;
  101. // error code used to communicate out of memory errors etc.
  102. HRESULT m_pHr;
  103. };
  104. // Method to clear all instances of a particular class in the namespace
  105. HRESULT DeleteInstances(
  106. WCHAR *pwszClass,
  107. IWbemServices *pWbemServices
  108. );
  109. /////////////////////////////////////////////////////////////////////
  110. // Error code conversion routines
  111. //////////////////////////////////////////////////////////////////////
  112. DWORD
  113. ScepSceStatusToDosError(
  114. IN SCESTATUS SceStatus
  115. );
  116. HRESULT
  117. ScepDosErrorToWbemError(
  118. IN DWORD rc
  119. );
  120. DWORD
  121. ScepWbemErrorToDosError(
  122. IN HRESULT hr
  123. );
  124. #endif