## The BUGCHECK Sample

The BUGCHECK Sample accompanies Chapter 3 and illustrates how to invoke KeBugCheckEx.

The sample includes one components:

- BUGCHECK.SYS is a WDM driver for a non-existent device.

### Building BUGCHECK

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

### Testing BUGCHECK

I highly recommend that you make one or all of these prepatory actions before testing BUGCHECK:

- Download the SYNC.EXE tool from http://www.sysinternals.com. Run SYNC to flush all disk caches out to disk.
- Change the Startup and Recovery Settings in My Computer/Properties/Advanced to produce a kernel dump.
- Start a kernel debugger

Now use FASINST to install BUGCHECK.SYS. It will call KeBugCheckEx during DriverEntry. You can investigate the bug check in the debugger or after the fact from the crash dump.

### What to look for

DriverEntry registers a bug check callback and then calls KeBugCheckEx. Note that you're very unlikely to need to cause a bug check in a driver, but you might very well want to arrange a callback to record information critical to debugging failures through Online Crash Analysis or otherwise.