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.

134 lines
4.6 KiB

  1. /*----------------------------------------------------------------------------
  2. download.h
  3. Download handling for Signup
  4. Copyright (C) 1995 Microsoft Corporation
  5. All rights reserved.
  6. Authors:
  7. ArulM
  8. --------------------------------------------------------------------------*/
  9. class MyBaseClass
  10. {
  11. public:
  12. void * operator new( size_t cb );
  13. void operator delete( void * p );
  14. };
  15. #include <wininet.h>
  16. #define InternetSessionCloseHandle(h) InternetCloseHandle(h)
  17. #define InternetRequestCloseHandle(h) InternetCloseHandle(h)
  18. #define InternetGetLastError(h) GetLastError()
  19. #define InternetCancel(h) InternetCloseHandle(h)
  20. extern HANDLE g_hDLLHeap; // private Win32 heap
  21. extern HINSTANCE g_hInst; // our DLL hInstance
  22. class CFileInfo //: public MyBaseClass
  23. {
  24. public:
  25. CFileInfo* m_pfiNext;
  26. LPSTR m_pszPath;
  27. BOOL m_fInline;
  28. CFileInfo(LPSTR psz, BOOL f) { m_pfiNext = NULL; m_pszPath = psz; m_fInline = f; }
  29. ~CFileInfo() { if(m_pszPath) MyFree(m_pszPath); }
  30. };
  31. class CDownLoad //: public MyBaseClass
  32. {
  33. CFileInfo* m_pfiHead;
  34. LPSTR m_pszURL;
  35. HINTERNET m_hSession;
  36. HINTERNET m_hRequest;
  37. DWORD m_dwContentLength;
  38. DWORD m_dwReadLength;
  39. LPSTR m_pszBoundary;
  40. DWORD m_dwBoundaryLen;
  41. LPSTR m_pszWindowsDir;
  42. LPSTR m_pszSystemDir;
  43. LPSTR m_pszTempDir;
  44. LPSTR m_pszICW98Dir;
  45. LPSTR m_pszSignupDir;
  46. DWORD m_dwWindowsDirLen;
  47. DWORD m_dwSystemDirLen;
  48. DWORD m_dwTempDirLen;
  49. DWORD m_dwSignupDirLen;
  50. DWORD m_dwICW98DirLen;
  51. INTERNET_STATUS_CALLBACK m_lpfnCB;
  52. INTERNET_STATUS_CALLBACK m_lpfnPreviousCB;
  53. void AddToFileList(CFileInfo* pfi);
  54. LPSTR FileToPath(LPSTR pszFile);
  55. HRESULT ProcessRequest(void);
  56. void ShowProgress(DWORD dwRead);
  57. DWORD FillBuffer(LPBYTE pbBuf, DWORD dwLen, DWORD dwRead);
  58. DWORD MoveAndFillBuffer(LPBYTE pbBuf, DWORD dwLen, DWORD dwValid, LPBYTE pbNewStart);
  59. #if defined(WIN16)
  60. HRESULT HandleDLFile(LPSTR pszFile, BOOL fInline, LPHFILE phFile);
  61. #else
  62. HRESULT HandleDLFile(LPSTR pszFile, BOOL fInline, LPHANDLE phFile);
  63. #endif
  64. HRESULT HandleURL(LPSTR pszPath);
  65. public:
  66. CDownLoad(LPSTR psz);
  67. ~CDownLoad(void);
  68. HRESULT Execute(void);
  69. HRESULT Process(void);
  70. HINTERNET GetSession(void) { return m_hRequest; }
  71. HANDLE m_hCancelSemaphore;
  72. DWORD_PTR m_lpCDialingDlg;
  73. HRESULT SetStatusCallback (INTERNET_STATUS_CALLBACK lpfnCB);
  74. void Cancel() { if(m_hRequest) InternetCancel(m_hRequest); }
  75. };
  76. #define USERAGENT_FMT "MSSignup/1.1 (%s; %d.%d; Lang=%04x\")"
  77. #define SIGNUP "signup"
  78. #define SIGNUP_LEN (sizeof(SIGNUP)-1)
  79. #define SYSTEM "system"
  80. #define SYSTEM_LEN (sizeof(SYSTEM)-1)
  81. #define WINDOWS "windows"
  82. #define WINDOWS_LEN (sizeof(WINDOWS)-1)
  83. #define TEMP "temp"
  84. #define TEMP_LEN (sizeof(TEMP)-1)
  85. #define ICW98DIR "icw98dir"
  86. #define ICW98DIR_LEN (sizeof(ICW98DIR)-1)
  87. #define MULTIPART_MIXED "multipart/mixed"
  88. #define MULTIPART_MIXED_LEN (sizeof(MULTIPART_MIXED)-1)
  89. #define CONTENT_DISPOSITION "content-disposition"
  90. #define CONTENT_DISPOSITION_LEN (sizeof(CONTENT_DISPOSITION)-1)
  91. #define BOUNDARY "boundary"
  92. #define BOUNDARY_LEN (sizeof(BOUNDARY)-1)
  93. #define FILENAME "filename"
  94. #define FILENAME_LEN (sizeof(FILENAME)-1)
  95. #define INLINE "inline"
  96. #define INLINE_LEN (sizeof(INLINE)-1)
  97. #define ATTACHMENT "attachment"
  98. #define ATTACHMENT_LEN (sizeof(ATTACHMENT)-1)
  99. #define DEFAULT_DATABUF_SIZE 4096
  100. #define SLOP 5
  101. #define OVERLAP_LEN 100
  102. #define DOUBLE_CRLF "\r\n\r\n"
  103. #define DOUBLE_CRLF_LEN (sizeof(DOUBLE_CRLF)-1)
  104. #define DIALOGBOXCLASS "#32770"
  105. #define REGEDIT_CMD "regedit /s "
  106. #define EXT_EXE "exe"
  107. #define EXT_REG "reg"
  108. #define EXT_INF "inf"
  109. #define EXT_CHG "chg"
  110. #define EXT_URL "url"
  111. // ICW Version 2.0 stuff. Ref Server can send cabbed files now,
  112. // this is the extension for it. We have a cab File Handler which
  113. // blasts open the cab and decompresses the files.
  114. #define EXT_CAB "cab"