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.

193 lines
4.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000
  6. //
  7. // File: wuaueng.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #pragma once
  11. #include <windows.h>
  12. #include <wchar.h>
  13. #include <tchar.h>
  14. #include <ole2.h>
  15. #include <setupapi.h>
  16. #include <wininet.h>
  17. #include <inseng.h>
  18. //#include <newtrust.h>
  19. #include <malloc.h>
  20. #include <stddef.h>
  21. //#include <atlconv.h>
  22. #include <wuaustate.h>
  23. #include "wuaulib.h"
  24. #include "AUSessions.h"
  25. #include <URLLogging.h>
  26. #define AUSCHEDINSTALLDAY_MIN 0
  27. #define AUSCHEDINSTALLDAY_MAX 7
  28. #define AUSCHEDINSTALLTIME_MIN 0
  29. #define AUSCHEDINSTALLTIME_MAX 23
  30. typedef struct tagWORKER_THREAD_INIT_DATA
  31. {
  32. UINT uFirstMsg;
  33. BOOL fWaitB4Detect;
  34. DWORD dwWaitB4Detect;
  35. } WORKER_THREAD_INIT_DATA;
  36. #define E_NOCONNECTION HRESULT_FROM_WIN32(ERROR_CONNECTION_UNAVAIL)
  37. HRESULT SelfUpdate(void);
  38. HRESULT CheckForUpdatedComponents(BOOL *pfInstalledWUAUENG);
  39. HRESULT InstallFromCIF(LPCTSTR pstrCifCab, LPCTSTR pstrDownloadDir, LPCTSTR pstrWhich);
  40. /////////////////////////////////////////////////////////
  41. // Status ping information
  42. /////////////////////////////////////////////////////////
  43. class PingStatus: public CUrlLog //group together status ping functions
  44. {
  45. public:
  46. inline PingStatus(void):CUrlLog(_T("au"), NULL, NULL){}
  47. void ReadLiveServerUrlFromIdent(void);
  48. void PingDetectionSuccess(
  49. BOOL fOnline,
  50. UINT cItems);
  51. void PingDetectionFailure(
  52. BOOL fOnline,
  53. DWORD dwError,
  54. LPCTSTR ptszMessage = NULL);
  55. void PingDownload(
  56. BOOL fOnline,
  57. URLLOGSTATUS status,
  58. DWORD dwError,
  59. LPCTSTR ptszItemID = NULL,
  60. LPCTSTR ptszDeviceID = NULL,
  61. LPCTSTR ptszMessage = NULL);
  62. void PingSelfUpdate(
  63. BOOL fOnline,
  64. URLLOGSTATUS status,
  65. DWORD dwError);
  66. void PingDeclinedItem(
  67. BOOL fOnline,
  68. URLLOGACTIVITY activity,
  69. LPCTSTR ptszItemID);
  70. private:
  71. //----------------------------------------------------------------------
  72. //
  73. // private function to gather common info and perform ping
  74. //
  75. //----------------------------------------------------------------------
  76. void _Ping(
  77. BOOL fOnline,
  78. URLLOGACTIVITY activity,
  79. URLLOGSTATUS status,
  80. DWORD dwError,
  81. LPCTSTR ptszMessage,
  82. LPCTSTR ptszItemID,
  83. LPCTSTR ptszDeviceID);
  84. };
  85. #define IDOWNLOAD_COMPLETE_EVT 0
  86. #define IDOWNLOAD_TRANSIENT_ERROR_EVT 1
  87. #define IDOWNLOAD_DOWNLOAD_IN_PROGRESS 2
  88. #define IDOWNLOAD_SERVICE_FINISH 3
  89. #define IDOWNLOAD_SERVICE_DISABLED 4
  90. #define IDOWNLOAD_DOWNLOAD_CANCELED 5
  91. #define IDOWNLOAD_MESSAGE 6
  92. #define CNUM_DOWNLOAD_EVT 6
  93. extern HANDLE ghServiceFinished;
  94. extern HANDLE ghEngineState;
  95. extern HANDLE ghServiceDisabled;
  96. extern HANDLE ghValidateCatalog;
  97. extern HANDLE ghNotifyClient;
  98. extern HANDLE ghWorkerThreadMsgQueueCreation;
  99. extern CLIENT_NOTIFY_DATA gClientNotifyData;
  100. extern DWORD gdwWorkerThreadId;
  101. extern SESSION_STATUS gAdminSessions;
  102. extern PingStatus gPingStatus;
  103. typedef struct _ENGINE_EVENTS
  104. {
  105. public:
  106. void CloseEvents(void)
  107. {
  108. //Don't close the ServiceFinish handle and EngineState events
  109. m_grEvents[IDOWNLOAD_SERVICE_FINISH] = NULL;
  110. m_grEvents[IDOWNLOAD_SERVICE_DISABLED] = NULL;
  111. for ( int i = 0; i < CNUM_DOWNLOAD_EVT; i++)
  112. {
  113. SafeCloseHandleNULL(m_grEvents[i]);
  114. }
  115. }
  116. BOOL CreateEvents(void)
  117. {
  118. BOOL fRet = TRUE;
  119. ZeroMemory(m_grEvents, sizeof(m_grEvents));
  120. m_grEvents[IDOWNLOAD_SERVICE_FINISH] = ghServiceFinished;
  121. m_grEvents[IDOWNLOAD_SERVICE_DISABLED] = ghServiceDisabled;
  122. for ( int i = 0; i < CNUM_DOWNLOAD_EVT; i++)
  123. {
  124. if ( IDOWNLOAD_SERVICE_FINISH != i && IDOWNLOAD_SERVICE_DISABLED != i )
  125. {
  126. if ( NULL == (m_grEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL)) )
  127. {
  128. CloseEvents();
  129. fRet = FALSE;
  130. break;
  131. }
  132. }
  133. }
  134. return fRet;
  135. }
  136. void SetEvent(ULONG iEvent)
  137. {
  138. if ( (iEvent < CNUM_DOWNLOAD_EVT) && (NULL != m_grEvents[iEvent]) )
  139. {
  140. ::SetEvent(m_grEvents[iEvent]);
  141. }
  142. }
  143. ULONG cEvents(void)
  144. {
  145. return CNUM_DOWNLOAD_EVT;
  146. }
  147. CONST HANDLE * grEventHandles(void)
  148. {
  149. return m_grEvents;
  150. }
  151. private:
  152. HANDLE m_grEvents[CNUM_DOWNLOAD_EVT];
  153. } ENGINE_EVENTS;
  154. //defined in wuaueng.cpp
  155. HRESULT HrCreateNewCatalog(void);
  156. void CancelDownload(void);
  157. void ResumeDownloadIfNeccesary(void);
  158. HRESULT UpdateProc(WORKER_THREAD_INIT_DATA &initData);
  159. DWORD RandomWaitTimeBeforeDetect();
  160. //defined in service.cpp
  161. BOOL FDownloadIsPaused();