From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.9418.1670223503374099593 for ; Sun, 04 Dec 2022 22:58:23 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=FJse1hjW; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670223503; x=1701759503; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Vz5c2AppJB7fxsC1ZA4G+U38eSFbnYvTAsKvE77y7dE=; b=FJse1hjW2AD5lScKnccpZ7vTkK1hA+afEBCEdgBuYGBt8HSkQVEEGi4h YP67UwOBJmG7EUHVvn3AvmRO7SAR1zhst2+siQ8BUkatCMhn8OX0mrJa4 GhtXmazapluFl8Dvidx/fIEkWayu+0SmpBuqlC8i/RIRjxO+skHNeuyX6 Dd3zokSzjBB/W1yNcXkZvspNqHf9b+adU2R3CY/zfN+sqRETCTzddmX6O X2ksET14xOnyVI0EkpfdkyGHWaWzW6FJ4lSBlCwiX31sU7CkLlsvr2KT1 XwDKUWmZQ5WMhOem6JJ4jC4bITMNGbwhJi0I1RNITdGYN8/iPRxKPnnPj g==; X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="378436078" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="378436078" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2022 22:58:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="645712888" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="645712888" Received: from ray-dev.ccr.corp.intel.com ([10.239.158.139]) by orsmga002.jf.intel.com with ESMTP; 04 Dec 2022 22:58:17 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Zhiguang Liu , Andrew Fish Subject: [PATCH] EmulatorPkg/Win: Unload DLLs before reset Date: Mon, 5 Dec 2022 14:58:42 +0800 Message-Id: <20221205065842.1792-1-ray.ni@intel.com> X-Mailer: git-send-email 2.37.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable EmulatorPkg/Win calls LoadLibraryEx() when the corresponding DLL file is found for each PEIM or DXE driver. The module entry point is changed to point to the entry point from the DLL. This helps to notify Visual Studio that a new windows module is loaded and corresponding symbol parsing is performed for source level debugging. But entry point from the DLL is only executed when the module is not loaded by AddModHandle(). When reset happens, we need to clear the DLL loading so that in next boot the module can be loaded again by AddModHandle(). Without this patch, source level debugging doesn't work after reset. Signed-off-by: Ray Ni Cc: Zhiguang Liu Cc: Andrew Fish --- EmulatorPkg/Win/Host/WinHost.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 096292f95a..084cd4cbd7 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -226,12 +226,26 @@ WinReset ( IN VOID *ResetData OPTIONAL=0D )=0D {=0D + UINTN Index;=0D +=0D ASSERT (ResetType <=3D EfiResetPlatformSpecific);=0D SecPrint (" Emu ResetSystem is called: ResetType =3D %s\n", mResetTypeS= tr[ResetType]);=0D =0D if (ResetType =3D=3D EfiResetShutdown) {=0D exit (0);=0D } else {=0D + //=0D + // Unload all DLLs=0D + //=0D + for (Index =3D 0; Index < mPdbNameModHandleArraySize; Index++) {=0D + if (mPdbNameModHandleArray[Index].PdbPointer !=3D NULL) {=0D + SecPrint (" Emu Unload DLL: %s\n", mPdbNameModHandleArray[Index].= PdbPointer);=0D + FreeLibrary (mPdbNameModHandleArray[Index].ModHandle);=0D + HeapFree (GetProcessHeap (), 0, mPdbNameModHandleArray[Index].PdbP= ointer);=0D + mPdbNameModHandleArray[Index].PdbPointer =3D NULL;=0D + }=0D + }=0D +=0D //=0D // Jump back to SetJump with jump code =3D ResetType + 1=0D //=0D --=20 2.37.2.windows.2