Code sample that shows how to filter IOCTLs that retrieve ATRs from a smart card reader driver by using the Windows 7 WDK

This article has been archived. It is offered "as is" and will no longer be updated.
This code sample shows how to filter smart card reader Input/Output Controls (IOCTL) that retrieve the answer to reset (ATR) from a smart card reader driver by using the Windows 7 Windows Development Kit (WDK). This sample can be used to make sure that the warm reset ATR matches the cold reset ATR so that the warm reset ATR is in compliance with the WinSCard discovery mechanism in the following Smart Card Minidriver Specification:
The following file is available for download from the Microsoft Download Center:

DownloadDownload the AtrFilter.exe package now.

Release Date: March 3, 2010

For more information about how to download Microsoft support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.

The AtrFilter.exe self-extracting file contains the following files.
Source and Header filesatrfilter.c, atrfilter.h, atrfilter.rc
Build filessources, makefile,
INF filesatrfilter.inx
Readme filesReadme.txt
Microsoft Software License TermsLicense.txt, License.rtf

Build the code sample

  1. Download and run AtrFilter.exe to extract the files.
  2. Select the desired build environment from the Windows 7 WDK. The build environment can be free, or you can specify a 32-bit or 64-bit environment.
  3. Run the build from the directory to which you extracted the files in step 1.
Note This filter is based on Kernel Mode Driver Framework (KMDF). You must include the KMDF co-installer in your driver setup package.

Install the code sample

Note This code sample was tested only on Windows 7.

Note A valid digital signature may be required to load this sample filter driver.
For more information about how to create an installation application that adds this service as an upper filter for all smart card readers, read the MSDN article, "Installing a Filter Driver." To do this, visit the following Web site:To manually add the driver service, you can run a command from an elevated command prompt. To do this, follow these steps:
  1. Click Startstart button, and then type cmd in the Search programs and files box.
  2. Right-click cmd.exe in the Programs list, and then click Run as administrator.
    UAC If you are prompted for an administrator password or for confirmation, type the password, or provide confirmation.
  3. At the command prompt, copy or type the following command, and then press ENTER:
    sc create atrfiltr binPath= system32\drivers\atrfiltr.sys type= kernel start= demand error= normal
  4. Click Start, click Run, type regedit, and then click OK.
    UAC If you are prompted for an administrator password or for confirmation, type the password, or provide confirmation.
  5. Locate and then click the following key in the registry:
  6. On the Edit menu, click Modify.
  7. Add atrfiltr to the existing list of upper filters, and then press ENTER.
  8. Exit Registry Editor.

Article ID: 981665 - Last Review: 12/12/2015 03:51:21 - Revision: 1.0

Windows 7 Enterprise, Windows 7 Professional

  • kbnosurvey kbarchive kbcodesnippet atdownload kbexpertiseadvanced kbsurveynew kbinfo KB981665