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.

179 lines
6.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Declaration of class CParseInf
  3. //
  4. // One instance of this class is created for each OCX being removed. It stores
  5. // all the files associated with the OCX in a linked list. It also does the
  6. // jobs of determining if the OCX is uninstallable and of the actual file
  7. // removal.
  8. #ifndef __PARSE_INF__
  9. #define __PARSE_INF__
  10. #include "filenode.h"
  11. #include <pkgmgr.h>
  12. #define REGSTR_COM_BRANCH "CLSID"
  13. #define REGSTR_DOWNLOAD_INFORMATION "DownloadInformation"
  14. #define REGSTR_DLINFO_INF_FILE "INF"
  15. #define REGSTR_DLINFO_CODEBASE "CODEBASE"
  16. #define REGSTR_PATH_DIST_UNITS "Software\\Microsoft\\Code Store Database\\Distribution Units"
  17. #define REGSTR_DU_CONTAINS_FILES "Contains\\Files"
  18. #define REGSTR_DU_CONTAINS_JAVA "Contains\\Java"
  19. #define REGSTR_DU_CONTAINS_DIST_UNITS "Contains\\Distribution Units"
  20. #define REGSTR_VALUE_INF "INF"
  21. #define REGSTR_VALUE_OSD "OSD"
  22. #define REGSTR_INSTALLED_VERSION "InstalledVersion"
  23. #define REGSTR_VALUE_EXPIRE "Expire"
  24. #define REGSTR_SHOW_ALL_FILES "ShowAllFiles"
  25. #define MAX_REGPATH_LEN 2048
  26. #define MAX_CONTROL_NAME_LEN 1024
  27. #define MAX_MSGBOX_STRING_LEN 2048
  28. #define MAX_MSGBOX_TITLE_LEN 256
  29. #define BYTES_MAXSIZE 32
  30. BOOL IsShowAllFilesEnabled();
  31. void ToggleShowAllFiles();
  32. class CParseInf
  33. {
  34. // Construction
  35. public:
  36. CParseInf();
  37. ~CParseInf();
  38. // Data members
  39. protected:
  40. DWORD m_dwTotalFileSize;
  41. DWORD m_dwFileSizeSaved;
  42. DWORD m_dwStatus; // status value from the STATUS_CTRL set in <cleanoc.h>
  43. int m_nTotalFiles;
  44. CFileNode *m_pHeadFileList;
  45. CFileNode *m_pCurFileNode;
  46. CFileNode *m_pFileRetrievalPtr;
  47. CPackageNode *m_pHeadPackageList;
  48. CPackageNode *m_pCurPackageNode;
  49. CPackageNode *m_pPackageRetrievalPtr;
  50. TCHAR m_szInf[MAX_PATH];
  51. TCHAR m_szFileName[MAX_PATH];
  52. TCHAR m_szCLSID[MAX_CLSID_LEN];
  53. BOOL m_bIsDistUnit;
  54. BOOL m_bHasActiveX;
  55. BOOL m_bHasJava;
  56. IJavaPackageManager *m_pijpm;
  57. BOOL m_bCoInit;
  58. ULONG m_cExpireDays;
  59. // Operations
  60. public:
  61. virtual HRESULT DoParse(
  62. LPCTSTR szOCXFileName,
  63. LPCTSTR szCLSID);
  64. virtual HRESULT RemoveFiles(
  65. LPCTSTR lpszTypeLibID = NULL,
  66. BOOL bForceRemove = FALSE,
  67. DWORD dwIsDistUnit = FALSE,
  68. BOOL bSilent=FALSE);
  69. virtual DWORD GetTotalFileSize() const;
  70. virtual DWORD GetTotalSizeSaved() const;
  71. virtual int GetTotalFiles() const;
  72. virtual CFileNode* GetFirstFile();
  73. virtual CFileNode* GetNextFile();
  74. virtual CPackageNode* GetFirstPackage();
  75. virtual CPackageNode* GetNextPackage();
  76. virtual HRESULT DoParseDU(LPCTSTR szOCXFileName, LPCTSTR szCLSID);
  77. virtual void SetIsDistUnit(BOOL bDist);
  78. virtual BOOL GetIsDistUnit() const;
  79. virtual DWORD GetStatus() const;
  80. virtual BOOL GetHasActiveX(void) { return m_bHasActiveX; };
  81. virtual BOOL GetHasJava(void) { return m_bHasJava; };
  82. virtual ULONG GetExpireDays(void) { return m_cExpireDays; }
  83. // private helper methods
  84. protected:
  85. void Init();
  86. void DestroyFileList();
  87. void DestroyPackageList();
  88. HRESULT FindInf(LPTSTR szInf);
  89. HRESULT EnumSections();
  90. BOOL IsSectionInINF( LPCSTR lpCurCode);
  91. HRESULT HandleSatellites(LPCTSTR pszFileName);
  92. HRESULT GetFilePath(CFileNode* pFileNode);
  93. HRESULT ParseSetupHook();
  94. HRESULT ParseConditionalHook();
  95. HRESULT ParseUninstallSection(LPCTSTR lpszSection);
  96. HRESULT BuildDUFileList( HKEY hKeyDU );
  97. HRESULT BuildDUPackageList( HKEY hKeyDU );
  98. HRESULT BuildNamespacePackageList( HKEY hKeyNS, LPCTSTR szNamespace );
  99. HRESULT CheckFilesRemovability(void);
  100. HRESULT CheckLegacyRemovability( LONG *cOldSharedCount);
  101. HRESULT CheckDURemovability( HKEY hkeyDU, BOOL bSilent=FALSE );
  102. HRESULT RemoveLegacyControl( LPCTSTR lpszTypeLibID, BOOL bSilent=FALSE );
  103. HRESULT RemoveDU( LPTSTR szFullName, LPCTSTR lpszTypeLibID, HKEY hkeyDUDB, BOOL bSilent=FALSE );
  104. HRESULT CheckDUDependencies(HKEY hKeyDUDB, BOOL bSilent=FALSE);
  105. };
  106. ///////////////////////////////////////////////////////////////////////////////
  107. // Structure storing information about an ActiveX control.
  108. //
  109. // szName -- descriptive name of control (eg. "Circle control")
  110. // szFile -- full filename of the control
  111. // (eg. "C:\WINDOWS\OCCACHE\CIRC3.INF")
  112. // szCLSID -- CLSID of control, in a string
  113. // szTypeLibID -- TypeLib ID of the control, in a string
  114. // dwTotalFileSize -- total size in bytes of all control-related files
  115. // dwTotalSizeSaved -- total size in bytes restored when the control is removed
  116. // cTotalFiles -- total number of control-related files, including the
  117. // control itself
  118. // parseInf -- pointer to an instance of class CParseInf, which does
  119. // all the jobs of parsing the inf file and removing the
  120. // control. Users of this struct should not in anyway
  121. // manipulate this pointer.
  122. //
  123. class CCacheItem : public CParseInf
  124. {
  125. public:
  126. TCHAR m_szName[LENGTH_NAME];
  127. TCHAR m_szFile[MAX_PATH];
  128. TCHAR m_szCLSID[MAX_DIST_UNIT_NAME_LEN];
  129. TCHAR m_szTypeLibID[MAX_CLSID_LEN];
  130. TCHAR m_szCodeBase[INTERNET_MAX_URL_LENGTH];
  131. TCHAR m_szVersion[VERSION_MAXSIZE];
  132. CCacheItem(void) {};
  133. virtual ~CCacheItem(void) {};
  134. virtual DWORD ItemType(void) const = 0;
  135. };
  136. class CCacheLegacyControl : public CCacheItem
  137. {
  138. public:
  139. CCacheLegacyControl(void) {};
  140. virtual ~CCacheLegacyControl(void) {};
  141. static DWORD s_dwType;
  142. virtual DWORD ItemType(void) const { return s_dwType; };
  143. virtual HRESULT Init( HKEY hkeyCLSID, LPCTSTR szFile, LPCTSTR szCLSID );
  144. };
  145. class CCacheDistUnit : public CCacheLegacyControl
  146. {
  147. public:
  148. CCacheDistUnit(void) {};
  149. virtual ~CCacheDistUnit() {};
  150. static DWORD s_dwType;
  151. virtual DWORD ItemType(void) const { return s_dwType; };
  152. virtual HRESULT Init( HKEY hkeyCLSID, LPCTSTR szFile, LPCTSTR szCLSID, HKEY hkeyDist, LPCTSTR szDU );
  153. // override this - we'll do this work when we DoParseDU
  154. virtual HRESULT DoParse( LPCTSTR szOCXFileName, LPCTSTR szCLSID ) { return S_OK; };
  155. };
  156. #endif