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.

153 lines
6.4 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1997-2002 Microsoft Corporation, All Rights Reserved
  4. //
  5. //***************************************************************************
  6. #ifndef _WMIMOF_HEADER
  7. #define _WMIMOF_HEADER
  8. #include <autoptr.h>
  9. #define NOT_INITIALIZED 0
  10. #define PARTIALLY_INITIALIZED 1
  11. #define FULLY_INITIALIZED 2
  12. ////////////////////////////////////////////////////////////////////
  13. class CWMIBinMof
  14. {
  15. public:
  16. CWMIBinMof();
  17. ~CWMIBinMof();
  18. HRESULT Initialize( CWMIManagement* p, BOOL fUpdateNamespace);
  19. HRESULT Initialize (
  20. CHandleMap * pList,
  21. BOOL fUpdateNamespace,
  22. ULONG uDesiredAccess,
  23. IWbemServices __RPC_FAR * pServices,
  24. IWbemServices __RPC_FAR * pRepository,
  25. IWbemObjectSink __RPC_FAR * pHandler,
  26. IWbemContext __RPC_FAR *pCtx
  27. );
  28. //=====================================================================
  29. // Public functions
  30. //=====================================================================
  31. void ProcessListOfWMIBinaryMofsFromWMI();
  32. BOOL UserConfiguredRegistryToProcessStrandedClassesDuringEveryInit(void);
  33. BOOL UpdateMofTimestampInHMOM(WCHAR * wcsFile,ULONG & lLowDateTime, ULONG & lHighDateTime, BOOL fSuccess );
  34. BOOL NeedToProcessThisMof(WCHAR * wcsFileName,ULONG & lLowDateTime, ULONG & lHighDateTime);
  35. BOOL ThisMofExistsInRegistry(WCHAR * wcsKey,WCHAR * wcsFileName, ULONG lLowDateTime, ULONG lHighDateTime, BOOL fCompareDates);
  36. BOOL GetListOfDriversCurrentlyInRegistry(WCHAR * wcsKey,KeyList & ArrDriversInRegistry);
  37. BOOL DeleteOldDriversInRegistry(KeyList & ArrDriversInRegistry);
  38. BOOL CopyWDMKeyToDredgeKey();
  39. HRESULT AddThisMofToRegistryIfNeeded(WCHAR * wcsKey, WCHAR * wcsFileName, ULONG & lLowDateTime, ULONG & lHighDateTime, BOOL fSuccess);
  40. HRESULT DeleteMofFromRegistry(WCHAR * wcsFileName);
  41. HRESULT ProcessBinaryMofEvent(PWNODE_HEADER WnodeHeader );
  42. BOOL BinaryMofsHaveChanged();
  43. BOOL BinaryMofEventChanged(PWNODE_HEADER WnodeHeader );
  44. inline CWMIManagement * WMI() { return m_pWMI; }
  45. HRESULT InitializePtrs (
  46. CHandleMap * pList,
  47. IWbemServices __RPC_FAR * pServices,
  48. IWbemServices __RPC_FAR * pRepository,
  49. IWbemObjectSink __RPC_FAR * pHandler,
  50. IWbemContext __RPC_FAR *pCtx
  51. );
  52. private:
  53. //======================================================
  54. // For use with binary mof related items
  55. //======================================================
  56. BOOL m_fUpdateNamespace;
  57. ULONG m_uCurrentResource;
  58. ULONG m_uResourceCount;
  59. int m_nInit;
  60. MOFRESOURCEINFO * m_pMofResourceInfo;
  61. CWMIManagement * m_pWMI;
  62. IWinmgmtMofCompiler * m_pCompiler;
  63. HRESULT OpenFileAndLookForItIfItDoesNotExist(wmilib::auto_buffer<TCHAR> & pFile, HANDLE & hFile );
  64. BOOL GetFileDateAndTime(ULONG & lLowDateTime, ULONG & lHighDateTime, WCHAR * p, int cchSize );
  65. BOOL GetPointerToBinaryResource(BYTE *& pRes,DWORD & dw, HGLOBAL & hResource, HINSTANCE & hInst,WCHAR * wcsResource, WCHAR * wcsKey, int cchSizeKey);
  66. //==========================================================
  67. // Common function
  68. //==========================================================
  69. HRESULT SendToMofComp(DWORD dwSize,BYTE * pRes,WCHAR * wcs);
  70. //==========================================================
  71. // Locale functions
  72. //==========================================================
  73. BOOL UseDefaultLocaleId(WCHAR * wcsFile, WORD & wLocalId);
  74. BOOL GetNextSectionFromTheEnd(WCHAR * pwcsTempPath, WCHAR * pwcsEnd, int cchSize);
  75. //==========================================================
  76. // THE BINARY MOF GROUP
  77. //==========================================================
  78. BOOL GetListOfBinaryMofs();
  79. BOOL GetBinaryMofFileNameAndResourceName(WCHAR * pwcsFileName, int cchSizeFile, WCHAR * pwcsResource, int cchSizeResource);
  80. HRESULT CreateKey(WCHAR * wcsFileName, WCHAR * wcsResource,WCHAR * wcsKey, int cchSizeKey);
  81. BOOL ExtractFileNameFromKey(wmilib::auto_buffer<TCHAR> & pKey,WCHAR * wcsKey,int cchSize);
  82. public:
  83. HRESULT SetBinaryMofClassName( WCHAR * wcsIn, WCHAR * wcsOut, int cchSize )
  84. {
  85. return StringCchPrintfW ( wcsOut, cchSize, L"%s-%s",wcsIn,WMI_BINARY_MOF_GUID );
  86. }
  87. //==========================================================
  88. // THE BINARY MOF GROUP VIA Data blocks
  89. //==========================================================
  90. HRESULT ExtractBinaryMofFromDataBlock(BYTE * pByte, ULONG m,WCHAR *, BOOL & fMofHasChanged);
  91. //==========================================================
  92. // Processing Binary Mofs via file
  93. //==========================================================
  94. BOOL ExtractBinaryMofFromFile(WCHAR * wcsFile, WCHAR * wcsResource,WCHAR * wcsKey, int cchSizeKey, BOOL & fMofChanged);
  95. BYTE * DecompressBinaryMof(BYTE * pRes);
  96. HRESULT DeleteMofsFromEvent(CVARIANT & vImagePath,CVARIANT & vResourceName, BOOL & fMofChanged);
  97. };
  98. class CNamespaceManagement
  99. {
  100. public:
  101. CNamespaceManagement(CWMIBinMof * pOwner);
  102. ~CNamespaceManagement();
  103. BOOL DeleteOldClasses(WCHAR * wcsFileName,CVARIANT & vLow, CVARIANT & vHi,BOOL fCompareDates);
  104. BOOL DeleteStrandedClasses();
  105. BOOL DeleteOldDrivers(BOOL);
  106. HRESULT DeleteUnusedClassAndDriverInfo(BOOL fDeleteOldClass, WCHAR * wcsClass, WCHAR * wcsPath);
  107. BOOL CreateInstance ( WCHAR * wcsDriver, WCHAR * wcsClass, ULONG lLowDateTime, ULONG lHighDateTime );
  108. void CreateClassAssociationsToDriver(WCHAR * wcsFileName, BYTE* pRes, ULONG lLowDateTime, ULONG lHighDateTime);
  109. HRESULT UpdateQuery( WCHAR * pQueryAddOn, WCHAR * Param );
  110. HRESULT UpdateQuery( WCHAR * pQueryAddOn, ULONG lLong );
  111. HRESULT InitQuery(WCHAR * p);
  112. HRESULT AddToQuery(WCHAR * p);
  113. private:
  114. BOOL IsClassAsociatedWithDifferentDriver ( LPCWSTR wcsClass, LPCWSTR wcsDriver = NULL ) ;
  115. BOOL IsClassPseudoSystem ( LPCWSTR wcsClass ) ;
  116. void RestoreQuery();
  117. void SaveCurrentQuery();
  118. HRESULT AllocMemory(WCHAR * & p);
  119. WCHAR * m_pwcsQuery, *m_pwcsSavedQuery;
  120. CWMIBinMof * m_pObj;
  121. int m_nSize,m_nSavedSize;
  122. BOOL m_fInit,m_fSavedInit;
  123. };
  124. #endif