NT 4.0 DosDevice Failed under Win2000

I’m trying to use the dosdevice application from the NT 4.0 DDK as a
starting template to query the keyboard kernel driver attribute and
other stuff. DosDevice works fine when using NT 4.0. However it doesn’t
work under Win2000. If I trace the code I see it fails when the driver
is opened with CreateFile. Under Win2000 the call failed with an ACCESS
DENIED error code. Any idea why it is not possible to Open the driver
under Win2000 the ways it worked under NT 4.0? Any hint how I could
overcome the problem?

Thanks
Guy Bonneau


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Well I’found the answer to my question. The \Device\KeyboardClass0
is opened with CreateFile with GENERIC_READ | GENERIC_WRITE
attribute. This work fine under NT 4.0. But under Win2000 I have
to set the 0 attribute meaning Device Query access only to have
a successful access.

Seems to me that another instance of the device object is opened with
exclusive access to the Keyboard.

Any comments about my findings?

Thanks
Guy Bonneau

I’m trying to use the dosdevice application from the NT 4.0 DDK as a
starting template to query the keyboard kernel driver attribute and
other stuff. DosDevice works fine when using NT 4.0. However
it doesn’t
work under Win2000. If I trace the code I see it fails when the driver
is opened with CreateFile. Under Win2000 the call failed with
an ACCESS
DENIED error code. Any idea why it is not possible to Open the driver
under Win2000 the ways it worked under NT 4.0? Any hint how I could
overcome the problem?

Thanks
Guy Bonneau


You are currently subscribed to ntdev as: xxxxx@Matrox.COM
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello,

Check out the following thread discussed long back on
dejanews. It was about getting the keyboard input from
native applications.

http://x72.deja.com/[ST_rn=fs]/getdoc.xp?AN=591704821&search=thread&CONTEXT=981700197.820379691&HIT_CONTEXT=981700171.820510752&HIT_NUM=1&hitnum=6

You will have to use ZwCreateFile native API from
NTDLL.DLL to open handle to keyboard driver and you
have to specify FILE_DIRECTORY_FILE in ‘CreateOptions’
parameter.

rc=NtCreateFile(&hKbd,
GENERIC_READ|GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_DIRECTORY_FILE,
0,
0);

The function is documented in DDK. I am still not sure
why one has to specify FILE_DIRECTORY_FILE for
keyboard device :-). But this works great.

Hope this helps.

-Prasad

— Guy Bonneau wrote:
> Well I’found the answer to my question. The
> \Device\KeyboardClass0
> is opened with CreateFile with GENERIC_READ |
> GENERIC_WRITE
> attribute. This work fine under NT 4.0. But under
> Win2000 I have
> to set the 0 attribute meaning Device Query access
> only to have
> a successful access.
>
> Seems to me that another instance of the device
> object is opened with
> exclusive access to the Keyboard.
>
> Any comments about my findings?
>
> Thanks
> Guy Bonneau
>
>
> > I’m trying to use the dosdevice application from
> the NT 4.0 DDK as a
> > starting template to query the keyboard kernel
> driver attribute and
> > other stuff. DosDevice works fine when using NT
> 4.0. However
> > it doesn’t
> > work under Win2000. If I trace the code I see it
> fails when the driver
> > is opened with CreateFile. Under Win2000 the call
> failed with
> > an ACCESS
> > DENIED error code. Any idea why it is not possible
> to Open the driver
> > under Win2000 the ways it worked under NT 4.0? Any
> hint how I could
> > overcome the problem?
> >
> > Thanks
> > Guy Bonneau
> >
> >
> > —
> > You are currently subscribed to ntdev as:
> xxxxx@Matrox.COM
> > To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

=====
Prasad S. Dabak
Director of Engineering, Windows NT/2000 Division
Cybermedia Software Private Limited
http://www.cybermedia.co.in
Co-author of the book “Undocumented Windows NT”
ISBN 0764545698

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Thanks Prasad,

I read the thread and found the information usefull.

However it doesn’t provide any explanation about the
new behavior of the Keyboard accessibility under
Win2000. Neither that’s give the under the hood
relationship of keyboard driver with the
FILE_DIRECTORY_FILE option.

Perhaps someone on this list could shade more light
on the subject?

Microsoft?

Thanks
Guy

You will have to use ZwCreateFile native API from
NTDLL.DLL to open handle to keyboard driver and you
have to specify FILE_DIRECTORY_FILE in ‘CreateOptions’
parameter.

rc=NtCreateFile(&hKbd,
GENERIC_READ|GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_DIRECTORY_FILE,
0,
0);


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Keyboard/Mouse devices are made secure devices on Win2K. You must have the
SE_TCB privilege set to be able to open the device. furthermore, you must
open the device readonly. The fact you were able to open using
FILE_DIRECTORY_FILE with Native APIs is to workaround a problem we had with
HID clients.

-Eliyas

-----Original Message-----
From: Guy Bonneau [mailto:xxxxx@Matrox.COM]
Sent: Friday, February 09, 2001 9:47 AM
To: NT Developers Interest List
Subject: [ntdev] RE: NT 4.0 DosDevice Failed under Win2000

Thanks Prasad,

I read the thread and found the information usefull.

However it doesn’t provide any explanation about the
new behavior of the Keyboard accessibility under
Win2000. Neither that’s give the under the hood
relationship of keyboard driver with the
FILE_DIRECTORY_FILE option.

Perhaps someone on this list could shade more light
on the subject?

Microsoft?

Thanks
Guy

You will have to use ZwCreateFile native API from
NTDLL.DLL to open handle to keyboard driver and you
have to specify FILE_DIRECTORY_FILE in ‘CreateOptions’
parameter.

rc=NtCreateFile(&hKbd,
GENERIC_READ|GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_DIRECTORY_FILE,
0,
0);


You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello,

I myself was not aware of under the hood relationship
of keyboard driver with the FILE_DIRECTORY_FILE
option. However, I think Eliyas from Microsoft has
clarified it.

I figured out FILE_DIRECTORY_FILE mystery by tracing
into the AUTOCHK code, which allows you to press a key
to abort a scheduled chkdsk run.

-Prasad

— Guy Bonneau wrote:
> Thanks Prasad,
>
> I read the thread and found the information usefull.
>
> However it doesn’t provide any explanation about the
> new behavior of the Keyboard accessibility under
> Win2000. Neither that’s give the under the hood
> relationship of keyboard driver with the
> FILE_DIRECTORY_FILE option.
>
> Perhaps someone on this list could shade more light
> on the subject?
>
> Microsoft?
>
> Thanks
> Guy
>
>
>
> >You will have to use ZwCreateFile native API from
> >NTDLL.DLL to open handle to keyboard driver and you
> >have to specify FILE_DIRECTORY_FILE in
> ‘CreateOptions’
> >parameter.
>
> >
> > rc=NtCreateFile(&hKbd,
> > GENERIC_READ|GENERIC_WRITE,
> > &ObjectAttributes,
> > &IoStatusBlock,
> > 0,
> > FILE_ATTRIBUTE_NORMAL,
> > 0,
> > FILE_OPEN,
> > FILE_DIRECTORY_FILE,
> > 0,
> > 0);
> >
> >
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.co

=====
Prasad S. Dabak
Director of Engineering, Windows NT/2000 Division
Cybermedia Software Private Limited
http://www.cybermedia.co.in
Co-author of the book “Undocumented Windows NT”
ISBN 0764545698

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com