Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a...

36
Printer Driver Setup and 64-bit Implications

Transcript of Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a...

Page 1: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Printer Driver Setup and 64-bit Implications

Page 2: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

OutlineOutline

DevelopmentUnderstanding how to write a printer driver for 64-bit systems

What’s different and what stays the same

SetupGuidance for installing 64-bit drivers and “additional drivers”

How to write an INF that installs 64-bit and 32-bit versions of a printer driver

Page 3: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

GoalsGoals

Understand how to develop printer drivers for 64-bit Windows

Understand differences in printing in native mode and across the Windows thunking layer

Create an INF that installs 32-bit and 64-bit print drivers

Identify the changes made in Windows Server 2003 SP1 and Windows XP Professional 64-bit Edition to facilitate cross-platform driver installation

Page 4: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

64-bit Printer Driver Development

Page 5: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

OverviewOverview

The Windows Printing Subsystem is at feature parity between x64 and x86 versions of the OS

64-bit drivers are required to print from 64-bit Windows

Special cases while printing across the thunking layer

Some 64-bit specific INF requirements

Line servers, such as File and Print servers are in the sweet spot for the price/performance ratio of the x64 platform

Will be a key segment for the future

Driver availability is critical to adoption of 64-bit platform

Page 6: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Supported 64-bit ArchitecturesSupported 64-bit Architectures

ScalabilityScalability

Bre

ad

th o

f A

pp

lica

tio

ns

Bre

ad

th o

f A

pp

lica

tio

ns

64-bit IPF64-bit IPF

Most ScalableMost Scalable

VersatileVersatileMainstreamMainstream

64-bit x6464-bit x64

32-bit x8632-bit x86

Page 7: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

x64 Platform Optionsx64 Platform Options

x64 hardware supports multiple configurations

Extends hardware investment by allowing gradual migration to 64-bit computing

PC HardwarePC Hardware

Device DriversDevice Drivers

Windows EditionWindows Edition

ApplicationsApplications

32-bit Stack32-bit Stack 64-bit Stack64-bit StackHybrid StackHybrid Stack

x64

32-bit

32-bit

32-bit

x64x64

x64x64

x64x64

32-bit32-bit

x64x64

x64x64

x64x64

x64x64

x64x64

Page 8: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Print Driver Development for 64-bitPrint Driver Development for 64-bit

No special requirements to build printer driver code for x64

If you can write a printer driver for 32-bit, you can write one for 64-bit

Follow regular porting guidelines

Windows XP Professional x64 Edition ships with thousands of printer drivers

Porting to x64 architecture was relatively straightforward

Print system components are the same as 32-bit

Page 9: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Coding GuidelinesCoding Guidelines

Use Windows 64- and 32-bit safe data types

Examine all pointer usage, especially pointer arithmetic

Remove inline assembly code (use intrinsics or native assembly code)

Use #if defined (__AMD64__) for x64 specific code

No __x64__ definition

Use #if defined(__IA64__) for Itanium specific code

Build environment for x64 is AMD64

Page 10: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Areas for Caution While DevelopingAreas for Caution While Developing64-bit Print Drivers64-bit Print Drivers

Location of binariesSystem32 and Syswow64 directories

Use Dirids rather than full paths in infs

Thunking layerThere are some GDI printing callbacks which work differently in the thunking case compared to the native case

DrvDocumentEvent

Extended escapes

Page 11: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Printing Across the Thunking LayerPrinting Across the Thunking Layer

If you load/run a 32-bit application on the 64-bit platform some calls need to be translated from 32-bit mode to64-bit mode

This translation is called thunking

WOW64 is the main Windows 64-bit thunking layerRuns Windows NT x86 binaries

No support for mixing of 32-bit and 64-bit code within a process

User/kernel transitions are thunked to account for structure differences and transition between instruction sets

Only a few dlls are thunked: ntdll.dll, user.dll, gdi.dll are the main ones

On 64-bit Windows, GDI is a 64-bit component

While printing from a 32-bit application, interactions with GDI are managed by the WOW64 thunking layer

Page 12: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

GDI:DrvDocumentEventGDI:DrvDocumentEvent

Some printer drivers make GDI callbacks from a UI module during printing

For example to add a watermark, to do some types of ICM profile matching, to do certain types of run time job accounting

Typically made from DrvDocumentEvent

Not part of the original design intent of the API

This call is made across the thunking layer from application space to driver space

GDI must marshall the state of any data across the thunking layer in order to have the data available for the print driver.

Problem: the data is essentially unbounded Extremely difficult (trending towards unachievable) to accurately marshall all data

Page 13: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Extended EscapesExtended Escapes

DrvDocumentEvent calls which use ExtEscapes are supported

Enables the majority of call back scenarios

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/graphics/hh/graphics/drvrfnc_ffc39ed1-d1b8-4e3d-b0a3-515b90cd6c8f.xml.asp for details on the available parameters

Other uses of DrvDocumentEvent callbacks are not supported in the current release across the thunking layer

Several thousand drivers have been testedVery low numbers of functional problems found

Page 14: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Mitigations and DrawbacksMitigations and Drawbacks

