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.

224 lines
4.5 KiB

  1. #ifndef _Common_IWbemObjectSink_H
  2. #define _Common_IWbemObjectSink_H
  3. /*++
  4. Copyright (C) 1996-2001 Microsoft Corporation
  5. Module Name:
  6. ProvObSk.H
  7. Abstract:
  8. History:
  9. --*/
  10. #include "Queue.h"
  11. #include "CGlobals.h"
  12. typedef bool (__stdcall * fn__uncaught_exception)();
  13. class InterlockedGuard
  14. {
  15. private:
  16. LPLONG volatile lValue_;
  17. #ifdef DBG
  18. bool bIsUnwind_;
  19. static fn__uncaught_exception __uncaught_exception;
  20. class FunctLoader
  21. {
  22. private:
  23. HMODULE hCRT_;
  24. public:
  25. FunctLoader()
  26. {
  27. hCRT_ = LoadLibraryExW(L"msvcrt.dll",0,0);
  28. if (hCRT_) __uncaught_exception = (fn__uncaught_exception)GetProcAddress(hCRT_,"__uncaught_exception");
  29. };
  30. ~FunctLoader(){ if (hCRT_) FreeLibrary(hCRT_); };
  31. };
  32. static FunctLoader FunctLoader_;
  33. #endif
  34. public:
  35. InterlockedGuard(LPLONG volatile lValue):lValue_(lValue)
  36. {
  37. InterlockedIncrement(lValue_);
  38. #ifdef DBG
  39. if (__uncaught_exception)
  40. {
  41. bIsUnwind_ = __uncaught_exception();
  42. }
  43. #endif
  44. }
  45. ~InterlockedGuard()
  46. {
  47. InterlockedDecrement(lValue_);
  48. #ifdef DBG
  49. if (__uncaught_exception)
  50. {
  51. bool bIsUnwind = __uncaught_exception();
  52. if (bIsUnwind_ != bIsUnwind)
  53. DebugBreak();
  54. }
  55. #endif
  56. }
  57. };
  58. #define SYNCPROV_USEBATCH
  59. /******************************************************************************
  60. *
  61. * Name:
  62. *
  63. *
  64. * Description:
  65. *
  66. *
  67. *****************************************************************************/
  68. #define ProxyIndex_IWbemObjectSink 0
  69. #define ProxyIndex_Internal_IWbemObjectSink 1
  70. #define ProxyIndex_ObjectSink_Size 2
  71. /******************************************************************************
  72. *
  73. * Name:
  74. *
  75. *
  76. * Description:
  77. *
  78. *
  79. *****************************************************************************/
  80. class CCommon_IWbemSyncObjectSink : public IWbemObjectSink ,
  81. public IWbemShutdown ,
  82. public ObjectSinkContainerElement
  83. {
  84. private:
  85. LONG m_InProgress ;
  86. LONG m_StatusCalled ;
  87. ULONG m_Dependant ;
  88. IWbemObjectSink *m_InterceptedSink ;
  89. IUnknown *m_Unknown ;
  90. protected:
  91. LONG m_GateClosed ;
  92. protected:
  93. HRESULT STDMETHODCALLTYPE Helper_Indicate (
  94. long a_ObjectCount ,
  95. IWbemClassObject **a_ObjectArray
  96. ) ;
  97. HRESULT STDMETHODCALLTYPE Helper_SetStatus (
  98. long a_Flags ,
  99. HRESULT a_Result ,
  100. BSTR a_StringParamater ,
  101. IWbemClassObject *a_ObjectParameter
  102. ) ;
  103. public:
  104. CCommon_IWbemSyncObjectSink (
  105. WmiAllocator &a_Allocator ,
  106. IWbemObjectSink *a_InterceptedSink ,
  107. IUnknown *a_Unknown ,
  108. CWbemGlobal_IWmiObjectSinkController *a_Controller ,
  109. ULONG a_Dependant = FALSE
  110. ) ;
  111. ~CCommon_IWbemSyncObjectSink() ;
  112. void CallBackInternalRelease () ;
  113. virtual HRESULT SinkInitialize () ;
  114. //Non-delegating object IUnknown
  115. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  116. STDMETHODIMP_( ULONG ) AddRef () ;
  117. STDMETHODIMP_( ULONG ) Release () ;
  118. HRESULT STDMETHODCALLTYPE Indicate (
  119. long a_ObjectCount ,
  120. IWbemClassObject **a_ObjectArray
  121. ) ;
  122. HRESULT STDMETHODCALLTYPE SetStatus (
  123. long a_Flags ,
  124. HRESULT a_Result ,
  125. BSTR a_StringParamater ,
  126. IWbemClassObject *a_ObjectParameter
  127. ) ;
  128. HRESULT STDMETHODCALLTYPE Shutdown (
  129. LONG a_Flags ,
  130. ULONG a_MaxMilliSeconds ,
  131. IWbemContext *a_Context
  132. ) ;
  133. } ;
  134. /******************************************************************************
  135. *
  136. * Name:
  137. *
  138. *
  139. * Description:
  140. *
  141. *
  142. *****************************************************************************/
  143. class CCommon_Batching_IWbemSyncObjectSink : public CCommon_IWbemSyncObjectSink
  144. {
  145. private:
  146. DWORD m_Size ;
  147. WmiQueue <IWbemClassObject *,8> m_Queue ;
  148. CriticalSection m_CriticalSection ;
  149. protected:
  150. public:
  151. CCommon_Batching_IWbemSyncObjectSink (
  152. WmiAllocator &a_Allocator ,
  153. IWbemObjectSink *a_InterceptedSink ,
  154. IUnknown *a_Unknown ,
  155. CWbemGlobal_IWmiObjectSinkController *a_Controller ,
  156. ULONG a_Dependant = FALSE
  157. ) ;
  158. ~CCommon_Batching_IWbemSyncObjectSink () ;
  159. HRESULT SinkInitialize () ;
  160. HRESULT STDMETHODCALLTYPE Indicate (
  161. long a_ObjectCount ,
  162. IWbemClassObject **a_ObjectArray
  163. ) ;
  164. HRESULT STDMETHODCALLTYPE SetStatus (
  165. long a_Flags ,
  166. HRESULT a_Result ,
  167. BSTR a_StringParamater ,
  168. IWbemClassObject *a_ObjectParameter
  169. ) ;
  170. } ;
  171. #endif _Common_IWbemObjectSink_H