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.

272 lines
12 KiB

  1. // Keys in cif file
  2. #include "download.h"
  3. #define URL_KEY "URL"
  4. #define GUID_KEY "GUID"
  5. #define ARGS_KEY "Switches"
  6. #define CMD_KEY "Command"
  7. #define SIZE_KEY "Size"
  8. #define INSTALLSIZE_KEY "InstalledSize"
  9. #define DISPLAYNAME_KEY "DisplayName"
  10. #define VERSION_KEY "Version"
  11. #define QFE_VERSION_KEY "QFEVersion"
  12. #define TYPE_KEY "Type"
  13. #define UNINSTALL_KEY "Uninstall"
  14. #define DEPENDENCY_KEY "Dependencies"
  15. #define UNINSTALLSTRING_KEY "UninstallKey"
  16. #define SUCCESS_KEY "SuccessKey"
  17. #define REBOOT_KEY "Reboot"
  18. #define ADMIN_KEY "AdminCheck"
  19. #define LOCALE_KEY "Locale"
  20. #define MUTEX_KEY "CancelMutex"
  21. #define ISINSTALLED_KEY "IsInstalled"
  22. #define ACTSETUPAWARE_KEY "ActiveSetupAware"
  23. #define PRIORITY "Priority"
  24. #define PROGRESS_KEY "ProgressKey"
  25. #define COMPID_KEY "ComponentID"
  26. #define STUBPATH_KEY "StubPath"
  27. #define PARENTID_KEY "ParentID"
  28. #define PATCHID_KEY "PatchID"
  29. #define APPLIESTO_KEY "AppliesTo"
  30. #define MINFILESIZE_KEY "MinFileSize"
  31. #define URLSIZE_KEY "Size"
  32. #define DETAILS_KEY "Details"
  33. #define MODES_KEY "Modes"
  34. #define UIVISIBLE_KEY "UIVisible"
  35. #define PLATFORM_KEY "Platform"
  36. #define GROUP_KEY "Group"
  37. #define ENTRYTYPE_KEY "SectionType"
  38. #define DETVERSION_KEY "DetectVersion"
  39. #define TREATAS_KEY "TreatAsOne"
  40. #define BUDDY_KEY "Buddies"
  41. #define DETDLLS_KEY "DetectDlls"
  42. #define ENTRYTYPE_COMP "Component"
  43. #define ENTRYTYPE_GROUP "Group"
  44. #define ENTRYTYPE_MODE "Mode"
  45. #define REGSTR_PROGRESS_KEY "Software\\Microsoft\\Active Setup\\Component Progress\\"
  46. #define COMPONENT_KEY "Software\\Microsoft\\Active Setup\\Installed Components"
  47. #define ACTIVESETUP_KEY "Software\\Microsoft\\Active Setup"
  48. #define COMPONENTBLOCK_KEY "Software\\Microsoft\\Active Setup\\Component Block"
  49. #define CANCEL_VALUENAME "Cancel"
  50. #define SAFE_VALUENAME "Safe"
  51. #define PROGRESS_DISPLAY "DisplayString"
  52. #define DEP_NEVER_INSTALL 'N'
  53. #define DEP_INSTALL 'I'
  54. #define DEP_BUDDY 'B'
  55. #define DEFAULT_LOCALE "en"
  56. #define ISINSTALLED_YES 1
  57. #define ISINSTALLED_NO 0
  58. // Default command type
  59. #define CMDF_DEFAULT 0
  60. #define STR_WIN95 "win95"
  61. #define STR_WIN98 "win98"
  62. #define STR_NT4 "nt4"
  63. #define STR_NT5 "nt5"
  64. #define STR_NT4ALPHA "nt4alpha"
  65. #define STR_NT5ALPHA "nt5alpha"
  66. #define STR_MILLEN "millen"
  67. #define SETACTION_DEPENDENCYINSTALL 0x00010000
  68. #define SETACTION_DEPENDENCYNONE 0x00020000
  69. #define BUFFERSIZE 4096
  70. class CCifFile;
  71. class CCifEntry
  72. {
  73. public:
  74. BOOL IsID(LPCSTR pszID) { return (lstrcmpi(_szID, pszID) == 0); }
  75. virtual void ClearCachedInfo() { _uPriority = 0xffffffff; }
  76. protected:
  77. CCifEntry(LPCSTR pszID, CCifFile *pCif) { lstrcpyn(_szID, pszID, sizeof(_szID)); _pCif = pCif; _uPriority = 0xffffffff; }
  78. ~CCifEntry() {}
  79. CCifFile *_pCif;
  80. char _szID[MAX_ID_LENGTH];
  81. UINT _uPriority;
  82. };
  83. class CCifComponent : public ICifComponent, public CCifEntry, public IMyDownloadCallback
  84. {
  85. public:
  86. CCifComponent(LPCSTR pszID, CCifFile *pCif);
  87. ~CCifComponent();
  88. HRESULT Download();
  89. HRESULT Install();
  90. void ClearQueueState() { _uInstallCount = 0; }
  91. void ClearCachedInfo() { CCifEntry::ClearCachedInfo(); _dwPlatform = 0xffffffff; _uInstallStatus = 0xffffffff; }
  92. // IMyDownloadCallback
  93. HRESULT OnProgress(ULONG progress, LPCSTR pszStatus);
  94. // ICifComponent interface
  95. STDMETHOD(GetID)(LPSTR pszID, DWORD dwSize);
  96. STDMETHOD(GetGUID)(LPSTR pszGUID, DWORD dwSize);
  97. STDMETHOD(GetDescription)(LPSTR pszDesc, DWORD dwSize);
  98. STDMETHOD(GetDetails)(LPSTR pszDetails, DWORD dwSize);
  99. STDMETHOD(GetUrl)(UINT uUrlNum, LPSTR pszUrl, DWORD dwSize, LPDWORD pdwUrlFlags);
  100. STDMETHOD(GetFileExtractList)(UINT uUrlNum, LPSTR pszExtract, DWORD dwSize);
  101. STDMETHOD(GetUrlCheckRange)(UINT uUrlNum, LPDWORD pdwMin, LPDWORD pdwMax);
  102. STDMETHOD(GetCommand)(UINT uCmdNum, LPSTR pszCmd, DWORD dwCmdSize, LPSTR pszSwitches,
  103. DWORD dwSwitchSize, LPDWORD pdwType);
  104. STDMETHOD(GetVersion)(LPDWORD pdwVersion, LPDWORD pdwBuild);
  105. STDMETHOD(GetLocale)(LPSTR pszLocale, DWORD dwSize);
  106. STDMETHOD(GetUninstallKey)(LPSTR pszKey, DWORD dwSize);
  107. STDMETHOD(GetInstalledSize)(LPDWORD pdwWin, LPDWORD pdwApp);
  108. STDMETHOD_(DWORD, GetDownloadSize)();
  109. STDMETHOD_(DWORD, GetExtractSize)();
  110. STDMETHOD(GetSuccessKey)(LPSTR pszKey, DWORD dwSize);
  111. STDMETHOD(GetProgressKeys)(LPSTR pszProgress, DWORD dwProgSize,
  112. LPSTR pszCancel, DWORD dwCancelSize);
  113. STDMETHOD(IsActiveSetupAware)();
  114. STDMETHOD(IsRebootRequired)();
  115. STDMETHOD(RequiresAdminRights)();
  116. STDMETHOD_(DWORD, GetPriority)();
  117. STDMETHOD(GetDependency)(UINT uDepNum, LPSTR pszID, DWORD dwBuf, char *pchType, LPDWORD pdwVer, LPDWORD pdwBuild);
  118. STDMETHOD_(DWORD, GetPlatform)();
  119. STDMETHODIMP_(BOOL) DisableComponent();
  120. STDMETHOD(GetMode)(UINT uModeNum, LPSTR pszModes, DWORD dwSize);
  121. STDMETHOD(GetGroup)(LPSTR pszID, DWORD dwSize);
  122. STDMETHOD(IsUIVisible)();
  123. STDMETHOD(GetPatchID)(LPSTR pszID, DWORD dwSize);
  124. STDMETHOD(GetDetVersion)(LPSTR pszDLL, DWORD dwdllSize, LPSTR pszEntry, DWORD dwentSize);
  125. STDMETHOD(GetTreatAsOneComponents)(UINT uNum, LPSTR pszID, DWORD dwBuf);
  126. STDMETHOD(GetCustomData)(LPSTR pszKey, LPSTR pszData, DWORD dwSize);
  127. // access to state
  128. STDMETHOD_(DWORD, IsComponentInstalled)();
  129. STDMETHOD(IsComponentDownloaded)();
  130. STDMETHOD_(DWORD, IsThisVersionInstalled)(DWORD dwAskVer, DWORD dwAskBld, LPDWORD pdwVersion, LPDWORD pdwBuild);
  131. STDMETHOD_(DWORD, GetInstallQueueState)();
  132. STDMETHOD(SetInstallQueueState)(DWORD dwState);
  133. STDMETHOD_(DWORD, GetActualDownloadSize)();
  134. STDMETHOD_(DWORD, GetCurrentPriority)();
  135. STDMETHOD(SetCurrentPriority)(DWORD dwPriority);
  136. protected:
  137. static char _szDetDllName[MAX_PATH];
  138. static HINSTANCE _hDetLib;
  139. char _szDesc[MAX_DISPLAYNAME_LENGTH];
  140. char _szDLDir[MAX_PATH];
  141. UINT _dwPlatform;
  142. UINT _uInstallStatus;
  143. UINT _uInstallCount; // refcount of dependendant installs, 0x80000000 if directly installed
  144. UINT _uTotalProgress;
  145. UINT _uIndivProgress;
  146. UINT _uTotalGoal;
  147. UINT _uPhase;
  148. BOOL _fDependenciesQueued:1;
  149. BOOL _fUseSRLite:1;
  150. BOOL _fBeforeInstall:1;
  151. HRESULT _DownloadUrl(UINT uUrlNum, LPCSTR pszUrl, UINT dwType);
  152. BOOL _FileIsDownloaded(LPCSTR pszFile, UINT i, DWORD *pdwSize);
  153. BOOL _CompareDownloadInfo();
  154. void _MarkAsInstalled();
  155. void _MarkDownloadStarted();
  156. void _MarkFileDownloadStarted(UINT i);
  157. void _MarkFileDownloadFinished(LPCSTR pszFilePath, UINT i, LPCSTR pszFilename);
  158. HRESULT _CheckForTrust(LPCSTR pszURL, LPCSTR pszFilename);
  159. HRESULT _CopyAllUrls(LPCSTR pszTemp);
  160. void _MarkComponentInstallStarted();
  161. HRESULT _RunAllCommands(LPCSTR psDir, DWORD *pdwStatus);
  162. HRESULT _ExtractFiles(UINT i, LPCSTR pszFile, DWORD dwType);
  163. HRESULT _CheckForDependencies();
  164. HRESULT _GetDetVerResult(LPCSTR pszDll, LPCSTR pszEntry, DETECTION_STRUCT *pDet, UINT *uStatus);
  165. HRESULT _SRLiteDownloadFiles();
  166. LPCSTR GetDownloadDir() { return _szDLDir; }
  167. void SetDownloadDir(LPCSTR pszDownloadDir);
  168. };
  169. class CCifRWComponent : public ICifRWComponent, public CCifComponent
  170. {
  171. public:
  172. // ICifComponent interface
  173. STDMETHOD(GetID)(LPSTR pszID, DWORD dwSize);
  174. STDMETHOD(GetGUID)(LPSTR pszGUID, DWORD dwSize);
  175. STDMETHOD(GetDescription)(LPSTR pszDesc, DWORD dwSize);
  176. STDMETHOD(GetDetails)(LPSTR pszDetails, DWORD dwSize);
  177. STDMETHOD(GetUrl)(UINT uUrlNum, LPSTR pszUrl, DWORD dwSize, LPDWORD pdwUrlFlags);
  178. STDMETHOD(GetFileExtractList)(UINT uUrlNum, LPSTR pszExtract, DWORD dwSize);
  179. STDMETHOD(GetUrlCheckRange)(UINT uUrlNum, LPDWORD pdwMin, LPDWORD pdwMax);
  180. STDMETHOD(GetCommand)(UINT uCmdNum, LPSTR pszCmd, DWORD dwCmdSize, LPSTR pszSwitches,
  181. DWORD dwSwitchSize, LPDWORD pdwType);
  182. STDMETHOD(GetVersion)(LPDWORD pdwVersion, LPDWORD pdwBuild);
  183. STDMETHOD(GetLocale)(LPSTR pszLocale, DWORD dwSize);
  184. STDMETHOD(GetUninstallKey)(LPSTR pszKey, DWORD dwSize);
  185. STDMETHOD(GetInstalledSize)(LPDWORD pdwWin, LPDWORD pdwApp);
  186. STDMETHOD_(DWORD, GetDownloadSize)();
  187. STDMETHOD_(DWORD, GetExtractSize)();
  188. STDMETHOD(GetSuccessKey)(LPSTR pszKey, DWORD dwSize);
  189. STDMETHOD(GetProgressKeys)(LPSTR pszProgress, DWORD dwProgSize,
  190. LPSTR pszCancel, DWORD dwCancelSize);
  191. STDMETHOD(IsActiveSetupAware)();
  192. STDMETHOD(IsRebootRequired)();
  193. STDMETHOD(RequiresAdminRights)();
  194. STDMETHOD_(DWORD, GetPriority)();
  195. STDMETHOD(GetDependency)(UINT uDepNum, LPSTR pszID, DWORD dwBuf, char *pchType, LPDWORD pdwVer, LPDWORD pdwBuild);
  196. STDMETHOD_(DWORD, GetPlatform)();
  197. STDMETHOD(GetMode)(UINT uModeNum, LPSTR pszModes, DWORD dwSize);
  198. STDMETHOD(GetGroup)(LPSTR pszID, DWORD dwSize);
  199. STDMETHOD(IsUIVisible)();
  200. STDMETHOD(GetPatchID)(LPSTR pszID, DWORD dwSize);
  201. STDMETHOD(GetDetVersion)(LPSTR pszDLL, DWORD dwdllSize, LPSTR pszEntry, DWORD dwentSize);
  202. STDMETHOD(GetTreatAsOneComponents)(UINT uNum, LPSTR pszID, DWORD dwBuf);
  203. STDMETHOD(GetCustomData)(LPSTR pszKey, LPSTR pszData, DWORD dwSize);
  204. // access to state
  205. STDMETHOD_(DWORD, IsComponentInstalled)();
  206. STDMETHOD(IsComponentDownloaded)();
  207. STDMETHOD_(DWORD, IsThisVersionInstalled)(DWORD dwAskVer, DWORD dwAskBld, LPDWORD pdwVersion, LPDWORD pdwBuild);
  208. STDMETHOD_(DWORD, GetInstallQueueState)();
  209. STDMETHOD(SetInstallQueueState)(DWORD dwState);
  210. STDMETHOD_(DWORD, GetActualDownloadSize)();
  211. STDMETHOD_(DWORD, GetCurrentPriority)();
  212. STDMETHOD(SetCurrentPriority)(DWORD dwPriority);
  213. // ICifRWComponent interface
  214. CCifRWComponent(LPCSTR pszID, CCifFile *pCif);
  215. ~CCifRWComponent();
  216. STDMETHOD(SetGUID)(THIS_ LPCSTR pszGUID);
  217. STDMETHOD(SetDescription)(THIS_ LPCSTR pszDesc);
  218. STDMETHOD(SetCommand)(THIS_ UINT uCmdNum, LPCSTR pszCmd, LPCSTR pszSwitches, DWORD dwType);
  219. STDMETHOD(SetVersion)(THIS_ LPCSTR pszVersion);
  220. STDMETHOD(SetUninstallKey)(THIS_ LPCSTR pszKey);
  221. STDMETHOD(SetInstalledSize)(THIS_ DWORD dwWin, DWORD dwApp);
  222. STDMETHOD(SetDownloadSize)(THIS_ DWORD);
  223. STDMETHOD(SetExtractSize)(THIS_ DWORD);
  224. STDMETHOD(DeleteDependency)(THIS_ LPCSTR pszID, char chType);
  225. STDMETHOD(AddDependency)(THIS_ LPCSTR pszID, char chType);
  226. STDMETHOD(SetUIVisible)(THIS_ BOOL);
  227. STDMETHOD(SetGroup)(THIS_ LPCSTR pszID);
  228. STDMETHOD(SetPlatform)(THIS_ DWORD);
  229. STDMETHOD(SetPriority)(THIS_ DWORD);
  230. STDMETHOD(SetReboot)(THIS_ BOOL);
  231. STDMETHOD(SetUrl)(THIS_ UINT uUrlNum, LPCSTR pszUrl, DWORD dwUrlFlags);
  232. STDMETHOD(DeleteFromModes)(THIS_ LPCSTR pszMode);
  233. STDMETHOD(AddToMode)(THIS_ LPCSTR pszMode);
  234. STDMETHOD(SetModes)(THIS_ LPCSTR pszMode);
  235. STDMETHOD(CopyComponent)(THIS_ LPCSTR pszCifFile);
  236. STDMETHOD(AddToTreatAsOne)(THIS_ LPCSTR pszCompID);
  237. STDMETHOD(SetDetails)(THIS_ LPCSTR pszDesc);
  238. };