Unable to solve BytesNeeded and unable to clear address list in NDIS Test

I am currently trying to pass " 2c_oidsndisrequest " HLK test for my network driver . When i run this test , my driver failed to pass this test case . Using HLK Logs i can see that error as

Errors :

Testing OID_GEN_SUPPORTED_LIST

  • BytesNeeded is not a multiple of 4

Testing unknown length OID OID_802_3_MULTICAST_LIST

  • Unable to clear multicast address list. NdisStatus = 0xC0010009

But i am handling these OID’s inside mini port driver is like this :

miniport.cpp

ULONG Id = 0 ;
MaximumListSize = 32;
SupportedOidsSize = 45;
SupportedOids = new NDIS_OID[SupportedOidsSize];
SupportedOids[Id++] = OID_GEN_SUPPORTED_LIST;
SupportedOids[Id++] = OID_802_3_MAXIMUM_LIST_SIZE;
etc…

NDIS_STATUS CMiniport::OidRequest(
__in PNDIS_OID_REQUEST OidRequest
) {

NDIS_STATUS status = NDIS_STATUS_SUCCESS;

if ((OidRequest->RequestType == NdisRequestQueryInformation) || (OidRequest->RequestType == NdisRequestQueryStatistics)) {

PVOID pInformation = NULL;
ULONG ulInformationLength = 0;
ULONG ulZerro = 0;

switch (OidRequest->DATA.QUERY_INFORMATION.Oid) {

case OID_GEN_SUPPORTED_LIST:
pInformation = (PVOID)SupportedOids;
ulInformationLength = sizeof(SupportedOids);
//OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof(ULONG64);
break;

… etc … OID’s


case OID_802_3_MAXIMUM_LIST_SIZE:
pInformation = &MaximumListSize;
ulInformationLength = sizeof(MaximumListSize);
break;

default:
status = NDIS_STATUS_NOT_SUPPORTED;
break;

}

if (pInformation != NULL) {
if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength < ulInformationLength) {
OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = ulInformationLength;
status = NDIS_STATUS_BUFFER_TOO_SHORT;
}
else
{
NdisMoveMemory(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer, pInformation, ulInformationLength);
OidRequest->DATA.QUERY_INFORMATION.BytesWritten = ulInformationLength;
status = NDIS_STATUS_SUCCESS;
}
}
}
else if (OidRequest->RequestType == NdisRequestSetInformation) {

switch (OidRequest->DATA.SET_INFORMATION.Oid) {
case OID_802_3_MULTICAST_LIST:
break;
}
}

return status;
}

I don’t know what mistake i made . i tried to add

OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof(ULONG64);

as BytesNeeded in OID_GEN_SUPPORTED_LIST Oid’s .

I am not handling anything in OID_802_3_MULTICAST_LIST . just skip it . If i add NDIS_STATUS_NOT_SUPPORTED in OID_802_3_MULTICAST_LIST , still i got same error in HLK Test .

Any suggestions ?

Thanks

Could this be your problem? From the MSDN:
“Miniport drivers that support multicast address lists must support OID_802_3_MULTICAST_LIST set requests.”

you can’t just drop it, you may need to send it on down to lower drivers if there are any or do a proper completion.

Larry C

ulInformationLength = sizeof(SupportedOids);

This line is wrong. Read up on what sizeof means.

@Larry Clawson

Yeah . got it . i should send it on down to lower drivers . i am working on it .

@Alex Grig

supported required bytes


OID_GEN_SUPPORTED_LIST, Query Arr(4)

sizeof(SupportedOids) , that means it return 4 bytes . isn’t ? i am sending ulInformationLength 4 bytes . then what is wrong with this ?
Any mistakes ?

  1. sizeof(SupportedOids)==sizeof(NDIS_OID*)==8
  2. The request returns an array of OIDs into the NDIS-provided buffer, and returns size of an array.
    You are allocating your own buffer and trying to return a pointer to it. This is not going to work.

So should i change to

sizeof(SupportedOids) * SupportedOidsSize = ?

Here SupportedOidsSize = size of supported list = 45 .

But most of the sample codes

https://github.com/Microsoft/Windows-driver-samples/blob/master/network/ndis/mux/driver/60/miniport.c

Doing same concept like sizeof(SupportedOids) . Is it different with my array ?

What you’re doing, which is dynamically locating an array of NDIS_OID items in pool using the c++ new operator, is totally different than the second sample you reference, which statically allocates an array as global memory. The size of your pointer is 4/8 bytes, the size of the static global array is size of(NDIS_OID)*nbr of elements. If you return the size of your pointer, the OS has no way of knowing how many elements in the array. You need to return the size of what your pointer points at.

Jan


From: xxxxx@lists.osr.com on behalf of xxxxx@gmail.com
Sent: Thursday, January 12, 2017 11:17:56 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Unable to solve BytesNeeded and unable to clear address list in NDIS Test

So should i change to

sizeof(SupportedOids) * SupportedOidsSize = ?

Here SupportedOidsSize = size of supported list = 45 .

But most of the sample codes

https://github.com/Microsoft/Windows-driver-samples/blob/master/network/ndis/mux/driver/60/miniport.c

Doing same concept like sizeof(SupportedOids) . Is it different with my array ?


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:>

>So should i change to sizeof(SupportedOids) * SupportedOidsSize = ?

I would recommend that you take “Programming in C 101” course first.

> I would recommend that you take “Programming in C 101” course first.

As someone ( I cannot immediately recall this poster’s name but I think it rhymes
with “Jim Floberts”) is so fond of saying, we were all inexperienced once…

Anton Bassov

>we were all inexperienced once

…then we learned to program C…

> …then we learned to program C…

Fair enough - the story with this particular OP and his NDIS driver is truly unique. I think that even above mentioned mega-patient poster had eventually given up on him at least a year ago,and IIRC, even gave him a trashing on a couple of occasions before finally turning his back to him for good…

Anton Bassov

Yeah . I solved this supported OID List error . Thank you all for your valuable suggestions .