MitigationsThis entire problem set only affects printing from a 32-bit app on 64-bit Windows, and within that space only affects “advanced” printing features It is possible to work around the limitations by designing the driver differently

Use print processorApplication level watermarks64-bit applications do not show these problems

Development of x64 applications will minimize the impact of this limitation

DrawbacksIn some cases more than a simple driver recompile is required to get the same printing experienceValue add applications may need to be ported to 64-bit to ensure the same functionality is available

Page 15: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Installing 64-bit Printer Drivers

Page 16: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

IntroductionIntroduction

We expect mixed 32-bit and 64-bit environmentsfor many yearsPrinting is unique among device classes

To support Point & Print, non-native platform printer drivers may be loaded onto a system as “additional drivers”

The challenge:How do I write an INF that loads an x64 driver on any platform?How do I write an INF that installs an x86 driver on an x64 platform?

The answer:Use INF decorationsWhat’s mandatory, what’s notWhat works on what versions of Windows

Page 17: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

64-bit Drivers64-bit Drivers

How to install x64 and x86 driversThere are no setup differences between AMD64 and Intel EM64T

The examples show how to install the x86 and x64 version of a driver from one INF

Itanium isn’t covered in the examples in this presentation but the logic Is the same

There is more Itanium-specific information in the Driver Development Kit (DDK)

Page 18: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

[MANUFACTURER]

%Acme Corp.% = Acme, NTamd64

[Acme.NTamd64]

%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]

CopyFiles = DriverFile.DLL

[SourceDisksFiles.amd64]

<location of driver files on media>

Some INF TerminologySome INF TerminologyManufacturer

Section

Model Sectionx64 = NTamd64

DDInstall Section

SourceDisksFiles Section

Page 19: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

INF Decorations are Required on x64INF Decorations are Required on x64

An x64 driver must use a decorated Model section on the following platforms:

Windows Server 2003 SP1

Windows XP Professional x64 Edition

…and future versions of Windows

The x64 Editions of Windows will not recognize drivers that are not decorated correctly

Decorations will be required for Itanium (ia64) drivers on Longhorn

So - how do you write an INF that works on Windows Server 2003 SP1/XP x64 and on earlier versions of Windows?

Page 20: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

ApproachApproach

Decorate the Model section to match the processor architecture of the 64-bit driver that you are installing

This will install the driver correctly on Windows 2003 SP1 (any platform), Windows XP Professional x64 Edition, and Longhorn

Also provide an undecorated Model section This will install the x86 driver

It will install a driver correctly on earlier versions of Windows

Use decorated SourceDisksFiles to point the installer to the correct location of your binaries

Page 21: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Getting Started – 32-bit DriverGetting Started – 32-bit Driver

[MANUFACTURER]

%Acme Corp.% = Acme

[Acme]

%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]

CopyFiles = Driver.DLL

The INF Model section below installs an x86 driver on any version of Windows

Page 22: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Getting Started – x64 DriverGetting Started – x64 Driver

[MANUFACTURER]

%Acme Corp.% = Acme, NTamd64

[Acme.NTamd64]

%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]

CopyFiles = Driver.DLL

The INF Model section below loads an x64 driver on:Windows Server 2003 SP1 (any processor architecture)

Windows XP Professional x64 Edition

Page 23: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Supporting More Versions of WindowsSupporting More Versions of Windows

This also installs the x64 driver on versions of Windows prior to Windows 2003 SP1 and XP x64

[MANUFACTURER]

%Acme Corp.% = Acme, NTamd64

[Acme]

%Acme Model% = Acme100PS, <hardware IDs>

[Acme.NTamd64]

%Acme Model% = Acme100PS, <hardware IDs>

But: also matches x86

drivers!

Page 24: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Solution with Three Example UsagesSolution with Three Example Usages

The following slides show a complete example

Separate install scenarios are presented,all using the same INF

Page 25: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Complete Example Complete Example [MANUFACTURER]%Acme Corp.% = Acme, NTamd64

[Acme]%Acme Model% = Acme100PS, <hardware IDs>

[Acme.NTamd64]%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]CopyFiles = MyDriverFile.dll, ...

[SourceDisksNames.x86]1= %Location%,,,

[SourceDisksFiles.x86]MyDriverFile.dll = 1,\i386

[SourceDisksNames.amd64]1= %Location%,,,

[SourceDisksFiles.amd64]MyDriverFile.dll = 1,\amd64

Page 26: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Install an x64 Driver on Server 2003 SP1/XP x64Install an x64 Driver on Server 2003 SP1/XP x64[MANUFACTURER]%Acme Corp.% = Acme, NTamd64

[Acme]%Acme Model% = Acme100PS, <hardware IDs>

[Acme.NTamd64]%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]CopyFiles = MyDriverFile.dll, ...

[SourceDisksNames.x86]1= %Location%,,,

[SourceDisksFiles.x86]MyDriverFile.dll = 1,\i386

[SourceDisksNames.amd64]1= %Location%,,,

[SourceDisksFiles.amd64]MyDriverFile.dll = 1,\amd64

