Combine 2 drivers

Hi,

I have a miniport driver, which supports multiple HW.
I have a few versions of the driver and the newer version runs also on a newer hardware.
Probably the older version (which runs only on the older HW) is more stable.
I would like to merge both drivers into one driver and build a logic which select the correct code to run after initialization. Off course I have many multiple definitions of functions and types. Is there any way to compile a lib from one driver and another lib from the second driver and build a sys file from both lib together, which won’t have multiple definitions (for example to add a const different prefix to all symbol each lib).

Thanks,
Shai

Offhand no, and this sounds like a terrible idea. Don’t release the new
driver until it is stabile, or only release the new driver for the new
hardware until it is able to handle the old hardware without problems. You
could of course rename all the functions in one or the other code bases with
some differentiating prefix or suffix. (For example, Microsoft’s use of the
‘Ex’ suffix.)

On Dec 26, 2007 5:07 PM, wrote:

> Hi,
>
> I have a miniport driver, which supports multiple HW.
> I have a few versions of the driver and the newer version runs also on a
> newer hardware.
> Probably the older version (which runs only on the older HW) is more
> stable.
> I would like to merge both drivers into one driver and build a logic which
> select the correct code to run after initialization. Off course I have many
> multiple definitions of functions and types. Is there any way to compile a
> lib from one driver and another lib from the second driver and build a sys
> file from both lib together, which won’t have multiple definitions (for
> example to add a const different prefix to all symbol each lib).
>
> Thanks,
> Shai
>
> —
> 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
>


Mark Roddy

Can you tell the difference between your new hardware and your old hardware
by differences in the bus detected PnP id? If so, you could just have an INF
with PnP id’s that match your hardware version specifically, and let the OS
pick an appropriate driver. You would need to name the .sys files and
service entry uniquely.

This also has the advantage that when your new driver becomes as stable as
the old one, you just change the PnP id’s in the INF and let the OS now pick
the new and improved driver for the older hardware.

It also has the feature that your customer can have both old and new
hardware versions in the same machine, and the OS uses the correct
(different) driver for each instance. Customers are unhappy if they like
your device so much they buy another one, but find that installing the new
device and driver disk makes their old device stop working. It could be this
is the case you’re trying to avoid by merging the 2 drivers into 1 binary.

