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.

121 lines
3.4 KiB

  1. // NCProvider.h : Declaration of the CNCProvider
  2. #ifndef __NCProvider_H_
  3. #define __NCProvider_H_
  4. #include "resource.h" // main symbols
  5. #include <map>
  6. #include <list>
  7. #include <wstlallc.h>
  8. #include "NCDefs.h"
  9. #include "buffer.h"
  10. #include "QueryHelp.h" // For CBstrList
  11. #include "ProvInfo.h"
  12. #include "EventInfo.h"
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CNCProvider
  15. class CNCProvider :
  16. public CComObjectRootEx<CComMultiThreadModel>,
  17. public CComCoClass<CNCProvider, &CLSID_NCProvider>,
  18. public IWbemProviderInit,
  19. public IWbemProviderIdentity,
  20. public IWbemEventProviderSecurity,
  21. public IWbemEventProviderQuerySink,
  22. public IWbemEventProvider
  23. {
  24. public:
  25. CNCProvider();
  26. ~CNCProvider();
  27. void FinalRelease();
  28. DECLARE_REGISTRY_RESOURCEID(IDR_NCPROVIDER)
  29. DECLARE_PROTECT_FINAL_CONSTRUCT()
  30. BEGIN_COM_MAP(CNCProvider)
  31. COM_INTERFACE_ENTRY(IWbemProviderInit)
  32. COM_INTERFACE_ENTRY(IWbemProviderIdentity)
  33. COM_INTERFACE_ENTRY(IWbemEventProviderSecurity)
  34. COM_INTERFACE_ENTRY(IWbemEventProviderQuerySink)
  35. COM_INTERFACE_ENTRY(IWbemEventProvider)
  36. END_COM_MAP()
  37. // Globals
  38. HANDLE m_heventDone,
  39. m_heventConnect,
  40. m_hthreadConnect;
  41. _bstr_t m_strNamespace,
  42. m_strProvider;
  43. TCHAR m_szNamedPipe[256];
  44. HANDLE // Objects visible to P2 clients
  45. m_hPipe;
  46. CProvInfo* m_pProv;
  47. CRITICAL_SECTION m_cs;
  48. static DWORD WINAPI ConnectThreadProc(CNCProvider *pThis);
  49. void ConnectLoop();
  50. BOOL ConnectToNewClient(HANDLE hPipe, OVERLAPPED *pOverlap);
  51. BOOL CreateAndConnectInstance(OVERLAPPED *pOverlap, BOOL bFirst);
  52. void DisconnectAndClose(CClientInfo *pInfo);
  53. static void WINAPI CompletedReadRoutine(
  54. DWORD dwErr,
  55. DWORD cbBytesRead,
  56. LPOVERLAPPED lpOverLap);
  57. void Lock() { EnterCriticalSection(&m_cs); }
  58. void Unlock() { LeaveCriticalSection(&m_cs); }
  59. // IWbemProviderInit
  60. public:
  61. HRESULT STDMETHODCALLTYPE Initialize(
  62. /* [in] */ LPWSTR pszUser,
  63. /* [in] */ LONG lFlags,
  64. /* [in] */ LPWSTR pszNamespace,
  65. /* [in] */ LPWSTR pszLocale,
  66. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  67. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  68. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink);
  69. // IWbemProviderIdentity
  70. public:
  71. HRESULT STDMETHODCALLTYPE SetRegistrationObject(
  72. LONG lFlags,
  73. IWbemClassObject __RPC_FAR *pProvReg);
  74. // IWbemEventProviderSecurity
  75. public:
  76. HRESULT STDMETHODCALLTYPE AccessCheck(
  77. /* [in] */ WBEM_CWSTR wszQueryLanguage,
  78. /* [in] */ WBEM_CWSTR wszQuery,
  79. /* [in] */ long lSidLength,
  80. /* [unique][size_is][in] */ const BYTE __RPC_FAR *pSid);
  81. // IWbemEventProviderQuerySink
  82. public:
  83. HRESULT STDMETHODCALLTYPE NewQuery(
  84. /* [in] */ unsigned long dwId,
  85. /* [in] */ WBEM_WSTR wszQueryLanguage,
  86. /* [in] */ WBEM_WSTR wszQuery);
  87. HRESULT STDMETHODCALLTYPE CancelQuery(
  88. /* [in] */ unsigned long dwId);
  89. // IWbemEventProvider
  90. public:
  91. HRESULT STDMETHODCALLTYPE ProvideEvents(
  92. /* [in] */ IWbemObjectSink __RPC_FAR *pSink,
  93. /* [in] */ long lFlags);
  94. };
  95. #endif //__NCProvider_H_