NDIS (minor) bugs...

Some minor bugs I have found along the way…

o Compiler/PreFast does not do strict type checking - did not
locate/warn about passing in a BOOLEAN in a prototype of ULONG:

NdisMSendNetBufferListsComplete(…, …, );

Perhaps they can’t; both types probably resolve to an unsigned long?

o Documentation: http://msdn.microsoft.com/en-us/library/ee206723.aspx
has multiple repeated elements in the displayed structure.

o Documentation: No references in the online docs to some useful
macros:

NDIS_TEST_RETURN_AT_DISPATCH_LEVEL()
NDIS_TEST_SEND_AT_DISPATCH_LEVEL()

Best,
-PWM

BOOLEAN is USHORT (or unsigned char) which promotes silently under C rules
to ULONG (or unsigned long). What do you want? A new language? :wink:

The bonus repetition for effect is just one side-effect of template driven
display. “A computer can make more mistakes in a millisecond than a person
can make in a lifetime.” Well, templates just improved that effectiveness!

You will be real impressed with the many under documented useful macros in
the WDF headers, NTDDK.H, etc. The header files have always proven to be
useful sources of ‘documentation’ in their own right.

Cheers,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter W. Morreale
Sent: Wednesday, January 27, 2010 4:53 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NDIS (minor) bugs…

Some minor bugs I have found along the way…

o Compiler/PreFast does not do strict type checking - did not
locate/warn about passing in a BOOLEAN in a prototype of ULONG:

NdisMSendNetBufferListsComplete(…, …, );

Perhaps they can’t; both types probably resolve to an unsigned long?

o Documentation: http://msdn.microsoft.com/en-us/library/ee206723.aspx
has multiple repeated elements in the displayed structure.

o Documentation: No references in the online docs to some useful
macros:

NDIS_TEST_RETURN_AT_DISPATCH_LEVEL()
NDIS_TEST_SEND_AT_DISPATCH_LEVEL()

Best,
-PWM


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

With respect to NDIS_TEST_RETURN_AT_DISPATCH_LEVEL and related omissions…

Most of us consider the WDK Ndis.h file to be a supplement to the
documentation. Go there pretty often…

Thomas F. Divine
http://www.pcausa.com


From: “Peter W. Morreale”
Sent: Wednesday, January 27, 2010 4:53 PM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] NDIS (minor) bugs…

>
> Some minor bugs I have found along the way…
>
>
> o Compiler/PreFast does not do strict type checking - did not
> locate/warn about passing in a BOOLEAN in a prototype of ULONG:
>
> NdisMSendNetBufferListsComplete(…, …, );
>
> Perhaps they can’t; both types probably resolve to an unsigned long?
>
>
> o Documentation: http://msdn.microsoft.com/en-us/library/ee206723.aspx
> has multiple repeated elements in the displayed structure.
>
> o Documentation: No references in the online docs to some useful
> macros:
>
> NDIS_TEST_RETURN_AT_DISPATCH_LEVEL()
> NDIS_TEST_SEND_AT_DISPATCH_LEVEL()
>
>
> Best,
> -PWM
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

>

With respect to NDIS_TEST_RETURN_AT_DISPATCH_LEVEL and related
omissions…

Most of us consider the WDK Ndis.h file to be a supplement to the
documentation. Go there pretty often…

Or the other way around. If ndis.h says one thing and the documentation
says another, which one do you think is wrong? :slight_smile:

James

“Peter W. Morreale” wrote in message
news:xxxxx@ntdev…
>
> Some minor bugs I have found along the way…
>
>
> o Compiler/PreFast does not do strict type checking - did not
> locate/warn about passing in a BOOLEAN in a prototype of ULONG:
>
> NdisMSendNetBufferListsComplete(…, …, );
>
> Perhaps they can’t; both types probably resolve to an unsigned long?

BOOLEAN is defined as UCHAR, so it naturally casts to ULONG without
warnings.

–pa

>From the SDK:

“BOOL:
Boolean variable (should be TRUE or FALSE).
This type is declared in WinNT.h as follows:
typedef int BOOL;;”

“BOOLEAN:
Boolean variable (should be TRUE or FALSE).
This type is declared in WinNT.h as follows:
typedef BYTE BOOLEAN;”

I forget about this often, which is a disaster when Marshalling under
managed languages. For alignment efficiency these days using BOOLEAN (a
byte) should be banned.

Thomas F. Divine
http://www.pcausa.com


From: “David R. Cattley”
Sent: Wednesday, January 27, 2010 4:59 PM
To: “Windows System Software Devs Interest List”
Subject: RE: [ntdev] NDIS (minor) bugs…