Just keep in mind how the OS finds the best PnP match (slightly simplified):

  1. WHQL signed drivers take priority over non-signed ones

  2. more specific PnP strings have priority over more general one, like a
    string with a subsystem id will match over a string with only a vid/pid

  3. for equal PnP matches, newer drivers have priority over older ones (based
    on date in the DriverVer string in the INF

  4. the version part of DriverVer breaks ties for identical dated drivers

There are a few extra details when Windows Update gets involved and a few
details about internal file version resources. Vista/W2K8 can also allow
admin designated trust to a non-WHQL certificate.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-309549-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, December 26, 2007 2:07 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Combine 2 drivers

Hi,

I have a miniport driver, which supports multiple HW.
I have a few versions of the driver and the newer version runs also on a
newer hardware.
Probably the older version (which runs only on the older HW) is more
stable.
I would like to merge both drivers into one driver and build a logic which
select the correct code to run after initialization. Off course I have
many multiple definitions of functions and types. Is there any way to
compile a lib from one driver and another lib from the second driver and
build a sys file from both lib together, which won’t have multiple
definitions (for example to add a const different prefix to all symbol
each lib).

Thanks,
Shai


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

You could also compile your drivers/libraries as C++ (-TP), use a
namespace for each version, and reflect the use of the proper namespace
in your ‘new’ driver’s conditional logic. That being said, I couldn’t
agree more with Mark that this is a disaster waiting to happen, and you
would be much better off getting the new driver working correctly and
fully. What you’re considering, in my opinion, even if it works, will
be very confusing, give you more or less twice as much code to maintain,
and the next person who has to maintain it will never forgive you for
implementing this.

Good luck,

mm

Mark Roddy wrote:

Offhand no, and this sounds like a terrible idea. Don’t release the new
driver until it is stabile, or only release the new driver for the new
hardware until it is able to handle the old hardware without problems.
You could of course rename all the functions in one or the other code
bases with some differentiating prefix or suffix. (For example,
Microsoft’s use of the ‘Ex’ suffix.)

On Dec 26, 2007 5:07 PM, > mailto:xxxxx> wrote:
>
> Hi,
>
> I have a miniport driver, which supports multiple HW.
> I have a few versions of the driver and the newer version runs also
> on a newer hardware.
> Probably the older version (which runs only on the older HW) is more
> stable.
> I would like to merge both drivers into one driver and build a logic
> which select the correct code to run after initialization. Off
> course I have many multiple definitions of functions and types. Is
> there any way to compile a lib from one driver and another lib from
> the second driver and build a sys file from both lib together, which
> won’t have multiple definitions (for example to add a const
> different prefix to all symbol each lib).
>
> Thanks,
> Shai
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>
>
> –
> Mark Roddy</http:></mailto:xxxxx>

Variations of this idea have been used in the past by companies who had to
support a variety of different chips and revs, for example, graphics chips
with multiple flavors and multiple revs at different hw bug levels.

If your chips and boards are distinguishable at PCI config register level, I
would just have two (or more) drivers, it’s simpler. The INF files do the
work of keeping them separated. Plus, that allows you to easily be able to
run old hw side by side with new hw.

I have seen drivers that supported multiple chips and that separated among
them through code in the driver itself, although I’m ready to admit, it’s
not the way I would do things. I would also steer away from distinguishing
between your chips at compile time, because with time the driver code
becomes very hard to read and to maintain.

If you need to dig within non-PCI registers to differentiate your hardware,
I would still have two or more drivers, and add a “supervisor” driver to
dispatch to the right one. If you have trouble fitting this tree
architecture into the wdm/wdf driver stack, there are subarchitectural ways
to pass information between your drivers, for example, through a common
kernel buffer. I used this way back when to interchange information between
my OpenGL ICD and the chip’s Graphics Driver, which were two totally
different pieces of code.

But, looks like we’re ready for versioning, no ? It’s already bread and
butter in .NET and the CLR. Sign of things to come ?

Alberto.

----- Original Message -----
From: “Martin O’Brien”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Saturday, December 29, 2007 7:48 PM
Subject: Re:[ntdev] Combine 2 drivers

> You could also compile your drivers/libraries as C++ (-TP), use a
> namespace for each version, and reflect the use of the proper namespace in
> your ‘new’ driver’s conditional logic. That being said, I couldn’t agree
> more with Mark that this is a disaster waiting to happen, and you would be
> much better off getting the new driver working correctly and fully. What
> you’re considering, in my opinion, even if it works, will be very
> confusing, give you more or less twice as much code to maintain, and the
> next person who has to maintain it will never forgive you for implementing
> this.
>
> Good luck,
>
> mm
>
> Mark Roddy wrote:
>> Offhand no, and this sounds like a terrible idea. Don’t release the new
>> driver until it is stabile, or only release the new driver for the new
>> hardware until it is able to handle the old hardware without problems.
>> You could of course rename all the functions in one or the other code
>> bases with some differentiating prefix or suffix. (For example,
>> Microsoft’s use of the ‘Ex’ suffix.)
>>
>> On Dec 26, 2007 5:07 PM, >> mailto:xxxxx> wrote:
>>
>> Hi,
>>
>> I have a miniport driver, which supports multiple HW.
>> I have a few versions of the driver and the newer version runs also
>> on a newer hardware.
>> Probably the older version (which runs only on the older HW) is more
>> stable.
>> I would like to merge both drivers into one driver and build a logic
>> which select the correct code to run after initialization. Off
>> course I have many multiple definitions of functions and types. Is
>> there any way to compile a lib from one driver and another lib from
>> the second driver and build a sys file from both lib together, which
>> won’t have multiple definitions (for example to add a const
>> different prefix to all symbol each lib).
>>
>> Thanks,
>> Shai
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>>
>>
>> –
>> Mark Roddy
>
> —
> 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</http:></mailto:xxxxx>