150 likes | 295 Views
Best Practices for Developing Printer Drivers. Justin Hutchings Program Manager Microsoft Corporation. Shawn Maloney Program Manager Microsoft Corporation. Agenda. Setup & Installation INFs PnP ranking for printers Installers/Co-installers Device Physical Configuration
E N D
Best Practices for Developing Printer Drivers Justin Hutchings Program Manager Microsoft Corporation Shawn Maloney Program Manager Microsoft Corporation
Agenda • Setup & Installation • INFs • PnP ranking for printers • Installers/Co-installers • Device Physical Configuration • Performance Guidelines • Reliability Guidelines • Using Microsoft Core Components • Security Guidelines • Call To Action/Resources
Setup & Install – Multiple INFs • Managing driver packages with multiple driver INFs • Support for multifunction printers (MFPs) and core drivers • Create individual driver subdirectories • Use CopyINF command to preload drivers [MyMFPDevice.NTx86] CopyINF = \i386\ntprint.INF
Setup & Install - PnP Ranking for Printers • Never list the same hardware ID twice in a single model section • Never put hardware IDs for different devices on the same line • Compatible IDs for a printer (new in Windows 7) always go in the 2nd position • Hardware IDs on a line from most specific to least specific Device Name = Install_Section, HWID, CompatID “Fabrikam 6000” = InstallMe, USBPrint\Fabrikam6000, 1284_CID_FabrikamClass1
Setup & Install - Installers and Co-Installers • Avoid version checks in the installer • Use OS mechanisms for installing the driver • Do not circumvent OS security and stability mechanisms • Avoid hard dependencies between applications and drivers • The use of co-installers is discouraged. Never perform essential installation functions in a co-installer.
Device Physical Configuration • MFPs should enumerate all device functions (print, scan, fax, storage) on all available ports (USB, Ethernet, Wireless) • “Maintenance ports” should be exclusively for maintenance • Identical ports should expose the same functionality • PictBridge and modem ports may vary, but should be marked clearly • Installable options should be auto-configured
Performance Guidelines • User interface (UI) Modules should use worker threads to maintain a responsive UI • Filters in filter pipeline should flow from XPS document to stream • Stream to XPS Document conversion is very costly
Reliability Guidelines • Power cycling is not an acceptable error mitigation • Use Driver Isolation in Windows 7 • Will protect the spooler from crashing drivers • If you use COM, use only multithreaded apartment (MTA) threading in spooler processes • Do not crash on unsupported escapes or fail print jobs • Test with Print Verifier • Will identify unsafe usage of spooler methods • Validates reference counts, handles, COM interactions • Helps with debugging PrintTicket/PrintCapabilities issues
Processor Architecture • 64-bit OS adoption is at critical mass • Print driver components must be built in the proper architecture • Applications should be built in the proper architecture
Using Microsoft Core Components • Unidrv & PostScript • Use generic printer description (GPD) and PostScript printer description (PPD) files as the backbone of your driver • They are simple, robust, backwards and forwards compatible, and have good performance • Port monitors • One of the most crash-prone, difficult components in the stack • Custom port monitors are expensive to build and maintain • USBMon andWSDMon are the preferred, supported port monitors and represent the best experience for customers • WSDMon is a foundational piece in the Rally platform • Microsoft is moving away from TCPMon– so should you
Security Guidelines • User account control • Test drivers as a limited user • Store data only in the registry or in locations you control (not C:\Temp) • Clean up data in any temporary folders on uninstall • Data execution prevention (DEP) • Protects our customers from viruses • Do not disable DEP on the system or the application • Do not mark data pages as executable • Encrypt personally identifiable information • Secure devices should be denial-of-service safe • Clear unretrieved jobs • Always accept new jobs
Call To Action • Review your development and test processes and make needed changes • Look for Best Practices Guide at WinHEC • Provide feedback to prninfo@microsoft.com
Additional Resources • Blogs • Print Verifier Team Blog: http://blogs.msdn.com/PrintVerifier • WDK Documentation • Data Execution Prevention http://msdn.microsoft.com/en-us/library/aa366553.aspx • Updating Your Package-Aware Driver’s INF http://msdn.microsoft.com/en-us/library/cc678339.asp