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.

148 lines
5.4 KiB

  1. #ifndef _PATCHDOWNLOAD
  2. #define _PATCHDOWNLOAD
  3. #include "advpext.h"
  4. #include "download.h"
  5. #define WM_FILEAVAILABLE WM_USER + 1
  6. #define PATCHFLAG_DOWNLOAD_NEEDED 0x00000001
  7. typedef struct {
  8. WORD wOSVer;
  9. WORD wQuietMode;
  10. BOOL bUpdHlpDlls;
  11. HINSTANCE hSetupLibrary;
  12. BOOL fOSSupportsINFInstalls;
  13. LPSTR lpszTitle;
  14. HWND hWnd;
  15. DWORD dwSetupEngine;
  16. BOOL bCompressed;
  17. char szBrowsePath[MAX_PATH];
  18. HINF hInf;
  19. BOOL bHiveLoaded;
  20. CHAR szRegHiveKey[MAX_PATH];
  21. } ADVCONTEXT, *PADVCONTEXT;
  22. HRESULT ProcessFileSection(ADVCONTEXT ctx, LPCSTR lpszSrcDir);
  23. typedef struct _FILE_LIST_INFO
  24. {
  25. PDOWNLOAD_FILEINFO FileList; //original file list
  26. DWORD FileCount;
  27. PATCH_DOWNLOAD_CALLBACK Callback;
  28. PVOID CallbackContext;
  29. }FILE_LIST_INFO, *PFILE_LIST_INFO;
  30. typedef struct _PATCH_THREAD_INFO
  31. {
  32. //PATCH_QUEUE PatchQueue;
  33. FILE_LIST_INFO FileListInfo; //original file list
  34. DOWNLOAD_INFO* lpdwnProgressInfo;
  35. HANDLE hFileDownloadEvent;
  36. }PATCH_THREAD_INFO, *PPATCH_THREAD_INFO;
  37. typedef struct _FILE
  38. {
  39. LPTSTR lpszFileName;
  40. DWORD dwFileSize;
  41. } FILE, *LPFILE;
  42. class CPatchDownloader : public CDownloader
  43. {
  44. DOWNLOAD_FILEINFO* m_lpFileInfo;
  45. PATCH_DOWNLOAD_CALLBACK m_lpfnCallback;
  46. LPTSTR m_lpszRequestBuffer;
  47. LPTSTR m_lpszSiteName;
  48. TCHAR m_lpszDownLoadDir[MAX_PATH];
  49. DWORD m_dwFileCount;
  50. DWORD m_dwServerFileCount;
  51. DWORD m_dwRequestDataLength;
  52. DWORD m_dwCurrentFileSize;
  53. DWORD m_dwCurrFileSizeRemaining;
  54. DWORD m_dwCurrentFileIndex;
  55. DWORD m_dwPatchThreadId;
  56. HANDLE m_hCurrentFileHandle;
  57. HANDLE m_hSubAllocator;
  58. LPFILE m_lpFileList;
  59. LPVOID m_lpvContext;
  60. DOWNLOAD_INFO m_DownloadInfo;
  61. HRESULT CreateRequestBuffer(DWORD);
  62. BOOL ProcessDownloadChunk(LPTSTR lpBuffer, DWORD dwLength);
  63. public:
  64. CPatchDownloader(DOWNLOAD_FILEINFO* pdwn, DWORD dwFileCount, PATCH_DOWNLOAD_CALLBACK lpfn);
  65. ~CPatchDownloader();
  66. STDMETHOD(GetBindInfo)(/* [out] */ DWORD *grfBINDINFOF, /* [unique][out][in] */ BINDINFO *pbindinfo);
  67. STDMETHOD(OnProgress)(
  68. /* [in] */ ULONG ulProgress,
  69. /* [in] */ ULONG ulProgressMax,
  70. /* [in] */ ULONG ulStatusCode,
  71. /* [in] */ LPCWSTR szStatusText);
  72. STDMETHOD(OnDataAvailable)(
  73. /* [in] */ DWORD grfBSCF,
  74. /* [in] */ DWORD dwSize,
  75. /* [in] */ FORMATETC *pformatetc,
  76. /* [in] */ STGMEDIUM *pstgmed);
  77. HRESULT InternalDownloadAndPatchFiles(LPCTSTR lpszPath, CSiteMgr*, LPVOID lpvContext);
  78. };
  79. DWORD WINAPI PatchThread(IN LPVOID ThreadParam);
  80. BOOL ProtectedPatchDownloadCallback(PATCH_DOWNLOAD_CALLBACK Callback, IN PATCH_DOWNLOAD_REASON CallbackReason,
  81. IN PVOID CallbackData, IN PVOID CallbackContext);
  82. void AddToFileList(LPCSTR lpszSrc, LPCSTR lpszTarget);
  83. UINT WINAPI MyFileQueueCallback( PVOID Context,UINT Notification,UINT_PTR parm1,UINT_PTR parm2 );
  84. void FreeFileList(PDOWNLOAD_FILEINFO pFileList);
  85. HRESULT CreateRequestBuffer(DOWNLOAD_FILEINFO*pFileInfo, DWORD dwFileCount, DWORD dwDownloadClientID,
  86. LPTSTR* lpRequestBuffer, LPDWORD);
  87. BOOL IsDownloadedNeeded(LPCTSTR lp, LPCTSTR lpszFileName);
  88. BOOL CALLBACK ProgressDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  89. BOOL SetProgressText(LPCTSTR lpszText);
  90. BOOL SetProgressText(UINT uID);
  91. BOOL VerifyHash(LPTSTR lpszFile);
  92. HRESULT LoadSetupAPIFuncs();
  93. HRESULT ApplyPatchesToLocalFiles(DOWNLOAD_FILEINFO* pFileList, DWORD dwFileCount);
  94. static const TCHAR c_szSetupDefaultQueueCallback[] = "SetupDefaultQueueCallbackA";
  95. static const TCHAR c_szSetupInstallFromInfSection[] = "SetupInstallFromInfSectionA";
  96. static const TCHAR c_szSetupInitDefaultQueueCallbackEx[] = "SetupInitDefaultQueueCallbackEx";
  97. static const TCHAR c_szSetupTermDefaultQueueCallback[] = "SetupTermDefaultQueueCallback";
  98. static const TCHAR c_szSetupGetLineText[] = "SetupGetLineTextA";
  99. static const TCHAR c_szSetupFindFirstLine[] = "SetupFindFirstLineA";
  100. static const TCHAR c_szSetupFindNextLine[] = "SetupFindNextLine";
  101. static const TCHAR c_szSetupGetStringField[] = "SetupGetStringFieldA";
  102. static const TCHAR c_szSetupDecompressOrCopyFile[] = "SetupDecompressOrCopyFileA";
  103. typedef UINT (WINAPI *PFSetupDefaultQueueCallback)( PVOID, UINT, UINT_PTR, UINT_PTR );
  104. typedef BOOL (WINAPI *PFSetupInstallFromInfSection)( HWND, HINF, PCSTR, UINT, HKEY, PCSTR, UINT, PSP_FILE_CALLBACK_A, PVOID, HDEVINFO, PSP_DEVINFO_DATA );
  105. typedef PVOID (WINAPI *PFSetupInitDefaultQueueCallbackEx)( HWND,HWND,UINT,DWORD,PVOID );
  106. typedef VOID (WINAPI *PFSetupTermDefaultQueueCallback)( PVOID );
  107. typedef BOOL (WINAPI *PFSetupFindFirstLine)( HINF, PCSTR, PCSTR, PINFCONTEXT );
  108. typedef BOOL (WINAPI *PFSetupGetLineText)( PINFCONTEXT, HINF, PCSTR, PCSTR, PSTR, DWORD, PDWORD );
  109. typedef BOOL (WINAPI *PFSetupFindNextLine)( PINFCONTEXT, PINFCONTEXT );
  110. typedef BOOL (WINAPI *PFSetupGetStringField)(PINFCONTEXT, DWORD, PSTR, DWORD, PDWORD);
  111. typedef DWORD (WINAPI *PFSetupDecompressOrCopyFile)(PCTSTR, PCTSTR, PUINT);
  112. #endif