## The POWTRACE Sample

The POWTRACE Sample accompanies Chapter 16 and provides a way to trace power management IRPs in a device stack.

The sample includes one component:

- POWTRACE.SYS is a WDM lower filter driver.

### Building POWTRACE

To build POWTRACE.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project file is named SYS\POWTRACE.DSP.

### Testing POWTRACE

Right-click on the SYS\POWTRACE.INF file and select the Install choice from the context menu. Setup will copy POWTRACE.SYS into the Drivers directory, and it will define the POWTRACE service. Note that you should not use FASTINST or the Add New Hardware wizard to install POWTRACE.SYS.

Now edit the registry by hand to add POWTRACE as a lower filter for some device. The next time you start this device, POWTRACE.SYS will print debugging messages for IRPs related to power management. You’ll need to be running a debugger or DbgView to see these messages. You can restart most devices in Windows XP by disabling and then reenabling them. In Windows 98/Me, you generally need to reboot the computer.

### What to look for

POWTRACE is probably more useful as a tool than as a sample. All the code is in the DriverEntry.cpp file if you want to see how it works.