OS detection

Here is one that I am stuck on…

I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that would have same binary run on NT4 as regular NT driver and as WDM on 9x, w2k, XP.

Via registry keys access I can distinguish either OS 9x or NT. But then I can’t use PsGetVersion, it is not available on 9x, or IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea what wdm is all about. So, if I use either of these APIs, the binary would fail to load on NT4 or Win9x OSs.

So, using initial knowledge about Nt or 9x os platform how can a single binary driver inside its DriverEntry dissect further what version of OS it is running on?

Thanks in advance,

Paul

Even if you succeeded to distinguish between the OS’s, there is a great
chance that
your PnP driver won’t load on NT40 because its kernel doesn’t export entry
points
that you driver want to resolve at driver load ( for example Po… power
management
procedures )

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Tuesday, February 04, 2003 12:04 AM
Subject: [ntdev] OS detection

> Here is one that I am stuck on…
>
> I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
would have same binary run on NT4 as regular NT driver and as WDM on 9x,
w2k, XP.
>
> Via registry keys access I can distinguish either OS 9x or NT. But then I
can’t use PsGetVersion, it is not available on 9x, or
IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea what
wdm is all about. So, if I use either of these APIs, the binary would fail
to load on NT4 or Win9x OSs.
>
> So, using initial knowledge about Nt or 9x os platform how can a single
binary driver inside its DriverEntry dissect further what version of OS it
is running on?
>
> Thanks in advance,
>
> Paul
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

That wasn’t the question… if I can detect correct os I’ll use different execution paths inside DriverEntry… So, any usefull suggestions?

-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Monday, February 03, 2003 5:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Even if you succeeded to distinguish between the OS’s, there is a great
chance that
your PnP driver won’t load on NT40 because its kernel doesn’t export entry
points
that you driver want to resolve at driver load ( for example Po… power
management
procedures )

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Tuesday, February 04, 2003 12:04 AM
Subject: [ntdev] OS detection

> Here is one that I am stuck on…
>
> I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
would have same binary run on NT4 as regular NT driver and as WDM on 9x,
w2k, XP.
>
> Via registry keys access I can distinguish either OS 9x or NT. But then I
can’t use PsGetVersion, it is not available on 9x, or
IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea what
wdm is all about. So, if I use either of these APIs, the binary would fail
to load on NT4 or Win9x OSs.
>
> So, using initial knowledge about Nt or 9x os platform how can a single
binary driver inside its DriverEntry dissect further what version of OS it
is running on?
>
> Thanks in advance,
>
> Paul
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@krollontrack.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Well my first suggestion is : Read what christiaan said carefully.

The system won’t load your driver on NT4 if it can’t find all of the
routines you import from the kernel. So if you need function X then
your driver won’t load, even if you were smart enough to put:

