> Sorry there is no safe way to handle input from a keyboard before the
system is up.
Thank you for the answer.
What has been recomended over the years is using a custom switch on the
boot.ini line, this can be read from the registry and is safe.
boot.ini is not the only candidate, your very own my.cfg file works fine.
In some [production] cases you will have to do some rounds: if you need
these settings too early, postpone the decision to some later stage when
file[s] and/or hives are accessible, and do whatever you need then and
there.
For instance on XP, it is more then likely that KeyboardClass0 is the
terminal
services redirected virtual keyboard, not a physical keyboard.
This one hit me recently.
My guess was that keyboard0 is always local, and keyboard1 is always
MSTSC’s (I’m talking about wxp, not w2k3s).
Wrong I was: on a couple of [my] boxes it was the case, on a QA’s box -
where else? - it was not.
BTW, I still do not know how to tell which is which, does anyone?
A hint - not a solution - would be appreciated.
I think that the solution can be found in VNC sources, but maybe someone can
save me some time.
Here’s the problem: I need to control kbd lights [when some lengthy download
is being done] without changing the kbd status, that is, “num lock” light
blinks, but “num lock” state does not.
A sample (symlink to \Device\keyboard0 and IOCTLs) I googled out and
modified is ok, but - see above.
Your assumption that by the time your filter starts, the keyboard is
working is completely bogus. There is no such guarantee.
Oh! Even if it’s an upper filter?
See how good it is to do the research before?
I quickly browsed thru kbd-related samples in the DDK and decided that it
may be the case (check my post, I say “probably” twice).
Your code isn’t even system friendly in terms of time consumed.
Oh yes.
The ugliness of polling can compete only with ugliness of port reads.
The two just shine.
Not that the speed matters under the circumstances though.
I thought that the [ugliness of the] code speaks for itself and therefore
omitted obvious comments.
I repeat: it is a typical “what if” research. Nothing more, nothing less.
Your design is awful IMO
There was no such thing as “design” here. See above, below and my previous
post.
Please let me know what product this is going into
Good gracious, probably my English is not good enough also:
(a) as I already said, this was a ctrl2cap-related research;
(b) as I already said, it is not (where “not” means “not”) going into any
product, my product at least;
(c) as I already said, I have to use a product [that was bought from
another comapny] that apparently uses port reads, and this is what scares
me.
And sorry, I am not at liberty to name the product I’m talking about. I
have to talk to the vendor instead, and I will certainly quote all the
emotionally charged lyrics from this thread. Thanks for you helping me out
here.
Oh dear, I almost forgot to say that it was and is a research, it is not
going into a product and I do have to deal with a suspicious driver from a
vendor I can not name.
[That’s how it all started actually: why do they need port reads? Let’s
check using my uctl2cap/kctl2cap as a test base etc.]
I am not just some chicken little screaming at the sky ;).
Is someone trying to fry you?
----- Original Message -----
From: “Doron Holan”
To: “Windows System Software Devs Interest List”
Sent: Saturday, December 24, 2005 12:52 PM
Subject: RE: [ntdev] How to read from Keyboard in Native Mode
Even on a machine with only one physical keyboard attached, there can be
multiple /virtual/ keyboards which are also enumerated as keyboards on the
machine. For instance on XP, it is more then likely that KeyboardClass0 is
the terminal services redirected virtual keyboard, not a physical keyboard.
You cannot make this assumption that there is a mapping to hard coded name.
You need to use the device interface and you need to read from all the
keyboards.
I used to own all of the input stacks in Windows. I have debugged these
types of issues and assumptions for years, I am not just some chicken little
screaming at the sky ;).
d
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pruthviraj Kajale
Sent: Saturday, December 24, 2005 5:08 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to read from Keyboard in Native Mode
Hi,
I am assuming that there is only one keyboard. In that case Keyboardclass0
will work. So I need the method to read the key. Please help
Prithvi
Don Burn wrote:
Well how do you know the device is KeyboardClass0? Systems can have
multiple keyboards, or zero keyboards in the case of headless. Even if you
get this working for some class of systems, what are you going to do about
“lights out operations” where the computer is in a closet and the monitor is
turned off. I know of a small software firm that did this, and was sued
after they sold software licenses to a large company. It turns out that a
power glitch caused a system in the midwest to reboot, unfortunately if hung
by this stuff, and the large company sent someone from New York to see what
was wrong. In the end the software company refunded all the sales (a huge
loss) and paid for the cost of the trip to the midwest.
Why do you think you need this, there are other approaches to gettiug
information at boot time, explain your needs to the group, there may be an
answer that works.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply
“Pruthviraj Kajale” wrote in message
news:xxxxx@ntdev…
> Hi,
>
> I am writing a Native Application. I want to read from Keyboard. I have
> written following code. but NtReadFile fails. can anybody tell me what’s
> wrong with it.
>
> NTSTATUS Status;
> UNICODE_STRING UnicodeFilespec;
> OBJECT_ATTRIBUTES ObjectAttributes;
> HANDLE FileHandle;
> IO_STATUS_BLOCK Iosb;
> ULONG MessageLength = strlen(Message);
> KEYBOARD_INPUT_DATA kbInputData;
> ULONG uiSize = 0, uiByteOffset = 0;
> RtlInitUnicodeString(&UnicodeFilespec, L"\Device\KeyboardClass0");
> InitializeObjectAttributes(&ObjectAttributes, // ptr to structure
> &UnicodeFilespec, // ptr to file spec
> OBJ_CASE_INSENSITIVE, // attributes
> NULL, // root directory handle
> NULL ); // ptr to security descriptor
> Status = NtCreateFile(&FileHandle, // returned file handle
> ( GENERIC_READ | SYNCHRONIZE | GENERIC_WRITE ), // desired access
> &ObjectAttributes, // ptr to object attributes
> &Iosb, // ptr to I/O status block
> 0, // allocation size
> FILE_ATTRIBUTE_NORMAL, // file attributes
> FILE_SHARE_WRITE /| FILE_SHARE_READ/, // share access
> FILE_OPEN, // create disposition
> FILE_DIRECTORY_FILE, // create options
> NULL, // ptr to extended attributes
> 0); // length of ea buffer
> if( !NT_SUCCESS(Status) )
> {
> DisplayString ( L"\r\n *NtCreateFile: Unable to create keyboard device
> " );
> swprintf ( szwError, L" Status = %0x “, Status );
> DisplayString ( szwError );
> }
> DisplayString ( L”\r\nPress a Key" );
>
> uiSize = sizeof ( kbInputData );
> memset( &kbInputData, 0, sizeof( kbInputData ) );
> Status = NtReadFile ( FileHandle, // file Handle
> 0, // event Handle
> NULL, // APC entry point
> NULL, // APC context
> &Iosb, // IOSB address
> &kbInputData, // ptr to data buffer
> uiSize, // length
> &uiByteOffset, // byte offset
> NULL ); // key
> if ( ! NT_SUCCESS ( Status ) )
> {
> DisplayString ( L"\r\nNtReadFile to Read From keyboard is FAILED" );
> swprintf ( szwError, L" Status = %0x “, Status );
> DisplayString ( szwError );
> //printf(“NtWriteFile request failed 0x%0x\n”, Status);
>
> }
> swprintf ( szwError, L” kbInputData.MakeCode = %0x “,
> kbInputData.MakeCode );
> DisplayString ( szwError );
> DisplayString ( L”\r\n ***NtReadFile FINISHED" );
> NtClose ( FileHandle );
>
>
> Prithvi
>
>
>
> ---------------------------------
> Yahoo! Photos
> Ring in the New Year with Photo Calendars. Add photos, events, holidays,
> whatever.
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping — Questions? First
check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com