I am trying to pass AddressChnage test case in WHQL test for my virtual miniport driver . During the test i can see the error log like :
Check network addresses on the test adapter after modifying the registry with new network address
-------------------------------------------------------------------------------
Name: Test open for receiving
- RequestType: QueryInformation
- OID: OID_802_3_CURRENT_ADDRESS
- RequestId: 0
- BufferLength: 6
- Flags: 0x00000000
- PortNumber: 0
Results
- Status: NDIS_STATUS_SUCCESS (0x0)
- Bytes Written: 6
- Bytes Needed: 1737485104
Current address from test adapter is 0a-1b-3c-4d-5e-6f
New network address under test is 02-02-04-06-08-02
50009 **Current network address did not change after driver was reloaded. The driver should have picked up a new network address from the registry**.
For dummy mac , i am intiallty setting the MAC address . 0a-1b-3c-4d-5e-6f
PermenentAddress[0] = 0x0a
PermenentAddress[1] = 0x1b
PermenentAddress[2] = 0x3c
PermenentAddress[3] = 0x4d
PermenentAddress[4] = 0x5e
PermenentAddress[5] = 0x6f
But i am handling all the required calls during miniport initialization .
NDIS_STATUS InitializeEx(
__in NDIS_HANDLE MiniportAdapterHandle,
__in NDIS_HANDLE MiniportDriverContext ,
__in PNDIS_MINIPORT_INIT_PARAMETERS MiniportInitParameters
) {
NDIS_CONFIGURATION_OBJECT ndisConfigurationObject;
NdisZeroMemory(&ndisConfigurationObject, sizeof(NDIS_CONFIGURATION_OBJECT));
C_ASSERT(sizeof(NDIS_CONFIGURATION_OBJECT) >= NDIS_SIZEOF_CONFIGURATION_OBJECT_REVISION_1);
ndisConfigurationObject.Header.Type = NDIS_OBJECT_TYPE_CONFIGURATION_OBJECT;
ndisConfigurationObject.Header.Size = NDIS_SIZEOF_CONFIGURATION_OBJECT_REVISION_1;
ndisConfigurationObject.Header.Revision = NDIS_CONFIGURATION_OBJECT_REVISION_1;
ndisConfigurationObject.NdisHandle = MiniportAdapterHandle;
ndisConfigurationObject.Flags = 0;
NDIS_HANDLE Configuration = NULL;
status = NdisOpenConfigurationEx(&ndisConfigurationObject, &Configuration);
if (status != NDIS_STATUS_SUCCESS) {
return NDIS_STATUS_FAILURE;
}
//getting mac address from registry
UCHAR* MacAddress = NULL;
UINT MacAddressLength = 0;
NdisReadNetworkAddress(&status, (PVOID*) &MacAddress, &MacAddressLength, Configuration);
if ((status == NDIS_STATUS_SUCCESS) && (MacAddressLength == 6)) {
NdisMoveMemory(CurrentAddress, MacAddress, 6);
}
NdisCloseConfiguration(Configuration);
}
and adding to the miniort adapter :
NdisMoveMemory(ndisMiniportAdapterGeneralAttributes.PermanentMacAddress, PermenentAddress, 6);
NdisMoveMemory(ndisMiniportAdapterGeneralAttributes.CurrentMacAddress, CurrentAddress, 6);
Finally during the OID query request , i am passing the CurrentAddress and PermenentAddress values .
case OID_802_3_PERMANENT_ADDRESS:
Information = &PermenentAddress ;
InformationLength = sizeof(PermenentAddress);
break;
case OID_802_3_CURRENT_ADDRESS:
Information = &CurrentAddress ;
InformationLength = sizeof(CurrentAddress );
break;
This is the exact problem i am facing during the test . I don't know why i am facing the problem . I am handling NdisReadNetworkAddress
handler to get the registry values of the configuration . miniport initialize will invoke after the driver restart and set the registry values to the currentaddress . isn't ?
Then why this is failing ? Any other alternative method to invoke and getting mac address of the adapter ? I am using NDIS 6.2 miniport with Windows 7 and higher OS .