Determining the DDK/WDK version at compile time?

Does anyone have a clever technique for easily determining the specific
version of the DDK/WDK at compile time? Right now I am faced with the
challenge of PreFast complaining that I did not declare some functions with
the correct function type code such as DRIVER_DISPATCH but at the same time,
I need to be able to compile the driver on versions of the DDK that do not
define this type.


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

How about the compiler version? I haven’t tried it but _MSC_VER returns the
compiler version.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Don Burn
Sent: Monday, December 29, 2008 12:12 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Determining the DDK/WDK version at compile time?

Does anyone have a clever technique for easily determining the specific
version of the DDK/WDK at compile time? Right now I am faced with the
challenge of PreFast complaining that I did not declare some functions with
the correct function type code such as DRIVER_DISPATCH but at the same time,
I need to be able to compile the driver on versions of the DDK that do not
define this type.


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


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

Yes, but the compiler version has stayed the same for some SP’s while the
includes have not.


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

“Bill Wandel” wrote in message news:xxxxx@ntdev…
> How about the compiler version? I haven’t tried it but _MSC_VER returns
> the
> compiler version.
>
> Bill Wandel
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]
> On Behalf Of Don Burn
> Sent: Monday, December 29, 2008 12:12 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Determining the DDK/WDK version at compile time?
>
> Does anyone have a clever technique for easily determining the specific
> version of the DDK/WDK at compile time? Right now I am faced with the
> challenge of PreFast complaining that I did not declare some functions
> with
> the correct function type code such as DRIVER_DISPATCH but at the same
> time,
> I need to be able to compile the driver on versions of the DDK that do not
> define this type.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
> —
> 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 Burn wrote:

Yes, but the compiler version has stayed the same for some SP’s while the
includes have not.

Define it manually? C_DEFINES = /DWDK_VERSION=…

–PA

Well that will work, but at that point I might as well have the various
things like DRIVER_DISPATCH_DEFINED, I was really looking for an automated
way so that when my customer uses for instance WDK 6000 and I use WDK 7000
the world does not go crazy.


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

“Pavel A.” wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>> Yes, but the compiler version has stayed the same for some SP’s while the
>> includes have not.
>>
>>
>
> Define it manually? C_DEFINES = /DWDK_VERSION=…
>
> --PA
>

Don,

On one such occasion I used a combination of script run in the PROJECT.MK
(could be in MAKEFILE.INC I suppose) to figure out the DDK version and
define it as a NMAKE macro. I then used the NMAKE macro to place a (ddk
version specific) include path in the INCLUDES. In that folder I had a
header file that worked the magic. It was a real PITA to setup but did
‘dispatch’ compile time include process to a location from which a kit
specific header (or headers in this case) could be picked up.

Very frustrating as it would have just been nice to have a single header in
the DDK/WDK that defined the kit version without any additional nonsense.
Pulling it out of NTVERP.H proved to be too difficult and I am not that sure
it is even reliable.

Even my hair-brained scheme relied on the benevolence of the kit installer
to choose a ‘versioned’ name like C:\WINDDK\2600.1106.… and so I had to go
back and ‘re-install’ the older kits (2K, in particular) with a similar
scheme to make it work.

It was ugly, but it worked.

-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Monday, December 29, 2008 12:48 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Determining the DDK/WDK version at compile time?

Well that will work, but at that point I might as well have the various
things like DRIVER_DISPATCH_DEFINED, I was really looking for an automated
way so that when my customer uses for instance WDK 6000 and I use WDK 7000
the world does not go crazy.


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

“Pavel A.” wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>> Yes, but the compiler version has stayed the same for some SP’s while the

>> includes have not.
>>
>>
>
> Define it manually? C_DEFINES = /DWDK_VERSION=…
>
> --PA
>


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 Burn wrote:

Well that will work, but at that point I might as well have the various
things like DRIVER_DISPATCH_DEFINED, I was really looking for an automated
way so that when my customer uses for instance WDK 6000 and I use WDK 7000
the world does not go crazy.

A small batch file can translate various parameters
to environment vars.
For example: if your BASEDIR is C:\WinDDK\6001.18000, command

for %i in (%BASEDIR%) do set WDK_VER=%~ni

sets WDK_VER to “6001”.
Then you can pass it to C_DEFINES or go further:

if not %WDK_VER% GTR 7000 echo this is not 7000 yet

Extremely low tech, but simple and does the job…

Regards,
–PA

I appreciate the suggestions, but so far all of them will make my customers
have to do excess work to use my code, which is the one thing I will not do.
I guess this is one to hope Microsoft fixes in the future, so maybe by Win10
we can handle things cleanly.


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

“Pavel A.” wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>> Well that will work, but at that point I might as well have the various
>> things like DRIVER_DISPATCH_DEFINED, I was really looking for an
>> automated way so that when my customer uses for instance WDK 6000 and I
>> use WDK 7000 the world does not go crazy.
>>
>
> A small batch file can translate various parameters
> to environment vars.
> For example: if your BASEDIR is C:\WinDDK\6001.18000, command
>
> for %i in (%BASEDIR%) do set WDK_VER=%~ni
>
> sets WDK_VER to “6001”.
> Then you can pass it to C_DEFINES or go further:
>
> if not %WDK_VER% GTR 7000 echo this is not 7000 yet
>
> Extremely low tech, but simple and does the job…
>
> Regards,
> --PA
>

Bill Wandel wrote:

How about the compiler version? I haven’t tried it but _MSC_VER returns the
compiler version.

New WDKs have DDKVersion.xml with content like
1.1.6001.000

( but possibly we can’t use it, because there’s no public schema :wink:

–PA

Telling customers to install an XML parser and tools is the last thing in
the world I would do. Personally I have fought against XML and it
predecessors for almost 30 years.


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

“Pavel A.” wrote in message news:xxxxx@ntdev…
> Bill Wandel wrote:
>> How about the compiler version? I haven’t tried it but _MSC_VER returns
>> the
>> compiler version.
>
> New WDKs have DDKVersion.xml with content like
> 1.1.6001.000
>
> ( but possibly we can’t use it, because there’s no public schema :wink:
>
> --PA
>

… no public schema :wink:

Nor any readily apparent (to a bear of little brain like me) translation
from what we all know and ‘love’ as 6001.18002 and the corresponding
1.1.6001.000 node in that file.

Who thinks this stuff up?

-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pavel A.
Sent: Monday, December 29, 2008 2:12 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Determining the DDK/WDK version at compile time?

Bill Wandel wrote:

How about the compiler version? I haven’t tried it but _MSC_VER returns
the
compiler version.

New WDKs have DDKVersion.xml with content like
1.1.6001.000

( but possibly we can’t use it, because there’s no public schema :wink:

–PA


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