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.

255 lines
8.5 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. StdAfx.h
  5. Abstract:
  6. Precompiled header.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 03/16/2000
  9. created
  10. ******************************************************************************/
  11. #if !defined(AFX_STDAFX_H__6877C875_4E31_4E1C_8AC2_024A50599D66__INCLUDED_)
  12. #define AFX_STDAFX_H__6877C875_4E31_4E1C_8AC2_024A50599D66__INCLUDED_
  13. #pragma once
  14. #include <windows.h>
  15. #include <winnls.h>
  16. #include <ole2.h>
  17. #include <comcat.h>
  18. #include <stddef.h>
  19. #include <tchar.h>
  20. #include <malloc.h>
  21. #include <olectl.h>
  22. #include <winreg.h>
  23. #include <atlbase.h>
  24. extern CComModule _Module;
  25. #include <mpc_trace.h>
  26. #include <mpc_com.h>
  27. #include <mpc_main.h>
  28. #include <mpc_utils.h>
  29. #include <mpc_security.h>
  30. #include <ProjectConstants.h>
  31. #include <initguid.h>
  32. #include <HelpServiceTypeLib.h>
  33. #include <Uploadmanager.h>
  34. ////////////////////////////////////////////////////////////////////////////////
  35. struct CComRedirectorFactory : public IClassFactory, public IDispatchImpl<IPCHUtility, &IID_IPCHUtility, &LIBID_HelpServiceTypeLib>
  36. {
  37. const CLSID* m_pclsid;
  38. const CLSID* m_pclsidReal;
  39. const IID* m_piidDirecty;
  40. LPCWSTR m_szExecutable;
  41. DWORD m_dwRegister;
  42. CRITICAL_SECTION m_sec;
  43. CComRedirectorFactory( const CLSID* pclsid ,
  44. const CLSID* pclsidReal ,
  45. const IID* piidDirecty ,
  46. LPCWSTR szExecutable );
  47. ////////////////////////////////////////////////////////////////////////////////
  48. bool GetCommandLine( /*[out]*/ WCHAR* rgCommandLine, /*[in]*/ DWORD dwSize, /*[out]*/ bool& fProfiling );
  49. HRESULT GetServer ( LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj );
  50. HRESULT StartServer( LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj );
  51. HRESULT Register ();
  52. void Unregister();
  53. ////////////////////////////////////////
  54. public:
  55. // IUnknown
  56. STDMETHOD_(ULONG, AddRef)();
  57. STDMETHOD_(ULONG, Release)();
  58. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
  59. ////////////////////////////////////////
  60. // IClassFactory
  61. STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj);
  62. STDMETHOD(LockServer)(BOOL fLock);
  63. ////////////////////////////////////////
  64. // IPCHUtility
  65. STDMETHOD(get_UserSettings)( /*[out, retval]*/ IPCHUserSettings* *pVal ) { return E_NOTIMPL; }
  66. STDMETHOD(get_Channels )( /*[out, retval]*/ ISAFReg* *pVal ) { return E_NOTIMPL; }
  67. STDMETHOD(get_Security )( /*[out, retval]*/ IPCHSecurity* *pVal ) { return E_NOTIMPL; }
  68. STDMETHOD(get_Database )( /*[out, retval]*/ IPCHTaxonomyDatabase* *pVal ) { return E_NOTIMPL; }
  69. STDMETHOD(FormatError)( /*[in]*/ VARIANT vError, /*[out, retval]*/ BSTR *pVal ) { return E_NOTIMPL; }
  70. STDMETHOD(CreateObject_SearchEngineMgr)( /*[out, retval]*/ IPCHSEManager* *ppSE ) { return E_NOTIMPL; }
  71. STDMETHOD(CreateObject_DataCollection )( /*[out, retval]*/ ISAFDataCollection* *ppDC ) { return E_NOTIMPL; }
  72. STDMETHOD(CreateObject_Cabinet )( /*[out, retval]*/ ISAFCabinet* *ppCB ) { return E_NOTIMPL; }
  73. STDMETHOD(CreateObject_Encryption )( /*[out, retval]*/ ISAFEncrypt* *ppEn ) { return E_NOTIMPL; }
  74. STDMETHOD(CreateObject_Channel )( /*[in]*/ BSTR bstrVendorID, /*[in]*/ BSTR bstrProductID, /*[out, retval]*/ ISAFChannel* *ppCh ) { return E_NOTIMPL; }
  75. STDMETHOD(CreateObject_RemoteDesktopConnection)( /*[out, retval]*/ ISAFRemoteDesktopConnection* *ppRDC ) { return E_NOTIMPL; }
  76. STDMETHOD(CreateObject_RemoteDesktopSession )( /*[in] */ REMOTE_DESKTOP_SHARING_CLASS sharingClass ,
  77. /*[in] */ long lTimeout ,
  78. /*[in] */ BSTR bstrConnectionParms ,
  79. /*[in] */ BSTR bstrUserHelpBlob ,
  80. /*[out, retval]*/ ISAFRemoteDesktopSession* *ppRCS );
  81. STDMETHOD(ConnectToExpert)( /*[in]*/ BSTR bstrExpertConnectParm, /*[in]*/ LONG lTimeout, /*[out, retval]*/ LONG *lSafErrorCode );
  82. STDMETHOD(SwitchDesktopMode)( /*[in]*/ int nMode, /* [in]*/ int nRAType );
  83. };
  84. ////////////////////////////////////////////////////////////////////////////////
  85. struct ServiceHandler
  86. {
  87. LPCWSTR m_szServiceName;
  88. CComRedirectorFactory* m_rgClasses;
  89. HANDLE m_hShutdownEvent;
  90. bool m_fComInitialized;
  91. SERVICE_STATUS_HANDLE m_hServiceStatus;
  92. SERVICE_STATUS m_status;
  93. ServiceHandler( /*[in]*/ LPCWSTR szServiceName, /*[in]*/ CComRedirectorFactory* rgClasses );
  94. DWORD HandlerEx( DWORD dwControl , // requested control code
  95. DWORD dwEventType , // event type
  96. LPVOID lpEventData ); // user-defined context data
  97. void Run();
  98. void SetServiceStatus( DWORD dwState );
  99. virtual HRESULT Initialize ();
  100. void WaitUntilStopped();
  101. virtual void Cleanup ();
  102. };
  103. struct ServiceHandler_HelpSvc : public ServiceHandler
  104. {
  105. friend class LocalEvent;
  106. friend class LocalTimer;
  107. typedef HRESULT (ServiceHandler_HelpSvc::*METHOD)(BOOLEAN);
  108. class LocalEvent : public MPC::Pooling::Event
  109. {
  110. ServiceHandler_HelpSvc* m_Parent;
  111. METHOD m_Method;
  112. public:
  113. LocalEvent( /*[in]*/ ServiceHandler_HelpSvc* pParent, /*[in]*/ METHOD pMethod, /*[in]*/ DWORD dwFlags = WT_EXECUTEDEFAULT )
  114. : MPC::Pooling::Event( dwFlags ), m_Parent(pParent), m_Method(pMethod)
  115. {
  116. }
  117. HRESULT Signaled( /*[in]*/ BOOLEAN TimerOrWaitFired )
  118. {
  119. HRESULT hr;
  120. AddRef();
  121. hr = (m_Parent->*m_Method)( TimerOrWaitFired );
  122. Release();
  123. return hr;
  124. }
  125. };
  126. class LocalTimer : public MPC::Pooling::Timer
  127. {
  128. ServiceHandler_HelpSvc* m_Parent;
  129. METHOD m_Method;
  130. public:
  131. LocalTimer( /*[in]*/ ServiceHandler_HelpSvc* pParent, /*[in]*/ METHOD pMethod ) : m_Parent(pParent), m_Method(pMethod) {}
  132. HRESULT Execute( /*[in]*/ BOOLEAN TimerOrWaitFired )
  133. {
  134. HRESULT hr;
  135. AddRef();
  136. hr = (m_Parent->*m_Method)( TimerOrWaitFired );
  137. Release();
  138. return hr;
  139. }
  140. };
  141. MPC::CComSafeAutoCriticalSection m_cs;
  142. CComPtr<IPCHService> m_svc;
  143. LocalTimer m_svc_Timer;
  144. HANDLE m_batch_Notification;
  145. LocalEvent m_batch_Event;
  146. LocalTimer m_batch_Timer;
  147. LocalTimer m_dc_Timer;
  148. LocalTimer m_dc_TimerRestart;
  149. HANDLE m_dc_IdleHandle;
  150. HANDLE m_dc_IdleStart;
  151. HANDLE m_dc_IdleStop;
  152. LocalEvent m_dc_EventStart;
  153. LocalEvent m_dc_EventStop;
  154. ////////////////////
  155. ServiceHandler_HelpSvc( /*[in]*/ LPCWSTR szServiceName, /*[in]*/ CComRedirectorFactory* rgClasses );
  156. virtual HRESULT Initialize();
  157. virtual void Cleanup ();
  158. ////////////////////
  159. void ConnectToServer();
  160. HRESULT ServiceShutdownCallback ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  161. HRESULT BatchCallback ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  162. HRESULT BatchCallback2 ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  163. HRESULT IdleStartCallback ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  164. HRESULT IdleStopCallback ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  165. HRESULT DataCollectionCallback ( /*[in]*/ BOOLEAN TimerOrWaitFired );
  166. HRESULT DataCollectionRestartCallback( /*[in]*/ BOOLEAN TimerOrWaitFired );
  167. ////////////////////
  168. HRESULT IdleTask_Initialize();
  169. void IdleTask_Cleanup ();
  170. HRESULT DataCollection_Queue ( );
  171. HRESULT DataCollection_Execute( /*[in]*/ bool fCancel );
  172. };
  173. ////////////////////////////////////////////////////////////////////////////////
  174. #endif // !defined(AFX_STDAFX_H__6877C875_4E31_4E1C_8AC2_024A50599D66__INCLUDED)