Installs an x64 driver on XP x64, and

Windows Server 2003 SP1 (any platform, so

may be additional driver)

Page 27: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Install an x86 Driver on Server 2003 SP1/XP x64 Install an x86 Driver on Server 2003 SP1/XP x64 [MANUFACTURER]%Acme Corp.% = Acme, NTamd64

[Acme]%Acme Model% = Acme100PS, <hardware IDs>

[Acme.NTamd64]%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]CopyFiles = MyDriverFile.dll, ...

[SourceDisksNames.x86]1= %Location%,,,

[SourceDisksFiles.x86]MyDriverFile.dll = 1,\i386

[SourceDisksNames.amd64]1= %Location%,,,

[SourceDisksFiles.amd64]MyDriverFile.dll = 1,\amd64

This section is used when the user

installs an x86 driver on XP x64, or Server

2003 SP1 (any platform)

Page 28: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Install an x64 Driver on XP SP2Install an x64 Driver on XP SP2[MANUFACTURER]%Acme Corp.% = Acme, NTamd64

[Acme]%Acme Model% = Acme100PS, <hardware IDs>

[Acme.NTamd64]%Acme Model% = Acme100PS, <hardware IDs>

[Acme100PS]CopyFiles = MyDriverFile.dll, ...

[SourceDisksNames.x86]1= %Location%,,,

[SourceDisksFiles.x86]MyDriverFile.dll = 1,\i386

[SourceDisksNames.amd64]1= %Location%,,,

[SourceDisksFiles.amd64]MyDriverFile.dll = 1,\amd64

SourceDisksFiles locates the correct

driver files

This section is also used to install the

x64 driver on XP SP2 as an additional

driver

Page 29: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

User Experience ChangesUser Experience Changes

To make the Driver installation experience more predictable and consistent, we made some changes for Server 2003 SP1 and XP x64 Edition

We changed the path through the Add Printer Driver Wizard so that the user can select the platform before the printer model

We improved the way in which Unidrv-based printer drivers are installed

Page 30: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Add Printer Driver WizardAdd Printer Driver Wizard

Install an x86 driver on an x64 Server

Use Have Disk to locate non-native

drivers

Page 31: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

UnidrvUnidrv

Problem: when installing an x64 Unidrv-based driver on an x86 print server as an additional driver, how do we locate the x64 version of Unidrv?

Old solution: use remote admin from machine with matching architecture. But:

This requires that you have x64 installed locally

No version predictability

New solution: Windows prompts for correct Windows media

Gives the user controlIf it’s on a network share this is transparent to the user

Page 32: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Summary of Printer Driver Installation SectionSummary of Printer Driver Installation Section

INF Model section decorations are now required for x64 drivers

They are supported on Itanium and will be required so decorate Itanium drivers too

Undecorated model sections are used to install x86 drivers, and also for x64 drivers on earlier versions of Windows

So use decorations on the SourceDisksFiles section to distinguish between different driver platforms

There are some tweaks in Windows Server 2003 SP1 and XP x64 to improve the overall user experience

Page 33: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Call to ActionCall to Action

Use Model section decorations in your INF to describe the target platform for your driver

Assess market needs for x64 drivers for your devicesNow - CAD / DCC / CAM

FuturePhoto / enthusiast

Print servers / enterprise deployment

Examine driver and application code for use of GDI:DrvDocumentEvent

Plan for workarounds if required

Use the Designed for Windows Logo Program to certify 64-bit drivers

Page 34: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Additional ResourcesAdditional ResourcesCommunity Sites

http://www.microsoft.com/communities/default.mspx MSDN Developer Community Chats:

Printer Drivers -- Ask the Experts Online http://msdn.microsoft.com/chats/windows/windows_102402.aspWindows Drivers: Printer Drivers http://msdn.microsoft.com/chats/windows/windows_101602.aspWindows Drivers Printing and Networking http://msdn.microsoft.com/chats/windows/windows_022002.asp

Web resourcesWS-Devices Profile:

http://msdn.microsoft.com/webservices/understanding/specs/default.aspx?pull=/library/en-us/dnglobspec/html/devprof.asp Printer Working Grouphttp://www.pwg.org WHDC Printing home page: http://www.microsoft.com/whdc/device/print/default.mspxWHDC Still Imaging / WIA home page: http://www.microsoft.com/whdc/device/stillimage/default.mspx

Page 35: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

Additional ResourcesAdditional Resources

E-mailFor developer print questions: prninfo @ microsoft.comFor developer scan questions: wiainfo @ microsoft.com For developer color questions: mscolor @ microsoft.com

DDKEspecially important: read the section entitled “How to Use Decorations in INF Files for Printer Drivers” which was recently updated. This is currently on MSDN.

White papers:On www.microsoft.com/whdc: Printer Driver Setup: 64-bit Drivers and Platforms

For print administratorsInformation on planning for mixed 32-bit/64-bit environments will be published on www.microsoft.com/printserver

Page 36: Printer Driver Setup and 64-bit Implications. Outline Development Understanding how to write a printer driver for 64-bit systems What’s different and.

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.