Ann and Jason Edmeades jason@edmeades.me.uk writes:
+BOOL WINAPI write_console_input( HANDLE handle, const INPUT_RECORD *buffer,
DWORD count, LPDWORD written )
+{
- BOOL result = WriteConsoleInputW(handle, buffer, count, written);
- /* If this fails with access denied */
- if (!result && GetLastError() == ERROR_ACCESS_DENIED)
- {
HANDLE hConRW = CreateFileW(coninW, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (hConRW != INVALID_HANDLE_VALUE)
{
result = WriteConsoleInputW(hConRW, buffer, count, written);
CloseHandle(hConRW);
}
That doesn't look right. There's no guarantee that the handle is for the current process console.