IT tutorials
 
Technology
 

Windows 7 : Kernel Mode Installation and Build - Building Featured Toaster

10/9/2013 7:36:08 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

The Toaster sample is set of simple software drivers that were created by Microsoft as a learning tool for new driver developers. If you are new to KMDF driver development, it’s the first sample you should look at. Not only does Toaster provide a simple example of how to write drivers by using the best coding practices, it includes detailed comments that explain every step. Toaster is located at WinDDK\BuildNmber\src\kmdf\toaster.

Toaster includes a number of drivers, including two function drivers. One is a minimal version that is named Simple and the other a full-featured version that is named Featured. This section uses the Featured Toaster sample as a convenient way to demonstrate the basics of the build, install, and debug process. We will walk through how to create a Windows 7 checked build of Featured Toaster. We will discuss some of the supporting files that are mentioned in the previous material. The KMDF version of Toaster is essentially a port of the WDM Toaster sample. If you are familiar with the WDM version, compare it to the KMDF version to see just how much KMDF can simplify driver code.

1. Makefile and Makefile.inc

The contents of Makefile are the same for all driver projects. Featured Toaster also includes an optional file, Makefile.inc. This file contains some additional make directives that handle two targets that aren’t covered by makefile.def. The following example shows the contents of Featured Toaster’s makefile.inc file:

_LNG=$(LANGUAGE)
_INX=.
STAMP=$(STAMPINF_PATH) –f $@ -a $(_BUILDARCH) -v 1.0.0.0

$(OBJ_PATH)\$(0)\$(INF_NAME) .inf: $(_INX)\$(INF_NAME .inx
copy $(_INX)\$(@B) .inx $@
$(STAMP)

mofcomp: $(OBJ_PATH)\$(0)\toaster.bmf

$(OBJ_PATH)\$(0)\toaster.bmf: toaster.mof
mofcomp –WMI –B:$(OBJ_PATH)\$0\toaster.bmf toaster.mof
wmimofck –m –h$(OBJ_PATH)\$0\ToasterMof.h –
w$(OBJ_PATH)\$0\htm $(OBJ_PATH)\$(0)\toaster.bmf

The first part of makefile.inc uses the project’s INX file, wdffeatured.inx, to produce an architecture-specific INF file. The second part of makefile.inc produces the WMI target file.

2. The Sources File

The Sources file contains most of the project-specific information that the build utility uses to build the project. It consists of a series of directives that assign project-specific values to a set of macros and environment variables. The following example shows the contents of the Featured Toaster Sources file, which is a typical Sources file for a simple KMDF driver:

TARGETNAME=wdffeatured
TARGETTYPE=DRIVER

KMDF_VERSION=1.5

INF_NAME=wdffeatured
MISCFILES=$(OBJ_PATH)\$(0)\$(INF_NAME) .inf
INCLUDES = $(INCLUDES) ;..\..\inc;..\shared

NTTARGETFILES=
NTTARGETDILE0=mofcomp

#
# List of source files to compile.
#
SOURCES= \
toaster.rc \
toaster.c \
power.c \
wmi.c

C_DEFINES=

!include $(WDF_ROOT)\project.mk

The following list gives brief descriptions of the macros and environment variables in this file. For a complete list, see the WDK documentation.

  • TARGETNAME— Required. This macro specifies wdffeatured as the name to be used for output files such as the project’s .sys and .pdb files.

  • TARGETTYPE— Required. The build utility can be used to build a variety of binary types. This macro specifies which type of binary is to be built; DRIVER indicates a Kernel Mode Driver.

  • KMDF_VERSION— Required. This environment variable specifies the KMDF version number. This project uses KMDF version 1.5.

  • INF_NAME— Optional. INF_NAME is a custom macro for projects that use INX files. It specifies that the INF file that is generated from the projects INXwdffeatured.inf. file is to be named

  • MISCFILES— Optional. MISCFILES is a custom macro for projects that use INX files. It specifies where to place the INF file that is generated. In this example, the INF file is placed in the output folder with the other output files.

  • INNLUDES— Optional. This macro specifies the location of folders, other than the project folder, that contain header files. These are typically header files that are shared across multiple projects.

  • NTTARGETFILE0— Optional. This macro is used to specify additional targets and dependencies that are not covered by makefile.def. In this case, it is used for WMI-related aspects of the build.

  • SOURCES— Required. This macro lists the project’s source files. By default, the files must be on a single line. The backslash (\) is a line-continuation character that allows the files to be listed on separate lines.

  • C_DEFINES— Required for Unicode builds. Specifies any compile-time switches that must be passed to the C compiler.

3. The Build

The following procedure shows how to build Featured Toaster. For simplicity, assume that the WDK’s root folder is C:\WinDDK\6000.

1.
Launch the Windows 7 Checked Build Environment console window. It opens in the c:\WinDDK\6000 folder.

2.
Use cd to move to the project folder. The project folder is at C:\WinDDK\6000\src\kmdf\toaster\func\featured.

3.
Build the project by running the following command. This isn’t the only way to build the project, but it’s a commonly used set of flags.

build –ceZ

The output files go in the featured\objchk\w7_x86\i386 subfolder.

 
Others
 
- Windows 7 : Kernel Mode Installation and Build - WDK Build Tools, Build Environment, Building a Project
- System Center Configuration Manager 2007 : Using Microsoft Management Console 3.0 (part 3)
- System Center Configuration Manager 2007 : Using Microsoft Management Console 3.0 (part 2)
- System Center Configuration Manager 2007 : Using Microsoft Management Console 3.0 (part 1)
- Administering an Exchange Server 2007 Environment : Managing Exchange Server 2007 Remotely
- Administering an Exchange Server 2007 Environment : Administrative Tools
- Administering an Exchange Server 2007 Environment : Exchange Administrator Roles in Exchange Server 2007
- Sharepoint 2010 : Enterprise Content Management - Hierarchical File Plans and Folder-Based Retention, Records Center
- Sharepoint 2010 : Enterprise Content Management - In-Place Records Management
- Sharepoint 2010 : Enterprise Content Management - Enterprise Content Types
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us