Frequently Asked Questions

Q. How can I find the hardware address of a NDIS MAC adapter?
 

A. There are a variety of methods available to determine the hardware address of installed NDIS MAC adapters. Here are the methods that PCAUSA is aware of:

Method Limitation

Query The MAC Driver Directly From A Win32 Application

On the Windows NT platform it is possible for a Win32 application to query a NDIS MAC driver for certain types of information. The query is made using the IOCTL_NDIS_QUERY_GLOBAL_STATS DeviceIoControl call.

The Windows NT DDK MACADDR sample shows how to make this call. You can also see the PCAUSA MACADDR II sample, which illustrates the same technique for Windows 2000.

NT/W2K Only
Query The MAC Driver Indirectly Using A Helper NDIS Protocol Driver

A NDIS protocol driver can use the NdisRequest function to query a bound adapter for it's hardware address. It is possible to develop a dynamically loadable NDIS protocol driver to assist Win32 applications in asking the NDIS MAC adapter driver for it's address.

This is the method used by the NDIScope application of PCAUSA's Win32 NDIS Framework.

Must have protocol driver for each platform.

Use The CoCreateGuid Function

The lower six bytes of the 128-bit GUID created by the CoCreateGuid function is the Ethernet or Token-ring hardware address for the computer.

If multiple adapters are installed, then this function returns one of the adapter hardare addresses in the lower six bytes; however, it does not provide any indication that there are, in fact, multiple installed adapters nor does it provide any way to specify which adapter address is returned in the lower six bytes of the GUID.

Note: This method fails on Windows 2000 because the function has been re-defined, for security reasons, to prevent the generated GUID from being traceable to the adapter; the bytes of interest are different for each call to CoCreateGuid.

However, Microsoft has introduced a new function, UuidCreateSequential, which behaves as CoCreateGuid did on previous versions.

Indeterminate result when multiple adapters are installed.

Use The NETBIOS API

If the workstation has the NETBIOS protocol installed, then adapter hardware addresses can be determined using the NETBIOS API.

Microsoft Knowledge Base Article Q118623, "HOWTO: Get the MAC Address for an Ethernet Adapter", also discusses this technique.

Here is a code fragment provided by David Goldberg:

Using NETBIOS To Get MAC Address

NETBIOS protocol must be installed.

Use the GetAdaptersInfo function

This function is one of the "IP Helper API" functions.

Documentation for GetAdaptersInfo is not included with Microsoft Visual C++ (at least through VC++ 6.0). However, documentation for GetAdaptersInfo, necessary import libraries and samples that illustrate use of the IP Helper API can be found in the Platform SDK.

 

Windows 98, Windows Me, Windows 2000 and Windows XP.

Use the GetIfTable or GetIfEntry functions

These functions are also "IP Helper API" functions.

Both of these functions can be used to fetch a MIB_IFROW structure, which includes the MAC address as the bPhysAddr member.

 

Windows 98, Windows Me, Windows NT SP 4, Windows 2000 and Windows XP.

Use the SendArp function

This function is one of the "IP Helper API" functions.

Documentation for SendArp is not included with Microsoft Visual C++ (at least through VC++ 6.0). However, documentation for SendArp, necessary import libraries and samples that illustrate use of the IP Helper API can be found in the Platform SDK.

SendArp can be used to find that MAC address of the local host if you pass in a local host IP address (other then the loopback address).

The primary se of SendArp is to find the MAC address of a remote host on the local network.

 

Windows 2000 and Windows XP only.

Use Windows Management Instrumentation API (WMI)

WMI  can be used to fetch the Ethernet current address. Use the root\WMI namespace and examine the MSNdis class for properties of the class MSNdis_EthernetCurrentAddress.

See the topic:

How do I query NDIS miniport OIDs using WMI?

 

Windows 98 and higher, if WMI support installed.

Use the Simple Network Management Protocol (SNMP)

SNMP can be used to fetch this information. See the information about this on the Winsock FAQ.

Using SNMP To Get MAC Address

 

All???

 

 

Topic Status

January 22, 2003 Clarified that GetAdaptersInfo is not available on Windows NT.
January 20, 2003 Added mention of WMI and SendArp function.
January 3, 2003 Moved to NDIS.COM.
2001 Information posted.
 

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-2007 Printing Communications Assoc., Inc. (PCAUSA)
Last modified: January 20, 2007