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 87A7A780091 for ; Wed, 27 Sep 2023 02:59:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=cPb8lGWAk01E81pgePHigxdCVo0RksWILzB9V4XCgdE=; 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=1695783549; v=1; b=dlGhH9W5INUZZcy1D0SRgpwksAkd7IS7/0QiC1XoqNypshTMPlS3BEw5wr763GnXtl+dSXfw XeTdd2OuKa6BChfUkSngDP3BtJuzC1G2EV0EKopKCmYzM/kgEFFGeubc1NFyLKUVmLC47DTI+2N apNiAXtaJcsz7EUcB3ZNDvps= X-Received: by 127.0.0.2 with SMTP id EoCBYY7687511xFhGd4B5kDq; Tue, 26 Sep 2023 19:59:09 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.9463.1695783548389303854 for ; Tue, 26 Sep 2023 19:59:08 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="448212673" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="448212673" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 19:59:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="384201" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 26 Sep 2023 19:58:36 -0700 X-Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 19:59:06 -0700 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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 19:59:06 -0700 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (192.55.55.68) 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 19:59:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+8ureZkP8fsRlnuhgwrQAeKgrLm4cl9BwI9ONG6wERe/hcUsUo7ev8oJLI2LOJK7wFM/Cu7Df+/nwq7Ergd5Gn5bbtL93lmYfpd0YpT2mupvZA8GfwwEJe0dxD/3OBvL7A1mFMPiMdTrM++jIU0ojY6NH/NrSeYIPk/AFeyi393iiTQQGG59Zf/YDpuclAuscFoa5BRhdYQZneWpVaFw+l88EdvszSjN2aZUQU7BVo0mfNj05kxy6Vqf0cRSZY2MqrYdlI3eXUSx18mNq132+Bc1UbezM2Q6uKEDiQG19lGoQV8WjNdlw59k6eP74H2CU0nPQThdpwxPqiiLF/2rQ== 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=DmZMvOBAawm35Vyem4nLv1B32HQxJh+XyY2RqiFdmcw=; b=K30jHLj5Y1aOOO4JBEqwLcJXbFqy6Q8s92i6jFXiTO0hgAQpYxJOFsOu0zYdzLNR8myGKo4wjS9cKxan5cfkf71EPGg8dnfa+gYlIBcF87FV+ZbgTjMea+77rkQzI3FkvUoAQtltGBKYfyy3704qyN+KgUwyhAc+5XnT50ZCqvp/dLSTmSYHtL9jGvu1SDBFn7hC5ODT7+w2rUOFMhiPpxcHYnMwu2oxVORHGquEI/SnlLdWpmerD5rnJ5JUW6RfuNyK6ldMVMHRaBUAcuLQkI5fSu0n8KNzamn1JdkyzxbEm8jQkiPP2zFeL2azTQwFmW49KKUhMdZFXSLr0a011A== 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 MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) by PH8PR11MB7095.namprd11.prod.outlook.com (2603:10b6:510:215::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 02:59:04 +0000 X-Received: from MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::89db:ecf0:29f5:9f3c]) by MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::89db:ecf0:29f5:9f3c%4]) with mapi id 15.20.6813.017; Wed, 27 Sep 2023 02:59:03 +0000 From: "Nate DeSimone" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Andrew Fish , "Ni, Ray" , "Chiu, Chasel" Subject: Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues Thread-Topic: [PATCH v1] EmulatorPkg: Fix Terminal Issues Thread-Index: AQHZ8KhcA9l2MMuSy0C673hGdEk4+rAth0pwgAAJYYCAAADRwIAAAtQggAALYKCAAFvVAA== Date: Wed, 27 Sep 2023 02:59:03 +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: MW4PR11MB5821:EE_|PH8PR11MB7095:EE_ x-ms-office365-filtering-correlation-id: 88a29871-8f8c-4051-656e-08dbbf05b53d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: YwSL9gDmmw2ib++YNT1jl16y7YtNCIbj1Kcxt9VTgA47viKusNLdBCPcuDXooSUaWd3RSzcgmYL0d4xKONsQeskoVYA9WGyyGRPbPr/NFdIzma58dCULVlHs2ycc0hue3OQ3Cjl9tT8MAx69P/9kpqBtpODUnNQmfzPbqfzStW3vwa3023U+EyaGM9CxR5fN/FWnI70u4GoDYnt/DzNJ6bRYBgHPTFLsNYcCrD6RaTSGkTU1hY4/Gp0ZNWcR+YNJ+BewaqxvROVaaswk/eucEXXJeODbe9XpLWJxsVuK3q6QUy4frdZs4fEZjtwofIhIVISiEOU7yvXFm3YMw2W7HArIdv39rzTEuKRZPs8oo6A6+3smmge3/2g3mL3lo8nIugs3Nb8TAOU0R2P6E745GeXaJkifBjiXEUH7vTt6JEajZtiivyxOQqxC8fWkR/RJWrNx39JUxAkGKF5rp+f0TEe4ATohgvzV3klyaj341iYv1ZmLCmHEy6t8ay5xbaSZ7IYqYc++PMa5yEiiijGOfimhLhLHAoUSldZuQ6cd50YyQsQLUezGNoMeOLSWJVuvusWRb16b5QO9R+mBVrfe0TCgE4QYBIUsjqLjrv6nuHw= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?f7Pwq/uOoWrdoLs2DiiQb/ettXeH7nR/RGCRlEAh6EH8+GC5Lp7JQ10yGbjA?= =?us-ascii?Q?1sSMlOr2vc3RHf+zzMRTymFZBUUBkeallloKJt2bUNEB5shVECDZjPa8dqpe?= =?us-ascii?Q?Quo92B4fV4+ovjyuSuagdRIqrLHsZfXu9585H/A+KV4KgsKhr+cZm+XZaCyS?= =?us-ascii?Q?/X+5mBBV0BOuyvD3SbVrOeYuPs+r2OqbzJbXF5RNMM84Q+7V9+d5Rg6KudoP?= =?us-ascii?Q?gZWWuAo+5UdixBfY79qy+x/hupv9w8KFnw06vSM9cK7P8dWPS+w3gmWMjsEI?= =?us-ascii?Q?cshrJt1pbbo//jWxTuUH5FhYV9Dcd1K1HMi/mWv7pkcNYOSSmyAgLqdVxNEW?= =?us-ascii?Q?O34dwMvjGqkOsTyQBsko1UlR+dWDTblc0ZHDv8+nw2Ycg3sKXXwLZYFIcARv?= =?us-ascii?Q?69rlLIEjonZAhVDE6U1e7hzvLPNAf/2D6VQJRfNauPxPmkltlpgIgxjz/dmE?= =?us-ascii?Q?573Xmlrq32LMEjNMWgVK9znDcQcbgHooV1WP4BDJR7wXJgO8uHaxhYXALYHO?= =?us-ascii?Q?gWh4X4kSNbHdkrh36bXKonKbhF0o0O2vbXTdbvaq11na9I1Gj8woQ3cgYULp?= =?us-ascii?Q?yXny2cOhi3USDn4xkA/2d9nTGZKQOp63VBBRWiEav/9tbziPoXfM60ddiyvq?= =?us-ascii?Q?dV6Lus0ZGSc9vDiaSzkqHiPUKuL3JtgPUpO7HkWfC0rQkLHJTc7svbXDStFl?= =?us-ascii?Q?H4Z3pE9z63BTr6mu/Ugreqmk8I+OJfKUK9ifQcLJVcskqxw8quRoVOyC2/zP?= =?us-ascii?Q?4lN+PNp3ZPJcKWCupr2itMi8AAxKaGfzxZbh24veKv722dos8sSk5/wvY4Ih?= =?us-ascii?Q?ZygNc9hk4lLG7N+kEG7XmZFJcfVE43NKZit0sGak+bw+/1z0hzPNmI5JOsvk?= =?us-ascii?Q?zfxlJULNT3E3eOoJWoiiNzrF56wxviOnZlWLKUgjiwxzGgB0N5oopIWyhTVb?= =?us-ascii?Q?jWDIDKf0OiPjrEv6nBBtDADHneAWjhqZ0tryOW9wtMiipEyzQh+Ux/fpeiXP?= =?us-ascii?Q?hRI1lHAbwQpjYkSySimxTDMPaDugSJNHVP8/YIagtFcZgzoXWJYrC2MGNLiH?= =?us-ascii?Q?aPiYQGISNde/IP2apkYrFq0YN51yDMi0l9gQrqUZrVgq1+Ou28mIe1giXNlQ?= =?us-ascii?Q?KX04n5OC4YJGqByt1mSMvBfZwynSvNdHrCh9qlu/eVzdfmXH75m4B4C18D0v?= =?us-ascii?Q?iCB7GVCBc0IbUTKpMA/8gGDGgAUKSVPV4WG97NPTbxTCq7R+T4IibVzpO2xS?= =?us-ascii?Q?FQCeWb20gB4XRLkJc6awZ+SK1u4P+27Sc/KtCyk62OJBjOCzYhpp8TVAFEBy?= =?us-ascii?Q?2mvTLxteFveGTlbYbJPCTb1WYY3zmldUCqo6jkqLXe7AAqHMGhnIkzUG/im3?= =?us-ascii?Q?6XaBtLWzdHIb9y7J+aNeJzf3T6FmG0+zSYa4cdD1VPwgXR3LFD5aYZRANLbT?= =?us-ascii?Q?byod1l8vzAR8CAp541x9pDMkQMQ8lzSD+h9uzK5yMcQ0/DmHMsPdrffPU8Lr?= =?us-ascii?Q?8/FZUiRIWoUyhF9k86bxwL0Ck8jeOT7szT/Q8YoqY1RLANXatxCHUk8v3aIx?= =?us-ascii?Q?cvzA8K7EazO25o3GrngtY6sBMz3NIaTpyua2By31NgucxuXlGyGXYyYL93WZ?= =?us-ascii?Q?kw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88a29871-8f8c-4051-656e-08dbbf05b53d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2023 02:59:03.9174 (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: eZZc1ORRc/EehKu1QEsMsyE/ZbZEak9Anb6tqfTI8e1tECHxUHqOilu95FH13XjtF9auM/5/J/vMzWb0BHr2t/U1P60XgNEr7CnNpA3qA7s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7095 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,nathaniel.l.desimone@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0bSKs2bniCixwg93Qd9zKTUDx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=dlGhH9W5; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 Thanks for the reminder/education on the coding style. I knew my habit of p= utting variables at the top of functions came from somewhere. Pushed: https://github.com/tianocore/edk2/commit/ad1c039 -----Original Message----- From: Kinney, Michael D =20 Sent: Tuesday, September 26, 2023 2:43 PM To: Desimone, Nathaniel L ; devel@edk2.grou= ps.io Cc: Andrew Fish ; Ni, Ray ; Chiu, Chasel= ; Kinney, Michael D Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues Hi Nate, Declaring all the local variables at the top of the function is really a co= ding style recommendation documented in the EDK II C Coding Style Specifica= tion. 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 improving reada= bility of the windows specific version checks 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 ;=20 > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu,=20 > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Looks like it compiles fine in VS2015, and we just removed the=20 > tools_def entries for every VC++ version older than that. And C99 has=20 > been in gcc for a very long time and clang forever. So perhaps we can=20 > 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 ;=20 > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu,=20 > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Oh, never mind, I see you are suggesting a C99 style variable=20 > declaration. Do we need to worry about old compiler that want all=20 > 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 ;=20 > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu,=20 > Chasel > Subject: RE: [PATCH v1] EmulatorPkg: Fix Terminal Issues >=20 > Hi Mike, >=20 > Unfortunately, that change will generate the following warning on=20 > GCC4.6+ >=20 > warning: variable "Success" set but not used [-Wunused-but-set-=20 > variable] >=20 > Hence why I wrote it that way. Let me know if you would like me to=20 > 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 ;=20 > devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Chiu,=20 > Chasel ; Kinney, Michael D=20 > > 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=20 > > > > Subject: [PATCH v1] EmulatorPkg: Fix Terminal Issues > > > > After running EmulatorPkg, one will notice that their terminal acts=20 > > strangely. This is caused by the EmulatorPkg Host changing the=20 > > 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 ++++++++++++-=20 > > 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=20 > > end being > > set to zero. This is bad as jumping to zero will crash. > > > > -Copyright (c) 2004 - 2019, Intel Corporation. All rights=20 > > reserved.
> > +Copyright (c) 2004 - 2023, Intel Corporation. All rights > > reserved.
> > Portions copyright (c) 2008 - 2011, Apple Inc. All rights=20 > > 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=20 > > +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=20 > > 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=20 > > 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=20 > > +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),=20 > > &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=20 > > @@ 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=20 > #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);=20 > > + #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 (#109099): https://edk2.groups.io/g/devel/message/109099 Mute This Topic: https://groups.io/mt/101602599/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-