## The MEMTEST Sample

The MEMTEST Sample accompanies Chapter 3 and determines how much memory can be allocated from the paged and nonpaged pools.

The sample includes two components:

- MEMTEST.SYS (SYS subdirectory) is a WDM driver for a non-existent device.
- TEST.EXE (TEST subdirectory) is a Win32 console application that tests the MEMTEST driver.

### Building MEMTEST

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

To build TEST.EXE, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project file is named TEST.DSP in the TEST subdirectory.

### Testing MEMTEST

First arrange a way to see debug messages. You can run under control of a kernel debugger such as Soft-Ice, or you can run Mark Russinovitch’s DbgView utility (see http://www.sysinternals.com).

Now install MEMTEST.SYS. Follow the instructions for using FASTINST in either Windows XP or Windows 98/Me. The INF file is named SYS\MEMTEST.inf.

Finally, open a DOS prompt and navigate to the TEST\DEBUG subdirectory. Issue the "TEST" command, which will use a DeviceIoControl to perform the test. MEMTEST.SYS will use a binary search to determine the largest single block it can allocate of paged and nonpaged memory, respectively, and will report the results in the debug trace output.

### What to look for

DoMemoryTest in Control.cpp is the function that actually attempts the memory allocations reported by the test program.