From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ECD3321BADAB2 for ; Thu, 6 Sep 2018 22:47:40 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 22:47:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="255241672" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.8]) by orsmga005.jf.intel.com with ESMTP; 06 Sep 2018 22:47:39 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Michael D Kinney , Hao A Wu Date: Fri, 7 Sep 2018 13:48:28 +0800 Message-Id: <20180907054828.28240-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH v2] Emulator/Win: Fix build failure using VS2015x86 or old WinSDK X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2018 05:47:41 -0000 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 Cc: Michael D Kinney Cc: Hao A Wu --- EmulatorPkg/Win/Host/WinHost.c | 2 +- EmulatorPkg/Win/Host/WinThunk.c | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 9b98d5330f..65e8960eff 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -673,7 +673,7 @@ Returns: // Transfer control to the SEC Core // SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)SecCoreEntryPoint, + (SWITCH_STACK_ENTRY_POINT)(UINTN)SecCoreEntryPoint, SecCoreData, GetThunkPpiList (), TopOfStack diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c index 306fe75ecd..6007db73b5 100644 --- a/EmulatorPkg/Win/Host/WinThunk.c +++ b/EmulatorPkg/Win/Host/WinThunk.c @@ -71,15 +71,23 @@ SecConfigStdIn ( // // Disable buffer (line input), echo, mouse, window // - Success = SetConsoleMode ( - GetStdHandle (STD_INPUT_HANDLE), - Mode | ENABLE_VIRTUAL_TERMINAL_INPUT & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT) - ); - } - if (Success) { + Mode &= ~(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 terminal mode + // 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) { Success = GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &Mode); if (Success) { Success = SetConsoleMode ( @@ -88,6 +96,7 @@ SecConfigStdIn ( ); } } +#endif return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR; } -- 2.16.1.windows.1