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.

311 lines
8.1 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: iuengine.h
  6. //
  7. // Description:
  8. //
  9. // Common include file for IUEngine DLL
  10. //
  11. //=======================================================================
  12. #ifndef __IUENGINE_H_
  13. #define __IUENGINE_H_
  14. #include <windows.h>
  15. #include <tchar.h>
  16. #include <ole2.h>
  17. #include "..\inc\iu.h"
  18. #include <logging.h>
  19. #include <shlwapi.h>
  20. #include <iucommon.h>
  21. #include <osdet.h>
  22. #include <UrlAgent.h>
  23. // #define __IUENGINE_USES_ATL_
  24. #if defined(__IUENGINE_USES_ATL_)
  25. #include <atlbase.h>
  26. #define USES_IU_CONVERSION USES_CONVERSION
  27. #else
  28. #include <MemUtil.h>
  29. #endif
  30. #include "schemakeys.h"
  31. #include <mistsafe.h>
  32. #include <wusafefn.h>
  33. //***********************************************************************
  34. //
  35. // The following constants are defined in engmain.cpp
  36. //
  37. //***********************************************************************
  38. /**
  39. * the following two groups of constants can be used to construct
  40. * lMode parameter of the following APIs:
  41. * Download()
  42. * DownloadAsync()
  43. * Install()
  44. * InstallAsync()
  45. *
  46. * Obviousely, you can only pick one from each group to make up
  47. * lMode parameter.
  48. *
  49. */
  50. extern const LONG UPDATE_NOTIFICATION_DEFAULT;
  51. extern const LONG UPDATE_NOTIFICATION_ANYPROGRESS;
  52. extern const LONG UPDATE_NOTIFICATION_COMPLETEONLY;
  53. extern const LONG UPDATE_NOTIFICATION_1PCT;
  54. extern const LONG UPDATE_NOTIFICATION_5PCT;
  55. extern const LONG UPDATE_NOTIFICATION_10PCT;
  56. /**
  57. * constant can also be used for SetOperationMode() and GetOperationMode()
  58. */
  59. extern const LONG UPDATE_MODE_THROTTLE;
  60. /**
  61. * constant can be used by Download() and DownloadAsync(), which will
  62. * tell these API's to use Corporate directory structure for destination folder.
  63. */
  64. extern const LONG UPDATE_CORPORATE_MODE;
  65. /**
  66. * constant can be used by Install() and InstallAsync(). Will disable all
  67. * internet related features
  68. */
  69. extern const LONG UPDATE_OFFLINE_MODE;
  70. /**
  71. * constants for SetOperationMode() API
  72. */
  73. extern const LONG UPDATE_COMMAND_PAUSE;
  74. extern const LONG UPDATE_COMMAND_RESUME;
  75. extern const LONG UPDATE_COMMAND_CANCEL;
  76. /**
  77. * constants for GetOperationMode() API
  78. */
  79. extern const LONG UPDATE_MODE_PAUSED;
  80. extern const LONG UPDATE_MODE_RUNNING;
  81. extern const LONG UPDATE_MODE_NOTEXISTS;
  82. /**
  83. * constants for SetProperty() and GetProperty() API
  84. */
  85. extern const LONG UPDATE_PROP_USECOMPRESSION;
  86. extern const LONG UPDATE_PROP_OFFLINEMODE;
  87. /**
  88. * constants for BrowseForFolder() API
  89. *
  90. * IUBROWSE_WRITE_ACCESS - validate write access on selected folder
  91. * IUBROWSE_AFFECT_UI - write-access validation affect OK button enable/disable
  92. * IUBROWSE_NOBROWSE - do not show browse folder dialog box. validate path passed-in only
  93. *
  94. * default:
  95. * pop up browse folder dialog box, not doing any write-access validation
  96. *
  97. */
  98. extern const LONG IUBROWSE_WRITE_ACCESS;
  99. extern const LONG IUBROWSE_AFFECT_UI;
  100. extern const LONG IUBROWSE_NOBROWSE;
  101. // constants for historical speed registry
  102. const TCHAR REGKEY_IUCTL[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\IUControl");
  103. const TCHAR REGVAL_HISTORICALSPEED[] = _T("HistoricalSpeed"); // in bytes/sec
  104. const TCHAR REGVAL_TIMEELAPSED[] = _T("TimeElapsed"); // in seconds
  105. // constant for default downloads folder name
  106. const TCHAR IU_WUTEMP[] = _T("WUTemp");
  107. //
  108. // Globals for the IUEngine
  109. extern LONG g_lThreadCounter;
  110. extern HANDLE g_evtNeedToQuit;
  111. extern CUrlAgent *g_pUrlAgent;
  112. typedef struct IUOPERATIONINFO
  113. {
  114. TCHAR szOperationUUID[64];
  115. LONG lUpdateMask;
  116. BSTR bstrOperationResult;
  117. IUOPERATIONINFO *pNext;
  118. } IUOPERATIONINFO, *PIUOPERATIONINFO;
  119. class COperationMgr
  120. {
  121. public:
  122. COperationMgr();
  123. ~COperationMgr();
  124. BOOL AddOperation(LPCTSTR pszOperationID, LONG lUpdateMask);
  125. BOOL RemoveOperation(LPCTSTR pszOperationID);
  126. BOOL FindOperation(LPCTSTR pszOperationID, PLONG plUpdateMask, BSTR *pbstrOperationResult);
  127. BOOL UpdateOperation(LPCTSTR pszOperationID, LONG lUpdateMask, BSTR bstrOperationResult);
  128. private:
  129. PIUOPERATIONINFO m_pOperationInfoList;
  130. };
  131. //
  132. // CEngUpdate class used to export apartment safe instances of the update class to WU clients (iuctl, AU, DU, CDM)
  133. //
  134. class CEngUpdate
  135. {
  136. public:
  137. CEngUpdate();
  138. ~CEngUpdate();
  139. public:
  140. HRESULT WINAPI GetSystemSpec(BSTR bstrXmlClasses, DWORD dwFlags, BSTR *pbstrXmlDetectionResult);
  141. HRESULT WINAPI GetManifest(BSTR bstrXmlClientInfo, BSTR bstrXmlSystemSpec, BSTR bstrXmlQuery, DWORD dwFlags, BSTR *pbstrXmlCatalog);
  142. HRESULT WINAPI Detect(BSTR bstrXmlCatalog, DWORD dwFlags, BSTR *pbstrXmlItems);
  143. HRESULT WINAPI Download(BSTR bstrXmlClientInfo, BSTR bstrXmlCatalog, BSTR bstrDestinationFolder, LONG lMode,
  144. IUnknown *punkProgressListener, HWND hWnd, BSTR *pbstrXmlItems);
  145. HRESULT WINAPI DownloadAsync(BSTR bstrXmlClientInfo, BSTR bstrXmlCatalog, BSTR bstrDestinationFolder, LONG lMode,
  146. IUnknown *punkProgressListener, HWND hWnd, BSTR bstrUuidOperation, BSTR *pbstrUuidOperation);
  147. HRESULT WINAPI Install(BSTR bstrXmlClientInfo,
  148. BSTR bstrXmlCatalog,
  149. BSTR bstrXmlDownloadedItems,
  150. LONG lMode,
  151. IUnknown *punkProgressListener,
  152. HWND hWnd,
  153. BSTR *pbstrXmlItems);
  154. HRESULT WINAPI InstallAsync(BSTR bstrXmlClientInfo,
  155. BSTR bstrXmlCatalog,
  156. BSTR bstrXmlDownloadedItems,
  157. LONG lMode,
  158. IUnknown *punkProgressListener,
  159. HWND hWnd,
  160. BSTR bstrUuidOperation,
  161. BSTR *pbstrUuidOperation);
  162. HRESULT WINAPI SetOperationMode(BSTR bstrUuidOperation, LONG lMode);
  163. HRESULT WINAPI GetOperationMode(BSTR bstrUuidOperation, LONG* plMode);
  164. HRESULT WINAPI GetHistory(
  165. BSTR bstrDateTimeFrom,
  166. BSTR bstrDateTimeTo,
  167. BSTR bstrClient,
  168. BSTR bstrPath,
  169. BSTR* pbstrLog);
  170. HRESULT WINAPI BrowseForFolder(BSTR bstrStartFolder,
  171. LONG flag,
  172. BSTR* pbstrFolder);
  173. HRESULT WINAPI RebootMachine();
  174. private:
  175. void WINAPI ShutdownInstanceThreads(); // called in dtor to shut down any outstanding threads
  176. public:
  177. LONG m_lThreadCounter;
  178. HANDLE m_evtNeedToQuit;
  179. BOOL m_fOfflineMode;
  180. COperationMgr m_OperationMgr;
  181. };
  182. //
  183. // CDM Internal Exports (called by IUCDM stub cdm.dll)
  184. //
  185. //
  186. // We use a separate Real(tm) global for CDM to hold an instance of the CEngUpdate class,
  187. // since it is never multiple instanced.
  188. //
  189. extern CEngUpdate* g_pCDMEngUpdate;
  190. VOID WINAPI InternalDetFilesDownloaded(
  191. IN HANDLE hConnection
  192. );
  193. BOOL InternalDownloadGetUpdatedFiles(
  194. IN PDOWNLOADINFOWIN98 pDownloadInfoWin98,
  195. IN OUT LPTSTR lpDownloadPath,
  196. IN UINT uSize
  197. );
  198. BOOL WINAPI InternalDownloadUpdatedFiles(
  199. IN HANDLE hConnection,
  200. IN HWND hwnd,
  201. IN PDOWNLOADINFO pDownloadInfo,
  202. OUT LPWSTR lpDownloadPath,
  203. IN UINT uSize,
  204. OUT PUINT puRequiredSize
  205. );
  206. BOOL WINAPI InternalFindMatchingDriver(
  207. IN HANDLE hConnection,
  208. IN PDOWNLOADINFO pDownloadInfo,
  209. OUT PWUDRIVERINFO pWuDriverInfo
  210. );
  211. VOID WINAPI InternalLogDriverNotFound(
  212. IN HANDLE hConnection,
  213. IN LPCWSTR lpDeviceInstanceID,
  214. IN DWORD dwFlags
  215. );
  216. int WINAPI InternalQueryDetectionFiles(
  217. IN HANDLE hConnection,
  218. IN void* pCallbackParam,
  219. IN PFN_QueryDetectionFilesCallback pCallback
  220. );
  221. void InternalSetGlobalOfflineFlag(
  222. IN BOOL fOfflineMode
  223. );
  224. //
  225. // GetSystemSpec functionality exported for use by CDM
  226. //
  227. class CXmlSystemSpec;
  228. HRESULT AddComputerSystemClass(CXmlSystemSpec& xmlSpec);
  229. HRESULT AddRegKeyClass(CXmlSystemSpec& xmlSpec);
  230. HRESULT AddPlatformClass(CXmlSystemSpec& xmlSpec, IU_PLATFORM_INFO iuPlatformInfo);
  231. HRESULT AddLocaleClass(CXmlSystemSpec& xmlSpec, BOOL fIsUser);
  232. HRESULT AddDevicesClass(CXmlSystemSpec& xmlSpec, IU_PLATFORM_INFO iuPlatformInfo, BOOL fIsSysSpecCall);
  233. //
  234. // Misc. functionality
  235. //
  236. extern LONG g_lDoOnceOnLoadGuard;
  237. void WINAPI DeleteExpiredDownloadFolders();
  238. HRESULT WINAPI CreateGlobalCDMEngUpdateInstance();
  239. HRESULT WINAPI DeleteGlobalCDMEngUpdateInstance();
  240. void WINAPI ShutdownThreads(); // called by UnlockEnginge -- maintains backwards CDM compatibility
  241. void WINAPI ShutdownGlobalThreads(); // called to shut down any outstanding global threads
  242. #endif // __IUENGINE_H_