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.

155 lines
6.4 KiB

  1. #include "inseng.h"
  2. #include <wininet.h>
  3. #include "util2.h"
  4. #include "ciffile.h"
  5. #define CMDLINE "\"%s%s\" %s"
  6. #define COMPONENT_KEY "Software\\Microsoft\\Active Setup\\Installed Components"
  7. #define ACTIVESETUP_KEY "Software\\Microsoft\\Active Setup"
  8. #define STEPPING_VALUE "SteppingMode"
  9. #define COMMAND_VALUE "CommandMode"
  10. #define CHECKTRUST_VALUE "DisableCheckTrust"
  11. #define VERSION_KEY "Version"
  12. #define STR_FAILED "Failed"
  13. #define STR_OK "OK"
  14. #define COMPONENTSIZES_SIZE_V1 32
  15. #define COMPONENTSIZES_SIZE_V2 35
  16. #define COMPONENTSIZES_SIZE_V3 39
  17. class CInstallEngine : public IInstallEngine2, public IInstallEngineTiming,
  18. public IInstallEngineCallback
  19. {
  20. friend DWORD WINAPI InitInstaller(LPVOID pv);
  21. friend DWORD WINAPI InitDownloader(LPVOID pv);
  22. public:
  23. CInstallEngine(IUnknown **punk);
  24. ~CInstallEngine();
  25. // the usual IUnknown members
  26. STDMETHOD_(ULONG, AddRef)(void);
  27. STDMETHOD_(ULONG, Release)(void);
  28. STDMETHOD(QueryInterface)(REFIID, void **);
  29. // IInstallEngine methods
  30. //
  31. STDMETHOD(GetEngineStatus)(THIS_ DWORD *theenginestatus);
  32. STDMETHOD(GetSizes)(THIS_ LPCSTR pszID, COMPONENT_SIZES *p);
  33. STDMETHOD(SetAction)(THIS_ LPCSTR pszID,DWORD dwAction,DWORD dwPriority);
  34. STDMETHOD(EnumInstallIDs)(THIS_ UINT uIndex, LPSTR *ppszID);
  35. STDMETHOD(EnumDownloadIDs)(THIS_ UINT uIndex, LPSTR *ppszID);
  36. STDMETHOD(IsComponentInstalled)(THIS_ LPCSTR pszID, DWORD *pdwStatus);
  37. STDMETHOD(DownloadComponents)(THIS_ DWORD dwFlags);
  38. STDMETHOD(InstallComponents)(THIS_ DWORD dwFlags);
  39. STDMETHOD(LaunchExtraCommand)(THIS_ LPCSTR pszInfName, LPCSTR pszSection);
  40. STDMETHOD(RegisterInstallEngineCallback)(THIS_ IInstallEngineCallback *pcb);
  41. STDMETHOD(UnregisterInstallEngineCallback)(THIS);
  42. STDMETHOD(GetDisplayName)(THIS_ LPCSTR pszComponentID, LPSTR *ppszName);
  43. // Intall info stuff
  44. STDMETHOD(SetCifFile)(THIS_ LPCSTR pszCabName, LPCSTR pszCifName);
  45. STDMETHOD(SetBaseUrl)(THIS_ LPCSTR pszBaseName);
  46. STDMETHOD(SetDownloadDir)(THIS_ LPCSTR pszDownloadDir);
  47. STDMETHOD(SetInstallDrive)(THIS_ char chDrive);
  48. STDMETHOD(SetInstallOptions)(THIS_ DWORD dwInsFlag);
  49. STDMETHOD(GetInstallOptions)(THIS_ DWORD *pdwInsFlag);
  50. STDMETHOD(SetHWND)(THIS_ HWND hForUI);
  51. STDMETHOD(SetIStream)(THIS_ IStream *pstm);
  52. // Engine Control
  53. STDMETHOD(Abort)(THIS_ DWORD dwFlags);
  54. STDMETHOD(Suspend)(THIS);
  55. STDMETHOD(Resume)(THIS);
  56. // IInstallEngineTiming
  57. STDMETHOD(GetRates)(THIS_ DWORD *pdwDownload, DWORD *pdwInstall);
  58. STDMETHOD(GetInstallProgress)(THIS_ INSTALLPROGRESS *pinsprog);
  59. // IInstallEngine2
  60. STDMETHOD(SetLocalCif)(THIS_ LPCSTR pszLocalCif);
  61. STDMETHOD(GetICifFile)(THIS_ ICifFile **pcif);
  62. // IInstallEngineCallback
  63. STDMETHOD(OnEngineStatusChange)(THIS_ DWORD dwEngStatus, DWORD substatus);
  64. STDMETHOD(OnStartInstall)(THIS_ DWORD dwDLSize, DWORD dwInstallSize);
  65. STDMETHOD(OnStartComponent)(THIS_ LPCSTR pszID, DWORD dwDLSize,
  66. DWORD dwInstallSize, LPCSTR pszString);
  67. STDMETHOD(OnComponentProgress)(THIS_ LPCSTR pszID, DWORD dwPhase,
  68. LPCSTR pszString, LPCSTR pszMsgString, ULONG progress, ULONG themax);
  69. STDMETHOD(OnStopComponent)(THIS_ LPCSTR pszID, HRESULT hError,
  70. DWORD dwPhase, LPCSTR pszString, DWORD dwStatus);
  71. STDMETHOD(OnStopInstall)(THIS_ HRESULT hrError, LPCSTR szError,
  72. DWORD dwStatus);
  73. STDMETHOD(OnEngineProblem)(THIS_ DWORD dwProblem, LPDWORD dwAction);
  74. void WriteToLog(char *sz, BOOL pause);
  75. CDownloader *GetDownloader() { return _pDL; }
  76. CInstaller *GetInstaller() { return _pIns; }
  77. CPatchDownloader *GetPatchDownloader() { return _pPDL; }
  78. LPCSTR GetBaseUrl() { return _szBaseUrl; }
  79. void SetStatus(DWORD dwStatus) { _dwStatus |= dwStatus; }
  80. UINT GetStatus() { return _dwStatus; }
  81. UINT GetCommandMode() { return _uCommandMode; }
  82. HWND GetHWND() { return _hwndForUI; }
  83. BOOL IgnoreTrustCheck() { return _fIgnoreTrust; }
  84. BOOL IgnoreDownloadError() { return _fIgnoreDownloadError; }
  85. char GetInstallDrive() { return _chInsDrive; }
  86. HRESULT CheckForContinue();
  87. BOOL UseCache() { return _fUseCache; }
  88. BOOL AllowCrossPlatform() { return !(_dwInstallOptions & INSTALLOPTIONS_DONTALLOWXPLATFORM); }
  89. BOOL ForceDependencies() { return (_dwInstallOptions & INSTALLOPTIONS_FORCEDEPENDENCIES); }
  90. BOOL IsAdvpackExtAvailable() { return _fSRLiteAvailable; }
  91. private:
  92. char _szBaseUrl[INTERNET_MAX_URL_LENGTH];
  93. HWND _hwndForUI;
  94. IStream *_pStmLog;
  95. UINT _uCommandMode;
  96. char _chInsDrive;
  97. DWORD _dwDLRemaining;
  98. DWORD _dwInstallRemaining;
  99. DWORD _dwDLOld;
  100. DWORD _dwInstallOptions;
  101. DWORD _dwInstallOld;
  102. DWORD _enginestatus;
  103. DWORD _dwStatus;
  104. ULONG _cRef;
  105. HANDLE _hAbort;
  106. HANDLE _hContinue;
  107. IInstallEngineCallback *_pcb;
  108. CDownloader *_pDL;
  109. CInstaller *_pIns;
  110. CPatchDownloader *_pPDL;
  111. BOOL _fUseCache:1;
  112. BOOL _fSteppingMode:1;
  113. BOOL _fIgnoreTrust:1;
  114. BOOL _fIgnoreDownloadError:1;
  115. BOOL _fResetTrust:1;
  116. BOOL _fCleanUpDir:1;
  117. BOOL _fSRLiteAvailable:1;
  118. CCifFile *_pCif;
  119. void _GetTotalSizes(COMPONENT_SIZES *p);
  120. DWORD _GetTotalDownloadSize();
  121. DWORD _GetActualDownloadSize(BOOL bLogMissing);
  122. DWORD _GetTotalDependencySize();
  123. DWORD _GetTotalInstallSize();
  124. BOOL _IsValidBaseUrl(LPCSTR pszUrl);
  125. };
  126. DWORD WINAPI InitInstaller(LPVOID);
  127. DWORD WINAPI InitDownloader(LPVOID);
  128. extern CRITICAL_SECTION g_cs;