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.

108 lines
3.0 KiB

  1. // EventInfo.h
  2. #pragma once
  3. #include <map>
  4. #include <wstlallc.h>
  5. #include "array.h"
  6. #include "ObjAccess.h"
  7. #include "buffer.h"
  8. #include "ProvInfo.h"
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CEventInfo
  11. _COM_SMARTPTR_TYPEDEF(IWbemClassObject, __uuidof(IWbemClassObject));
  12. _COM_SMARTPTR_TYPEDEF(_IWmiObject, __uuidof(_IWmiObject));
  13. class CEventInfo;
  14. class CClientInfo;
  15. typedef BOOL (CEventInfo::*PROP_FUNC)();
  16. typedef CArray<PROP_FUNC> CPropFuncArray;
  17. class CEventInfo : public CObjAccess
  18. {
  19. public:
  20. CEventInfo();
  21. ~CEventInfo();
  22. BOOL InitFromBuffer(CClientInfo *pInfo, CBuffer *pBuffer);
  23. BOOL SetPropsWithBuffer(CBuffer *pBuffer);
  24. HRESULT Indicate();
  25. void SetSink(IWbemEventSink *pSink) { m_pSink = pSink; }
  26. // These are used when we're decoding an object.
  27. LPBYTE m_pBitsBase;
  28. DWORD m_cBitsBase;
  29. DWORD *m_pdwPropTable;
  30. int m_iCurrentVar;
  31. CPropFuncArray m_pPropFuncs;
  32. // We need this for embedded objects, so they can call InitFromBuffer.
  33. CClientInfo *m_pInfo;
  34. // The sink to indicate to. This keeps us from having to lookup the
  35. // restricted sink in a map each time an event is received.
  36. IWbemEventSink *m_pSink;
  37. // Used only for generic events.
  38. _variant_t m_vParamValues;
  39. BSTR *m_pValues;
  40. // Used to get a new _IWmiObject when processing an _IWmiObject property.
  41. _IWmiObjectPtr m_pObjSpawner;
  42. PROP_FUNC TypeToPropFunc(DWORD type);
  43. BOOL SetBlobPropsWithBuffer(CBuffer *pBuffer);
  44. LPBYTE GetPropDataPointer(DWORD dwIndex, DWORD& rcData )
  45. {
  46. LPBYTE pData = m_pBitsBase + m_pdwPropTable[dwIndex];
  47. rcData = m_cBitsBase - m_pdwPropTable[dwIndex];
  48. return pData;
  49. }
  50. // Prop type functions for non-generic events.
  51. BOOL ProcessString();
  52. BOOL ProcessBYTE();
  53. BOOL ProcessWORD();
  54. BOOL ProcessDWORD();
  55. BOOL ProcessDWORD64();
  56. BOOL ProcessObject();
  57. BOOL ProcessWmiObject();
  58. BOOL ProcessArray1();
  59. BOOL ProcessArray2();
  60. BOOL ProcessArray4();
  61. BOOL ProcessArray8();
  62. BOOL ProcessStringArray();
  63. // Helpers
  64. BOOL ProcessScalarArray(DWORD dwItemSize);
  65. // Digs out an embedded object from the buffer.
  66. BOOL GetEmbeddedObject(IUnknown **ppObj, LPBYTE pBits, DWORD cBits );
  67. BOOL GetWmiObject(_IWmiObject **ppObj, LPBYTE pBits, DWORD cBits );
  68. };
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CEventInfoMap
  71. class CEventInfoMap
  72. {
  73. public:
  74. ~CEventInfoMap();
  75. CEventInfo *GetNormalEventInfo(DWORD dwIndex);
  76. BOOL AddNormalEventInfo(DWORD dwIndex, CEventInfo *pInfo);
  77. protected:
  78. typedef std::map<DWORD, CEventInfo*, std::less<DWORD>, wbem_allocator<CEventInfo*> > CNormalInfoMap;
  79. typedef CNormalInfoMap::iterator CNormalInfoMapIterator;
  80. CNormalInfoMap m_mapNormalEvents;
  81. };