Microsoft KB Archive/186759

{|
 * width="100%"|

SAMPLE: PhysMem.exe Gets Total Physical Memory Size

 * }

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:

"PhysMem.exe" Release Date: Jun-03-1998

For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

"Q119591 How to Obtain Microsoft Support Files from Online Services" Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

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

Issue type :

Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT351 kbWin32DDKNT400 kbWin32DDKNTSearch