Emulator/Win: Fix build failure using VS2015x86 or old WinSDK

When build with WinSDK <= Win10 TH2, the terminal over CMD.exe
doesn't work. Because Win10 later than TH2 starts to support VT
terminal.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Ruiyu Ni 2018-08-31 16:55:36 +08:00
parent 289cb872ed
commit f4eaaf1a6d
2 changed files with 17 additions and 8 deletions

View File

@ -673,7 +673,7 @@ Returns:
// Transfer control to the SEC Core // Transfer control to the SEC Core
// //
SwitchStack ( SwitchStack (
(SWITCH_STACK_ENTRY_POINT)SecCoreEntryPoint, (SWITCH_STACK_ENTRY_POINT)(UINTN)SecCoreEntryPoint,
SecCoreData, SecCoreData,
GetThunkPpiList (), GetThunkPpiList (),
TopOfStack TopOfStack

View File

@ -71,15 +71,23 @@ SecConfigStdIn (
// //
// Disable buffer (line input), echo, mouse, window // Disable buffer (line input), echo, mouse, window
// //
Success = SetConsoleMode ( Mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
GetStdHandle (STD_INPUT_HANDLE),
Mode | ENABLE_VIRTUAL_TERMINAL_INPUT & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT) #if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
); //
// Enable virtual terminal input for Win10 above TH2
//
Mode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
#endif
Success = SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), Mode);
} }
#if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
//
// Enable terminal mode for Win10 above TH2
//
if (Success) { if (Success) {
//
// Enable terminal mode
//
Success = GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &Mode); Success = GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &Mode);
if (Success) { if (Success) {
Success = SetConsoleMode ( Success = SetConsoleMode (
@ -88,6 +96,7 @@ SecConfigStdIn (
); );
} }
} }
#endif
return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR; return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR;
} }