From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 2D3D921A0480F for ; Wed, 5 Apr 2017 08:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491404911; x=1522940911; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=wShNqLsOk8Nk9hH6kKK42AmgkgwuzNTTVzMzLXuT3+c=; b=sIKKbLw2u7Kgsqvz74QsSLrLulbZTNhAtvrDfJsfsgIM8sAzullaoojI iTzzwU7JHvLw0I9Vvwdu3XZ/M2tueQ==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2017 08:08:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,279,1486454400"; d="scan'208";a="83505524" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 05 Apr 2017 08:08:30 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 5 Apr 2017 08:08:28 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.246]) by FMSMSX153.amr.corp.intel.com ([169.254.9.6]) with mapi id 14.03.0319.002; Wed, 5 Apr 2017 08:08:28 -0700 From: "Carsey, Jaben" To: "Jim.Dailey@dell.com" , "Ni, Ruiyu" CC: "edk2-devel@lists.01.org" Thread-Topic: UEFI Shell Lib Constructor and Shell Parameters Protocol Thread-Index: AdKuFe4dMrnMRkXwRa+ni64zpaOLZAACDXMA Date: Wed, 5 Apr 2017 15:08:27 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTk4YWM5NGEtNGY3YS00MjQwLTg4ZmMtNDI2NWQ2MTRiZTliIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InFXb3RkNVBYeEsyK21qRDZaaXhxQ3NqaHBuN1RwVUVYNnpiTEF1WEU4dWM9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: UEFI Shell Lib Constructor and Shell Parameters Protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2017 15:08:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jim, That protocol must be installed on your applications own image handle for i= t to be valid. Locating the protocol on some other image would result with= finding the other image's command line parameters and the like... -Jaben > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Jim.Dailey@dell.com > Sent: Wednesday, April 05, 2017 7:07 AM > To: Carsey, Jaben ; Ni, Ruiyu > Cc: edk2-devel@lists.01.org > Subject: [edk2] UEFI Shell Lib Constructor and Shell Parameters Protocol > Importance: High >=20 >=20 > A question or two for all shell experts: >=20 > In the UEFI Shell Lib constructor code, if the Shell protocol cannot > be opened, then an attempt is made to locate it before "giving up". >=20 > However, if the Shell parameters protocol cannot be opened, no attempt > is made to locate it---the code simply leaves the parameters protocol > pointer set to NULL. Can anyone explain why this is? >=20 > I came across an app that crashes because of this behavior, but if I > add code to try and locate the parameters protocol, then the app works > as designed WRT accessing command line parameters. Is there some > lurking issue if an attempt to locate the parameters protocol is made > and is successful? >=20 > Thanks, > Jim >=20 > ------- > Here is the relevant code: >=20 > EFI_STATUS > ShellLibConstructorWorker ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > EFI_STATUS Status; >=20 > // > // UEFI 2.0 shell interfaces (used preferentially) > // > Status =3D gBS->OpenProtocol( > ImageHandle, > &gEfiShellProtocolGuid, > (VOID **)&gEfiShellProtocol, > ImageHandle, > NULL, > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (EFI_ERROR(Status)) { > // > // Search for the shell protocol > // > Status =3D gBS->LocateProtocol( > &gEfiShellProtocolGuid, > NULL, > (VOID **)&gEfiShellProtocol > ); > if (EFI_ERROR(Status)) { > gEfiShellProtocol =3D NULL; > } > } > Status =3D gBS->OpenProtocol( > ImageHandle, > &gEfiShellParametersProtocolGuid, > (VOID **)&gEfiShellParametersProtocol, > ImageHandle, > NULL, > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (EFI_ERROR(Status)) { > #if 1 // _Dell_ : Search for the parameters protocol too! > // > // Search for the shell parameters protocol > // > Status =3D gBS->LocateProtocol( > &gEfiShellParametersProtocolGuid, > NULL, > (VOID **)&gEfiShellParametersProtocol > ); > if (EFI_ERROR(Status)) { > gEfiShellParametersProtocol =3D NULL; > } > #else > gEfiShellParametersProtocol =3D NULL; > #endif > } > ... > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel