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.

359 lines
10 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. #define MIPS_ENVIRONMENT _T("Windows NT R4000")
  54. #define ALPHA_ENVIRONMENT _T("Windows NT Alpha_AXP")
  55. #define PPC_ENVIRONMENT _T("Windows NT PowerPC")
  56. #define WIN95_ENVIRONMENT _T("Windows 4.0")
  57. enum EPrintUpgConstants
  58. {
  59. kReplacementDriver = 1,
  60. kWarnLevelWks = 2,
  61. kWarnLevelSrv = 3,
  62. kFileTime = 4,
  63. };
  64. enum EPrintUpgLevels
  65. {
  66. kBlocked = 1,
  67. kWarned = 2,
  68. };
  69. extern "C"
  70. {
  71. extern TCHAR cszUpgradeInf[];
  72. extern TCHAR cszPrintDriverMapping[];
  73. extern TCHAR cszVersion[];
  74. extern TCHAR cszExcludeSection[];
  75. BOOL
  76. StringToDate(
  77. IN LPTSTR pszDate,
  78. OUT SYSTEMTIME *pInfTime
  79. );
  80. }
  81. HRESULT
  82. GetFileTimeByName(
  83. IN LPCTSTR pszPath,
  84. OUT FILETIME *pFileTime
  85. );
  86. HRESULT
  87. IsDriverBadLocally(
  88. IN LPCTSTR pszServer, OPTIONAL
  89. IN DRIVER_INFO_6 *pDriverInfo6,
  90. IN BOOL bIsDriverPathFullPath,
  91. OUT DWORD *pdwBlockingStatus,
  92. OUT LPTSTR *ppszReplacementDriver
  93. );
  94. HRESULT
  95. InternalPrintUpgUI(
  96. IN LPCTSTR pszDriverModel,
  97. IN LPCTSTR pszDriverPath, // main rendering driver dll
  98. IN LPCTSTR pszEnvironment,
  99. IN DWORD dwVersion,
  100. IN OUT DWORD *pdwBlockingStatus
  101. );
  102. HRESULT
  103. GetPrinterDriverPath(
  104. IN LPCTSTR pszServer, OPTIONAL
  105. IN LPCTSTR pszDriverPath,
  106. IN LPCTSTR pszEnvionment,
  107. IN BOOL bIsDriverPathFullPath,
  108. OUT TString *pstrFullPath
  109. );
  110. HRESULT
  111. GetPrinterDriverVersion(
  112. IN LPCTSTR pszFileName,
  113. OUT DWORD *pdwFileMajorVersion, OPTIONAL
  114. OUT DWORD *pdwFileMinorVersion OPTIONAL
  115. );
  116. HRESULT
  117. GetDriverVersionFromFileVersion(
  118. IN VS_FIXEDFILEINFO *pFileVersion,
  119. OUT DWORD *pdwFileMajorVersion, OPTIONAL
  120. OUT DWORD *pdwFileMinorVersion OPTIONAL
  121. );
  122. HRESULT
  123. IsDateInLineNoOlderThanDriverDate(
  124. IN INFCONTEXT *pInfContext,
  125. IN FILETIME *pDriverFileTime,
  126. OUT UINT *puWarnLevelSrv,
  127. OUT UINT *puWarnLevelWks,
  128. OUT TString *pstrReplacementDriver
  129. );
  130. HRESULT
  131. PrintUpgRetry(
  132. IN LPCTSTR pszServer, OPTIONAL
  133. IN DWORD dwLevel,
  134. IN DRIVER_INFO_6 *pDriverInfo6,
  135. IN DWORD dwAddDrvFlags,
  136. IN BOOL bIsDriverPathFullPath,
  137. IN BOOL bOfferReplacement,
  138. IN OUT DWORD *pdwBlockingStatus,
  139. OUT LPTSTR *ppszReplacementDriver
  140. );
  141. HRESULT
  142. PrintUpgUI(
  143. IN LPCTSTR pszServer, OPTIONAL
  144. IN DRIVER_INFO_6 *pDriverInfo6,
  145. IN BOOL bIsDriverPathFullPath,
  146. IN BOOL bOfferReplacement,
  147. IN OUT DWORD *pdwBlockingStatus,
  148. OUT LPTSTR *ppszReplacementDriver
  149. );
  150. HRESULT
  151. InternalCompatibleDriverCheck(
  152. IN LPCTSTR pszDriverModel,
  153. IN LPCTSTR pszDriverPath,
  154. IN LPCTSTR pszEnvironment,
  155. IN FILETIME *pFileTimeDriver,
  156. IN LPCTSTR pszPrintUpgInf,
  157. IN UINT uVersion,
  158. IN BOOL bIsServer,
  159. OUT UINT *puBlockingStatus,
  160. OUT TString *pstrReplacementDriver
  161. );
  162. HRESULT
  163. InternalCompatibleInfDriverCheck(
  164. IN LPCTSTR pszModelName,
  165. IN LPCTSTR pszDriverPath,
  166. IN LPCTSTR pszEnvironment,
  167. IN FILETIME *pFileTimeDriver,
  168. IN HINF hPrintUpgInf,
  169. IN UINT uVersion,
  170. IN BOOL bIsServer,
  171. OUT UINT *puBlockingStatus,
  172. OUT TString *pstrReplacementDriver
  173. );
  174. HRESULT
  175. IsDriverInMappingSection(
  176. IN LPCTSTR pszModelName,
  177. IN LPCTSTR pszEnvironment,
  178. IN UINT uVersion,
  179. IN HINF hPrintUpgInf,
  180. IN FILETIME *pFileTimeDriver,
  181. OUT UINT *puWarnLevelSrv,
  182. OUT UINT *puWarnLevelWks,
  183. OUT TString *pstrReplacementDriver
  184. );
  185. HRESULT
  186. GetSectionName(
  187. IN LPCTSTR pszEnviornment,
  188. IN UINT uVersion,
  189. OUT TString *pstrSection
  190. );
  191. HRESULT
  192. InfGetString(
  193. IN INFCONTEXT *pInfContext,
  194. IN UINT uFieldIndex,
  195. OUT TString *pstrReplacementDriver
  196. );
  197. HRESULT
  198. InfGetStringAsFileTime(
  199. IN INFCONTEXT *pInfContext,
  200. IN UINT uFieldIndex,
  201. OUT FILETIME *pFileTime
  202. );
  203. HRESULT
  204. StringTimeToFileTime(
  205. IN LPCTSTR pszFileTime,
  206. OUT FILETIME *pFileTime
  207. );
  208. HRESULT
  209. GetBlockingStatusByWksType(
  210. IN UINT uWarnLevelSrv,
  211. IN UINT uWarnLevelWks,
  212. IN BOOL bIsServer,
  213. OUT UINT *puBlockingStatus
  214. );
  215. HRESULT
  216. IsPrintUpgCheckNeeded(
  217. IN LPCTSTR pszServer, OPTIONAL
  218. IN LPCTSTR pszEnvironment,
  219. IN UINT uVersion,
  220. OUT BOOL *pbIsServer
  221. );
  222. HRESULT
  223. IsLocalMachineServer(
  224. VOID
  225. );
  226. HRESULT
  227. IsDriverDllInExcludedSection(
  228. IN LPCTSTR pszDriverPath,
  229. IN HINF hPrintUpgInf
  230. );
  231. HRESULT
  232. IsEnvironmentAndVersionNeededToCheck(
  233. IN LPCTSTR pszEnvironment,
  234. IN UINT uVersion
  235. );
  236. HRESULT
  237. GetCurrentThreadLastPopup(
  238. OUT HWND *phwnd
  239. );
  240. #if DBG_PRINTUPG
  241. extern TCHAR cszPrintUpgInf[];
  242. struct PrintUpgTest
  243. {
  244. LPCTSTR pszDriverModel;
  245. LPCTSTR pszDriverPath;
  246. LPCTSTR pszEnvironment;
  247. LPCTSTR pszDriverTime;
  248. UINT uVersion;
  249. BOOL bIsServer;
  250. UINT uBlockingStatus;
  251. LPCTSTR pszReplacementDriver;
  252. BOOL bSuccess;
  253. };
  254. HRESULT
  255. TestPrintUpgOne(
  256. IN LPCTSTR pszDriverModel,
  257. IN LPCTSTR pszDriverPath,
  258. IN LPCTSTR pszEnviornment,
  259. IN LPCTSTR pszFileTimeDriver,
  260. IN LPCTSTR pszPrintUpgInf,
  261. IN UINT uVersion,
  262. IN BOOL bIsServer,
  263. IN UINT uBlockingStatus,
  264. IN LPCTSTR pszReplacementDriver,
  265. IN BOOL bSuccess
  266. );
  267. HRESULT
  268. TestPrintUpgAll(
  269. VOID
  270. );
  271. BOOL
  272. StringToDate(
  273. LPTSTR pszDate,
  274. SYSTEMTIME *pInfTime
  275. );
  276. VOID
  277. LocalFreeMem(
  278. IN VOID *p
  279. );
  280. LPTSTR
  281. FileNamePart(
  282. IN LPCTSTR pszFullName
  283. );
  284. LPTSTR
  285. AllocStr(
  286. IN LPCTSTR pszStr
  287. );
  288. #ifdef UNICODE
  289. #define lstrchr wcschr
  290. #define lstrncmp wcsncmp
  291. #define lstrncmpi _wcsnicmp
  292. #else
  293. #define lstrchr strchr
  294. #define lstrtok strtok
  295. #define lstrncmp strncmp
  296. #define lstrncmpi _strnicmp
  297. #endif
  298. #else // DBG_PRINTUPG
  299. #define DBG_MSG(uDbgLevel, argsPrint ) // remove all DBG_MSG
  300. #endif // DBG_PRINTUPG
  301. #endif // PRINTUG_HXX