From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 50BC2941BA0 for ; Tue, 26 Sep 2023 21:43:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2uZWSyikPmT6zU5XvOEwM7XZXx4TEHp0/wSxb+L6en8=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1695764584; v=1; b=k2piekBdkr8uzkCDHZodpPLob0WqtsJH7ZrTO8Q/EjYQ5FlN6qinnsuKR3hqzS+LIU3aceyZ 6kMgaStyKvvH0suVmz8pDTn8UCak2Wn27DjFqdzxED9ZW1EFbMOYjmfacoBYB+5jdxF6+n+7+4u +lj0YV6kfDJIT0t64PWmkuA8= X-Received: by 127.0.0.2 with SMTP id g1mIYY7687511xBuugISZ2Dm; Tue, 26 Sep 2023 14:43:04 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.3537.1695764583136095172 for ; Tue, 26 Sep 2023 14:43:03 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="380542440" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="380542440" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 14:43:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="725579805" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="725579805" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 26 Sep 2023 14:43:01 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 26 Sep 2023 14:43:01 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 26 Sep 2023 14:43:00 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Tue, 26 Sep 2023 14:43:00 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Tue, 26 Sep 2023 14:43:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jqXzl8d/oaP8jjeBf99wF/OGPcnv0CyrHznm9my9qF2Di6CKTR1Y4teYtIywKrWrlp/2KX5kYcCRmLFuCzOHDZsM0k3r2ZyqqQnbYYEVQBNZYrApOyWn1HKXE7HiCnZqYiPB3lSqAIkg1BSx3p5OgYeVth5twVwXAwwAOODk4oOi7JSCfCiBu10o7xPA28dHz9tQtkNY6Y2V6BnFP/Qqo4S+CvNH1L8SYG00+Kz6ZRcD6ye1xD16un1Nxi9LtzQb6qKlt7QKb+291LFrsy1YJAWq6EYsBG5ulXdhRdsBJA7HfHhLMcetu5IiZHVCRZkmaW9/WFKEXDC4m4ZBWcPt/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K+EAoBQpq6O1/cyMGsfzkBUutEMgcWnbV/vxEfcLPaU=; b=bvL3m7lEAHtH96MrTFZgfxpcudFEln1B51urYKVPIkO9PhaEM75K6NfQvRYVAb+2FEjBPAwLnlW4pswD0XtVeNs90W1V6i1eSfD3faTBtWYeAy0PM3OopHrNo8j55+DUSdBM67SR8jJ9luzTp1fqc1VlNSImSkdXU9/VCN6aFj6k4eY6W1n7YJLP+H5FAMKpCUY4CCeFyzEm+1oBY5nQdrfDBDWfX5tRjAPKgBrwWymtiO+2kxWrnX4UX7wypUwQuqwvMgUvE+8UpzLXB+rgWLc2RG7SlF5TQhQdSvFqDw0GCoJiOhGPlq6JVl12jwyFwVpdbUgWiGo1dNYHVIyv0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from SA2PR11MB4938.namprd11.prod.outlook.com (2603:10b6:806:fb::14) by SA1PR11MB8320.namprd11.prod.outlook.com (2603:10b6:806:37c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Tue, 26 Sep 2023 21:42:58 +0000 X-Received: from SA2PR11MB4938.namprd11.prod.outlook.com ([fe80::ca3:8eed:9332:b6e0]) by SA2PR11MB4938.namprd11.prod.outlook.com ([fe80::ca3:8eed:9332:b6e0%6]) with mapi id 15.20.6813.017; Tue, 26 Sep 2023 21:42:58 +0000 From: "Michael D Kinney" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: Andrew Fish , "Ni, Ray" , "Chiu, Chasel" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues Thread-Topic: [PATCH v1] EmulatorPkg: Fix Terminal Issues Thread-Index: AQHZ8KhcA9l2MMuSy0C673hGdEk4+rAth0pwgAAJYYCAAADRwIAAAtQggAALYKA= Date: Tue, 26 Sep 2023 21:42:58 +0000 Message-ID: References: <20230926183601.2974-1-nathaniel.l.desimone@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA2PR11MB4938:EE_|SA1PR11MB8320:EE_ x-ms-office365-filtering-correlation-id: 65780212-3a5d-4a84-88ea-08dbbed98cfe x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 562Guw6hr9VcQzprwe2YExsPgY+1h1YfTpZsUCKE24W8gQmT7tFs3ilzD1VzC7kttcR5B/j20OSX6kwCwWNMKnadD90iIvs4pxxLbrZsMMluVriiYlUGcsv1BXzsLRhwvTXhufbPCsieG1IuxTiWeJSKnEfmiFkcZgnmwYvTwgufIEo0bG3HNGITDJnPysTo+1uuhW8Gv20T5jJWAiN0q/sfeimy+E0HJl+xRG+PcFUgD6aNn9HUtSErwd45pde8xgyDliA6KxMDAYNdcVts9bvcV2SR1eKD9rjWoO+7WEUfQH2nPLsinmGQC81Iqb7WCAthIFOL2X56I6d4YosXcU1klKjk81rXCNLrtUdTNCH6vD2YkRYT6AzX+67mb8HsCfUaazHr5v8Ei+j6TL4Jmygj2cpUf3NAJZV2BEVdegt0no5YnWgCTrViS2KBH0AHOtQxM4uACL88szLZm6DRtSs2eY/+3YkjbgisMsMoGNmCGh0HgfzhNvI4/n50SJj147+GxKyhG9QxHgYuFJau4VQngVEMCgpDRwN/WdlXZ/DoBPwz9I7Hz2dIAxFjCj3VQhV1UgYNyPsAXG6AHGHI9jDyJt5ansdcumGQZWBy5YM= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?vjPUG4ebzYRlytUBNTPERmEy5nNJtJOLGMxZcC5g1uIw2aJKJqK1l+vB1jsX?= =?us-ascii?Q?Ec3sFVN0DNLQihy8BHHoIwJwDb38qPPk6kCVMvoDcIDp8kBqg/j+4i2jSRw9?= =?us-ascii?Q?11U2aAawBYpDnTXtxtWX7rv3lvulxWNr5glz/+go31hlurgBtlXhFPZRBJaY?= =?us-ascii?Q?9ZjofRp/rXWd1+nGyc2o0VKkkU5JvCEwdwyvL0BsXH9RvnXXcr8d3h1BV/CV?= =?us-ascii?Q?GuNfYU8n+GB1MR8Cpeg0UiUROIx+DlOK8RXnRfphhWbQIXwI8MX93GlCFUys?= =?us-ascii?Q?cytLBRoUeNr8QBQ/kSfmnnl1pTTAuxwmMySSSdyVecOFX7ubRHenjMPLvemn?= =?us-ascii?Q?qXp3kel0n/0RCb9o9PWPU61xAnKiGGbADCpdNf8CFCu91FIwKbZnor59yy4e?= =?us-ascii?Q?zfNIOz/HtFY7d5GTCCsq1L38JS54pm0R17q9claa+4/kxPVaDTuLvrddO49E?= =?us-ascii?Q?oCEB07uBQuAEoOe4b4KYM0SQlo4DShc1m1Ugd9Vy0tEBqToY8y1GylSEFA8L?= =?us-ascii?Q?FPysu4hU5e5t+M/mbT9Xx4XSOH99ajXM0hcBo8r+eJEgrYfntxzVfky6XiQ2?= =?us-ascii?Q?TwAd8IFgTmk3K6ZJ7Gi1WXZ5qtTuRnL/sfI1gkbSjlJ4rifn+oKyQHnDN75J?= =?us-ascii?Q?57nTAV2yuL4e2Z/QMDmXpj4Jy2E8kFQeYpAxi9WQtNxECr1D1cZccUGdIQLa?= =?us-ascii?Q?eQ0OF+G3Li2wbiWZdIMa1ObEAdv5TRLOid+P+nRKST2k7a8jUzZMwTN5ClWM?= =?us-ascii?Q?zYEbHwJe7l6Qaj5bGN6J6RXYZeKvBktsTyso7b5OZCIyOGs/KaBNjUC6ideB?= =?us-ascii?Q?YqfPGExTslDptk5i1P/MkW8Q9i9hcmDhWOX+0665rYGGEg3jRvVSqCm2Z7KD?= =?us-ascii?Q?3hFxk4YPq8b5k/k3H8YpEeS+/xKwpjti5GFYGwDaQ5YD07fwNsY8CIwVRBxj?= =?us-ascii?Q?sazcSS+56+xDDuw2wr0SWtUsZcmYgQ88XIlllQCDwhy4gQeKZGswK1DkjgNy?= =?us-ascii?Q?H/v/7/5129TSfu7EqVBF/CtIa3V06SazvijfZjQX7UkkL/GK/XKMEu5NqC2z?= =?us-ascii?Q?DdjQHvJ47Uf6MaKZzrLk1P+PVcKNDU8PCkxUkYuRo41zH+ioAkExJS958aDQ?= =?us-ascii?Q?JuFdcz85X6dnRVm15TTE1NFEwgbBsPvZe2nRt/8eXvY0hmDg21FBwpwHqVIf?= =?us-ascii?Q?/ccVSILNO1fB121pqFZmb/v+WuYjYQrkbRIG+UkKOB0YsV/ZpuX6Uio1Y2b+?= =?us-ascii?Q?eqGYamgDDpKOlqRvhH+pwgMHUKZVyMAhfVwYLIhUzeGNfJxmPF4TyqIAR4AZ?= =?us-ascii?Q?kL6xvwGtVcgzcg9qMzqNS5sIe1XGnmR8XbX85jJk2+PbRlU/KMjjg6Kq6tqo?= =?us-ascii?Q?iUEXUsNlr6QmYBdfG0tH6spfRbQ09fi1ua1IvY9micPsEUqAwQBTqJHeKx0L?= =?us-ascii?Q?m+3vA3JH7ROuQLz6MWZKJ1cJldO0+heNuHv3powddKzlJ6RLwjOMsz/L4WH+?= =?us-ascii?Q?3GbMYPKEaY3ktiX0aIbOIxfOLZ9ptPdk6zzMzBDlI04UP3ZKiaqodNG8Zmcb?= =?us-ascii?Q?Jz+MyITnFeehKgZexm5kSjXWDGUtE8k9DdruOoUN?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR11MB4938.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65780212-3a5d-4a84-88ea-08dbbed98cfe X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2023 21:42:58.5650 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /lIA1zY36JeOpnghxDlEEy3828ZuTgKu0VHVkQeTsiW6qYjXmGp6/NlsDEShFBTp0SjSAWA82mbOgXmDYSk9bJVcMn6ST0JCIhmQGlHTD98= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB8320 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: wndBBAcq2yox9QjShdZxmmfwx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=k2piekBd; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Nate, Declaring all the local variables at the top of the function is=20 really a coding style recommendation documented in the EDK II C Coding Style Specification. End of Section 5.4.1.1.=20 Declaring local in other scopes is strongly discouraged. https://tianocore-docs.github.io/edk2-CCodingStandardsSpecification/draft/5= _source_files/54_code_file_structure.html#54-code-file-structure Block (local) Scope Formal parameters in function definitions and data defined within=20 compound statements have block scope. Any group of statements that=20 are encompassed within a pair of braces, { }, is a compound statement.= =20 The body of a function is also a compound statement. Compound=20 statements can be nested, with each creating a new scope. Data declarations may follow the opening brace of a compound statement,= =20 regardless of nesting depth, and before any code generating statements= =20 have been entered. Other than at the outermost block of a function body= ,=20 this type of declaration is strongly discouraged. This specific change here is in a windows specific file and=20 improving readability of the windows specific version checks=20 in #if statements warrants an exception. Mike > -----Original Message----- > From: Desimone, Nathaniel L > Sent: Tuesday, September 26, 2023 1:51 PM > To: Kinney, Michael D ; > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu, > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Looks like it compiles fine in VS2015, and we just removed the > tools_def entries for every VC++ version older than that. And C99 has > been in gcc for a very long time and clang forever. So perhaps we can > start using C99 style variable declarations finally? >=20 > Thanks, > Nate >=20 > -----Original Message----- > From: Desimone, Nathaniel L > Sent: Tuesday, September 26, 2023 1:39 PM > To: Kinney, Michael D ; > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu, > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Oh, never mind, I see you are suggesting a C99 style variable > declaration. Do we need to worry about old compiler that want all > variable declarations at the top still? >=20 > Thanks, > Nate >=20 > -----Original Message----- > From: Desimone, Nathaniel L > Sent: Tuesday, September 26, 2023 1:38 PM > To: Kinney, Michael D ; > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu, > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Hi Mike, >=20 > Unfortunately, that change will generate the following warning on > GCC4.6+ >=20 > warning: variable "Success" set but not used [-Wunused-but-set- > variable] >=20 > Hence why I wrote it that way. Let me know if you would like me to > make a different change before committing. >=20 > Thanks, > Nate >=20 > -----Original Message----- > From: Kinney, Michael D > Sent: Tuesday, September 26, 2023 1:03 PM > To: Desimone, Nathaniel L ; > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu, > Chasel ; Kinney, Michael D > > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Thanks Nate! >=20 > I have noticed this issue for a while. >=20 > One comment below. With that update: >=20 > Reviewed-by: Michael D Kinney >=20 > Mike >=20 > > -----Original Message----- > > From: Desimone, Nathaniel L > > Sent: Tuesday, September 26, 2023 11:36 AM > > To: devel@edk2.groups.io > > Cc: Andrew Fish ; Ni, Ray ; > Kinney, > > Michael D ; Chiu, Chasel > > > > Subject: [PATCH v1] EmulatorPkg: Fix Terminal Issues > > > > After running EmulatorPkg, one will notice that their terminal acts > > strangely. This is caused by the EmulatorPkg Host changing the > > terminal mode and not restoring the original mode, which is now > fixed. > > > > Cc: Andrew Fish > > Cc: Ray Ni > > Cc: Michael D Kinney > > Cc: Chasel Chiu > > Signed-off-by: Nate DeSimone > > --- > > EmulatorPkg/Unix/Host/EmuThunk.c | 16 ++++++++++++- > > EmulatorPkg/Win/Host/WinThunk.c | 40 > > +++++++++++++++++++++++++++++++- > > 2 files changed, 54 insertions(+), 2 deletions(-) > > > > diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c > > b/EmulatorPkg/Unix/Host/EmuThunk.c > > index 6422f056a6..e6879db650 100644 > > --- a/EmulatorPkg/Unix/Host/EmuThunk.c > > +++ b/EmulatorPkg/Unix/Host/EmuThunk.c > > @@ -9,7 +9,7 @@ > > it may cause the table to be initialized with the members at the > > end being > > set to zero. This is bad as jumping to zero will crash. > > > > -Copyright (c) 2004 - 2019, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2004 - 2023, Intel Corporation. All rights > > reserved.
> > Portions copyright (c) 2008 - 2011, Apple Inc. All rights > > reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -34,6 +34,9 @@ UINTN settimer_callback =3D 0; > > > > BOOLEAN gEmulatorInterruptEnabled =3D FALSE; > > > > +STATIC BOOLEAN mEmulatorStdInConfigured =3D FALSE; STATIC struct > > +termios mOldTty; > > + > > UINTN > > SecWriteStdErr ( > > IN UINT8 *Buffer, > > @@ -58,8 +61,15 @@ SecConfigStdIn ( > > // Need to turn off line buffering, ECHO, and make it unbuffered. > > // > > tcgetattr (STDIN_FILENO, &tty); > > + if (!mEmulatorStdInConfigured) { > > + // > > + // Save the original state of the TTY so it can be restored on > > exit > > + // > > + CopyMem (&mOldTty, &tty, sizeof (struct termios)); } > > tty.c_lflag &=3D ~(ICANON | ECHO); > > tcsetattr (STDIN_FILENO, TCSANOW, &tty); > > + mEmulatorStdInConfigured =3D TRUE; > > > > // setvbuf (STDIN_FILENO, NULL, _IONBF, 0); > > > > @@ -338,6 +348,10 @@ SecExit ( > > UINTN Status > > ) > > { > > + // Reset the TTY back to its original state if > > + (mEmulatorStdInConfigured) { > > + tcsetattr (STDIN_FILENO, TCSANOW, &mOldTty); } > > exit (Status); > > } > > > > diff --git a/EmulatorPkg/Win/Host/WinThunk.c > > b/EmulatorPkg/Win/Host/WinThunk.c index 008e5755db..90a6da2ece > 100644 > > --- a/EmulatorPkg/Win/Host/WinThunk.c > > +++ b/EmulatorPkg/Win/Host/WinThunk.c > > @@ -1,6 +1,6 @@ > > /**@file > > > > -Copyright (c) 2006 - 2018, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2006 - 2023, Intel Corporation. All rights > > reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > Module Name: > > @@ -30,6 +30,12 @@ Abstract: > > > > #include "WinHost.h" > > > > +STATIC BOOLEAN mEmulatorStdInConfigured =3D FALSE; STATIC DWORD > > +mOldStdInMode; #if defined (NTDDI_VERSION) && defined > > +(NTDDI_WIN10_TH2) && > > (NTDDI_VERSION > NTDDI_WIN10_TH2) > > + STATIC DWORD mOldStdOutMode; > > +#endif > > + > > UINTN > > SecWriteStdErr ( > > IN UINT8 *Buffer, > > @@ -61,6 +67,12 @@ SecConfigStdIn ( > > > > Success =3D GetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), > &Mode); > > if (Success) { > > + if (!mEmulatorStdInConfigured) { > > + // > > + // Save the original state of the console so it can be > restored > > on exit > > + // > > + mOldStdInMode =3D Mode; > > + } > > // > > // Disable buffer (line input), echo, mouse, window > > // > > @@ -82,6 +94,12 @@ SecConfigStdIn ( > > // > > if (Success) { > > Success =3D GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), > > &Mode); > > + if (!mEmulatorStdInConfigured) { > > + // > > + // Save the original state of the console so it can be > restored > > on exit > > + // > > + mOldStdOutMode =3D Mode; > > + } > > if (Success) { > > Success =3D SetConsoleMode ( > > GetStdHandle (STD_OUTPUT_HANDLE), @@ -91,6 +109,9 > > @@ SecConfigStdIn ( > > } > > > > #endif > > + if (Success) { > > + mEmulatorStdInConfigured =3D TRUE; > > + } > > return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR; } > > > > @@ -467,6 +488,23 @@ SecExit ( > > UINTN Status > > ) > > { > > + #if defined (NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && > > (NTDDI_VERSION > NTDDI_WIN10_TH2) > > + BOOL Success; > > + #endif > > + > > + if (mEmulatorStdInConfigured) { > > + // > > + // Reset the console back to its original state > > + // > > + #if defined (NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && > > (NTDDI_VERSION > NTDDI_WIN10_TH2) >=20 > I think the BOOL Success variable could be added here and reduce the > #if statements >=20 > > + Success =3D SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), > > mOldStdInMode); > > + if (Success) { > > + SetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), > > mOldStdOutMode); > > + } > > + #else > > + SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), mOldStdInMode); > > + #endif } > > exit ((int)Status); > > } > > > > -- > > 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109094): https://edk2.groups.io/g/devel/message/109094 Mute This Topic: https://groups.io/mt/101602599/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-