From 3fbe4cb10717f7822feb55fab8ca10d8a5ed102e Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 3 Nov 2013 21:52:58 +0000 Subject: [PATCH] [NTVDM] Use BiosConsoleInput instead of calling GetStdHandle in the keyboard input thread. svn path=/branches/ntvdm/; revision=60855 --- subsystems/ntvdm/bios.c | 7 +++++++ subsystems/ntvdm/ntvdm.c | 5 ----- subsystems/ntvdm/ps2.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/subsystems/ntvdm/bios.c b/subsystems/ntvdm/bios.c index 878badf2469..a0147415e41 100644 --- a/subsystems/ntvdm/bios.c +++ b/subsystems/ntvdm/bios.c @@ -26,6 +26,7 @@ static BYTE BiosKeyboardMap[256]; static HANDLE BiosConsoleInput = INVALID_HANDLE_VALUE; static HANDLE BiosConsoleOutput = INVALID_HANDLE_VALUE; static CONSOLE_SCREEN_BUFFER_INFO BiosSavedBufferInfo; +static HANDLE InputThread = NULL; /* * VGA Register Configurations for BIOS Video Modes @@ -555,6 +556,9 @@ BOOLEAN BiosInitialize(VOID) /* Set the console input mode */ SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT); + /* Start the input thread */ + InputThread = CreateThread(NULL, 0, &InputThreadProc, BiosConsoleInput, 0, NULL); + /* Initialize the PIC */ PicWriteCommand(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4); PicWriteCommand(PIC_SLAVE_CMD , PIC_ICW1 | PIC_ICW1_ICW4); @@ -593,6 +597,9 @@ VOID BiosCleanup(VOID) /* Close the console handles */ if (BiosConsoleOutput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleOutput); if (BiosConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleInput); + + /* Close the input thread handle */ + if (InputThread != NULL) CloseHandle(InputThread); } WORD BiosPeekCharacter(VOID) diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index 9c91778ed1e..5bcbfa9c07b 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -76,7 +76,6 @@ INT wmain(INT argc, WCHAR *argv[]) DWORD LastClockUpdate = GetTickCount(); LARGE_INTEGER Frequency, LastTimerTick, LastRtcTick, Counter; LONGLONG TimerTicks; - HANDLE InputThread = NULL; LARGE_INTEGER StartPerfCount; DWORD StartTickCount; @@ -139,9 +138,6 @@ INT wmain(INT argc, WCHAR *argv[]) return -1; } - /* Start the input thread */ - InputThread = CreateThread(NULL, 0, &InputThreadProc, NULL, 0, NULL); - /* Find the starting performance and tick count */ StartTickCount = GetTickCount(); QueryPerformanceCounter(&StartPerfCount); @@ -226,7 +222,6 @@ INT wmain(INT argc, WCHAR *argv[]) VgaRefreshDisplay(); Cleanup: - if (InputThread != NULL) CloseHandle(InputThread); SpeakerCleanup(); BiosCleanup(); EmulatorCleanup(); diff --git a/subsystems/ntvdm/ps2.c b/subsystems/ntvdm/ps2.c index ec39f053f25..03ff0182c39 100644 --- a/subsystems/ntvdm/ps2.c +++ b/subsystems/ntvdm/ps2.c @@ -268,7 +268,7 @@ VOID KeyboardWriteData(BYTE Data) DWORD WINAPI InputThreadProc(LPVOID Parameter) { INT i; - HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE); + HANDLE ConsoleInput = (HANDLE)Parameter; INPUT_RECORD InputRecord; DWORD Count;