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.

141 lines
4.1 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: ExtendedProperty.h
  4. Content: Declaration of the CExtendedProperty.
  5. History: 06-15-2001 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __EXTENDEDPROPERTY_H_
  8. #define __EXTENDEDPROPERTY_H_
  9. #include "Resource.h"
  10. #include "Lock.h"
  11. #include "Error.h"
  12. #include "Debug.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. //
  15. // Exported functions.
  16. //
  17. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. Function : CreateExtendedPropertyObject
  19. Synopsis : Create an IExtendedProperty object.
  20. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT to be used
  21. to initialize the IExtendedProperty
  22. object.
  23. DWORD dwPropId - Property ID.
  24. BOOL bReadOnly - TRUE for read-only, else FALSE.
  25. IExtendedProperty ** ppIExtendedProperty - Pointer to pointer
  26. IExtendedProperty
  27. object.
  28. Remark :
  29. ------------------------------------------------------------------------------*/
  30. HRESULT CreateExtendedPropertyObject (PCCERT_CONTEXT pCertContext,
  31. DWORD dwPropId,
  32. BOOL bReadOnly,
  33. IExtendedProperty ** ppIExtendedProperty);
  34. ////////////////////////////////////////////////////////////////////////////////
  35. //
  36. // CExtendedProperty
  37. //
  38. class ATL_NO_VTABLE CExtendedProperty :
  39. public CComObjectRootEx<CComMultiThreadModel>,
  40. public CComCoClass<CExtendedProperty, &CLSID_ExtendedProperty>,
  41. public ICAPICOMError<CExtendedProperty, &IID_IExtendedProperty>,
  42. public IDispatchImpl<IExtendedProperty, &IID_IExtendedProperty, &LIBID_CAPICOM,
  43. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  44. {
  45. public:
  46. CExtendedProperty()
  47. {
  48. }
  49. HRESULT FinalConstruct()
  50. {
  51. HRESULT hr;
  52. if (FAILED(hr = m_Lock.Initialized()))
  53. {
  54. DebugTrace("Error [%#x]: Critical section could not be created for ExtendedProperty object.\n", hr);
  55. return hr;
  56. }
  57. m_dwPropId = CAPICOM_PROPID_UNKNOWN;
  58. m_bReadOnly = FALSE;
  59. m_DataBlob.cbData = 0;
  60. m_DataBlob.pbData = NULL;
  61. m_pCertContext = NULL;
  62. return S_OK;
  63. }
  64. void FinalRelease()
  65. {
  66. if (m_DataBlob.pbData)
  67. {
  68. ::CoTaskMemFree((LPVOID) m_DataBlob.pbData);
  69. }
  70. if (m_pCertContext)
  71. {
  72. ::CertFreeCertificateContext(m_pCertContext);
  73. }
  74. }
  75. DECLARE_REGISTRY_RESOURCEID(IDR_EXTENDEDPROPERTY)
  76. DECLARE_PROTECT_FINAL_CONSTRUCT()
  77. BEGIN_COM_MAP(CExtendedProperty)
  78. COM_INTERFACE_ENTRY(IExtendedProperty)
  79. COM_INTERFACE_ENTRY(IDispatch)
  80. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  81. END_COM_MAP()
  82. //
  83. // IExtendedProperty
  84. //
  85. public:
  86. STDMETHOD(get_PropID)
  87. (/*[out, retval]*/ /*[in]*/ CAPICOM_PROPID * pVal);
  88. STDMETHOD(put_PropID)
  89. (/*[in]*/ CAPICOM_PROPID newVal);
  90. STDMETHOD(get_Value)
  91. (/*[in, defaultvalue(CAPICOM_ENCODE_BASE64)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  92. /*[out, retval]*/ BSTR * pVal);
  93. STDMETHOD(put_Value)
  94. (/*[in, defaultvalue(CAPICOM_ENCODE_BASE64)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  95. /*[in]*/ BSTR newVal);
  96. //
  97. // None COM functions.
  98. //
  99. STDMETHOD(Init)
  100. (PCCERT_CONTEXT pCertContext, DWORD dwPropId, BOOL bReadOnly);
  101. private:
  102. CLock m_Lock;
  103. DWORD m_dwPropId;
  104. BOOL m_bReadOnly;
  105. DATA_BLOB m_DataBlob;
  106. PCCERT_CONTEXT m_pCertContext;
  107. };
  108. #endif //__EXTENDEDPROPERTY_H_