static driver verifier

Folks,

I have a kernel driver which is built using Windows Server 2003 SP1 DDK. I use
prefast ( V 1.5 ) often on the driver code. I would like to use Static Driver Verifier.
But I think it’s not available for WS2003 SP1 DDK.
So my question is can I take Sdv binaries from WDK and just put it in the Server 2003 Sp1 DDK folder and start using it? Also can I use prefast latest version from WDK and use it as well?

I would appreciate if ppl can share their experiences with using SDV on their driver.

Thanks,
Shan.

Why don’t you shift to the current WDK? I know there are reasons that are
valid not to do this, but since you are using essentially an obsolete DDK
without any of the support for either Prefast or SDV that the includes give
it may be time to think about it. Note the current WDK Prefast will find a
lot more bugs than the Prefast you are using.


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

wrote in message news:xxxxx@ntdev…
> Folks,
>
> I have a kernel driver which is built using Windows Server 2003 SP1 DDK. I
> use
> prefast ( V 1.5 ) often on the driver code. I would like to use Static
> Driver Verifier.
> But I think it’s not available for WS2003 SP1 DDK.
> So my question is can I take Sdv binaries from WDK and just put it in the
> Server 2003 Sp1 DDK folder and start using it? Also can I use prefast
> latest version from WDK and use it as well?
>
> I would appreciate if ppl can share their experiences with using SDV on
> their driver.
>
> Thanks,
> Shan.
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature database 4447 (20090922)

>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

Information from ESET NOD32 Antivirus, version of virus signature database 4447 (20090922)

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Why can’t you just run sdv from a new wdk’s srv03 build window? The answer is no, you cannot move the tools from a new wdk to an older one. What driver model is your driver written against?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Tuesday, September 22, 2009 8:12 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] static driver verifier

Folks,

I have a kernel driver which is built using Windows Server 2003 SP1 DDK. I use
prefast ( V 1.5 ) often on the driver code. I would like to use Static Driver Verifier.
But I think it’s not available for WS2003 SP1 DDK.
So my question is can I take Sdv binaries from WDK and just put it in the Server 2003 Sp1 DDK folder and start using it? Also can I use prefast latest version from WDK and use it as well?

I would appreciate if ppl can share their experiences with using SDV on their driver.

Thanks,
Shan.


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

>Why can’t you just run sdv from a new wdk’s srv03 build window? The answer is

no, you cannot move the tools from a new wdk to an older one. What driver model
is your driver written against?

WDM.

I can move to the new WDK. But I plan to do it slowly. BTW, the target OS is Windows XP SP3.

> So my question is can I take Sdv binaries from WDK and just put it in the Server 2003 Sp1 DDK

Drop this ancient DDK forever and move to WDK as a build env.


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

> I can move to the new WDK. But I plan to do it slowly.

It is very simple - just build your code with the new WDK and re-test.


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

It actually can be very difficult to move from the W2K3 SP1 DDK to the vista
or later WDK’s. There were some changes in the behavior of signedness of
pointers and some bugs introduced in __ptr64. As I remember, if you had
structure members with __ptr64 attributes, the WDK compiler would crash with
an internal error everyplace you accessed them. A bug was filed with MSFT
about 18 months ago, and I never heard if the compiler was eventually fixed.
There were some workarounds to the compiler crash that involved manipulating
the optimization flags. The link
http://blogs.msdn.com/texblog/archive/2005/10/31/487436.aspx gives more info
on the pointer signed issue, which can introduce subtle bugs. I know about
18 months ago, me and another developer each spent about 3 weeks trying to
move 300k lines of DDK built source to the Vista WDK, without successfully
producing stable drivers. At this point, if it’s a product you expect to
support on W2K8/Win7/Vista, not being on the WDK is not really an option,
especially if you expect to get WHQL certified.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-381954-
xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Tuesday, September 22, 2009 12:03 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] static driver verifier

> I can move to the new WDK. But I plan to do it slowly.

It is very simple - just build your code with the new WDK and re-test.


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

>At this point, if it’s a product you expect to

support on W2K8/Win7/Vista, not being on the WDK is not really an option,
especially if you expect to get WHQL certified

The Target OS is Windows XP Sp3. I don’t think we will be moving to Vista anytime soon.
Thanks for the link Jan. I will take a look at it.

WHQL doesn’t really check what tools you used to build your driver. Of
course you have to be using the correct DTM test kit, but that is only
loosely linked to the WDK, and again the test kit does not check
‘tools used’. The OP should of course move to a recent WDK and use
SDV from that release with drivers build with that toolset.

Mark Roddy