If(isXAvailable == TRUE) {
X();

Into your code. The fact that your code might call X means the loader
has to resolve the import and if it can’t be resolved you won’t load.

If you were to do

#if isXAvailable
X();
#endif

That would be a different story. But you’ve implied you want a single
binary.

That said - you could write a driver which only used NT4 routines and
probably still get some PNP support. However you wouldn’t have power
management (since you’d need to invoke PoCallDriver which isn’t
available on NT4) so it’s still probably not very helpful.

At the least you’ll probably need 2 driver binaries. One for NT4 and
one for WDM platforms.

-p

-----Original Message-----
From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
Sent: Monday, February 03, 2003 4:14 PM
To: NT Developers Interest List

That wasn’t the question… if I can detect correct os I’ll use
different execution paths inside DriverEntry… So, any usefull
suggestions?

-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Monday, February 03, 2003 5:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Even if you succeeded to distinguish between the OS’s, there is a great
chance that your PnP driver won’t load on NT40 because its kernel
doesn’t export entry points
that you driver want to resolve at driver load ( for example Po…
power
management
procedures )

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Tuesday, February 04, 2003 12:04 AM
Subject: [ntdev] OS detection

> Here is one that I am stuck on…
>
> I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
would have same binary run on NT4 as regular NT driver and as WDM on 9x,
w2k, XP.
>
> Via registry keys access I can distinguish either OS 9x or NT. But
> then I
can’t use PsGetVersion, it is not available on 9x, or
IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
what wdm is all about. So, if I use either of these APIs, the binary
would fail to load on NT4 or Win9x OSs.
>
> So, using initial knowledge about Nt or 9x os platform how can a
> single
binary driver inside its DriverEntry dissect further what version of OS
it is running on?
>
> Thanks in advance,
>
> Paul
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Dynamic loading of X will solve this problem. The problem still recognize
OS still there.

At 04:48 PM 3/2/2003 -0800, you wrote:

Well my first suggestion is : Read what christiaan said carefully.

The system won’t load your driver on NT4 if it can’t find all of the
routines you import from the kernel. So if you need function X then
your driver won’t load, even if you were smart enough to put:

If(isXAvailable == TRUE) {
X();

Into your code. The fact that your code might call X means the loader
has to resolve the import and if it can’t be resolved you won’t load.

If you were to do

#if isXAvailable
X();
#endif

That would be a different story. But you’ve implied you want a single
binary.

That said - you could write a driver which only used NT4 routines and
probably still get some PNP support. However you wouldn’t have power
management (since you’d need to invoke PoCallDriver which isn’t
available on NT4) so it’s still probably not very helpful.

At the least you’ll probably need 2 driver binaries. One for NT4 and
one for WDM platforms.

-p

-----Original Message-----
From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
Sent: Monday, February 03, 2003 4:14 PM
To: NT Developers Interest List

That wasn’t the question… if I can detect correct os I’ll use
different execution paths inside DriverEntry… So, any usefull
suggestions?

-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Monday, February 03, 2003 5:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Even if you succeeded to distinguish between the OS’s, there is a great
chance that your PnP driver won’t load on NT40 because its kernel
doesn’t export entry points
that you driver want to resolve at driver load ( for example Po…
power
management
procedures )

----- Original Message -----
From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@jungo.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

During install of your driver, use win32 api GetVersionEx() to retrieve the
major and minor version number of the os. Store these in your
hklm.…\services<yourservice>\Parameters key. On start
of your driver, query these values.

-Jeff

-----Original Message-----
From: Ilya Lifshits [mailto:xxxxx@jungo.com]
Sent: Tuesday, February 04, 2003 4:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Dynamic loading of X will solve this problem. The problem still recognize
OS still there.

At 04:48 PM 3/2/2003 -0800, you wrote:
>Well my first suggestion is : Read what christiaan said carefully.
>
>The system won’t load your driver on NT4 if it can’t find all of the
>routines you import from the kernel. So if you need function X then
>your driver won’t load, even if you were smart enough to put:
>
> If(isXAvailable == TRUE) {
> X();
>
>
>Into your code. The fact that your code might call X means the loader
>has to resolve the import and if it can’t be resolved you won’t load.
>
>If you were to do
>
> #if isXAvailable
> X();
> #endif
>
>That would be a different story. But you’ve implied you want a single
>binary.
>
>
>
>That said - you could write a driver which only used NT4 routines and
>probably still get some PNP support. However you wouldn’t have power
>management (since you’d need to invoke PoCallDriver which isn’t
>available on NT4) so it’s still probably not very helpful.
>
>At the least you’ll probably need 2 driver binaries. One for NT4 and
>one for WDM platforms.
>
>-p
>
>
>-----Original Message-----
>From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
>Sent: Monday, February 03, 2003 4:14 PM
>To: NT Developers Interest List
>
>That wasn’t the question… if I can detect correct os I’ll use
>different execution paths inside DriverEntry… So, any usefull
>suggestions?
>
>
>-----Original Message-----
>From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
>Sent: Monday, February 03, 2003 5:49 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: OS detection
>
>
>
>
>Even if you succeeded to distinguish between the OS’s, there is a great
>chance that your PnP driver won’t load on NT40 because its kernel
>doesn’t export entry points
>that you driver want to resolve at driver load ( for example Po…
>power
>management
>procedures )
>
>
>
>----- Original Message -----
>From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@jungo.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@concord.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.

This kind of trick usually work. However, I am always worried by the fact
that the user might upgrade his version of Windows at a later point. For
example, upgrade from w2k to XP; or even worst, upgrade from ME to XP!!

Mathieu Routhier

-----Original Message-----
From: Curless, Jeffrey [mailto:xxxxx@concord.com]
Sent: Tuesday, February 04, 2003 8:05 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

During install of your driver, use win32 api GetVersionEx() to retrieve the
major and minor version number of the os. Store these in your
hklm.…\services<yourservice>\Parameters key. On start
of your driver, query these values.

-Jeff

-----Original Message-----
From: Ilya Lifshits [mailto:xxxxx@jungo.com]
Sent: Tuesday, February 04, 2003 4:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Dynamic loading of X will solve this problem. The problem still recognize
OS still there.

At 04:48 PM 3/2/2003 -0800, you wrote:
>Well my first suggestion is : Read what christiaan said carefully.
>
>The system won’t load your driver on NT4 if it can’t find all of the
>routines you import from the kernel. So if you need function X then
>your driver won’t load, even if you were smart enough to put:
>
> If(isXAvailable == TRUE) {
> X();
>
>
>Into your code. The fact that your code might call X means the loader
>has to resolve the import and if it can’t be resolved you won’t load.
>
>If you were to do
>
> #if isXAvailable
> X();
> #endif
>
>That would be a different story. But you’ve implied you want a single
>binary.
>
>
>
>That said - you could write a driver which only used NT4 routines and
>probably still get some PNP support. However you wouldn’t have power
>management (since you’d need to invoke PoCallDriver which isn’t
>available on NT4) so it’s still probably not very helpful.
>
>At the least you’ll probably need 2 driver binaries. One for NT4 and
>one for WDM platforms.
>
>-p
>
>
>-----Original Message-----
>From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
>Sent: Monday, February 03, 2003 4:14 PM
>To: NT Developers Interest List
>
>That wasn’t the question… if I can detect correct os I’ll use
>different execution paths inside DriverEntry… So, any usefull
>suggestions?
>
>
>-----Original Message-----
>From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
>Sent: Monday, February 03, 2003 5:49 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: OS detection
>
>
>
>
>Even if you succeeded to distinguish between the OS’s, there is a great
>chance that your PnP driver won’t load on NT40 because its kernel
>doesn’t export entry points
>that you driver want to resolve at driver load ( for example Po…
>power
>management
>procedures )
>
>
>
>----- Original Message -----
>From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@jungo.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@concord.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.



You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

That is a good point. To solve the problem completely I would create
a service that at startup would detect and set the windows version. Then
it would start the driver. Of course, sometimes this isn’t an option,
in the case of needing your driver to start at boot time… and you
would need to do it differently on Win9x… but I believe the issue
was NT vs 2K/XP.

-Jeff

-----Original Message-----
From: Mathieu Routhier [mailto:xxxxx@guillemot.com]
Sent: Tuesday, February 04, 2003 8:55 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

This kind of trick usually work. However, I am always worried by the fact
that the user might upgrade his version of Windows at a later point. For
example, upgrade from w2k to XP; or even worst, upgrade from ME to XP!!

Mathieu Routhier

-----Original Message-----
From: Curless, Jeffrey [mailto:xxxxx@concord.com]
Sent: Tuesday, February 04, 2003 8:05 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

During install of your driver, use win32 api GetVersionEx() to retrieve the
major and minor version number of the os. Store these in your
hklm.…\services<yourservice>\Parameters key. On start
of your driver, query these values.

-Jeff

-----Original Message-----
From: Ilya Lifshits [mailto:xxxxx@jungo.com]
Sent: Tuesday, February 04, 2003 4:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Dynamic loading of X will solve this problem. The problem still recognize
OS still there.

At 04:48 PM 3/2/2003 -0800, you wrote:
>Well my first suggestion is : Read what christiaan said carefully.
>
>The system won’t load your driver on NT4 if it can’t find all of the
>routines you import from the kernel. So if you need function X then
>your driver won’t load, even if you were smart enough to put:
>
> If(isXAvailable == TRUE) {
> X();
>
>
>Into your code. The fact that your code might call X means the loader
>has to resolve the import and if it can’t be resolved you won’t load.
>
>If you were to do
>
> #if isXAvailable
> X();
> #endif
>
>That would be a different story. But you’ve implied you want a single
>binary.
>
>
>
>That said - you could write a driver which only used NT4 routines and
>probably still get some PNP support. However you wouldn’t have power
>management (since you’d need to invoke PoCallDriver which isn’t
>available on NT4) so it’s still probably not very helpful.
>
>At the least you’ll probably need 2 driver binaries. One for NT4 and
>one for WDM platforms.
>
>-p
>
>
>-----Original Message-----
>From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
>Sent: Monday, February 03, 2003 4:14 PM
>To: NT Developers Interest List
>
>That wasn’t the question… if I can detect correct os I’ll use
>different execution paths inside DriverEntry… So, any usefull
>suggestions?
>
>
>-----Original Message-----
>From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
>Sent: Monday, February 03, 2003 5:49 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: OS detection
>
>
>
>
>Even if you succeeded to distinguish between the OS’s, there is a great
>chance that your PnP driver won’t load on NT40 because its kernel
>doesn’t export entry points
>that you driver want to resolve at driver load ( for example Po…
>power
>management
>procedures )
>
>
>
>----- Original Message -----
>From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@jungo.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@concord.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.



You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@concord.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

OK, here a wacky idea. Perhaps it would be possible to migrate all the
non-NT4 stuff to a kernel mode DLL. Then, the DLL could be packaged into
the driver binary as a resource. If (in DriverEntry) you discover that
you’re running on NT5+, you’d have to (somehow) extract the DLL and use it.

I’m aware of user mode programs that use this technique to package a .SYS
in the same binary as an EXE. The EXE can then extract the .SYS and load
it (via the Service Control Manager) to do some dirty work in kernel mode
on behalf of the EXE. I don’t know if the technique will translate to
kernel mode.

Subject: Re: OS detection
From: “Peter Wieland”
>Date: Mon, 3 Feb 2003 16:48:51 -0800
>X-Message-Number: 42
>
>Well my first suggestion is : Read what christiaan said carefully.
>
>The system won’t load your driver on NT4 if it can’t find all of the
>routines you import from the kernel. So if you need function X then
>your driver won’t load, even if you were smart enough to put:
>
> If(isXAvailable == TRUE) {
> X();
> }
>
>Into your code. The fact that your code might call X means the loader
>has to resolve the import and if it can’t be resolved you won’t load.
>
>If you were to do=20
>
> #if isXAvailable=20
> X();
> #endif
>
>That would be a different story. But you’ve implied you want a single
>binary.
>
>
>
>That said - you could write a driver which only used NT4 routines and
>probably still get some PNP support. However you wouldn’t have power
>management (since you’d need to invoke PoCallDriver which isn’t
>available on NT4) so it’s still probably not very helpful.
>
>At the least you’ll probably need 2 driver binaries. One for NT4 and
>one for WDM platforms.
>
>-p
>
>-----Original Message-----
>From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]=20
>Sent: Monday, February 03, 2003 4:14 PM
>To: NT Developers Interest List
>
>That wasn’t the question… if I can detect correct os I’ll use
>different execution paths inside DriverEntry… So, any usefull
>suggestions?
>
>
>-----Original Message-----
>From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
>Sent: Monday, February 03, 2003 5:49 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: OS detection
>
>
>
>
>Even if you succeeded to distinguish between the OS’s, there is a great
>chance that your PnP driver won’t load on NT40 because its kernel
>doesn’t export entry points
>that you driver want to resolve at driver load ( for example Po…
>power
>management
>procedures )
>
>
>
>----- Original Message -----
>From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But=20
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a=20
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >

It may be simpler to package things into 2 binaries (as Peter Wieland
suggested). The first, “main” binary tests OS level and, if suitable,
loads the second binary. I’ve done this, and the technique is a general
solution to the problem of wanting to use APIs that may not exist on a
given level of the OS. That is, this is going to be recurring problem.

For an example, see DriverDemo.zip at
http://home.mindspring.com/~antognini/drivers/.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini

Yeah, upgrades suck, doesn’t OS populate some registry key that can be used to distinguish OS version?

-----Original Message-----
From: Mathieu Routhier [mailto:xxxxx@guillemot.com]
Sent: Tuesday, February 04, 2003 7:55 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

This kind of trick usually work. However, I am always worried by the fact
that the user might upgrade his version of Windows at a later point. For
example, upgrade from w2k to XP; or even worst, upgrade from ME to XP!!

Mathieu Routhier

-----Original Message-----
From: Curless, Jeffrey [mailto:xxxxx@concord.com]
Sent: Tuesday, February 04, 2003 8:05 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

During install of your driver, use win32 api GetVersionEx() to retrieve the
major and minor version number of the os. Store these in your
hklm.…\services<yourservice>\Parameters key. On start
of your driver, query these values.

-Jeff

-----Original Message-----
From: Ilya Lifshits [mailto:xxxxx@jungo.com]
Sent: Tuesday, February 04, 2003 4:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Dynamic loading of X will solve this problem. The problem still recognize
OS still there.

At 04:48 PM 3/2/2003 -0800, you wrote:
>Well my first suggestion is : Read what christiaan said carefully.
>
>The system won’t load your driver on NT4 if it can’t find all of the
>routines you import from the kernel. So if you need function X then
>your driver won’t load, even if you were smart enough to put:
>
> If(isXAvailable == TRUE) {
> X();
>
>
>Into your code. The fact that your code might call X means the loader
>has to resolve the import and if it can’t be resolved you won’t load.
>
>If you were to do
>
> #if isXAvailable
> X();
> #endif
>
>That would be a different story. But you’ve implied you want a single
>binary.
>
>
>
>That said - you could write a driver which only used NT4 routines and
>probably still get some PNP support. However you wouldn’t have power
>management (since you’d need to invoke PoCallDriver which isn’t
>available on NT4) so it’s still probably not very helpful.
>
>At the least you’ll probably need 2 driver binaries. One for NT4 and
>one for WDM platforms.
>
>-p
>
>
>-----Original Message-----
>From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
>Sent: Monday, February 03, 2003 4:14 PM
>To: NT Developers Interest List
>
>That wasn’t the question… if I can detect correct os I’ll use
>different execution paths inside DriverEntry… So, any usefull
>suggestions?
>
>
>-----Original Message-----
>From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
>Sent: Monday, February 03, 2003 5:49 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: OS detection
>
>
>
>
>Even if you succeeded to distinguish between the OS’s, there is a great
>chance that your PnP driver won’t load on NT40 because its kernel
>doesn’t export entry points
>that you driver want to resolve at driver load ( for example Po…
>power
>management
>procedures )
>
>
>
>----- Original Message -----
>From:
>To: “NT Developers Interest List”
>Sent: Tuesday, February 04, 2003 12:04 AM
>Subject: [ntdev] OS detection
>
>
> > Here is one that I am stuck on…
> >
> > I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
>would have same binary run on NT4 as regular NT driver and as WDM on 9x,
>w2k, XP.
> >
> > Via registry keys access I can distinguish either OS 9x or NT. But
> > then I
>can’t use PsGetVersion, it is not available on 9x, or
>IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
>what wdm is all about. So, if I use either of these APIs, the binary
>would fail to load on NT4 or Win9x OSs.
> >
> > So, using initial knowledge about Nt or 9x os platform how can a
> > single
>binary driver inside its DriverEntry dissect further what version of OS
>it is running on?
> >
> > Thanks in advance,
> >
> > Paul
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@jungo.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@concord.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.



You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@krollontrack.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The driver I plan to write really doesn’t have any underlying hardware beneath, so I am not planning to import any power or Pnp functions. The only things there I need is memory manipulation functionality to compress and or encrypt user data. And since there are no hardware resources the driver will hold (I mean ports, ints, etc…) The Pnp OS should still be able to do all the Pnp interesting stuff like suspend, hibernation, etc…

-----Original Message-----
From: Peter Wieland [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, February 03, 2003 6:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Well my first suggestion is : Read what christiaan said carefully.

The system won’t load your driver on NT4 if it can’t find all of the
routines you import from the kernel. So if you need function X then
your driver won’t load, even if you were smart enough to put:

If(isXAvailable == TRUE) {
X();

Into your code. The fact that your code might call X means the loader
has to resolve the import and if it can’t be resolved you won’t load.

If you were to do

#if isXAvailable
X();
#endif

That would be a different story. But you’ve implied you want a single
binary.

That said - you could write a driver which only used NT4 routines and
probably still get some PNP support. However you wouldn’t have power
management (since you’d need to invoke PoCallDriver which isn’t
available on NT4) so it’s still probably not very helpful.

At the least you’ll probably need 2 driver binaries. One for NT4 and
one for WDM platforms.

-p

-----Original Message-----
From: xxxxx@KrollOntrack.com [mailto:xxxxx@KrollOntrack.com]
Sent: Monday, February 03, 2003 4:14 PM
To: NT Developers Interest List

That wasn’t the question… if I can detect correct os I’ll use
different execution paths inside DriverEntry… So, any usefull
suggestions?

-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Monday, February 03, 2003 5:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: OS detection

Even if you succeeded to distinguish between the OS’s, there is a great
chance that your PnP driver won’t load on NT40 because its kernel
doesn’t export entry points
that you driver want to resolve at driver load ( for example Po…
power
management
procedures )

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Tuesday, February 04, 2003 12:04 AM
Subject: [ntdev] OS detection

> Here is one that I am stuck on…
>
> I am trying to create a hybrid, PNP vs. Legacy NT4. small driver that
would have same binary run on NT4 as regular NT driver and as WDM on 9x,
w2k, XP.
>
> Via registry keys access I can distinguish either OS 9x or NT. But
> then I
can’t use PsGetVersion, it is not available on 9x, or
IoIsWdmVersionAvailable because NT4 doesn’t have even a slightest idea
what wdm is all about. So, if I use either of these APIs, the binary
would fail to load on NT4 or Win9x OSs.
>
> So, using initial knowledge about Nt or 9x os platform how can a
> single
binary driver inside its DriverEntry dissect further what version of OS
it is running on?
>
> Thanks in advance,
>
> Paul
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@krollontrack.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@krollontrack.com
To unsubscribe send a blank email to xxxxx@lists.osr.com