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 11C92D80144 for ; Thu, 28 Sep 2023 22:19:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=g+T7JE5Eh3F6xWY2Mavsu2OA8RY12PTQvwwWAd7gLew=; 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:msip_labels: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=1695939567; v=1; b=B+EfRpEFB4YFjeQ1s9t9Dxo8ZIBwyktelT1fKsGfttN7EY/hLCkH8ZPKrHtB61rSToO98q5h Y9arrFH/WLcrOv3Dn0ObGO8Y6ALrvYXWYrQ0nkVyH0uybSDIcBYCHCP2LV95+lDp+PAG/Gqaw9n VJAKLTKKWPyBj4h9tMrHx7Kk= X-Received: by 127.0.0.2 with SMTP id TrmvYY7687511xrRaaQ1q6eJ; Thu, 28 Sep 2023 15:19:27 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.5544.1695939566226621722 for ; Thu, 28 Sep 2023 15:19:27 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446350646" X-IronPort-AV: E=Sophos;i="6.03,185,1694761200"; d="scan'208";a="446350646" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 15:19:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="784890674" X-IronPort-AV: E=Sophos;i="6.03,185,1694761200"; d="scan'208";a="784890674" X-Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Sep 2023 15:19:18 -0700 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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; Thu, 28 Sep 2023 15:19:17 -0700 X-Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Thu, 28 Sep 2023 15:19:17 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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 via Frontend Transport; Thu, 28 Sep 2023 15:19:17 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) 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; Thu, 28 Sep 2023 15:19:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U3DMMsL7k6DRK+uD+g7NeJK0c/xr394N12lKUn3tEE4T1LaEK/Z/lMd3pNUNRpXlNpeqkfIYqut9ePSvq7MpgsTjs2B4MVDRKqt6bWa8Vq6X4Tx2kNC+qvhUEYT3EuqYm5Zaf5EDvIBvpE8SuxWT+w1uPYZt9pVbNAEyme1ihPqnUrZd4BjolcYuipeXVJFnfm04inemnwMC5OqV82yDRfI1Bf0qt0sgAsJVhz5DVQfQ2tPGFCp9itDF6MFYtHQwbEhcR6tdtJBhiOyUlzkuHr4+IM6DS8g8p/CLO33VT+dMfayWMovFsp6uP91v1PN9RTY3Rx8U9NDnEj3IAsJr7A== 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=eut77Vr+cPNhg0Da8G8glcdn2u9esr0G/2U+IphyTYY=; b=EZM3QpnN3o73altP8WIzp/kJgXy685W0oTcMhMiQ2chcX94bcw6qkGeLz/R5gWuz5tXVIG1KeApaBGmgMvyscwDDxIQS4DNQuEILsKh7/xN9O/j1kaZOzR2ZWJxdre+ML882iuK07NkNz+0snTmehlSXOS6eRpMrjiaCD9asVIivYC4XqLJL8rrw4RHbDR0co8PCi7B75FlfzJYGOEI7azJ3j/KXtwmD13+Ya+xUgd49OZ+KX+4VhbNUIiOactbdsNKbJxMbkpbYFOFMXiRsnMwkYbEUK+PK1xtqjAO0CMq18uDXnLTRVQJadfrBUDEft8kjBuM+yyIm7d2b+v4PJg== 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 SA1PR11MB5802.namprd11.prod.outlook.com (2603:10b6:806:235::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Thu, 28 Sep 2023 22:19:09 +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; Thu, 28 Sep 2023 22:19:08 +0000 From: "Nate DeSimone" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Andrew Fish , "Kinney, Michael D" , "Chiu, Chasel" Subject: Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows Thread-Topic: [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows Thread-Index: AQHZ8PUQLHA+4eW5jkeRufIXz2NvSLAwyx/wgAAAKZA= Date: Thu, 28 Sep 2023 22:19:08 +0000 Message-ID: References: <20230922224923.1978-1-nathaniel.l.desimone@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5821:EE_|SA1PR11MB5802:EE_ x-ms-office365-filtering-correlation-id: 5871dfd5-0c60-4847-34db-08dbc070ef71 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: YS/E4GGwm4MKdKDRjOG9MwWRdNq78VryeWbQswpc41IgAV6Yl3UHd1zcZs/8o6AF5XIwKNO69hcx7UIeg0s6Zow3+QVIVj/RqxRVZCsWh6QZH9zbxuP5nHuXprg5bFY89ZtLXZo1jVfgqGXZScICOr1SRhbQEdSKLjGV+68RfQLa1t8gO2Vmlg+tBQILGEyDrb5ne9qO2b0OaOteWRYBcYecouETGtjBkaqGle3fIfA6q40OnPGZd8JpVSumWFZpWc8KbXpUC7ZjQYb2n9J6RNSg/KeH+gxIHvIxHhgWmY6Ld7Z7gVIW+SwCIbwc6bWuU5qO5cRlBBBGfvLbry7AamWQ61mdC5NNf3xFzv3QhWRphYXeTVxfrGPHLh03j3Z/ozb6OllKJISLaNM7oU+e0jgGsNy74m8x9JSpoikL6oygg5ING11fuiWKdqft9ty2/4GuHQihaDfqjCZogw5Wfp3CHYA7I7qvdym/S9AhkvPQVPis1EU/YFKgvsoEa+48QQm7iZaIoZd0mVnbGm+RSc4OTjfc2Py5qplAMpWRsdAjC1mE+x5psjdsBFoXRub+Qj0QnVdmPIHrXfFEp7k7Hn4drpXuODNQ2eXEqywXey0WgKESvV9YdvhmU0Cmuy/U x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?u8yt8pEozcy+kI3QdWbFvl8adN9/EY/DOoh1lRr98bsO9qpOmBXKze8dl/?= =?iso-8859-1?Q?xQpvmmJ7rUIuSrDtvBAhJV+BZXtGgw8OjzBb7/41a7FVXZ28KwPZF6pD0n?= =?iso-8859-1?Q?8avXRTRK+qyQxViEnQSucpZSd8+eCgH1rLIflfZzgg9MAqFDYYCEpCfotw?= =?iso-8859-1?Q?4akCqaLYylWOxUQ0gVXfQTHk2XBDjkxzUgUr6UfNmqPzEuEC7F7JeSCUYL?= =?iso-8859-1?Q?qdD6FD+0A+tCXxCKzLU79zER/j0RDcNwC8JEVvgxdM6+b4+rSk5OQw2WTQ?= =?iso-8859-1?Q?3PNfmn7+lJ0UQe5pGoSlI6KRzGmFbckwpy82MqmHPUnBN4kASeBaxJJ7O5?= =?iso-8859-1?Q?3H0+Vh/NxxjeKLfCYSajlRoKQlSvgCWJOJPSonI7CDkhJ/ZUhCnxLz/8Y9?= =?iso-8859-1?Q?aQUNRFrYGE/2y/x6psjssEGZ1I4ShsctKZQG7J9GDbI7lXY0PHwka/VvfT?= =?iso-8859-1?Q?YUk40vrtnU2MZGGehBBG88sAtCWjGAXsIT7/xIe4EU7P/WeNOI2X7+Eytr?= =?iso-8859-1?Q?tw2rSTmpBjdSU5eBvyMBU9e8M9OAiWYXTaeD9+wQ+bAB1FaFTLPTJ1wKJU?= =?iso-8859-1?Q?XiItbekDd9vfIxQ7SfDCXL5Cg4rJGWtwVcrlHKSGngO7FQHo5OIJygZj7e?= =?iso-8859-1?Q?47y1Q8LvBB6zE4F6VXToccSyQ0Kee/pkY+qgMEOILne/T3ZRq/GW2EusnX?= =?iso-8859-1?Q?fqIfLx2YDVZOqc1Qx5Mq07BsuuJ/CsFm65Tu6U/22GojC7mhVZKXYgXwqz?= =?iso-8859-1?Q?82jl1cHE99vPa5VtWNwl9zQjSM/7T6KoRG2HgLcWopu5HjpKf5g/BUngsL?= =?iso-8859-1?Q?Nil+moeVRzrhARth3+h0SrwSZVXSP/PqVnkee8j1RNhWIRt4+gwAebNKEE?= =?iso-8859-1?Q?8ZJuvorqGAq9Ywvr6H8wCkwAKzHhvJJxsukHVNdIv4rMFqICXdrJaqi7gE?= =?iso-8859-1?Q?oAl33tod0wJyTD3H4pEmkDzpQVOCs3JzqYDSiXYE4BvuCTtHvQFJjKjM4E?= =?iso-8859-1?Q?EUkobygwd5CPL9c56G7bvjJ4h1U8b1D7qya5A8vpfgbtgFUxXBOuOZLvbq?= =?iso-8859-1?Q?Cah+ZCu9B6kPflN52b4Bpk/9yxZcYzxosLFhbmATwWdWcIfcRy6XX72qHm?= =?iso-8859-1?Q?IOmq/CvQ0X2QXr1uPZfmsQuBAdKfXTiO/8EYOOU92D+m8ST+ZlDsKuo/Q0?= =?iso-8859-1?Q?Zhy0oYFbz3SaF/t4t3Dz6iK+xNCVXtEDsfiwcRuQZHpJp4trQwyE6t77oF?= =?iso-8859-1?Q?Mq0p0FIr88611SylAH7dYx0RHR9FHkHXfWPqjeHwaaArMH2riVGM1pa0o5?= =?iso-8859-1?Q?q06o2tnQqPD0Y3jA5or0jKOkSiMyI6Ln3yeqrE/gmGmpWcZznhY6rX/Wvy?= =?iso-8859-1?Q?bI5HY77H6MER6zwJ/5xiy30cBagWugKqv7Gq8OQD2OQY3A2b5B6l6LrvsS?= =?iso-8859-1?Q?I8yXlfClbuotsgmpsRqQAB4Kl9/ALIZW9nPPUYt8rI3PobxFtuZEiGK8Hi?= =?iso-8859-1?Q?kCn5brgvTAYwojsvXPL1jWjlwFSB4oyO5T2ff1cM0YqKdM7zUgg5x5AQEZ?= =?iso-8859-1?Q?Nwc0WXSsXYcmoUXKrHejRKtuPqxTQMrf25pyxfhgk5VtyS0J1o3HoN4ron?= =?iso-8859-1?Q?TmGyxjlFxO56YWpzIhUjTyK4bEJOo/U9qFi48uMmS1pu9s64lE/oR9Bw?= =?iso-8859-1?Q?=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: 5871dfd5-0c60-4847-34db-08dbc070ef71 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2023 22:19:08.8522 (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: pL6wWSzz8ByUikJz4CUQ6A6iAbZJ3e+hI4KiOTbK17LemllLopvwmy+w46uh99USsal5odDTAdNGFWaThMlaJLgSLXA7ONmFq+7+o9D1eIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB5802 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: HH52CBvpx8HUrXAmewsrXOdDx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" 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=B+EfRpEF; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Ray, Responses inline below. Thanks, Nate > From: Ni, Ray > Sent: Tuesday, September 26, 2023 8:46 PM > To: Desimone, Nathaniel L ; > devel@edk2.groups.io > Cc: Andrew Fish ; Kinney, Michael D > ; Chiu, Chasel > Subject: Re: [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows >=20 > Nate, >=20 > Thanks for the great patch! Minor comments: > > 1. Regarding the DllEntryPoint, what's the difference between below line = in > your patch and the original code that calls GetProcAddress()? > a. DllEntryPoint =3D (VOID *) ((UINTN)Library + (UINTN)Hdr.Pe32Plus- > >OptionalHeader.AddressOfEntryPoint); The new code reads the driver's entry point from the PE32 optional header's= AddressOfEntryPoint, the old code reads the driver's entry point by locati= ng the .edata section and enumerating the entries in the export table until= one with the name "InitializeDriver" is found. > 2. Does it avoid relying on each driver exporting its entrypoint with a f= ixed > symbol name "InitializeDriver"? Yes. > Does the new DllEntryPoint equal to the original one retrieved from > GetProcAddress()? Assuming the following line is added to [BuildOptions]: MSFT:DEBUG_*_*_DLINK_FLAGS =3D /EXPORT:InitializeDriver=3D$(IMAGE_ENTRY_P= OINT) Then yes, they will be identical. But in the general case, there is no spec= ification level requirement and therefore no guarantee that this export ent= ry will exist, or that it will point to the same location. > What else benifits? (Just curious) Section 2.1.1 of the UEFI specification states the following: Once the image is loaded into memory, and the appropriate fix-ups have been performed, control is transferred to a loaded image at th= e AddressOfEntryPoint reference according to the normal indirect calling conventions of applicati= ons based on supported 32-bit, 64-bit, or 128-bit processors. All other linkage to and from an UEFI image = is done programmatically. Therefore, adding this patch will make EmulatorPkg's source level debug sup= port compliant with the UEFI specification. > Can it be in a separate patch so that future readers can easily understan= d the > purpose of the change? I would not recommend it for bisect-ability reasons because this EmulatorPk= g will crash if the page table fixups are not done. It appears that the act= of calling GetProcAddress() also causes the OS to set up the page table co= rrectly. > 3. It seems the patch assumes the handle returned from LoadLibrary() is t= he > address of the loaded DLL in memory. I tried to find in MSDN if any doc > supports this assumption but failed. Can you provide any? > I am ok if the assumption is based on the current LoadLibrary() > implementation. But can you please explicitly mention that assumption in > comments? It is very buried, but MSDN does explicitly state that the HMODULE data typ= e will always contain the load address of that module. It is discussed here= in the remarks section: https://learn.microsoft.com/en-us/windows/win32/ap= i/psapi/ns-psapi-moduleinfo >=20 > Thanks, > Ray > ________________________________________ > From: Desimone, Nathaniel L > Sent: Saturday, September 23, 2023 6:49 AM > To: mailto:devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray > ; Kinney, Michael D > ; Chiu, Chasel > > Subject: [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows >=20 > The Visual Studio Windows debugger will only load symbols for PE/COFF > images that Windows is aware of. Therefore, to enable source level debugg= ing, > all PEI/DXE modules must be loaded via LoadLibrary() or LoadLibraryEx() a= nd > the the instance in memory created by LoadLibrary() must be the one that = is > actually executed. >=20 > The current source level debug implementation in EmulatorPkg for Windows = is > inherited from the old Nt32Pkg. This implementation makes the assumption > that all PEI/DXE modules have a DLL export tables with a symbol named > InitializeDriver. Therefore, this source level debug implementation requi= res all > modules to be linked in a non-PI spec defined manner. Support for adding = the > InitializeDriver symbol was removed in EmulatorPkg, which broke source le= vel > debugging. >=20 > To fix this, the source level debugging implementation has been modified = to > use the PE/COFF entry point directly. This brings the implementation into > compliance with the PI spec and should work with any PEIM/DXE driver. > Implementing this requires parsing the in-memory instance of the PE/COFF > image created by Windows to find the entrypoint and since PEIMs/DXE drive= rs > are not garunteed to have 4KB aligned sections, it also requires explicit > configuration of the page table using VirtualProtect(). >=20 > With this fix, the debugging experience is now so good it is unprecedente= d! > In Visual Studio Code, add the following to launch.json: >=20 > { > =A0 "version": "0.2.0", > =A0 "configurations": [ > =A0=A0=A0 { > =A0=A0=A0=A0=A0 "name": "EmulatorPkg Launch", > =A0=A0=A0=A0=A0 "type": "cppvsdbg", > =A0=A0=A0=A0=A0 "request": "launch", > =A0=A0=A0=A0=A0 "program": > "${workspaceFolder}//Build/EmulatorX64/DEBUG_ in>/X64/WinHost", > =A0=A0=A0=A0=A0 "args": [], > =A0=A0=A0=A0=A0 "stopAtEntry": false, > =A0=A0=A0=A0=A0 "cwd": > "${workspaceFolder}//Build/EmulatorX64/DEBUG_ in>/X64/", > =A0=A0=A0=A0=A0 "environment": [], > =A0=A0=A0=A0=A0 "console": false, > =A0=A0=A0 } > =A0 ] > } >=20 > Make modifications to the above template as nessesary and build > EmulatorPkg. > Now, just add breakpoints directly in Visual Studio Code the way you woul= d > with any other software project. When you start the debugger, it will hal= t at > the breakpoint automatically without any extra configuration required. >=20 > Cc: Andrew Fish > Cc: Ray Ni > Cc: Michael D Kinney > Cc: Chasel Chiu > Signed-off-by: Nate DeSimone > --- > =A0EmulatorPkg/Win/Host/WinHost.c | 206 > +++++++++++++++++++++++++++++---- > =A01 file changed, 182 insertions(+), 24 deletions(-) >=20 > diff --git a/EmulatorPkg/Win/Host/WinHost.c > b/EmulatorPkg/Win/Host/WinHost.c index 193a947fbd..e414da6c55 > 100644 > --- a/EmulatorPkg/Win/Host/WinHost.c > +++ b/EmulatorPkg/Win/Host/WinHost.c > @@ -8,7 +8,7 @@ > =A0=A0 This code produces 128 K of temporary memory for the SEC stack by = directly > =A0=A0 allocate memory space with ReadWrite and Execute attribute. >=20 > -Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
> =A0(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP
> =A0SPDX-License-Identifier: BSD-2-Clause-Patent > =A0**/ > @@ -977,7 +977,7 @@ AddModHandle ( > =A0=A0 for (Index =3D 0; Index < mPdbNameModHandleArraySize; Index++, Arr= ay++) { > =A0=A0=A0=A0 if (Array->PdbPointer =3D=3D NULL) { > =A0=A0=A0=A0=A0=A0 // > -=A0=A0=A0=A0=A0 // Make a copy of the stirng and store the ModHandle > +=A0=A0=A0=A0=A0 // Make a copy of the string and store the ModHandle > =A0=A0=A0=A0=A0=A0 // > =A0=A0=A0=A0=A0=A0 Handle=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D GetProcess= Heap (); > =A0=A0=A0=A0=A0=A0 Size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D AsciiS= trLen (ImageContext->PdbPointer) + 1; @@ -1056,26 > +1056,45 @@ RemoveModHandle ( > =A0=A0 return NULL; > =A0} >=20 > +typedef struct { > +=A0 UINTN=A0=A0 Base; > +=A0 UINT32=A0 Size; > +=A0 UINT32=A0 Flags; > +} IMAGE_SECTION_DATA; > + > =A0VOID > =A0EFIAPI > =A0PeCoffLoaderRelocateImageExtraAction ( > =A0=A0 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT=A0 *ImageContext > =A0=A0 ) > =A0{ > -=A0 EFI_STATUS=A0 Status; > -=A0 VOID=A0=A0=A0=A0=A0=A0=A0 *DllEntryPoint; > -=A0 CHAR16=A0=A0=A0=A0=A0 *DllFileName; > -=A0 HMODULE=A0=A0=A0=A0 Library; > -=A0 UINTN=A0=A0=A0=A0=A0=A0 Index; > +=A0 EFI_STATUS=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 Status; > +=A0 VOID=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 *DllEntryPoint; > +=A0 CHAR16=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 *DllFileName; > +=A0 HMODULE=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 Library; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 Index; > +=A0 PE_COFF_LOADER_IMAGE_CONTEXT=A0=A0=A0=A0=A0=A0=A0 PeCoffImageContext= ; > +=A0 EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; > +=A0 EFI_IMAGE_SECTION_HEADER=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 *FirstSect= ion; > +=A0 EFI_IMAGE_SECTION_HEADER=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 *Section; > +=A0 IMAGE_SECTION_DATA=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 *SectionData; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 NumberOfSections; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 Base; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 End; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 RegionBase; > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 RegionSize; > +=A0 UINT32=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 Flags; > +=A0 DWORD=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection; > +=A0 DWORD=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 OldProtection; >=20 > =A0=A0 ASSERT (ImageContext !=3D NULL); > =A0=A0 // > -=A0 // If we load our own PE COFF images the Windows debugger can not > source > -=A0 //=A0 level debug our code. If a valid PDB pointer exists use it to = load > -=A0 //=A0 the *.dll file as a library using Windows* APIs. This allows > -=A0 //=A0 source level debug. The image is still loaded and relocated > -=A0 //=A0 in the Framework memory space like on a real system (by the co= de > above), > -=A0 //=A0 but the entry point points into the DLL loaded by the code bel= ow. > +=A0 // If we load our own PE/COFF images the Windows debugger can not > +source > +=A0 // level debug our code. If a valid PDB pointer exists use it to loa= d > +=A0 // the *.dll file as a library using Windows* APIs. This allows > +=A0 // source level debug. The image is still loaded and relocated > +=A0 // in the Framework memory space like on a real system (by the code > +above), > +=A0 // but the entry point points into the DLL loaded by the code below. > =A0=A0 // >=20 > =A0=A0 DllEntryPoint =3D NULL; > @@ -1106,27 +1125,166 @@ PeCoffLoaderRelocateImageExtraAction ( > =A0=A0=A0=A0 } >=20 > =A0=A0=A0=A0 // > -=A0=A0=A0 // Replace .PDB with .DLL on the filename > +=A0=A0=A0 // Replace .PDB with .DLL in the filename > =A0=A0=A0=A0 // > =A0=A0=A0=A0 DllFileName[Index - 3] =3D 'D'; > =A0=A0=A0=A0 DllFileName[Index - 2] =3D 'L'; > =A0=A0=A0=A0 DllFileName[Index - 1] =3D 'L'; >=20 > =A0=A0=A0=A0 // > -=A0=A0=A0 // Load the .DLL file into the user process's address space fo= r source > -=A0=A0=A0 // level debug > +=A0=A0=A0 // Load the .DLL file into the process's address space for sou= rce > +level > +=A0=A0=A0 // debug. > +=A0=A0=A0 // > +=A0=A0=A0 // EFI modules use the PE32 entry point for a different purpos= e > +than > +=A0=A0=A0 // Windows. For Windows DLLs, the PE entry point is used for t= he > +DllMain() > +=A0=A0=A0 // function. DllMain() has a very specific purpose; it initial= izes > +runtime > +=A0=A0=A0 // libraries, instance data, and thread local storage. > +LoadLibrary()/ > +=A0=A0=A0 // LoadLibraryEx() will run the PE32 entry point and assume it= to > +be a > +=A0=A0=A0 // DllMain() implementation by default. By passing the > +=A0=A0=A0 // DONT_RESOLVE_DLL_REFERENCES argument to LoadLibraryEx(), th= e > +execution > +=A0=A0=A0 // of the entry point as a DllMain() function will be suppress= ed. > +This > +=A0=A0=A0 // also prevents other modules that are referenced by the DLL = from > +being > +=A0=A0=A0 // loaded. We use LoadLibraryEx() to create a copy of the PE32 > +=A0=A0=A0 // image that the OS (and therefore the debugger) is aware of. > +=A0=A0=A0 // Source level debugging is the only reason to do this. > =A0=A0=A0=A0 // > =A0=A0=A0=A0 Library =3D LoadLibraryEx (DllFileName, NULL, > DONT_RESOLVE_DLL_REFERENCES); > =A0=A0=A0=A0 if (Library !=3D NULL) { > =A0=A0=A0=A0=A0=A0 // > -=A0=A0=A0=A0=A0 // InitializeDriver is the entry point we put in all our= EFI DLL's. The > -=A0=A0=A0=A0=A0 // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx= () > suppresses the > -=A0=A0=A0=A0=A0 // normal DLL entry point of DllMain, and prevents other= modules that are > -=A0=A0=A0=A0=A0 // referenced in side the DllFileName from being loaded.= There is no error > -=A0=A0=A0=A0=A0 // checking as the we can point to the PE32 image loaded= by Tiano. This > -=A0=A0=A0=A0=A0 // step is only needed for source level debugging > +=A0=A0=A0=A0=A0 // Parse the PE32 image loaded by the OS and find the en= try point > =A0=A0=A0=A0=A0=A0 // > -=A0=A0=A0=A0=A0 DllEntryPoint =3D (VOID *)(UINTN)GetProcAddress (Library= , > "InitializeDriver"); > +=A0=A0=A0=A0=A0 ZeroMem (&PeCoffImageContext, sizeof (PeCoffImageContext= )); > +=A0=A0=A0=A0=A0 PeCoffImageContext.Handle =3D Library; > +=A0=A0=A0=A0=A0 PeCoffImageContext.ImageRead =3D PeCoffLoaderImageReadFr= omMemory; > +=A0=A0=A0=A0=A0 Status =3D PeCoffLoaderGetImageInfo (&PeCoffImageContext= ); > +=A0=A0=A0=A0=A0 if (EFI_ERROR (Status) || (PeCoffImageContext.ImageError= !=3D > +IMAGE_ERROR_SUCCESS)) { > +=A0=A0=A0=A0=A0=A0=A0 SecPrint ("DLL is not a valid PE/COFF image.\n\r")= ; > +=A0=A0=A0=A0=A0=A0=A0 FreeLibrary (Library); > +=A0=A0=A0=A0=A0=A0=A0 Library =3D NULL; > +=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0 Hdr.Pe32 =3D (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Lib= rary + > +(UINTN)PeCoffImageContext.PeCoffHeaderOffset); > +=A0=A0=A0=A0=A0=A0=A0 if (Hdr.Pe32->OptionalHeader.Magic =3D=3D > +EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // Use PE32 offset > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 DllEntryPoint =3D (VOID *) ((UINTN)Library + > +(UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint); > +=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // Use PE32+ offset > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 DllEntryPoint =3D (VOID *) ((UINTN)Library + > +(UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPoint); > +=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 // Now we need to configure memory access for the = copy of the > +PE32 image > +=A0=A0=A0=A0=A0=A0=A0 // loaded by the OS. > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 // Most Windows DLLs are linked with sections 4KB = aligned but > +EFI > +=A0=A0=A0=A0=A0=A0=A0 // modules are not to reduce size. Because of this= we need to > +compute > +=A0=A0=A0=A0=A0=A0=A0 // the union of memory access attributes and expli= citly > +configure > +=A0=A0=A0=A0=A0=A0=A0 // each page. > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 FirstSection =3D (EFI_IMAGE_SECTION_HEADER *)( > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (UINTN)Library + > + > +PeCoffImageContext.PeCoffHeaderOffset + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sizeof (UINT32) + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sizeof > +(EFI_IMAGE_FILE_HEADER) + > + > +Hdr.Pe32->FileHeader.SizeOfOptionalHeader > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ); > +=A0=A0=A0=A0=A0=A0=A0 NumberOfSections =3D > +(UINTN)(Hdr.Pe32->FileHeader.NumberOfSections); > +=A0=A0=A0=A0=A0=A0=A0 Section =3D FirstSection; > +=A0=A0=A0=A0=A0=A0=A0 SectionData =3D malloc (NumberOfSections * sizeof > +(IMAGE_SECTION_DATA)); > +=A0=A0=A0=A0=A0=A0=A0 if (SectionData =3D=3D NULL) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 FreeLibrary (Library); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 Library =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 DllEntryPoint =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 ZeroMem (SectionData, NumberOfSections * sizeof > +(IMAGE_SECTION_DATA)); > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 // Extract the section data from the PE32 image > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 for (Index =3D 0; Index < NumberOfSections; Index+= +) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 SectionData[Index].Base =3D (UINTN)Library + > +Section->VirtualAddress; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 SectionData[Index].Size =3D Section->Misc.Vi= rtualSize; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (SectionData[Index].Size =3D=3D 0) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SectionData[Index].Size =3D Section->S= izeOfRawData; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 SectionData[Index].Flags =3D (Section->Chara= cteristics & > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (EFI_IMAGE_SCN_MEM_EXECUTE | > +EFI_IMAGE_SCN_MEM_WRITE)); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 Section +=3D 1; > +=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 // Loop over every DWORD in memory and compute the= union of the > +memory > +=A0=A0=A0=A0=A0=A0=A0 // access bits. > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 End =3D (UINTN)Library + (UINTN)PeCoffImageContext= .ImageSize; > +=A0=A0=A0=A0=A0=A0=A0 RegionBase =3D (UINTN)Library; > +=A0=A0=A0=A0=A0=A0=A0 RegionSize =3D 0; > +=A0=A0=A0=A0=A0=A0=A0 Flags =3D 0; > +=A0=A0=A0=A0=A0=A0=A0 for (Base =3D (UINTN)Library + sizeof (UINT32); Ba= se < End; Base > ++=3D sizeof (UINT32)) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 for (Index =3D 0; Index < NumberOfSections; = Index++) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (SectionData[Index].Base <=3D Base = && > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (SectionData[Index].Base += SectionData[Index].Size) > > +Base) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Flags |=3D SectionData[Index].Fl= ags; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // When a new page is reached configure the = memory access for > +the > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // previous page. > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (Base % SIZE_4KB =3D=3D 0) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 RegionSize +=3D SIZE_4KB; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_WRITE) = =3D=3D > +EFI_IMAGE_SCN_MEM_WRITE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_E= XECUTE) =3D=3D > +EFI_IMAGE_SCN_MEM_EXECUTE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_EXE= CUTE_READWRITE; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_REA= DWRITE; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_E= XECUTE) =3D=3D > +EFI_IMAGE_SCN_MEM_EXECUTE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_EXE= CUTE_READ; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_REA= DONLY; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (!VirtualProtect ((LPVOID)RegionBas= e, (SIZE_T) > +RegionSize, NewProtection, &OldProtection)) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SecPrint ("Setting PE32 Section = Access Failed\n\r"); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 FreeLibrary (Library); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 free (SectionData); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Library =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 DllEntryPoint =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Flags =3D 0; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 RegionBase =3D Base; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 RegionSize =3D 0; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 free (SectionData); > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 // Configure the last partial page > +=A0=A0=A0=A0=A0=A0=A0 // > +=A0=A0=A0=A0=A0=A0=A0 if (Library !=3D NULL && (End - RegionBase) > 0) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_WRITE) =3D=3D > +EFI_IMAGE_SCN_MEM_WRITE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_EXECUTE= ) =3D=3D > +EFI_IMAGE_SCN_MEM_EXECUTE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_EXECUTE_R= EADWRITE; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_READWRITE= ; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if ((Flags & EFI_IMAGE_SCN_MEM_EXECUTE= ) =3D=3D > +EFI_IMAGE_SCN_MEM_EXECUTE) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_EXECUTE_R= EAD; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NewProtection =3D PAGE_READONLY; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (!VirtualProtect ((LPVOID)RegionBase, (SI= ZE_T) (End - > +RegionBase), NewProtection, &OldProtection)) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SecPrint ("Setting PE32 Section Access= Failed\n\r"); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 FreeLibrary (Library); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Library =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 DllEntryPoint =3D NULL; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0=A0=A0 } > +=A0=A0=A0=A0=A0 } > =A0=A0=A0=A0 } >=20 > =A0=A0=A0=A0 if ((Library !=3D NULL) && (DllEntryPoint !=3D NULL)) { @@ -= 1142,7 +1300,7 > @@ PeCoffLoaderRelocateImageExtraAction ( > =A0=A0=A0=A0=A0=A0=A0=A0 // This DLL is not already loaded, so source lev= el debugging is supported. > =A0=A0=A0=A0=A0=A0=A0=A0 // > =A0=A0=A0=A0=A0=A0=A0=A0 ImageContext->EntryPoint =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)DllEntryPoint; > -=A0=A0=A0=A0=A0=A0=A0 SecPrint ("LoadLibraryEx (\n\r=A0 %S,\n\r=A0 NULL, > DONT_RESOLVE_DLL_REFERENCES)\n\r", DllFileName); > +=A0=A0=A0=A0=A0=A0=A0 SecPrint ("LoadLibraryEx (\n\r=A0 %S,\n\r=A0 NULL, > +DONT_RESOLVE_DLL_REFERENCES) @ 0x%X\n\r", DllFileName, (int) (UINTN) > +Library); > =A0=A0=A0=A0=A0=A0 } > =A0=A0=A0=A0 } else { > =A0=A0=A0=A0=A0=A0 SecPrint ("WARNING: No source level debug %S. \n\r", D= llFileName); > -- > 2.39.2.windows.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 (#109181): https://edk2.groups.io/g/devel/message/109181 Mute This Topic: https://groups.io/mt/101531560/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-