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.

155 lines
5.3 KiB

  1. //***************************************************************************
  2. //
  3. // TASK.H
  4. //
  5. // raymcc 23-Apr-00 First oversimplified draft for Whistler
  6. // raymcc 18-Mar-02 Security review
  7. //
  8. //***************************************************************************
  9. #ifndef _WMITASK_H_
  10. #define _WMITASK_H_
  11. #define CORE_TASK_TYPE(x) (x & 0xFF)
  12. #include <context.h>
  13. // forward
  14. class CAsyncReq;
  15. class CProviderSink;
  16. class CStatusSink;
  17. struct STaskProvider
  18. {
  19. IWbemServices *m_pProv;
  20. CProviderSink *m_pProvSink;
  21. STaskProvider() { m_pProv = 0; m_pProvSink = 0; }
  22. ~STaskProvider();
  23. HRESULT Cancel( CStatusSink* pStatusSink );
  24. HRESULT ExecCancelOnNewRequest ( IWbemServices* pProv, CProviderSink* pSink, CStatusSink* pStatusSink ) ;
  25. };
  26. class CWmiTask : public _IWmiCoreHandle
  27. {
  28. friend struct STaskProvider;
  29. private:
  30. ULONG m_uRefCount;
  31. ULONG m_uTaskType;
  32. ULONG m_uTaskStatus;
  33. ULONG m_uTaskId;
  34. HRESULT m_hResult ;
  35. BOOL m_bAccountedForThrottling ;
  36. BOOL m_bCancelledDueToThrottling ;
  37. CFlexArray m_aTaskProviders; // Array of STaskProvider structs
  38. IWbemObjectSink * m_pAsyncClientSink; // Used for cross-ref purposes only
  39. CStdSink * m_pReqSink; // The CStdSink pointer for each request
  40. LONG m_uMemoryUsage;
  41. ULONG m_uTotalSleepTime;
  42. ULONG m_uCancelState;
  43. ULONG m_uLastSleepTime;
  44. HANDLE m_hCompletion ;
  45. HANDLE m_hTimer;
  46. CWbemContext* m_pMainCtx;
  47. CFlexArray m_aArbitratees;
  48. CCritSec m_csTask;
  49. CWbemNamespace *m_pNs;
  50. DWORD m_uStartTime;
  51. CStatusSink * m_pStatusSink;
  52. CAsyncReq_RemoveNotifySink * m_pReqCancelNotSink;
  53. CFlexArray m_aTaskProvStorage;
  54. CFlexArray m_aArbitrateesStorage;
  55. CAsyncReq * m_pReqDoNotUse; // this is just a pointer copy for the debugger
  56. CWmiTask( );
  57. ~CWmiTask();
  58. CWmiTask(const CWmiTask &Src){};
  59. CWmiTask & operator=(const CWmiTask &Src){};
  60. static CStaticCritSec m_TaskCs;
  61. public:
  62. ULONG STDMETHODCALLTYPE AddRef();
  63. ULONG STDMETHODCALLTYPE Release();
  64. HRESULT STDMETHODCALLTYPE QueryInterface( IN REFIID riid, OUT LPVOID *ppvObj);
  65. CWbemContext *GetCtx() { return m_pMainCtx; }
  66. HRESULT STDMETHODCALLTYPE GetHandleType(ULONG *puType);
  67. static CWmiTask *CreateTask( ) ;
  68. ULONG GetTaskType() { return m_uTaskType; }
  69. ULONG GetTaskStatus() { return m_uTaskStatus; }
  70. HANDLE GetTimerHandle() { return m_hTimer; }
  71. void RemoveTaskStatusBit(ULONG uMask) { m_uTaskStatus &= !uMask; }
  72. VOID SetCancelledState ( BOOL bState ) { m_bCancelledDueToThrottling = bState ; }
  73. BOOL GetCancelledState ( ) { return m_bCancelledDueToThrottling ; }
  74. HRESULT SignalCancellation ( ) ;
  75. HRESULT ReleaseArbitratees (BOOL bIsShutdown = FALSE ) ;
  76. HRESULT SetTaskResult ( HRESULT hRes ) ;
  77. HRESULT AddTaskProv(STaskProvider *);
  78. BOOL IsESSNamespace ( );
  79. BOOL IsProviderNamespace ( );
  80. HRESULT GetFinalizer( _IWmiFinalizer **ppFnz );
  81. BOOL IsAccountedForThrottling ( ) { return m_bAccountedForThrottling ; }
  82. VOID SetAccountedForThrottling ( BOOL bSet ) { m_bAccountedForThrottling = bSet ; }
  83. HRESULT HasMatchingSink(void *Test, IN REFIID riid);
  84. HRESULT Cancel( HRESULT hRes = WBEM_E_CALL_CANCELLED );
  85. HRESULT GetPrimaryTask ( _IWmiCoreHandle** pPTask );
  86. HRESULT AddArbitratee(ULONG uFlags, _IWmiArbitratee* pArbitratee);
  87. HRESULT RemoveArbitratee(ULONG uFlags, _IWmiArbitratee* pArbitratee);
  88. HRESULT GetArbitratedQuery( ULONG uFlags, _IWmiArbitratedQuery** ppArbitratedQuery );
  89. HRESULT GetMemoryUsage ( ULONG* uMemUsage ){ *uMemUsage = m_uMemoryUsage; return WBEM_S_NO_ERROR; } // SEC:REVIEWED 2002-03-22 : Needs ptr check
  90. HRESULT UpdateMemoryUsage ( LONG lDelta ) ;
  91. HRESULT GetTotalSleepTime ( ULONG* uSleepTime ){ *uSleepTime = m_uTotalSleepTime; return WBEM_S_NO_ERROR; } // SEC:REVIEWED 2002-03-22 : Needs ptr check
  92. HRESULT UpdateTotalSleepTime ( ULONG uSleepTime ) ;
  93. HRESULT GetCancelState ( ULONG* uCancelState ){ *uCancelState = m_uCancelState; return WBEM_S_NO_ERROR; } // SEC:REVIEWED 2002-03-22 : Needs ptr check
  94. HRESULT SetCancelState ( ULONG uCancelState ){ m_uCancelState = uCancelState; return WBEM_S_NO_ERROR; }
  95. HRESULT SetLastSleepTime ( ULONG uSleep ){ m_uLastSleepTime = uSleep; return WBEM_S_NO_ERROR; }
  96. HRESULT CreateTimerEvent ( );
  97. HRESULT SetArbitrateesOperationResult ( ULONG, HRESULT );
  98. HRESULT Initialize(
  99. IN CWbemNamespace *pNs,
  100. IN ULONG uTaskType,
  101. IN IWbemContext *pCtx,
  102. IN IWbemObjectSink *pClientSinkCopy,
  103. IN CAsyncReq *pReq);
  104. HRESULT AssertProviderRef(IWbemServices *pProv);
  105. HRESULT RetractProviderRef(IWbemServices *pProv);
  106. ULONG GetTaskId() { return m_uTaskId; }
  107. HRESULT Dump(FILE* f); // Debug only
  108. HRESULT SetRequestSink(CStdSink *pSnk);
  109. CWbemNamespace* GetNamespace ( ) { return m_pNs; }
  110. };
  111. typedef CWmiTask *PCWmiTask;
  112. #endif