Ever have one of those nights when you lay awake and slowly convince
yourself that you no longer know anything? Well, lately, it has not taken
very much effort …
To wit:
The WDK Docs state quite clearly that for calls to
MiniportQueryInformation() if the supplied buffer length does not match the
required buffer length, the function should return
NDIS_STATUS_INVALID_LENGTH and place the required buffer length in
*BytesNeeded. Strangely, the older W2K3 DDK docs say that either
NDIS_STATUS_INVALID_LENGTH or NDIS_STATUS_BUFFER_TOO_SHORT are returned in
this case. I am not sure I understand the change in docs other than
perhaps the WDK team gets charged by the letter by MSDN to host the
documentation.
Well, for as long as I can remember (oh, lately, about 45 seconds or so),
MiniportQueryInformation() would typically return
NDIS_STATUS_BUFFER_TOO_SHORT in cases where the buffer was too small.
A quick survey of WDK samples shows that both the left and right hands at
MSFT are also just as tied in knots as my weak brain at this point since in
some samples you have one and other samples the other being returned from
MiniportQueryInformation(). Although I feel I am in good company, I still
don’t know how to recover my sanity.
As I think back (through the fog) I recall that the meaning of these two
return values was something like the following:
NDIS_STATUS_INVALID_LENGTH - the buffer you gave me is the wrong size. I
have written nothing or read nothing from it. The request is unprocessed.
I am giving you back the expected size so that you can try again, perhaps
getting it right the next time. Good Luck.
NDIS_STATUS_BUFFER_TOO_SHORT - the buffer you gave me is too short. I may
or may not have written or read a partial result from it. Check the
*BytesRead/*BytesWritten return if you care. In any event, I have returned
the length of the buffer that would allow the entire result to fit in
*BytesRequired. If you wish to try again, perhaps you could send me a
buffer of at least that size next time.
So let’s say that a protocol queries OID_802_3_CURRENT_ADDRESS and supplies
a request buffer with length less than ETH_ADDRESS_LEN (that is 6 for you
marketing types who read this list trying to play along .) , I would expect
NDIS_STATUS_INVALID_LENGTH but I cannot say that
NDIS_STATUS_BUFFER_TOO_SHORT is wrong.
However, for an OID_802_11_BSSID_LIST query that has *at least* the required
number of bytes to hold the header of the result, I would expect that if all
the BSSID entries did not fit in the supplied buffer, that the result could
plausibly be NDIS_STATUS_BUFFER_TOO_SHORT and maybe (depending on the
Miniport) the buffer would get a partial list. This could, of course, be
fantasy and I have no intentions of testing it. I use it as an illustration
of what I once thought the difference between the two status codes were.
Now the real question, of course, is what is NDIS expecting, what is WHQL
and NDISTest expecting, and just what is going to get me back to a restful
sleep tonight (Bookers, Bakers or Basil Haden perhaps)?
So if any of you can help me out here with a definitive clarification, I
greatly appreciate it. If it turns out that (as I have been apparently
treating it for 15+ years) that it does not matter, well, that is great too.
Cheers,
-dave