Source code of Windows XP (NT5)
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.

134 lines
5.8 KiB

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