/*++ * @name RtlCliGetChar * * The RtlCliGetChar routine FILLMEIN * * @param hDriver * FILLMEIN * * @return CHAR * * @remarks Documentation for this routine needs to be completed. * *--*/ CHAR RtlCliGetChar(IN HANDLE hDriver) { KEYBOARD_INPUT_DATA KeyboardData; KBD_RECORD kbd_rec; ULONG BufferLength = sizeof(KEYBOARD_INPUT_DATA); RtlClipWaitForInput(hDriver, &KeyboardData, &BufferLength); IntTranslateKey(&KeyboardData, &kbd_rec); if (!kbd_rec.bKeyDown) { return (-1); } return kbd_rec.AsciiChar; }
BOOL WINAPI ReadConsoleInput( IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead) { LARGE_INTEGER Offset; IO_STATUS_BLOCK IoStatusBlock; KEYBOARD_INPUT_DATA InputData; NTSTATUS Status; Offset.QuadPart = 0; Status = NtReadFile(hConsoleInput, NULL, NULL, NULL, &IoStatusBlock, &InputData, sizeof(KEYBOARD_INPUT_DATA), &Offset, 0); if (Status == STATUS_PENDING) { Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL); Status = IoStatusBlock.Status; } if (!NT_SUCCESS(Status)) return FALSE; lpBuffer->EventType = KEY_EVENT; Status = IntTranslateKey(&InputData, &lpBuffer->Event.KeyEvent); if (!NT_SUCCESS(Status)) return FALSE; *lpNumberOfEventsRead = 1; return TRUE; }