SAMPLE: PhysMem.exe Gets Total Physical Memory Size

ID: Q186759


The information in this article applies to:
  • Microsoft Win32 Device Driver Kit (DDK) for Windows NT, versions 3.51, 4.0


SUMMARY

PhysMem.exe is a sample driver that demonstrates how to get the total physical memory size in kernel-mode. The function GetPhysicalMemorySize in this driver uses Zw registry functions to query the registry and get this information.


MORE INFORMATION

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

PhysMem.exe
Release Date: Jun-03-1998

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

PhysMem.exe contains a sample driver source that shows how to get the total physical memory size in your device driver by querying the registry. Currently there are no documented DDK APIs to get this information. The driver has just DriverEntry, Unload, and GetPhysicalMemorySize routines.

The PhysMem.exe driver provides an example of a minimal driver. This is not intended to be used in a production environment. Rather, this sample is intended for educative purposes and as a skeleton driver.

Building the Driver and Examples

To compile the device driver:
  1. Start the checked or free build environment MS-DOS box.


  2. Run "BUILD". This invokes the Microsoft make routines. They produce log files called Build.wrn, and Build.log. The .wrn file contains warnings that no components have been extracted from certain libraries, even if the build succeeds. If it does succeed, the driver can be found in the %basedir%\lib\i386\free or %basedir%\lib\i386\checked directory.


  3. Copy the sys file to the %systemroot%\SYSTEM32\DRIVERS directory where all the Windows NT device drivers are stored.


To install the Sample driver use the REGINI utility to create the entries listed in the physmem.ini file.

Testing

  1. Restart the computer.


  2. Start the driver with "net start".


  3. if you run a checked build driver, debug print statements will show the results on the debugger.


Additional query words: kbDSupport kbdsh kbNoKeyword

Keywords : kbfile
Version : winnt:3.51,4.0
Platform : winnt
Issue type :


Last Reviewed: December 4, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.