SAMPLE: PhysMem.exe Gets Total Physical Memory Size

ID: Q186759


The information in this article applies to:


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 Software Library:

~ PhysMem.exe

Release Date: June-03-1998

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

Q119591 How to Obtain Microsoft Support Files from Online Services

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          : 
Version           : WINNT:3.51,4.0;
Platform          : winnt 
Issue type        : 

Last Reviewed: March 4, 1999