On Wed, Sep 23, 2009 at 5:09 AM, wrote:
>>At this point, if it’s a product you expect to
>>support on W2K8/Win7/Vista, not being on the WDK is not really an option,
>>especially if you expect to get WHQL certified
>
> The Target OS is Windows XP Sp3. I don’t think we will be moving to Vista anytime soon.
> Thanks for the link Jan. I will take a look at it.
>
> —
> 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
>

Jan Bottorff wrote:

It actually can be very difficult to move from the W2K3 SP1 DDK to the vista
or later WDK’s. There were some changes in the behavior of signedness of
pointers and some bugs introduced in __ptr64.

This is complete BS. The pointer signedness did not change. It’s
always been that way. It only came to be known because people started
worrying more about 64-bit pointers.

I found the transition from the 3790 DDK to the 6000 WDK to be
essentially painless in terms of code changes.

The link
http://blogs.msdn.com/texblog/archive/2005/10/31/487436.aspx gives more info
on the pointer signed issue, which can introduce subtle bugs. I know about
18 months ago, me and another developer each spent about 3 weeks trying to
move 300k lines of DDK built source to the Vista WDK, without successfully
producing stable drivers.

I find it impossible to believe that you actually found a bug in the
wild that could be explained by the pointer signedness issue. If you
have a real-world example, I challenge you to post it here.

At this point, if it’s a product you expect to
support on W2K8/Win7/Vista, not being on the WDK is not really an option,
especially if you expect to get WHQL certified.

This is unadulterated nonsense.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts wrote:

Jan Bottorff wrote:

> At this point, if it’s a product you expect to
> support on W2K8/Win7/Vista, not being on the WDK is not really an option,
> especially if you expect to get WHQL certified.
>
>

This is unadulterated nonsense.

Please allow me to apologize for this. I completely missed the “not” in
your sentence. Since you were railing against the WDK, I assumed you
had continued in that same vein. My mistake.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I don’t work on the code that had the issue anymore, so will have to depend
on a few searches…

One of the messages I posed about the issue was at
http://lists.openfabrics.org/pipermail/ofw/2007-December/001852.html

Another message from other people working on the issue can be found at
http://lists.openfabrics.org/pipermail/ofw/2008-February/002002.html

The compiler crashing bug related to __ptr64 was recorded in the Microsoft
bug database in August 2007 as “Windows OS Bugs : 2014888”.

Part of the problem with pointer signeness was the compiler generated
inconsistent code when dealing with __ptr64 attributed variables. For
example, as I remember, if you compared pointers, in 32-bit code, that had
the __ptr64 attribute, all 64-bits allocated were compared. When you
assigned to a 32-bit pointer with the __ptr64 attribute, 32-bits were
assigned. If the __ptr64 value was in a structure, and you zero filled the
structure, and you compared two such pointers, it was ok. If you had a local
variable, which will not normally be in zero filled memory, the comparison
was bogus, and how it failed could depend on what trash was left in what’s
now the stack frame in the upper 32-bit of the __ptr64 ptr.

My memory of an example of pointer signness issues was some code that
initialized a global pointer to -1. This global value was then used to
initialize some other pointers with a magic value. When the code then
compared the pointer to -1, it didn’t match. My memory is the sign extension
behavior of a statically initialized global was different than the behavior
of assignments between pointers.

I know at my company, at least 6 man-weeks (probably more) were spent
fooling with this. I don’t know how many man-weeks were spent by the people
working on the Infiniband stack full time (which included developers at
Intel, Mellanox, and Microsoft). I heard thousands of lines of code (on a
300k line project) eventually had to be changed, all to fix changes in the
compiler between the W2K3 SP1 DDK and Vista WDK (not sure which revision).
Since the Infinband stack is open source, you could probably find the
exactly deltas if you really wanted to.

It’s possible this only effected code that used __ptr64 (and I suppose
__ptr32 if you had 32-bit client code on a 64-bit OS). Without these, there
is no such thing as a 32-bit and 64-bit pointer types in the same module.

My point remains, moving from the W2K3 SP1 DDK to the WDK’s can be
difficult, although typically it’s easy. A large driver code base that
worked perfectly when compiled with W2K3 SP1 DDK, could not even be compiled
with the WDK, and when workarounds to the compiler were found the execution
behavior had changed.

I can think of at least 5 developers who probably have unpleasant memories,
and don’t think it’s nonsense.

I don’t personally have the W2K3 SP1 DDK installed anymore, so it would be
difficult to generate and confirm this again. Somebody with access to the
Microsoft bug database, might tell us if OS bug 2014888 was ever fixed.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-382068-
xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, September 23, 2009 10:05 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] static driver verifier

Jan Bottorff wrote:
> It actually can be very difficult to move from the W2K3 SP1 DDK to
the vista
> or later WDK’s. There were some changes in the behavior of signedness
of
> pointers and some bugs introduced in __ptr64.

