Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a Keyboard
filter driver that windows loads it in safe mode too, but if something
goes wrong there is no easy way to correct the problem (Suppose you are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I will
install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).

Read this KB article
http://support.microsoft.com/default.aspx?scid=kb;[LN];837643. I
would do as it suggests and just fail AddDevice. Failure from AddDEvice
in a filter is not catastrophic and the keyboard will still start

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 9:38 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a Keyboard
filter driver that windows loads it in safe mode too, but if something
goes wrong there is no easy way to correct the problem (Suppose you are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I will

install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Doron,
The KB article mentioned:
“Filter drivers
If your filter driver starts during boot time, check the value of the
InitSafeBootMode variable in the AddDevice routine. Do not attach to the
device stack. Return success from the AddDevice routine.”
Seems we should return success from the AddDevice routine and don’t
attach our device object to the stack.


Best Regards,
hanzhu

Doron Holan дµÀ:

Read this KB article
http://support.microsoft.com/default.aspx?scid=kb;[LN];837643. I
would do as it suggests and just fail AddDevice. Failure from AddDEvice
in a filter is not catastrophic and the keyboard will still start

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 9:38 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a Keyboard
filter driver that windows loads it in safe mode too, but if something
goes wrong there is no easy way to correct the problem (Suppose you are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I will

install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Doron Holan wrote:

Read this KB article
http://support.microsoft.com/default.aspx?scid=kb;[LN];837643. I
would do as it suggests and just fail AddDevice. Failure from AddDEvice
in a filter is not catastrophic and the keyboard will still start

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 9:38 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a Keyboard
filter driver that windows loads it in safe mode too, but if something
goes wrong there is no easy way to correct the problem (Suppose you are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I will

install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you Doron.

But does this info also apply to windows 98 series?

[resending due to bounce]

That’s fine too. The results of AddDevice for a filter device,
NT_SUCCESS or not, do not affect the stack being built
properly/successfully.

d

Nope, win9x is a completely different beast. Then again, the keyboard
stack is not WDM so the same driver does not run on both operating
systems.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 11:09 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Safe mode detection

Doron Holan wrote:

Read this KB article
http://support.microsoft.com/default.aspx?scid=kb;[LN];837643. I
would do as it suggests and just fail AddDevice. Failure from
AddDEvice
in a filter is not catastrophic and the keyboard will still start

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 9:38 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a
Keyboard
filter driver that windows loads it in safe mode too, but if something

goes wrong there is no easy way to correct the problem (Suppose you
are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I
will

install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you Doron.

But does this info also apply to windows 98 series?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I would suggest not failing AddDevice, but instead something like:

NTSTATUS AddDevice(…)
{
if (InSafeMode())
{
return STATUS_SUCCESS;
}
// continue with your normal code path
}

This method was first used in Win2k by REDBOOK.SYS; The way it works,
since your driver won’t actually get any device objects, you’ll also get
a DriverUnload() after the last keyboard stack is brought up since your
driver object won’t have any device objects. Thus, you won’t even be in
the driver chain at all, even though you’re listed as a filter driver
for the stack.

.

-----Original Message-----
From: Doron Holan
Sent: Monday, July 24, 2006 9:51 PM
Subject: RE: Safe mode detection

Read this KB article
http://support.microsoft.com/default.aspx?scid=kb;[LN];837643. I
would do as it suggests and just fail AddDevice. Failure from AddDEvice
in a filter is not catastrophic and the keyboard will still start

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moavenat
Sent: Monday, July 24, 2006 9:38 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Safe mode detection

Hi All,

Is there any way to detect driver is loading under windows safe mode?

The problem I’m trying to solve is that, I’m trying to write a Keyboard
filter driver that windows loads it in safe mode too, but if something
goes wrong there is no easy way to correct the problem (Suppose you are
at the login screen with no keyboard).

I want to detect safe mode in DriverEntry and if it is safe mode, I will

install different dispatch routines which only pass through the IRP
(like kbfiltr sample in DDK).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer