Upload
ginger-banks
View
224
Download
1
Tags:
Embed Size (px)
Citation preview
Windows Image Acquisition Windows Image Acquisition Enhancements In Windows VistaEnhancements In Windows Vista
Avijit SinhaAvijit SinhaProgram Manager Program Manager D2–Digital Documents Platform and SolutionsD2–Digital Documents Platform and Solutions
AgendaAgenda
Scanning infrastructure in Windows VistaScanning infrastructure in Windows VistaPush Scanning DemoPush Scanning Demo
WIA Enhancements in Windows VistaWIA Enhancements in Windows VistaMulti-image scanning DemoMulti-image scanning Demo
WIA Service Security Context changeWIA Service Security Context change
Additional InfoAdditional InfoWDK Samples and Tools WDK Samples and Tools
WIA Automation Layer and WIA VideoWIA Automation Layer and WIA Video
64-bit support64-bit support
TWAIN support in Windows VistaTWAIN support in Windows Vista
Windows Scanning Infrastructure For Windows Scanning Infrastructure For Network And Locally Connected ScannersNetwork And Locally Connected Scanners
DeviceDevice
New or Enhanced in
Windows Vista
Unchanged in Windows
Vista
KeyKey
Windows VistaWindows Vista
NetworkNetwork
Routing Destination
WSD Scan WSD Scan ProtocolProtocol
Windows Vista WIA application
Windows Rally Scan WIA Class
Driver for Network
Connected Scanners
Windows XP or Windows Server 2003 WIA application
TWAIN applicationTWAIN Data Source
Vista WIA Driver for Locally Connected
Scanner
TWAIN Compatibility Layer
W
I
A
S
E
R
V
I
C
E
Scanned Document Storage
TWAIN Data Source Manager
WIA ScannerWIA Scanner
TWAIN ScannerTWAIN Scanner
Routing Agent
Scan Profiles
Network connected Network connected ScannersScanners
Windows Fax and Scan Application
Scan Dialog
Routing Dialog
Scan Profiles Dialog
Windows Rally IHV WIA Driver
for Network Connected Scanners
Windows XP or Windows Server 2003 WIA Driver
Locally connected Locally connected ScannersScanners
Windows Photo
Gallery
Push Scanning From A Push Scanning From A Network Connected MFPNetwork Connected MFP
ImageRunner 3170
Scanner Tree ExampleScanner Tree Example
XP/Windows Server 2003XP/Windows Server 2003 Windows VistaWindows Vista
WIA represents scanners and images on a scanner using a tree of itemsWIA represents scanners and images on a scanner using a tree of items
Root Item
Image Item
FlatbedItem
FilmItem
FeederItem
StorageItem
Root Item
WIA Items And PropertiesWIA Items And Properties
WIA “items” are used to represent both WIA “items” are used to represent both device attributes and device datadevice attributes and device data
Two kinds of itemsTwo kinds of itemsApplications use IWiaItem(2) (application Applications use IWiaItem(2) (application items) – each application has its own items) – each application has its own “item tree”“item tree”
Drivers use IWiaDrvItem (driver items) – Drivers use IWiaDrvItem (driver items) – there is only one “driver item tree” per devicethere is only one “driver item tree” per device
Where do IWiaDrvItems come from?Where do IWiaDrvItems come from?IWiaDrvItems are created by the driver IWiaDrvItems are created by the driver using WIA helper functionsusing WIA helper functions
WIA Data TransfersWIA Data Transfers
WIA
Driver
Application
Request TransferRequest Transfer
1. Lock driver1. Lock driver
Return from TransferReturn from Transfer
3. Ask driver for data3. Ask driver for data
2. Ask driver to commit 2. Ask driver to commit properties to deviceproperties to device
4. Unlock driver4. Unlock driver
Simplified data transferSimplified data transfer
Optional Imaging Filter
Process boundaryProcess boundary
5. Imaging filter processes 5. Imaging filter processes data from scannerdata from scanner
11 22 33 44
55
KeyKey
MicrosoftMicrosoft
IHVIHV
ISVISV
Stream-Based TransfersStream-Based Transfers
IWiaTransfer for stream-based data transfersIWiaTransfer for stream-based data transfersNot required to support legacy transfers to get a logo Not required to support legacy transfers to get a logo
Legacy applications will still work via the compatibility layerLegacy applications will still work via the compatibility layer
Implement the code for data transfer in Implement the code for data transfer in drvAcquireItemDatadrvAcquireItemData
Check the lFlags parameter for Check the lFlags parameter for WIA_MINIDRV_TRANSFER_DOWNLOAD. WIA_MINIDRV_TRANSFER_DOWNLOAD. If true, the transfer is stream-basedIf true, the transfer is stream-basedCall QueryInterface on the minidriver callback, Call QueryInterface on the minidriver callback, requesting IID_IWiaMiniDrvTransferCallbackrequesting IID_IWiaMiniDrvTransferCallback
Call IWiaTransfer::GetNextStream to get an IStream Call IWiaTransfer::GetNextStream to get an IStream interface, and write data directly to that interface via interface, and write data directly to that interface via IStream::WriteIStream::WriteSend progress messages, such as Send progress messages, such as WIA_TRANSFER_MSG_END_OF_STREAM, WIA_TRANSFER_MSG_END_OF_STREAM, via IWiaTransfervia IWiaTransfer
Multi-Page TransfersMulti-Page Transfers
Multi-page transfers are supported with IWiaTransferMulti-page transfers are supported with IWiaTransfer
Drivers needs to call IWiaTransfer::GetNextStream to get Drivers needs to call IWiaTransfer::GetNextStream to get streams for the next pagesstreams for the next pages
Drivers should call GetNextStream in a loopDrivers should call GetNextStream in a loop
S_OK to indicate another page has been requestedS_OK to indicate another page has been requested
Multiple files can be produced by this method – the Multiple files can be produced by this method – the application requests the file types, and each page can application requests the file types, and each page can represent a file; Previously a single transfer resulted in a represent a file; Previously a single transfer resulted in a single filesingle file
For multi-page TIFF files, request a single stream and For multi-page TIFF files, request a single stream and write all the pages to the streamwrite all the pages to the stream
For multiple file transfers, request a stream for each fileFor multiple file transfers, request a stream for each file
New WIA InterfacesNew WIA Interfaces
In Windows Vista, WIA provides new In Windows Vista, WIA provides new COM interfacesCOM interfaces
IWiaItem2, IWiaDevMgr2, IEnumWiaItem2IWiaItem2, IWiaDevMgr2, IEnumWiaItem2
IWiaTransfer, IWiaTransferCallbackIWiaTransfer, IWiaTransferCallback
IWiaImageFilter, IWiaSegmentationFilter, IWiaImageFilter, IWiaSegmentationFilter, IWiaPreviewIWiaPreview
IWiaErrorHandler, IWiaAppErrorHandlerIWiaErrorHandler, IWiaAppErrorHandler
IWiaItem Versus IWiaItem2IWiaItem Versus IWiaItem2
IWiaItem versus IWiaItem2IWiaItem versus IWiaItem2IWiaItem2 is a superset of IWiaItem IWiaItem2 is a superset of IWiaItem
IWiaItem interface remains unchanged to guarantee compatibilityIWiaItem interface remains unchanged to guarantee compatibility
New WIA items are only accessible through IWiaItem2 New WIA items are only accessible through IWiaItem2
IWiaItem2 supports multi-region scanning, IWiaItem does notIWiaItem2 supports multi-region scanning, IWiaItem does not
IWiaItem2 and IWiaItem support the preview filterIWiaItem2 and IWiaItem support the preview filter
Windows Vista has a WIA Compatibility layer to Windows Vista has a WIA Compatibility layer to ensure thatensure that
Windows XP applications (IWiaItem) work with Windows XP applications (IWiaItem) work with Windows Vista driversWindows Vista drivers
Windows Vista applications (IWiaItem2) work with Windows Vista applications (IWiaItem2) work with Windows XP driversWindows XP drivers
WIA Compatibility LayerWIA Compatibility Layer
Flatbed and Feeder Scanners can be accessed from Flatbed and Feeder Scanners can be accessed from older (v1) and newer (v2) WIA Applicationsolder (v1) and newer (v2) WIA Applications
Storage and Film Scanners can only be accessed from Storage and Film Scanners can only be accessed from newer (v2) WIA Apps (e.g., Windows Fax and Scan newer (v2) WIA Apps (e.g., Windows Fax and Scan App, Windows Photo Gallery, New Scanning Common App, Windows Photo Gallery, New Scanning Common Dialog, etc)Dialog, etc)
Windows XP or Windows Server 2003 WIA driver
Windows Vista WIA driver
Windows XP or Windows Server 2003 WIA Application
Windows Vista WIA Application
Windows XP or Windows Server to Windows Vista
Compat Layer
Windows Vista to Windows XP or Windows Server
Compat Layer
KeyKey
MicrosoftMicrosoft
IHVIHV
ISVISV
WIA service
Windows Vista WIA Windows Vista WIA Driver ImplicationsDriver Implications
New functionality enablesNew functionality enablesSimplified driver development in many areas e.g., data transfersSimplified driver development in many areas e.g., data transfersLooser coupling between value-add componentsLooser coupling between value-add components
Example: Core driver functionality (data transfer, property negotiation) Example: Core driver functionality (data transfer, property negotiation) and enhanced functionality (Image Processing, Segmentation) can be and enhanced functionality (Image Processing, Segmentation) can be separately implementedseparately implemented
Recommendation: Write separate drivers for older WIA Recommendation: Write separate drivers for older WIA (Windows XP and Windows Server 2003) and enhanced (Windows XP and Windows Server 2003) and enhanced WIA (Windows Vista) functionality WIA (Windows Vista) functionality
WIA drivers developed for Windows XP and Windows Server WIA drivers developed for Windows XP and Windows Server 2003 will continue to work on Windows Vista but will not be able 2003 will continue to work on Windows Vista but will not be able to expose enhanced WIA functionality (e.g., image segmentation, to expose enhanced WIA functionality (e.g., image segmentation, live preview, error handling)live preview, error handling)Therefore it is easier to have separate drivers and install different Therefore it is easier to have separate drivers and install different package depending on operating systempackage depending on operating system
WIA Vendor Customization WIA Vendor Customization And ExtensionsAnd Extensions
Vendors can optionally provide Vendors can optionally provide components to enhance the components to enhance the user experienceuser experience
UI customization DLLUI customization DLL
Image processing filterImage processing filter
Segmentation filterSegmentation filter
Error handlerError handler
These components run in the These components run in the application processapplication process
Not the same process as the driverNot the same process as the driver
UI CustomizationUI Customization
WIA provides system-supplied UIWIA provides system-supplied UIProvides consistent user-interface across Provides consistent user-interface across many devicesmany devices
Less work for vendorsLess work for vendors
Much of the UI is replaceable or extensibleMuch of the UI is replaceable or extensibleScan dialogs (replaceable only)Scan dialogs (replaceable only)
Shell extension (Windows XP and Server 2003 only)Shell extension (Windows XP and Server 2003 only)
Property pages (extensible only)Property pages (extensible only)
Context menu (Windows XP and Server 2003 only)Context menu (Windows XP and Server 2003 only)
Segmentation FilterSegmentation Filter
The Segmentation Filter createsThe Segmentation Filter createschild items and sets the coordinateschild items and sets the coordinatesof the sub-images into each item.of the sub-images into each item.
It does not acquire the imagesIt does not acquire the images
Detects regions in preview imageDetects regions in preview image
““Cuts out” the regions creating Cuts out” the regions creating multiple imagesmultiple images
Scenario: Scanning multiple Scenario: Scanning multiple separate photos at the same time separate photos at the same time from a flatbed scannerfrom a flatbed scanner
WIA Application
WIA service
Scanner Driver
Segmentation Filter
Item Tree with Item Tree with Segmented Segmented
ImagesImages
KeyKey
MicrosoftMicrosoft
IHVIHV
ISVISV
Segmentation FilterSegmentation Filter
Segmentation filter enables IHVs to provide region Segmentation filter enables IHVs to provide region detection code and expose this functionality to detection code and expose this functionality to WIA application WIA application
In-proc COM component (runs in the In-proc COM component (runs in the application’s process)application’s process)
Microsoft will provide a replaceable segmentation filter Microsoft will provide a replaceable segmentation filter
Segmentation filter must support all image formats that Segmentation filter must support all image formats that the driver supports!the driver supports!
Simple modification to driver’s INF fileSimple modification to driver’s INF file
[MyDriver.AddReg][MyDriver.AddReg]……HKCR,CLSIDHKCR,CLSID\{UiClassId}\\{UiClassId}\shellex\shellex\ SegmentationFilter\ SegmentationFilter\{FilterClassId}{FilterClassId}
Image Processing FilterImage Processing Filter
Used for two purposesUsed for two purposesFiltering scanned image to do image processing that can’t be done in hardwareFiltering scanned image to do image processing that can’t be done in hardware
Provide live preview by modifying preview image with realistic estimate of the final Provide live preview by modifying preview image with realistic estimate of the final scan (no more flowers!)scan (no more flowers!)
The live preview is used by the The live preview is used by the Preview ComponentPreview Component provided by Microsoft in provided by Microsoft in Windows VistaWindows Vista
Invoked in the application process by WIA componentsInvoked in the application process by WIA components
WIA Application
IWiaPreview IWiaTransfer
Image Processing
Filter
WIA Service
Scanner Driver
KeyKey
MicrosoftMicrosoft
IHVIHV
ISVISV
Image Processing FilterImage Processing Filter
In-proc COM component implementing IWiaImageFilter and In-proc COM component implementing IWiaImageFilter and IWiaTransferCallback IWiaTransferCallback
Runs in the application’s processRuns in the application’s process
Needs to support any image format that driver supportsNeeds to support any image format that driver supports
Filter Filter andand driver need to read WIA_DPS_PREVIEW to determine driver need to read WIA_DPS_PREVIEW to determine what the current purpose iswhat the current purpose is
E.g., preview scan or final scanE.g., preview scan or final scan
Recommend to move filtering functionality from driver to filterRecommend to move filtering functionality from driver to filter
At a minimum, all filters should implement brightness and contrastAt a minimum, all filters should implement brightness and contrast
Simple modification to driver’s INF fileSimple modification to driver’s INF file
[MyDriver.AddReg][MyDriver.AddReg]……HKCR,CLSID\HKCR,CLSID\{UiClassId}{UiClassId}\shellex\\shellex\ ImageProcessingFilter\{ ImageProcessingFilter\{FilterClassIdFilterClassId}}
Error HandlingError Handling
Provides status and error messages Provides status and error messages during data acquisitionsduring data acquisitions
““Lamp warming up”Lamp warming up”
““Cover open”Cover open”
““Paper Jam”Paper Jam”
Can show UI (if application allows)Can show UI (if application allows)
Runs in application’s processRuns in application’s process
Microsoft provides a default error handler Microsoft provides a default error handler with limited number of messageswith limited number of messages
WIA Component InterfacesWIA Component Interfaces
ProcessProcessboundaryboundary
WIA service
User ModeUser Mode
Kernel ModeKernel Mode
IWiaDevMgr(2)IWiaDevMgr(2)IWiaItem(2)IWiaItem(2)IWiaDrvItemIWiaDrvItem
……
IWiaUIExtension(2)IWiaUIExtension(2)IShellExtInitIShellExtInit
……
Optional vendor UI
Bus Driver
WIA Application
COM Proxy
Default UI
IStiUsdIStiUsdIWiaMiniDrvIWiaMiniDrv
Vendor User Mode Driver (USD) Vendor Error Handler
Vendor filter
SegmentationFilter
KeyKey
MicrosoftMicrosoft
IHVIHV
ISVISV
Multi-image ScanningMulti-image Scanning
MP780
Security Context ChangeSecurity Context Change
Driver now runs under Driver now runs under LocalService accountLocalService accountAssumptions about access to resources Assumptions about access to resources can cause “Access denied” errors under can cause “Access denied” errors under new security contextnew security contextTypical areas affectedTypical areas affected
File system accessFile system accessRegistry accessRegistry accessNamed kernel objectsNamed kernel objectsOut-of-process COM objectsOut-of-process COM objectsCreating and opening other processesCreating and opening other processes
Security Context ChangeSecurity Context Change
Many problems can be solved by putting Many problems can be solved by putting correct security descriptors on objectscorrect security descriptors on objects
To share objects with other componentsTo share objects with other componentsCreate a discretionary access control list Create a discretionary access control list (DACL) that allows access to the object(DACL) that allows access to the object
Security Context ChangeSecurity Context Change
File system accessFile system accessUnder LocalSystem in Windows XP, driver Under LocalSystem in Windows XP, driver had Read/Write access to almost had Read/Write access to almost any directoryany directory
Under LocalService, driver has mainly Read Under LocalService, driver has mainly Read access onlyaccess only
If driver only reads files, then usually not If driver only reads files, then usually not a problema problem
Drivers should create or write their private Drivers should create or write their private files in the %userprofile% directoryfiles in the %userprofile% directory
Note: The user account in this case is Note: The user account in this case is “LocalSystem” or “LocalService”“LocalSystem” or “LocalService”
Security Context ChangeSecurity Context Change
Registry AccessRegistry AccessMuch of the registry is available for the driver Much of the registry is available for the driver to readto read
WIA drivers should only WIA drivers should only writewrite to the to the DeviceData section of the registry key that is DeviceData section of the registry key that is handed to them in the handed to them in the IStiUSD::InitializeIStiUSD::Initialize entry pointentry point
Security Context ChangeSecurity Context Change
Named kernel objectsNamed kernel objectsTwo main problemsTwo main problems
NamespacesNamespaces
Access permissionsAccess permissions
Applications and drivers may run in Applications and drivers may run in different sessionsdifferent sessions
Each has its own namespaceEach has its own namespace
Use the correct namespace when specifying the Use the correct namespace when specifying the object name e.g., Global\MyDeviceLock object name e.g., Global\MyDeviceLock
Set the object permissions correctly when Set the object permissions correctly when creating the objectcreating the object
Don’t rely on default permissionsDon’t rely on default permissions
Security Context ChangeSecurity Context Change
Out-of-process COM componentsOut-of-process COM componentsRequire two types of permissionsRequire two types of permissions
Launch permissionsLaunch permissions
Access permissionsAccess permissions
Ensure the permissions on the COM objects Ensure the permissions on the COM objects are set correctlyare set correctly
Use the COM supplied method of storing Use the COM supplied method of storing your permissions under the AppID keyyour permissions under the AppID key
Call CoInitializeSecurity with the EOAC_APPID Call CoInitializeSecurity with the EOAC_APPID
This allows administrators to adjust permissions This allows administrators to adjust permissions if necessaryif necessary
Security Context ChangeSecurity Context Change
Creating and opening processesCreating and opening processesWIA drivers should not manually start other WIA drivers should not manually start other processes on the systemprocesses on the system
In Fast User Switching or Terminal Services In Fast User Switching or Terminal Services environment, it is often difficult to say who the environment, it is often difficult to say who the “user” is“user” is
In Windows XP, driver could launch the process In Windows XP, driver could launch the process under the incorrect accountunder the incorrect account
Generally not possible under LocalService Generally not possible under LocalService account, unlessaccount, unless
Activating an installed COM componentActivating an installed COM component
Windows NT service etcWindows NT service etc
WIA In Windows Driver Kit (WDK)WIA In Windows Driver Kit (WDK)
WDK contains a very rich set of WIA samples WDK contains a very rich set of WIA samples and tools to help Scanner Driver Developers and tools to help Scanner Driver Developers quickly develop and test their new WIA driversquickly develop and test their new WIA driversSamplesSamples
Monster Driver Sample includesMonster Driver Sample includesSample for flatbed, feeder, film and storage sourceSample for flatbed, feeder, film and storage sourceError Handler SampleError Handler SampleWIA Transfer SampleWIA Transfer SampleFilters SampleFilters Sample
WIA Micro driver sampleWIA Micro driver sample
Diagnostic Tools to help driver developmentDiagnostic Tools to help driver developmentWIA navigation and property tool WIA navigation and property tool WIA Trace ViewerWIA Trace Viewer
WIA Tools In The WDKWIA Tools In The WDK
Test tools required for Logo/CertificationTest tools required for Logo/CertificationNew Data Transfer Test toolNew Data Transfer Test tool
New Item Tree and Properties Compatibility New Item Tree and Properties Compatibility Test toolTest tool
Error Handler Test toolError Handler Test tool
Twain Data-source Compliance Test toolTwain Data-source Compliance Test tool
Power Management Test Tool for ScannersPower Management Test Tool for Scanners
Additional toolsAdditional toolsFilter Test toolFilter Test tool
Imaging Driver Robustness Test toolImaging Driver Robustness Test tool
WIA VideoWIA Video
Functionality deprecated in Windows VistaFunctionality deprecated in Windows Vista
No infrastructure support in WIA for No infrastructure support in WIA for acquisition from web camsacquisition from web cams
Video acquisition support removed in Video acquisition support removed in older common dialogsolder common dialogs
WIA Automation LayerWIA Automation Layer
Available as download from microsoft.comAvailable as download from microsoft.com
Is now inbox in Windows VistaIs now inbox in Windows Vista
WIA On x64 Versions Of WIA On x64 Versions Of Windows VistaWindows Vista
32-bit and 64-bit functionality are identical32-bit and 64-bit functionality are identical
64-bit extension host 64-bit extension host Allows 32-bit WIA applications to work with Allows 32-bit WIA applications to work with 64-bit WIA drivers by hosting 64-bit WIA 64-bit WIA drivers by hosting 64-bit WIA UI extensionsUI extensions
TWAINTWAIN
Support same as Support same as Windows Server 2003 SP1Windows Server 2003 SP1
Only 32-bit TWAIN DSM in Windows VistaOnly 32-bit TWAIN DSM in Windows Vista
STI hosting component in x64 STI hosting component in x64 Windows Vista to enable 32-bit TWAIN Windows Vista to enable 32-bit TWAIN data-source and 64-bit STI driver data-source and 64-bit STI driver combination to be functionalcombination to be functional
Call To ActionCall To Action
IHVsIHVsWrite drivers exposing the new item tree structureWrite drivers exposing the new item tree structure
Write drivers that support the new stream based data transferWrite drivers that support the new stream based data transfer
Differentiate your device by providing your own image Differentiate your device by providing your own image processing filtersprocessing filters
Enhance device experience using error handlersEnhance device experience using error handlers
ISVs ISVs Write WIA applications that use the new COM interfacesWrite WIA applications that use the new COM interfaces
Provide focused experience for different scannersProvide focused experience for different scanners
Provide a superior scanning experience by using imaging filters Provide a superior scanning experience by using imaging filters and error handling capabilitiesand error handling capabilities
Ask the Experts at lunch todayAsk the Experts at lunch today
ReferencesReferences
Refer to “Refer to “Security-related Best Practices for WIA DrSecurity-related Best Practices for WIA Driver Developmentiver Development” whitepaper to ensure your WIA drivers ” whitepaper to ensure your WIA drivers work well in the Local Service security work well in the Local Service security contextcontext
http://www.microsoft.com/whdc/device/StillImhttp://www.microsoft.com/whdc/device/StillImage/default.mspxage/default.mspx
Consult general security referencesConsult general security referencesSecurity topics on MSDNSecurity topics on MSDN
““Writing Secure CodeWriting Secure Code”” (ISBN 0-7356-1588-8) (ISBN 0-7356-1588-8)
© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,
it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.