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.

164 lines
6.1 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1998-2001 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: RedirectUtil.h
  6. // Author: Charles Ma, 9/19/2001
  7. //
  8. // Revision History:
  9. //
  10. //
  11. //
  12. // Description:
  13. //
  14. // Helper function(s) for handling server redirect
  15. // Can be shared by IU control and other Windows Update components
  16. //
  17. //=======================================================================
  18. #pragma once
  19. //-----------------------------------------------------------------------
  20. //
  21. // DownloadCab()
  22. // download a cab file of specific name from a base web address. The
  23. // file will be saved locally, with file trust verified and extracted to
  24. // a specific folder.
  25. //
  26. // Parameters:
  27. // hQuitEvent - the event handle to cancel this operation
  28. // ptszCabName - the file name of the cab file (eg. iuident.cab)
  29. // ptszBaseUrl - the base web address to download the cab file
  30. // ptszExtractDir - the local dir to save the cab file and those extracted from it
  31. // dwFlags - the set of flags to be passed to DownloadFileLite()
  32. // fExtractFiles (default as TRUE) - extract files
  33. //
  34. // Returns:
  35. // HRESULT about success or error of this action
  36. // S_OK - iuident.cab was successfully downloaded into the specified location
  37. // other - error code
  38. //
  39. //-----------------------------------------------------------------------
  40. HRESULT DownloadCab(
  41. HANDLE hQuitEvent,
  42. LPCTSTR ptszCabName,
  43. LPCTSTR ptszBaseUrl,
  44. LPCTSTR ptszExtractDir,
  45. DWORD dwFlags = 0,
  46. BOOL fExtractFiles = TRUE);
  47. //-----------------------------------------------------------------------
  48. //
  49. // DownloadIUIdent()
  50. // download iuident.cab from a specific location, if provided.
  51. // Otherwise get it from where the WUServer registry value points to.
  52. // Either case, it will handle ident redirection.
  53. //
  54. // Parameters:
  55. // hQuitEvent - the event handle to cancel this operation
  56. // ptszBaseUrl - the initial base URL for iuident.cab, must be no bigger than
  57. // (INTERNET_MAX_URL_LENGTH) TCHARs. Otherwise use
  58. // WUServer entry from policy. If entry not found,
  59. // use "http://windowsupdate.microsoft.com/v4"
  60. // ptszFileCacheDir - the local base path to store the iuident.cab and
  61. // the files extracted from it
  62. // dwFlags - the set of flags used by DownloadCab()
  63. //
  64. // fIdentFromPolicy - tell if this is corpwu use. It has these impacts:
  65. // TRUE: (1) no iuident.txt timestamp validation will be done by
  66. // comparing the newly downloaded cab and existing one.
  67. // (2) if download fail and ident cab exist and valid,
  68. // we will verify trust and extract iuident to use.
  69. // FALSE: will validate newly downloaded cab against existing one
  70. //
  71. // Returns:
  72. // HRESULT about success or error of this action
  73. // S_OK - iuident.cab was successfully downloaded into the specified location
  74. // other - error code
  75. //
  76. //-----------------------------------------------------------------------
  77. HRESULT DownloadIUIdent(
  78. HANDLE hQuitEvent,
  79. LPCTSTR ptszBaseUrl,
  80. LPTSTR ptszFileCacheDir,
  81. DWORD dwFlags = 0,
  82. BOOL fIdentFromPolicy = TRUE);
  83. //-----------------------------------------------------------------------
  84. //
  85. // GetRedirectServerUrl()
  86. // Search the [redirect] section of the given init file for the base
  87. // server URL corresponding to the OS version.
  88. //
  89. // Parameters:
  90. // pcszInitFile - file name (including path) of the ini file.
  91. // if this paramater is NULL or empty string,
  92. // then it's assumed IUident.txt file.
  93. // lpszNewUrl - point to a buffer to receive redirect server url, if found
  94. // nBufSize - size of pointed buffer, in number of chars
  95. //
  96. // Returns:
  97. // HRESULT about success or error of this action
  98. // S_OK - the redirect server url is found and been put into pszBuffer
  99. // S_FALSE - no redirect server url defined for this OS.
  100. // other - error code
  101. //
  102. // Comments:
  103. // Expected section in IUIDENT has the following format;
  104. // Section name: [redirect]
  105. // Its entries should be defined according to GetINIValueByOSVer().
  106. //
  107. //-----------------------------------------------------------------------
  108. HRESULT GetRedirectServerUrl(
  109. LPCTSTR pcszInitFile, // path of file name.
  110. LPTSTR lpszNewUrl, // points to a buffer to receive new server url
  111. int nBufSize // size of buffer, in chars
  112. );
  113. //-----------------------------------------------------------------------
  114. //
  115. // GetINIValueByOSVer()
  116. // Search the specified section of the given init file for
  117. // the value corresponding to the version of the OS.
  118. //
  119. // Parameters:
  120. // pcszInitFile - file name (including path) of the ini file.
  121. // if this paramater is NULL or empty string,
  122. // then it's assumed IUident.txt file.
  123. // pcszSection - section name which the key is under
  124. // lpszValue - point to a buffer to receive the entry value, if found
  125. // nBufSize - size of pointed buffer, in number of chars
  126. //
  127. // Returns:
  128. // HRESULT about success or error of this action
  129. // S_OK - the redirect server url is found and been put into pszBuffer
  130. // S_FALSE - no value defined for this OS.
  131. // other - error code
  132. //
  133. // Comments:
  134. // Expected section in IUIDENT has the following format;
  135. // this section contains zero or more entries, each entry has format:
  136. // <beginVersionRange>-<endVersionRange>=<redirect server url>
  137. // where:
  138. // <beginVersionRange> ::= <VersionRangeBound>
  139. // <endVersionRange> ::= <VersionRangeBound>
  140. // <VersionRangeBound> ::= EMPTY | Major[.Minor[.Build[.ServicePackMajor[.ServicePackMinor]]]]
  141. // <redirect server url>=http://blahblah....
  142. // an empty version range bound means boundless.
  143. // a missing version component at end of a version data string means default value 0.
  144. // (e.g., 5.2 = 5.2.0.0.0)
  145. //
  146. //-----------------------------------------------------------------------
  147. HRESULT GetINIValueByOSVer(
  148. LPCTSTR pcszInitFile, // path of file name.
  149. LPCTSTR pcszSection, // section name
  150. LPTSTR lpszValue, // points to a buffer to receive new server url
  151. int nBufSize); // size of buffer, in chars