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.

144 lines
4.6 KiB

  1. #ifndef __NmSysInfo_h__
  2. #define __NmSysInfo_h__
  3. #include "SDKInternal.h"
  4. #include "resource.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CNmSysInfoObj
  7. class ATL_NO_VTABLE CNmSysInfoObj :
  8. public CComObjectRootEx<CComSingleThreadModel>,
  9. public CComCoClass<CNmSysInfoObj, &CLSID_NmSysInfo>,
  10. public IConnectionPointContainerImpl<CNmSysInfoObj>,
  11. public IConnectionPointImpl<CNmSysInfoObj, &IID_INmSysInfoNotify, CComDynamicUnkArray>,
  12. public IMarshal,
  13. public INmSysInfo,
  14. public IInternalSysInfoObj
  15. {
  16. CComPtr<IInternalConfExe> m_spConfHook;
  17. DWORD m_dwID;
  18. public:
  19. DECLARE_REGISTRY_RESOURCEID(IDR_NMSYSINFO)
  20. DECLARE_NOT_AGGREGATABLE(CNmSysInfoObj)
  21. DECLARE_PROTECT_FINAL_CONSTRUCT()
  22. BEGIN_COM_MAP(CNmSysInfoObj)
  23. COM_INTERFACE_ENTRY(INmSysInfo)
  24. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  25. COM_INTERFACE_ENTRY(IMarshal)
  26. COM_INTERFACE_ENTRY(IInternalSysInfoObj)
  27. END_COM_MAP()
  28. BEGIN_CONNECTION_POINT_MAP(CNmSysInfoObj)
  29. CONNECTION_POINT_ENTRY(IID_INmSysInfoNotify)
  30. END_CONNECTION_POINT_MAP()
  31. HRESULT FinalConstruct();
  32. void FinalRelease();
  33. ///////////////////////////////////////////////
  34. // INmSysInfo methods
  35. STDMETHOD(IsInstalled)(void);
  36. STDMETHOD(GetProperty)(NM_SYSPROP uProp, BSTR *pbstrProp);
  37. STDMETHOD(SetProperty)(NM_SYSPROP uProp, BSTR bstrName);
  38. STDMETHOD(GetUserData)(REFGUID rguid, BYTE **ppb, ULONG *pcb);
  39. STDMETHOD(SetUserData)(REFGUID rguid, BYTE *pb, ULONG cb);
  40. STDMETHOD(GetNmApp)(REFGUID rguid,BSTR *pbstrApplication, BSTR *pbstrCommandLine, BSTR *pbstrDirectory);
  41. STDMETHOD(SetNmApp)(REFGUID rguid,BSTR bstrApplication, BSTR bstrCommandLine, BSTR bstrDirectory);
  42. STDMETHOD(GetNmchCaps)(ULONG *pchCaps);
  43. STDMETHOD(GetLaunchInfo)(INmConference **ppConference, INmMember **ppMember);
  44. //--------------------------------------------------------------------------
  45. // IInternalSysInfoObj
  46. STDMETHOD(SetID)(DWORD ID) { m_dwID = ID; return S_OK; }
  47. /////////////////////////////////////////////////////////////////////////////////
  48. // IMarshal methods
  49. STDMETHOD(GetUnmarshalClass)(
  50. /* [in] */ REFIID riid,
  51. /* [unique][in] */ void *pv,
  52. /* [in] */ DWORD dwDestContext,
  53. /* [unique][in] */ void *pvDestContext,
  54. /* [in] */ DWORD mshlflags,
  55. /* [out] */ CLSID *pCid) { *pCid = CLSID_NmSysInfo; return S_OK; };
  56. STDMETHOD(GetMarshalSizeMax)(
  57. /* [in] */ REFIID riid,
  58. /* [unique][in] */ void *pv,
  59. /* [in] */ DWORD dwDestContext,
  60. /* [unique][in] */ void *pvDestContext,
  61. /* [in] */ DWORD mshlflags,
  62. /* [out] */ DWORD *pSize) { *pSize = sizeof(ULONG); return S_OK; }
  63. STDMETHOD(MarshalInterface)(
  64. /* [unique][in] */ IStream *pStm,
  65. /* [in] */ REFIID riid,
  66. /* [unique][in] */ void *pv,
  67. /* [in] */ DWORD dwDestContext,
  68. /* [unique][in] */ void *pvDestContext,
  69. /* [in] */ DWORD mshlflags)
  70. {
  71. // Since we don't know the endian-ness of the other side,
  72. // we use a private wire format for custom marshaling here.
  73. //
  74. BYTE buf[sizeof(DWORD)];
  75. BYTE * pByte = buf;
  76. *pByte++ = (BYTE)(m_dwID);
  77. *pByte++ = (BYTE)(m_dwID >> 8);
  78. *pByte++ = (BYTE)(m_dwID >> 16);
  79. *pByte++ = (BYTE)(m_dwID >> 24);
  80. pStm->Write(buf, sizeof(buf), NULL);
  81. return S_OK;
  82. }
  83. STDMETHOD(UnmarshalInterface)(
  84. /* [unique][in] */ IStream *pStm,
  85. /* [in] */ REFIID riid,
  86. /* [out] */ void **ppv)
  87. {
  88. // Since we don't know the endian-ness of the other side,
  89. // we use a private wire format for custom marshaling here.
  90. //
  91. BYTE buf[sizeof(DWORD)];
  92. pStm->Read(buf, sizeof(buf), NULL);
  93. BYTE * pByte = buf;
  94. m_dwID = (DWORD)(*pByte++);
  95. m_dwID += (DWORD)(*pByte++ << 8);
  96. m_dwID += (DWORD)(*pByte++ << 16);
  97. m_dwID += (DWORD)(*pByte++ << 24);
  98. return QueryInterface(riid, ppv);
  99. }
  100. STDMETHOD(ReleaseMarshalData)(
  101. /* [unique][in] */ IStream *pStm) { return S_OK; }
  102. STDMETHOD(DisconnectObject)(
  103. /* [in] */ DWORD dwReserved) { return S_OK; }
  104. ///////////////////////////////////////////////
  105. // Notifications and callbacks
  106. public:
  107. ///////////////////////////////////////////////
  108. // Helper Fns
  109. HRESULT _EnsureConfHook(void);
  110. static bool GetKeyDataForProp(NM_SYSPROP uProp, HKEY * phkey, LPTSTR * ppszSubKey, LPTSTR * ppszValue, bool *pfString);
  111. private:
  112. static void _GetSzKeyForGuid(LPTSTR psz, REFGUID rguid);
  113. };
  114. #endif // __NmSysInfo_h__