Build the sample scanner driver

You can build the sample scanner driver and include it in an OS image that you flash onto your device so that you can observe the interaction of the sample driver with the POSUTIL library. Build the sample scanner driver by using the following instructions.

Overview of steps

Step 1: Add project files

Add the sample scanner files to a new Kernel-Mode Driver Framework (KMDF) project.

Step 2: Set the project configuration and build

Select the include and library directories files and other configuration information, and build SampleScannerDriver.sys.

Step 3: Copy files

Copy the sample scanner .inf and .pkg.xml files to your build directory.

Step 4: Set environment variables and install certificates

Set environment variables that allow you to sign the driver and install certificates.

Step 5: Generate the package and build the image

Generate the scanner driver package and add it to your image.

Step 1: Add project files

In this step, you will add the sample scanner files to a new kernel mode driver (KMDF) project.

  1. Open Microsoft Visual Studio 2013.

  2. Click File > New > Project.

  3. In the New Project window, open Visual C++ > Windows Driver > WDF > Kernel Mode Driver, Empty (KMDF).

    New project dialog
  4. Name the project SampleScannerDriver, choose a location for the project, and then click OK.

  5. Ensure that the SampleScannerDriver project is highlighted in Solution Explorer and not the SampleScannerDriver Package.

    Solution explorer
  6. Click Project > Add Existing Item, and then add following the source files from C:\Program Files (x86)\Windows Phone Kits\8.1\Samples\Drivers\KMDF\samplescanner

    1. Device.c

    2. Driver.c

    3. Internal.h

    4. Pch.h

    5. TestPOSImage.h

  7. Click Project > Add New Item > Header File (.h), and then add a new empty header file named Trace.h to the project.

  8. Add a space to the Trace.h file and save the file.

Step 2: Set the project configuration and build

In this step, you will select the include and library directories files and other configuration information necessary to build SampleScannerDriver.sys.

  1. Click Build > Configuration Manager to open Configuration Manager.

  2. In the Active solution configuration list, click Win 8.1 Release.

    Configuration manager active solution config
  3. In the Active solution platform list, click New.

    Active solution dropdown
  4. In the New Solution Platform dialog box, click OK to accept the defaults.

    New solution platform dialog
  5. Close Configuration Manager.

  6. Click Project > SampleScannerDriver Properties to open the Property Pages dialog box.

  7. Open Configuration Properties > VC++ Directories.

  8. Select Include Directories, and then add C:\Program Files (x86)\Windows Phone Kits\8.1\Include\shared; to the front of the list.

    Include directories dialog
  9. Select Library Directories, and then add C:\Program Files (x86)\Windows Phone Kits\8.1\lib\win8\km\arm; to the front of the list.

    Library directories dialog
  10. Open Linker, and then click Input. Select Additional Dependencies, and then add POSUtilKM.lib; to the front of the list.

    Scanner driver additional dependencies dialog
  11. Close the Property Pages dialog box.

  12. Click Build > Rebuild Solution to build the project. SampleScannerDriver.sys is generated.

Step 3: Copy files

In this step, you will copy the sample scanner .inf and .pkg.xml file to your build directory so that you can build an installable package for the sample scanner driver.

  1. Create a network share for C:\Program Files (x86)\Windows Phone Kits\8.1 so that it is available as a network path that does not contain spaces. For example, from a command prompt execute:net use * "\\<your machine name>\c$\Program Files (x86)\Windows Phone Kits\8.1"

    This step exposes a drive that does not contain spaces for the pkggen tool to consume.

  2. Open an elevated Visual Studio 2013 developer command prompt.

  3. Copy following files from C:\Program Files (x86)\Windows Phone Kits\8.1\Samples\Drivers\KMDF\samplescanner into the folder where your SampleScannerDriver.sys built, for example c:\SampleScannerDriver\ARM\Win8.1Release

    • SampleScanner_phone.inf

    • SampleScanner.pkg.xml

  4. Change the current directory to the folder that contains SampleScannerDriver.sys, for example C:\SampleScannerDriver\ARM\Win8.1Release.

Step 4: Set environment variables and install certificates

In this step, you will set environment variables that allow you to sign the driver and install certificates.

  1. From the elevated Visual Studio 2013 developer command prompt, add C:\Program Files (x86)\Windows Phone Kits\8.1\tools\bin\i386 to your PATH environment variable by using the following command.

    SET PATH=C:\Program Files (x86)\Windows Phone Kits\8.1\Tools\bin\i386;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;%PATH%
    
    Warning  

    Do not include quotation marks (“”) when setting these paths.

  2. Set the WPDKCONTENTROOT variable by using the following command.

    SET WPDKCONTENTROOT=C:\Program Files (x86)\Windows Phone Kits\8.1
    
  3. Install certificates by using the following command.

    installoemcerts.cmd
    
  4. Set the SIGN_OEM environment variable by using the following command.

    SET SIGN_OEM=1
    

Step 5: Generate the package and build the image

In this step, you will generate the scanner driver package and add it to your image.

  1. In the following command, <share> refers to the network share that you created in step 3. Use the following command to generate the scanner driver package.

    pkggen SampleScanner.pkg.xml /config:<share>\tools\bin\i386\pkggen.cfg.xml /variables:HIVE_ROOT=<share>\Coresystem
    

    The driver package (for example, Microsoft.SampleScanner.spkg) is created.

  2. Build and flash your image.

 

 

Show: