Deploying Windows 7 drivers with Windows 8 development environment

Hi,

I was trying to use a driver compiled in Windows 8 development environment (Visual Studio 11 beta and Windows Consumer Preview) on a Windows 7 machine. The result was that the driver could not be initialized. The build configuration was set for Windows 7 release. The driver can however be used in Windows 8. Is any basic reason this behaviour?

Thanks,

With my best regards,

Nuno Santos

On 09-May-2012 18:47, xxxxx@imaginando.net wrote:

Hi,

I was trying to use a driver compiled in Windows 8 development environment (Visual Studio 11 beta and Windows Consumer Preview) on a Windows 7 machine. The result was that the driver could not be initialized. The build configuration was set for Windows 7 release. The driver can however be used in Windows 8. Is any basic reason this behaviour?

Of course there is. The OS and subsystem versions in the PE header are
not suitable for Win7. Or, the win8 environment possibly has some
imports missing in Win7.

– pa

The driver installed successfully, but “could not be initialized”?

Can you describe, specifically, what’s happening?

Peter
OSR

Sorry, my mistake. Of course if it was not initialized it could not be correctely installed. Maybe Pavel told it already. I just wanted to have sure it is not possible to deploy windows 7 drivers with windows 8 environment. I wanted to have a single environment for both arquitectures.

Nuno

You need to build for the minimum target os as the target, not the max

d

debt from my phone


From: xxxxx@imaginando.net
Sent: 5/10/2012 9:20 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Deploying Windows 7 drivers with Windows 8 development environment

Sorry, my mistake. Of course if it was not initialized it could not be correctely installed. Maybe Pavel told it already. I just wanted to have sure it is not possible to deploy windows 7 drivers with windows 8 environment. I wanted to have a single environment for both arquitectures.

Nuno


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

Doron,

I think I have done that, chosing in the configuration manager Windows 7 Release as target. Do I need to perform any addition step?

Thanks,

Nuno

If you really built the driver for Win7 target (make sure you built the same platform (x86 or x64) as the box on which you’ve tried to test it), then something may be missing. Are you using KMDF? You need to include it to your INF. Win7 includes older version of KMDF than your driver requires.

So… Putting KMDF aside for a moment, and speaking strictly about WDM: How does that work when I want to build a driver that uses Win8 features when running on Win8, Win7 features when running on Win7, and Vista features when running on Vista?

The guidance from the WDK team previously WAS:

  • If you want to build a single executable that uses the “least common denominator functions” (for example, no features newer than Vista on all platforms) build with the oldest build environment you want to support.

  • If you want to write a single executable that uses “restricted features when running on downlevel systems, new features when running on new systems” build with the highest build environment you will support.

This *was* the official guidance, at least at the time we did the hierarchical headers and header versioning project.

We were just having this discussion internally here at OSR as well so I, for one, would very much appreciate understanding the current “official” guidance. Lots of folks want to ship a single executable. And many folks want to use new features on newer platforms.

TIA,

Peter
OSR

Fundamentally the move to vs made no change here. The only visible change is that instead of an os target+arch+flavor dedicated window you now have multiple os targeting+arch+flavir in the same window. Other than that, the underlying mechanics are the same.

Building for multiple os targets and lighting up for functionality for targets newer than the minimum was equally difficult in the w7 kit as well. You can do it, it is just a bigger shotgun to shoot yourself in the foot with. Essentially you builds for the newest os target and then override the subsystem version setting in the linker to the minimum os target. This gets 98-100% of the way there. The remaining potential 2% are various quirks (like keinitializespinlock changing from am export to an inline in XP or linking against the static iocsq lib) that you have to search and destroy iteratively depending on min target

d

debt from my phone


From: xxxxx@osr.com
Sent: 5/11/2012 7:16 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Deploying Windows 7 drivers with Windows 8 development environment

So… Putting KMDF aside for a moment, and speaking strictly about WDM: How does that work when I want to build a driver that uses Win8 features when running on Win8, Win7 features when running on Win7, and Vista features when running on Vista?

The guidance from the WDK team previously WAS:

  • If you want to build a single executable that uses the “least common denominator functions” (for example, no features newer than Vista on all platforms) build with the oldest build environment you want to support.

  • If you want to write a single executable that uses “restricted features when running on downlevel systems, new features when running on new systems” build with the highest build environment you will support.

This *was* the official guidance, at least at the time we did the hierarchical headers and header versioning project.

We were just having this discussion internally here at OSR as well so I, for one, would very much appreciate understanding the current “official” guidance. Lots of folks want to ship a single executable. And many folks want to use new features on newer platforms.

TIA,

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

I haven’t done this in a while, obviously… I looks like things have become *much* more complicated than they used to be.

Avoiding exactly this type of mess was the reason behind having specialized defines that provided down-level compatibility for various things. Like compatibility with the old S-List format.

Anyhow… thanks for the update.

Peter
OSR

Well, like I said 98% of the headers work with versioning just fine. An example of the 2%

#if defined(X86) && (defined(WDM_INCLUDED) || defined(WIN9X_COMPAT_SPINLOCK))
#if (NTDDI_VERSION >= NTDDI_WIN2K)
NTKERNELAPI
VOID
NTAPI
KeInitializeSpinLock (
__out PKSPIN_LOCK SpinLock
);
#endif
#else

Notice that you need WIN9X_COMPAT_SPINLOCK defined otherwise you get the forceinline regardless of NTDDI_VERSION. The other part of the 2% are libs and defines that DO get added to the various command lines when you target a lower OS and you have to add these back. For instance, ntstrafe.lib when you want to use _vsnprintf on win2k, otherwise you can use just use the inlines.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Friday, May 11, 2012 12:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Deploying Windows 7 drivers with Windows 8 development environment

[quote]
The remaining potential 2% are various quirks (like keinitializespinlock changing from am export to an inline in XP or linking against the static iocsq
lib) that you have to search and destroy iteratively depending on min target [/quote]

I haven’t done this in a while, obviously… I looks like things have become *much* more complicated than they used to be.

Avoiding exactly this type of mess was the reason behind having specialized defines that provided down-level compatibility for various things. Like compatibility with the old S-List format.

Anyhow… thanks for the update.

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

Thanks, Doron.

As I have to figure this out for a project coming-up a few months from now, I think smell an article for The NT Insider brewing…

Peter
OSR

ok. i’l try it out again, carefully. I’ll post the results afterwards.

Regards,

Nuno

Doron,

Based on what you have exposed in previous posts, I have changed the linker parameter Minimum Required Version to version 6.1:

/SUBSYSTEM:NATIVE",6.1

When installing the driver on Windows 7, I hade code 37. (Windows cannot initializ the device driver for this hardware)

Which parameters do I need to change more? Have I changed the right parameter?

Thanks,

With my best regards,

Nuno

Did you make sure your import table contained only win7 APIs?

d

debt from my phone


From: xxxxx@imaginando.net
Sent: 5/21/2012 3:32 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Deploying Windows 7 drivers with Windows 8 development environment

Doron,

Based on what you have exposed in previous posts, I have changed the linker parameter Minimum Required Version to version 6.1:

/SUBSYSTEM:NATIVE",6.1

When installing the driver on Windows 7, I hade code 37. (Windows cannot initializ the device driver for this hardware)

Which parameters do I need to change more? Have I changed the right parameter?

Thanks,

With my best regards,

Nuno


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

Doron,

If i’m importing something related with Windows 8, that import could only be made by Visual Studio project wizard (which I have used to start my driver project import) and by any other shared included.

All my source and includes came from my Windows 7 console based makefile.

Where should I verify that?

Thanks

With my best regards,

Nuno Santos

You can use the wdk conversion tool via the IDE (convert sources and dirs) or command line (nmake2msbuild.exe)

d

debt from my phone


From: xxxxx@imaginando.net
Sent: 5/28/2012 9:53 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Deploying Windows 7 drivers with Windows 8 development environment

Doron,

If i’m importing something related with Windows 8, that import could only be made by Visual Studio project wizard (which I have used to start my driver project import) and by any other shared included.

All my source and includes came from my Windows 7 console based makefile.

Where should I verify that?

Thanks

With my best regards,

Nuno Santos


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