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.

341 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. printupg.hxx
  6. Abstract:
  7. The basic design is:
  8. 1. All decisions about blocking take place on the server with its
  9. printupg.inf. This means that you get the same behavior with respect to
  10. being blocked/warned as if you were on the machine itself: NT4 ==
  11. nothing blocked. Win2K == only bad level 2 drivers blocked that is
  12. blocked. Whistler == blocked and warned and we will distinguish between
  13. different environments and versions correctly in printupg.inf.
  14. 2. If there is a replacement driver, it is selected by the client,
  15. after being informed by the server that is blocked/warned. OEM
  16. installers will get Block/Warn popups like what we have today; we will
  17. publish the flag to stop this UI appearing (with the implicit threat
  18. that if OEM try and subvert it and produce a buggy driver we will have
  19. no choice but to move them to Blocked - don't know about the legalities
  20. of this).
  21. 3. The call for AddPrinterDriver to install a bad/warned driver shall fail
  22. with Block/Warn even if the UI is suppressed.
  23. The code works as follows: the class installer calls AddPrinterDriver
  24. and at the printing service or server side, the spooler reads printupg and
  25. checks the driver against it for the status of blocking/warning with date,
  26. environment, and version information. If the driver is either blocked
  27. or warned, print service will fail the AddPrinterDriver call with last
  28. error code set to be either blocked or warned. The class installer checks
  29. the return code of AddPrinterDriver and finds the replacement, if any, for
  30. the blocked or warned drivers by reading the client side printup.inf. If a
  31. replacement for a warned or blocked driver is found, it pops up the
  32. three-button message box to offer the replacement. Otherwise for the
  33. blocked driver, it pops up the one button message box to abort the
  34. installation or the two-button message box to install the warned driver or
  35. abort the installation. The class installer calls AddPrinterDriver again
  36. to install the warned or replacement driver and when it is the users
  37. intention to install the warned driver, the class installer sets the
  38. APD_INSTALL_WARNED_DRIVER while calling AddPrinterDriver.
  39. In all cases, the class installer calls AddPrinterDriver with APD_NO_UI
  40. flag set. This way spooler client stub (winspool) will just pass on the
  41. return code of AddPrinterDriver from the printing service to the class
  42. installer.
  43. Note on APD_XXX flags: these are new flags that shall be ignore by down
  44. level servers such win2k servers.
  45. Author:
  46. Larry Zhu (LZhu) 20-Feb-2001
  47. Revision History:
  48. --*/
  49. #ifndef PRINTUPG_HXX
  50. #define PRINTUG_HXX
  51. #define X86_ENVIRONMENT _T("Windows NT x86")
  52. #define IA64_ENVIRONMENT _T("Windows IA64")
  53. enum EPrintUpgConstants
  54. {
  55. kReplacementDriver = 1,
  56. kWarnLevelWks = 2,
  57. kWarnLevelSrv = 3,
  58. kFileTime = 4,
  59. };
  60. enum EPrintUpgLevels
  61. {
  62. kBlocked = 1,
  63. kWarned = 2,
  64. };
  65. extern "C"
  66. {
  67. extern TCHAR cszUpgradeInf[];
  68. extern TCHAR cszPrintDriverMapping[];
  69. extern TCHAR cszVersion[];
  70. extern TCHAR cszExcludeSection[];
  71. BOOL
  72. StringToDate(
  73. IN LPTSTR pszDate,
  74. OUT SYSTEMTIME *pInfTime
  75. );
  76. }
  77. HRESULT
  78. GetFileTimeByName(
  79. IN LPCTSTR pszPath,
  80. OUT FILETIME *pFileTime
  81. );
  82. HRESULT
  83. IsDriverBadLocally(
  84. IN LPCTSTR pszServer, OPTIONAL
  85. IN DRIVER_INFO_6 *pDriverInfo6,
  86. IN BOOL bIsDriverPathFullPath,
  87. OUT DWORD *pdwBlockingStatus,
  88. OUT LPTSTR *ppszReplacementDriver
  89. );
  90. HRESULT
  91. InternalPrintUpgUI(
  92. IN LPCTSTR pszDriverModel,
  93. IN LPCTSTR pszDriverPath, // main rendering driver dll
  94. IN LPCTSTR pszEnvironment,
  95. IN DWORD dwVersion,
  96. IN OUT DWORD *pdwBlockingStatus
  97. );
  98. HRESULT
  99. GetPrinterDriverPath(
  100. IN LPCTSTR pszServer, OPTIONAL
  101. IN LPCTSTR pszDriverPath,
  102. IN LPCTSTR pszEnvionment,
  103. IN BOOL bIsDriverPathFullPath,
  104. OUT TString *pstrFullPath
  105. );
  106. HRESULT
  107. GetPrinterDriverVersion(
  108. IN LPCTSTR pszFileName,
  109. OUT DWORD *pdwFileMajorVersion, OPTIONAL
  110. OUT DWORD *pdwFileMinorVersion OPTIONAL
  111. );
  112. HRESULT
  113. GetDriverVersionFromFileVersion(
  114. IN VS_FIXEDFILEINFO *pFileVersion,
  115. OUT DWORD *pdwFileMajorVersion, OPTIONAL
  116. OUT DWORD *pdwFileMinorVersion OPTIONAL
  117. );
  118. HRESULT
  119. IsDateInLineNoOlderThanDriverDate(
  120. IN INFCONTEXT *pInfContext,
  121. IN FILETIME *pDriverFileTime,
  122. OUT UINT *puWarnLevelSrv,
  123. OUT UINT *puWarnLevelWks,
  124. OUT TString *pstrReplacementDriver
  125. );
  126. HRESULT
  127. PrintUpgRetry(
  128. IN LPCTSTR pszServer, OPTIONAL
  129. IN DWORD dwLevel,
  130. IN DRIVER_INFO_6 *pDriverInfo6,
  131. IN DWORD dwAddDrvFlags,
  132. IN BOOL bIsDriverPathFullPath,
  133. IN BOOL bOfferReplacement,
  134. IN OUT DWORD *pdwBlockingStatus,
  135. OUT LPTSTR *ppszReplacementDriver
  136. );
  137. HRESULT
  138. PrintUpgUI(
  139. IN LPCTSTR pszServer, OPTIONAL
  140. IN DRIVER_INFO_6 *pDriverInfo6,
  141. IN BOOL bIsDriverPathFullPath,
  142. IN BOOL bOfferReplacement,
  143. IN OUT DWORD *pdwBlockingStatus,
  144. OUT LPTSTR *ppszReplacementDriver
  145. );
  146. HRESULT
  147. InternalCompatibleDriverCheck(
  148. IN LPCTSTR pszDriverModel,
  149. IN LPCTSTR pszDriverPath,
  150. IN LPCTSTR pszEnvironment,
  151. IN FILETIME *pFileTimeDriver,
  152. IN LPCTSTR pszPrintUpgInf,
  153. IN UINT uVersion,
  154. IN BOOL bIsServer,
  155. OUT UINT *puBlockingStatus,
  156. OUT TString *pstrReplacementDriver
  157. );
  158. HRESULT
  159. InternalCompatibleInfDriverCheck(
  160. IN LPCTSTR pszModelName,
  161. IN LPCTSTR pszDriverPath,
  162. IN LPCTSTR pszEnvironment,
  163. IN FILETIME *pFileTimeDriver,
  164. IN HINF hPrintUpgInf,
  165. IN UINT uVersion,
  166. IN BOOL bIsServer,
  167. OUT UINT *puBlockingStatus,
  168. OUT TString *pstrReplacementDriver
  169. );
  170. HRESULT
  171. IsDriverInMappingSection(
  172. IN LPCTSTR pszModelName,
  173. IN LPCTSTR pszEnvironment,
  174. IN UINT uVersion,
  175. IN HINF hPrintUpgInf,
  176. IN FILETIME *pFileTimeDriver,
  177. OUT UINT *puWarnLevelSrv,
  178. OUT UINT *puWarnLevelWks,
  179. OUT TString *pstrReplacementDriver
  180. );
  181. HRESULT
  182. GetSectionName(
  183. IN LPCTSTR pszEnviornment,
  184. IN UINT uVersion,
  185. OUT TString *pstrSection
  186. );
  187. HRESULT
  188. InfGetString(
  189. IN INFCONTEXT *pInfContext,
  190. IN UINT uFieldIndex,
  191. OUT TString *pstrReplacementDriver
  192. );
  193. HRESULT
  194. InfGetStringAsFileTime(
  195. IN INFCONTEXT *pInfContext,
  196. IN UINT uFieldIndex,
  197. OUT FILETIME *pFileTime
  198. );
  199. HRESULT
  200. StringTimeToFileTime(
  201. IN LPCTSTR pszFileTime,
  202. OUT FILETIME *pFileTime
  203. );
  204. HRESULT
  205. GetBlockingStatusByWksType(
  206. IN UINT uWarnLevelSrv,
  207. IN UINT uWarnLevelWks,
  208. IN BOOL bIsServer,
  209. OUT UINT *puBlockingStatus
  210. );
  211. HRESULT
  212. IsLocalMachineServer(
  213. VOID
  214. );
  215. HRESULT
  216. IsDriverDllInExcludedSection(
  217. IN LPCTSTR pszDriverPath,
  218. IN HINF hPrintUpgInf
  219. );
  220. HRESULT
  221. GetCurrentThreadLastPopup(
  222. OUT HWND *phwnd
  223. );
  224. #if DBG_PRINTUPG
  225. extern TCHAR cszPrintUpgInf[];
  226. struct PrintUpgTest
  227. {
  228. LPCTSTR pszDriverModel;
  229. LPCTSTR pszDriverPath;
  230. LPCTSTR pszEnvironment;
  231. LPCTSTR pszDriverTime;
  232. UINT uVersion;
  233. BOOL bIsServer;
  234. UINT uBlockingStatus;
  235. LPCTSTR pszReplacementDriver;
  236. BOOL bSuccess;
  237. };
  238. HRESULT
  239. TestPrintUpgOne(
  240. IN LPCTSTR pszDriverModel,
  241. IN LPCTSTR pszDriverPath,
  242. IN LPCTSTR pszEnviornment,
  243. IN LPCTSTR pszFileTimeDriver,
  244. IN LPCTSTR pszPrintUpgInf,
  245. IN UINT uVersion,
  246. IN BOOL bIsServer,
  247. IN UINT uBlockingStatus,
  248. IN LPCTSTR pszReplacementDriver,
  249. IN BOOL bSuccess
  250. );
  251. HRESULT
  252. TestPrintUpgAll(
  253. VOID
  254. );
  255. BOOL
  256. StringToDate(
  257. LPTSTR pszDate,
  258. SYSTEMTIME *pInfTime
  259. );
  260. VOID
  261. LocalFreeMem(
  262. IN VOID *p
  263. );
  264. LPTSTR
  265. FileNamePart(
  266. IN LPCTSTR pszFullName
  267. );
  268. LPTSTR
  269. AllocStr(
  270. IN LPCTSTR pszStr
  271. );
  272. #ifdef UNICODE
  273. #define lstrchr wcschr
  274. #define lstrncmp wcsncmp
  275. #define lstrncmpi _wcsnicmp
  276. #else
  277. #define lstrchr strchr
  278. #define lstrtok strtok
  279. #define lstrncmp strncmp
  280. #define lstrncmpi _strnicmp
  281. #endif
  282. #else // DBG_PRINTUPG
  283. #define DBG_MSG(uDbgLevel, argsPrint ) // remove all DBG_MSG
  284. #endif // DBG_PRINTUPG
  285. #endif // PRINTUG_HXX