This is complete BS. The pointer signedness did not change. It’s
always been that way. It only came to be known because people started
worrying more about 64-bit pointers.

I found the transition from the 3790 DDK to the 6000 WDK to be
essentially painless in terms of code changes.

> The link
> http://blogs.msdn.com/texblog/archive/2005/10/31/487436.aspx gives
more info
> on the pointer signed issue, which can introduce subtle bugs. I know
about
> 18 months ago, me and another developer each spent about 3 weeks
trying to
> move 300k lines of DDK built source to the Vista WDK, without
successfully
> producing stable drivers.

I find it impossible to believe that you actually found a bug in the
wild that could be explained by the pointer signedness issue. If you
have a real-world example, I challenge you to post it here.

> At this point, if it’s a product you expect to
> support on W2K8/Win7/Vista, not being on the WDK is not really an
option,
> especially if you expect to get WHQL certified.
>

This is unadulterated nonsense.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Sorry if I mixed ranting and good recommendations in the same message.

My correct position would be EVERYBODY should use the 7600 WDK currently,
for any driver under development. My position has always been it’s best to
use the latest RELEASED DDK/WDK. This get’s to be a chicken and egg problem
near on new OS release as the RTM WDK is not released before the RTM OS, and
you need to build the in-box drivers with something.

I also can understand that moving to the latest WDK might be some work for
some people, and know the pain they might have to go through, but strongly
recommend using the latest WDK, whatever it takes, unless you’re near YOUR
product release and changing compilers has risk to your product stability.
When checking in code to a version control, I often add a little comment
about what I think the risk level is, so that if release groups are near
freezing a specific set of changes, they have some sense of which ones are
safer and which ones are less safe.

For many companies, it’s difficult to sync up their product releases with
Microsoft releases, because they often have non-Microsoft components they
need to sync up with, like hardware, or standards, or other products they
make. On the other hand, some types of products (like boot devices), really
are better being in-box drivers, so companies should be paying close
attention to Microsoft deadlines.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-382073-
xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, September 23, 2009 10:20 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] static driver verifier

Tim Roberts wrote:
> Jan Bottorff wrote:
>
>> At this point, if it’s a product you expect to
>> support on W2K8/Win7/Vista, not being on the WDK is not really an
option,
>> especially if you expect to get WHQL certified.
>>
>>
>
> This is unadulterated nonsense.
>

Please allow me to apologize for this. I completely missed the “not”
in
your sentence. Since you were railing against the WDK, I assumed you
had continued in that same vein. My mistake.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Thanks Folks for the responses. I decided to move to the WDK 7600. Infact I installed it yesterday , compiled my code and now fixing the Prefast warnings. OACR is running in the taskbar.

Don,
you are right. The latest Prefast does give lot more warnings/errors. But lot of these are missing
annotations for functions. It did catch a few missed PAGED_CODE macro. The old prefast did not catch these.

>It is very simple - just build your code with the new WDK and re-test.
Yep it is.

> It’s possible this only effected code that used __ptr64

What is the need to ever use “__ptr64”?


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

> My correct position would be EVERYBODY should use the 7600 WDK currently,

for any driver under development.

…if they can afford dropping w2k support.


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

If you have a driver that runs on 64-bit Windows, that expose structures
that contain pointers that are used by both 32-bit and 64-bit applications,
__ptr64 is a common way you would make those structures have the same
layout.

Jan

> It’s possible this only effected code that used __ptr64

What is the need to ever use “__ptr64”?

an alternative would be to create an anonymous union of the pointer and ULONGLONG to make sure the size remains the same for both architectures

d


From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] on behalf of Jan Bottorff [xxxxx@pmatrix.com]
Sent: Friday, September 25, 2009 2:41 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] static driver verifier

If you have a driver that runs on 64-bit Windows, that expose structures
that contain pointers that are used by both 32-bit and 64-bit applications,
__ptr64 is a common way you would make those structures have the same
layout.

Jan

> It’s possible this only effected code that used __ptr64

What is the need to ever use “__ptr64”?


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

I agree that’s what __ptr32/__ptr64 do. What’s confusing me is the msdn docs on the subject:

http://msdn.microsoft.com/en-us/library/aa985900(VS.80).aspx

On a 32-bit system, a pointer declared with __ptr64 is truncated to a 32-bit pointer. On a 64-bit system, a pointer declared with __ptr32 is coerced to a 64-bit pointer.

The first sentence I guess could be talking about comparison, but the second one seems to me at least to imply that a __ptr32 on 64 is stored as 32bits.

What am I missing?

mm

Never mind.

My bad,

mm