if (hMAC != INVALID_HANDLE_VALUE)
{
//
// We successfully opened the driver, format the IOCTL to pass the
// driver.
//
OidCode = OID_802_3_CURRENT_ADDRESS;
if (DeviceIoControl(
hMAC,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&OidCode,
sizeof(OidCode),
OidData,
sizeof(OidData),
&ReturnedCount,
NULL
))
{
if (ReturnedCount == 6)
{
printf(
"Mac address = %02.2X-%02.2X-%02.2X-%02.2X-%02.2X-%02.2X\n",
OidData[0], OidData[1], OidData[2], OidData[3],
OidData[4], OidData[5], OidData[6], OidData[7]
);
}
else
{
printf(
"DeviceIoControl returned an invalid count = %d\n",
ReturnedCount
);
}
}
else
{
printf("DeviceIoControl returned an error = %d\n", GetLastError());
}
}
else
{
printf("CreateFile returned an error = %d\n", GetLastError());
}
if (bCreatedDevice)
{
//
// The MAC driver wasn't visible in the Win32 name space so we created
// a link. Now we have to delete it.
//
if (!DefineDosDevice(
DDD_RAW_TARGET_PATH and DDD_REMOVE_DEFINITION and
DDD_EXACT_MATCH_ON_REMOVE,
argv[1],
DeviceName)
)
{
printf(
"DefineDosDevice returned an error removing the device = %d\n",
GetLastError()
);
return(1);
}
}