Using WMI to Query
NDIS Miniport OIDs
 

Background

At first glance the breadth of the information associated with Windows Management Instrumentation (WMI) appears as overwhelming as the problem it attempts to solve: scalable local and remote system management of a wide variety of hardware devices and software using a single consistent, standards-based, extensible, object-oriented interface.

This article provides a quick look into WMI in the specific context of NDIS OIDs.

The examples will focus on fetching the NDIS MediaConnectedState because this is a frequent inquiry. Do understand, however, that the MediaConnectedState is of dubious value.

 

Useful Terminology

Although not technically accurate, it helps to think of the WMI in terms of a database. Definitions of WMI terms, and the corresponding concept in database terminology are in the following list.

Term Definition Database Term
Namespace A collection of classes. Database
Class Describes data types in a schema. Object class definition. Table
Property A single attribute of a class. Column
Instance One object of this class type Row
Value The data for a property of a specific instance. Field

Of course, the WMI database is multi-dimensional. Instance objects may be sub-classed in a hierarchical fashion.

The first step in answering this topic's question is to identify the namespace and superclass (top-level class) that specifies NDIS-specific objects. Focus on:

Namespace
root\WMI - Windows Management Instrumentation
 
Superclass
MSNdis - Microsoft NDIS Class

 

Exploring MSNdis Classes Using wbemtest Tool

The Microsoft WBEMTest tool is a utility which provides a GUI you can use to query for WMI classes and class instances, change property values, execute methods, and receive event notifications. If WMI and Web-Based Enterprise Management (WBEM) is installed on your system, then you should have WBENTest already installed as well.

NOTE: WBEMTest is a comprehensive test tool that displays much more detail then is really needed for an introduction to WMI. However, since it is readily available it will be used for the initial exploration.

 Follow these directions to get started with WBEMTest:

  1. Click Start and then click Run....
  2. Enter wbemtest in the Open edit field. Then press OK.
  3. In the Windows Management Instrumentation Tester press Connect....
  4. In the Connect dialog enter root/WMI in the Namespace field and then press Connect.
  5. In the Windows Management Instrumentation Tester press Enum Classes....
  6. In the Superclass Info dialog enter MSNdis and then press OK.

You should now see the Query Result dialog showing the child classes of MDNdis:

[ View Query Result Dialiog ]

 

The Query Results dialog lists the (class) names of each information object registered by the NDIS WMI provider. Most of these object have a one-to-one correspondence with NDIS object identifiers (OIDs), defined in the DDK Help file.

For example, the MSNdis_MediaConnectStatus class is the WMI object that corresponds to the NDIS OID OID_GEN_MEDIA_CONNECT_STATUS. This OID returns the connection status of the NIC on the network:

bullet

NdisMediaStateConnected (0)

bullet

NdisMediaStateDisconnected (1)

 

If you double click on the MSNdis_MediaConnectStatus class name you bring up the wbemest Object Editor dialog. The key information provided by this dialog are the Properties (that do not begin with double underscore):

bullet

InstanceName - A string

bullet

NdisMediaConnectStatus - A unit32

[ View Object editor for MSNdis_MediaConnectStatus ]

 

Press the Instances button on the Object editor to bring up a list of the the instances of MSNdis_MediaConnectStatus that are being managed. Each instance corresponds to a specific NDIS miniport.

Finally, double click on an instance to see its properties (values):

 

The instance that was selected in the example is identified by these properties:

InstanceName

National Semiconductor Corp. DP83815 10/100 MacPhyter3v PCI Adapter
 

NdisMediaConnectStatus

The value 0 (0x0), which corresponds to NdisMediaStateConnected.

 

Windows DDK WMI Client Samples

The DDK includes two WMI client sample applications under the src\genera\wmicli directory. Both of these include source code, so they are decent references for building your own WMI client applications.

The GUI version (wmicli) is much simpler then the WBEMTest tool, but adequate for exploring MSNdis WMI classes.

The console version (wmicon) is a little more difficult to use because one command-line parameter is a specific InstanceName - which is long and unwieldy to enter from the keyboard. I suggest writing a batch file that calls wmicon.

Here is he  IsConnected.bat batch file used on one machine to fetch NdisMediaZConnectStatus property value using the DDK wmicon sample application:

