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.

154 lines
3.5 KiB

  1. ////////////////////////////////////////////////////////////////////
  2. //
  3. // globals.h
  4. //
  5. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. ////////////////////////////////////////////////////////////////////
  8. #ifndef _GLOBALS_H_
  9. #define _GLOBALS_H_
  10. #include <WDMSHELL.h>
  11. #include <wchar.h>
  12. #include <flexarry.h>
  13. #include <provexpt.h>
  14. typedef LPVOID * PPVOID;
  15. #define PUT_INSTANCE 1
  16. #define CREATE_INSTANCE_ENUM 2
  17. // {0725C3CB-FEFB-11d0-99F9-00C04FC2F8EC}
  18. DEFINE_GUID(CLSID_WMIEventProvider, 0x725c3cb, 0xfefb, 0x11d0, 0x99, 0xf9, 0x0, 0xc0, 0x4f, 0xc2, 0xf8, 0xec);
  19. // {D2D588B5-D081-11d0-99E0-00C04FC2F8EC}
  20. DEFINE_GUID(CLSID_WMIProvider,0xd2d588b5, 0xd081, 0x11d0, 0x99, 0xe0, 0x0, 0xc0, 0x4f, 0xc2, 0xf8, 0xec);
  21. // {35B78F79-B973-48c8-A045-CAEC732A35D5}
  22. DEFINE_GUID(CLSID_WMIHiPerfProvider,0x35b78f79, 0xb973, 0x48c8, 0xa0, 0x45, 0xca, 0xec, 0x73, 0x2a, 0x35, 0xd5);
  23. #include "wdmperf.h"
  24. #include "classfac.h"
  25. #include "wmiprov.h"
  26. #include "wmievent.h"
  27. #include "wmimof.h"
  28. //===============================================================
  29. // These variables keep track of when the module can be unloaded
  30. //===============================================================
  31. extern long g_cObj;
  32. extern long g_cLock;
  33. extern CWMIEvent * g_pBinaryMofEvent;
  34. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  35. //
  36. // Common functions regarding binary mof processing & security
  37. //
  38. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  39. HRESULT CheckImpersonationLevel();
  40. HRESULT InitializeProvider (
  41. /* [in] */ LPWSTR pszNamespace,
  42. /* [in] */ LPWSTR pszLocale,
  43. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  44. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  45. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink,
  46. /* [in] */ CHandleMap * pMap,
  47. /* [out] */ IWbemServices ** ppServices,
  48. /* [out] */ IWbemServices ** ppRepository,
  49. /* [out] */ IWbemContext ** ppCtx = NULL,
  50. /* [in] */ BOOL bProcessMof = TRUE
  51. ) ;
  52. HRESULT UnInitializeProvider ( ) ;
  53. HRESULT GetRepository (
  54. /* [in] */ LPWSTR pszNamespace,
  55. /* [in] */ LPWSTR pszLocale,
  56. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  57. /* [out] */ IWbemServices __RPC_FAR ** pServices
  58. ) ;
  59. #define STANDARD_CATCH catch(Structured_Exception e_SE) { hr = E_UNEXPECTED; } \
  60. catch(Heap_Exception e_HE) { hr = E_OUTOFMEMORY; } \
  61. catch(...) { hr = WBEM_E_UNEXPECTED; }
  62. #ifndef __LEAVEPTR__
  63. #define __LEAVEPTR__
  64. template <typename T, typename FT, FT F>
  65. class LeavePtrFnc
  66. {
  67. private:
  68. T Val_;
  69. BOOL bExec;
  70. public:
  71. LeavePtrFnc ( T Val ): Val_ ( Val ), bExec ( FALSE )
  72. {
  73. };
  74. void Exec ( BOOL bSetExecFlag = TRUE )
  75. {
  76. (Val_->*F)();
  77. if ( bSetExecFlag )
  78. {
  79. bExec = TRUE;
  80. }
  81. }
  82. ~LeavePtrFnc ( )
  83. {
  84. if ( !bExec )
  85. {
  86. Exec ();
  87. }
  88. };
  89. };
  90. #endif __LEAVEPTR__
  91. #ifndef __WAITEXPTR__
  92. #define __WAITEXPTR__
  93. template < typename T, typename FT, FT F, int iTime >
  94. class WaitExceptionPtrFnc
  95. {
  96. public:
  97. WaitExceptionPtrFnc ( T Val_ )
  98. {
  99. BOOL bResult = FALSE;
  100. while ( ! bResult )
  101. {
  102. try
  103. {
  104. (Val_->*F)();
  105. bResult = TRUE;
  106. }
  107. catch ( ... )
  108. {
  109. }
  110. if ( ! bResult )
  111. {
  112. ::Sleep ( iTime );
  113. }
  114. }
  115. }
  116. };
  117. #endif __WAITEXPTR__
  118. #endif