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.

184 lines
6.0 KiB

  1. #include <windows.h>
  2. #include <setupapi.h>
  3. #include <shlwapi.h>
  4. #include <devguid.h>
  5. #include <regstr.h>
  6. #include <stdio.h>
  7. #include <lmcons.h>
  8. #include <wininet.h>
  9. #include <fdi.h>
  10. #include <wuv3.h>
  11. #include <varray.h>
  12. #include <v3stdlib.h>
  13. #include <filecrc.h>
  14. #include <newtrust.h>
  15. #include "log.h"
  16. #include "v3server.h"
  17. #include "dynamic.h"
  18. #include "MultiSZArray.h"
  19. #define DU_STATUS_SUCCESS 1
  20. #define DU_STATUS_ABORT 2
  21. #define DU_STATUS_FAILED 3
  22. #define WM_DYNAMIC_UPDATE_COMPLETE WM_APP + 1000 + 1000
  23. // (WPARAM) Completion Status (SUCCESS, ABORTED, FAILED) : (LPARAM) (DWORD) Error Code if Status Failed
  24. #define WM_DYNAMIC_UPDATE_PROGRESS WM_APP + 1000 + 1001
  25. // (WPARAM) (DWORD) TotalDownloadSize : (LPARAM) (DWORD) BytesDownloaded
  26. #define DU_CONNECTION_RETRY 2
  27. // REMOVE THIS when checked into Whistler Tree .. Personal Should be Defined.
  28. #ifndef VER_SUITE_PERSONAL
  29. #define VER_SUITE_PERSONAL 0x00000200
  30. #endif
  31. // RogerJ --- the next part of this header file contains information for avoid autodisconnection
  32. //
  33. #define WM_DIALMON_FIRST WM_USER+100
  34. #define WM_WINSOCK_ACTIVITY WM_DIALMON_FIRST + 0
  35. static const char c_szDialmonClass[] = "MS_WebcheckMonitor";
  36. // DONE
  37. #define DU_PINGBACK_DOWNLOADSTATUS 0
  38. #define DU_PINGBACK_DRIVERNOTFOUND 1
  39. #define DU_PINGBACK_SETUPDETECTIONFAILED 2
  40. #define DU_PINGBACK_DRIVERDETECTIONFAILED 3
  41. #define sizeOfArray(a) (sizeof(a) / sizeof(a[0]))
  42. #define SafeGlobalFree(x) if (NULL != x) { GlobalFree(x); x = NULL; }
  43. #define SafeInternetCloseHandle(x) if (NULL != x) { InternetCloseHandle(x); x = NULL; }
  44. #define SafeCloseHandle(x) if (INVALID_HANDLE_VALUE != x) { CloseHandle(x); x = INVALID_HANDLE_VALUE; }
  45. void WINAPI SetEstimatedDownloadSpeed(DWORD dwBytesPerSecond);
  46. HANDLE WINAPI DuInitializeA(IN LPCSTR pszBasePath, IN LPCSTR pszTempPath, IN POSVERSIONINFOEXA posviTargetOS,
  47. IN LPCSTR pszTargetArch, IN LCID lcidTargetLocale, IN BOOL fUnattend, IN BOOL fUpgrade,
  48. IN PWINNT32QUERY pfnWinnt32QueryCallback);
  49. BOOL WINAPI DuDoDetection(IN HANDLE hConnection, OUT PDWORD pdwEstimatedTime, OUT PDWORD pdwEstimatedSize);
  50. BOOL WINAPI DuBeginDownload(IN HANDLE hConnection, IN HWND hwndNotify);
  51. void WINAPI DuAbortDownload(IN HANDLE hConnection);
  52. void WINAPI DuUninitialize(IN HANDLE hConnection);
  53. // fdi.cpp
  54. BOOL fdi(char *cabinet_fullpath, char *directory);
  55. typedef struct DOWNLOADITEM
  56. {
  57. char mszFileList[2048]; // MultiSZ list of Cabs to Download
  58. DWORD dwTotalFileSize;
  59. DWORD dwBytesDownload;
  60. int iCurrentCab;
  61. int iNumberOfCabs;
  62. BOOL fComplete;
  63. PUID puid;
  64. DOWNLOADITEM *pNext;
  65. DOWNLOADITEM *pPrev;
  66. } DOWNLOADITEM;
  67. typedef struct DOWNLOADTHREADPROCINFO
  68. {
  69. char szLocalFile[MAX_PATH];
  70. BOOL fCheckTrust;
  71. BOOL fDecompress;
  72. HWND hwndNotify;
  73. HINTERNET hInternet;
  74. } DOWNLOADTHREADPROCINFO, *PDOWNLOADTHREADPROCINFO;
  75. class CDynamicUpdate
  76. {
  77. public:
  78. CDynamicUpdate(int iPlatformID, LCID lcidLocaleID, WORD wPlatformSKU, LPCSTR pszTempPath,
  79. LPCSTR pszDownloadPath, PWINNT32QUERY pfnWinnt32QueryCallback, POSVERSIONINFOEXA pVersionInfo);
  80. ~CDynamicUpdate();
  81. public:
  82. BOOL DoDriverDetection(void);
  83. BOOL IsHardwareIdHasDriversOnCD(LPCSTR pszHardwareIdList);
  84. BOOL DoWindowsUpdateDriverDetection(void);
  85. BOOL DoPrinterDriverDetection(void);
  86. DWORD DoSetupUpdateDetection(void);
  87. public:
  88. // Class Member Access Functions
  89. LPCSTR GetDuTempPath();
  90. LPCSTR GetDuDownloadPath();
  91. LPCSTR GetDuServerUrl();
  92. int GetTargetPlatformID();
  93. LCID GetTargetLocaleID();
  94. void SetCallbackHWND(HWND hwnd);
  95. void SetAbortDownload(BOOL fAbort);
  96. // Helper Functions
  97. LPSTR DuUrlCombine(LPSTR pszDest, LPCSTR pszBase, LPCSTR pszAdd);
  98. // Download Funcntions
  99. DWORD DownloadFilesAsync();
  100. DWORD DownloadFile(LPCSTR pszDownloadUrl, LPCSTR pszLocalFile, BOOL fDecompress, BOOL fCheckTrust);
  101. DWORD DownloadFileToMem(LPCSTR pszDownloadUrl, PBYTE *lpBuffer, DWORD *pdwAllocatedLength, BOOL fDecompress, LPSTR pszFileName, LPSTR pszDecompresedFileName);
  102. DWORD AsyncDownloadProc();
  103. DWORD PingBack(int iPingBackType, PUID puid, LPCSTR pszPnPID, BOOL fSucceeded);
  104. // Download Item Management Functions
  105. void AddDownloadItemToList(DOWNLOADITEM *pDownloadItem);
  106. void RemoveDownloadItemFromList(DOWNLOADITEM *pDownloadItem);
  107. void ClearDownloadItemList();
  108. void UpdateDownloadItemSize();
  109. void EnterDownloadListCriticalSection();
  110. void LeaveDownloadListCriticalSection();
  111. BOOL NeedRetry(DWORD dwErrCode);
  112. // Language Fix Up Helpers (BUG: 435184) Need to map Some Languages from XP LCID's to V3 LCID's.
  113. void FixUpV3LocaleID();
  114. // Download Helper Functions
  115. DWORD OpenHttpConnection(LPCSTR pszDownloadUrl, BOOL fGetRequest);
  116. BOOL IsServerFileNewer(FILETIME ft, DWORD dwServerFileSize, LPCSTR pszLocalFile);
  117. public:
  118. CV31Server *m_pV3;
  119. int m_iPlatformID;
  120. LCID m_lcidLocaleID;
  121. WORD m_wPlatformSKU;
  122. char m_szTempPath[MAX_PATH];
  123. char m_szDownloadPath[MAX_PATH];
  124. char m_szServerUrl[INTERNET_MAX_URL_LENGTH + 1];
  125. // This is the core list of files that we will download. It contains all the setup
  126. // update items, and all the drivers that are going to be downloaded.
  127. DOWNLOADITEM *m_pDownloadItemList;
  128. DWORD m_dwCurrentBytesDownloaded;
  129. DWORD m_dwDownloadItemCount;
  130. DWORD m_dwTotalDownloadSize;
  131. DWORD m_dwDownloadSpeedInBytesPerSecond;
  132. HWND m_hwndClientNotify;
  133. DWORD m_dwLastPercentComplete;
  134. BOOL m_fAbortDownload;
  135. CRITICAL_SECTION m_cs;
  136. CRITICAL_SECTION m_csDownload;
  137. OSVERSIONINFOEX m_VersionInfo;
  138. // RogerJ, this is the multi-sz array used for driver detection
  139. CMultiSZArray m_arrayHardwareId;
  140. // Download Connection Handles
  141. HINTERNET m_hInternet;
  142. HINTERNET m_hConnect;
  143. HINTERNET m_hOpenRequest;
  144. char m_szCurrentConnectedServer[INTERNET_MAX_URL_LENGTH];
  145. // RogerJ October 5th, 2000
  146. // call back function pointer
  147. PWINNT32QUERY m_pfnWinNT32Query;
  148. HANDLE m_hDownloadThreadProc;
  149. };