> BOOLEAN is USHORT (or unsigned char) which promotes silently under C rules
> to ULONG (or unsigned long). What do you want? A new language? :wink:
>
> The bonus repetition for effect is just one side-effect of template driven
> display. “A computer can make more mistakes in a millisecond than a
> person
> can make in a lifetime.” Well, templates just improved that
> effectiveness!
>
> You will be real impressed with the many under documented useful macros in
> the WDF headers, NTDDK.H, etc. The header files have always proven to be
> useful sources of ‘documentation’ in their own right.
>
> Cheers,
> Dave Cattley
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Peter W. Morreale
> Sent: Wednesday, January 27, 2010 4:53 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] NDIS (minor) bugs…
>
>
> Some minor bugs I have found along the way…
>
>
> o Compiler/PreFast does not do strict type checking - did not
> locate/warn about passing in a BOOLEAN in a prototype of ULONG:
>
> NdisMSendNetBufferListsComplete(…, …, );
>
> Perhaps they can’t; both types probably resolve to an unsigned long?
>
>
> o Documentation: http://msdn.microsoft.com/en-us/library/ee206723.aspx
> has multiple repeated elements in the displayed structure.
>
> o Documentation: No references in the online docs to some useful
> macros:
>
> NDIS_TEST_RETURN_AT_DISPATCH_LEVEL()
> NDIS_TEST_SEND_AT_DISPATCH_LEVEL()
>
>
> Best,
> -PWM
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

Don’t forget that “undocumented” functions – on a system that actually HAS official documentation for driver development, ahem – puts these functions in a particular category… regardless of whether they’re useful or included in ndis.h – Mr. Divine and Mr. Cattley implicitly understand this.

There are numerous undocumented yet useful such functions defined in the headers. Here in the community, and even in the WDK team internally, we strive to either get them documented, deprecate them, mark them as INTERNAL USE ONLY, or remove them from the headers. But this is always not possible (or even desirable, frankly).

Peter
OSR

I’d go with the header file since it is what the OS and your code is
compiled with.

(Of course, keeping old WDK/DDK documentation forever is a good crutch.)

Thomas F. Divine
http://www.pcausa.com


From: “James Harper”
Sent: Wednesday, January 27, 2010 5:06 PM
To: “Windows System Software Devs Interest List”
Subject: RE: [ntdev] NDIS (minor) bugs…

>>
>> With respect to NDIS_TEST_RETURN_AT_DISPATCH_LEVEL and related
> omissions…
>>
>> Most of us consider the WDK Ndis.h file to be a supplement to the
>> documentation. Go there pretty often…
>>
>
> Or the other way around. If ndis.h says one thing and the documentation
> says another, which one do you think is wrong? :slight_smile:
>
> James
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

Certainly Peter is right. Don’t go to the header files to find interesting
things. Docs first, then the headers.

BUT, in the NDIS world even the Microsoft-provided samples reference things
(most often MACROs or definitions…) that aren’t documented. The header
files are essential then.

(Of course, keeping old WDK/DDK headers forever can also provide useful
insight…)

Thomas


From:
Sent: Wednesday, January 27, 2010 5:23 PM
To: “Windows System Software Devs Interest List”
Subject: RE:[ntdev] NDIS (minor) bugs…

>


>
> Don’t forget that “undocumented” functions – on a system that actually
> HAS official documentation for driver development, ahem – puts these
> functions in a particular category… regardless of whether they’re useful
> or included in ndis.h – Mr. Divine and Mr. Cattley implicitly understand
> this.
>
> There are numerous undocumented yet useful such functions defined in the
> headers. Here in the community, and even in the WDK team internally, we
> strive to either get them documented, deprecate them, mark them as
> INTERNAL USE ONLY, or remove them from the headers. But this is always
> not possible (or even desirable, frankly).
>
> Peter
> OSR
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

> o Compiler/PreFast does not do strict type checking - did not

locate/warn about passing in a BOOLEAN in a prototype of ULONG:

Passing smaller integer type in a prototype as faster is a correct C construct, called “integral promotion”.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

On Wed, 27 Jan 2010 17:23:30 -0500 (EST)
xxxxx@osr.com wrote:

There are numerous undocumented yet useful such functions defined in
the headers. Here in the community, and even in the WDK team
internally, we strive to either get them documented, deprecate them,
mark them as INTERNAL USE ONLY, or remove them from the headers. But
this is always not possible (or even desirable, frankly).

I noticed that there are some functions that only appear in the online
MSDN pages. For example ULongToPtr, HandleToULong etc. only seem
to be in “The New Data Types” at
http://msdn.microsoft.com/en-us/library/aa489638.aspx and in “The
Tools” at http://msdn.microsoft.com/en-us/library/aa384267(VS.85).aspx .

Should they also be in the offline help file installed with the WDK
and appear in the index? If so, is the WDK connection the correct place
to log it as an issue?


Bruce Cran

I see the functions you mentioned in the offline docs that I use (the jumbo chm, dated ‘Built on August 06, 2009’). The don’t appear to be in the index, but that isn’t the most unusual thing either.

What version of the wdk are you using offline? There have been a few doc updates published on the wdk docs team blog; perhaps they were added then?

http://blogs.msdn.com/wdkdocs/archive/2010/01/22/documentation-updates.aspx

Apparently they just released an update.

mm

On Thu, 28 Jan 2010 10:31:00 -0500 (EST)
xxxxx@evitechnology.com wrote:

I see the functions you mentioned in the offline docs that I use (the
jumbo chm, dated ‘Built on August 06, 2009’). The don’t appear to be
in the index, but that isn’t the most unusual thing either.

What version of the wdk are you using offline? There have been a few
doc updates published on the wdk docs team blog; perhaps they were
added then?

http://blogs.msdn.com/wdkdocs/archive/2010/01/22/documentation-updates.aspx

Apparently they just released an update.

Sorry, I did a search and didn’t notice that “The New Data Types” was
actually found in Local Help too. I’m using the version of docs from
June 18th, I’m downloading the new chm file now.


Bruce Cran