wmicon root\WMI MSNdis_MediaConnectStatus "MSNdis_MediaConnectStatus.InstanceName=\"Intel(R) 82559 Fast Ethernet LAN on Motherboard\"" NdisMediaConnectStatus

(Sorry. All 158 characters should be on one line...)

Here is the output from wmicon for this case:

Class: MSNdis_MediaConnectStatus
Instance: MSNdis_MediaConnectStatus.InstanceName="Intel(R) 82559 Fast Ethernet LAN on Motherboard"

Property: NdisMediaConnectStatus

Property Type: uint32
Property Value: 0

 

Using C# for WMI Client Applications

Actually, it looks like C# is well suited for writing WMI client applications. A simple C# console application that enumerates all instances of MSNdis_MediaConnectStatus can be written in less then 60 lines of code. You can look at the source:

[ IsConnected C# Source ]

If you attempt to build IsConnected C# application, be sure to add references to the mscorelib and System.Management assemblies.

The output from IsConnected is crude, but adequate:

Active: True
InstanceName: GA622T Gigabit UTP Adapter
NdisMediaConnectStatus: 0
Active: True
InstanceName: WAN Miniport (IP)
NdisMediaConnectStatus: 0
Active: True
InstanceName: WAN Miniport (IP) - Packet Scheduler Miniport
NdisMediaConnectStatus: 0
Active: True
InstanceName: Intel(R) 82559 Fast Ethernet LAN on Motherboard
NdisMediaConnectStatus: 0
Active: True
InstanceName: Intel(R) 82559 Fast Ethernet LAN on Motherboard - Packet Scheduler Miniport
NdisMediaConnectStatus: 0
 

In this case all adapters report that they are connected to the network. (Actually a misleading result since no WAN connections were active when the test was run...)

 

Using ATL COM Object Using Events To Indicate Line State

Arkady Frenkel, a Microsoft MVP in the Windows SDK/Networking area, has provided a more sophisticated WMI sample that includes an ATL COM object that signals an event to a companion MFC client application when the line state (NdisMediaConnectedState) changes.

This sample is certainly over my head, so I appreciate Arkady's contribution.

See the topic "How to check line state using WMI with C/C++".

 

Additional Information

Read-Only OIDs

Some NDIS OIDs are query-only, and cannot be set. Since WMI is basically a convoluted wrapper around NDIS OIDs, it make perfect sense that WMI properties that correspond to query-only NDIS OIDs would be read-only.

For example, link speed is an operational characteristic of a network adapter.

The DDK documentation for OID_GEN_LINK_SPEED specifies that is is query-only, and can be fetched by making a NDIS query on OID_GEN_LINK_SPEED. You can fetch the same information with WMI by fetching the MSNdis_LinkSpeed property for an adapter.

However, you cannot set link speed using NDIS or by WMI.

 

WMI on Windows 9X/ME 

There are some "quirks" associated with WMI and NDIS on Windows 9X/ME.

See Microsoft Knowledge Base Article Q322363 - "INFO: Windows Management Instrumentation (WMI) on Computers Running Windows 98, Windows 98 Second Edition, and Windows Millennium Edition".

 

Some NDIS OIDs Are Not Exposed Via WMI

An example of a NDIS OID that is not exposed via WMI is OID_GEN_TRANSMIT_QUEUE_LENGTH.

This limitation may be addressed in future Windows versions.

 

Topic Status

November 3, 2009 Re-posted on.
February 18, 2003 Added comment that some NDIS OIDs are not exposed via WMI..
January 24, 2003 Added comment about read-only OIDs.
January 6, 2003 Initial release.

 

 

PCAUSA Home · Privacy Statement · Products · Ordering · Support · Utilities · Resources
Mailing Lists  · PCAUSA Newsletter · PCAUSA Discussion List
Rawether for Windows, Rawether .NET, WinDis 32 and NDIS Press are trademarks of Printing Communications Assoc., Inc. (PCAUSA)
Microsoft, MS, Windows, Windows Vista, Windows 95, Windows 98, Windows Millennium, Windows 2000, and Win32 are registered trademarks and Visual C++ and Windows NT are trademarks of the Microsoft Corporation.
Copyright © 1996-2010 Printing Communications Assoc., Inc. (PCAUSA)
Last modified: January 17, 2010