summaryrefslogtreecommitdiffstats
path: root/EmulatorPkg
diff options
context:
space:
mode:
authorRay Ni <ray.ni@intel.com>2022-12-05 14:51:18 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-12-08 10:04:24 +0000
commit4e17aba4b55003dde8de2671e968c75245fdfcae (patch)
treec091810944e6b822a473c82ab951692b3fd9fb56 /EmulatorPkg
parent2280af5ff8e97804e3ddceb85629da874ca4eb63 (diff)
downloadedk2-4e17aba4b55003dde8de2671e968c75245fdfcae.tar.gz
edk2-4e17aba4b55003dde8de2671e968c75245fdfcae.tar.bz2
edk2-4e17aba4b55003dde8de2671e968c75245fdfcae.zip
EmulatorPkg/Win: Unload DLLs before reset
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 <ray.ni@intel.com> Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Andrew Fish <afish@apple.com>
Diffstat (limited to 'EmulatorPkg')
-rw-r--r--EmulatorPkg/Win/Host/WinHost.c14
1 files changed, 14 insertions, 0 deletions
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,6 +226,8 @@ WinReset (
IN VOID *ResetData OPTIONAL
)
{
+ UINTN Index;
+
ASSERT (ResetType <= EfiResetPlatformSpecific);
SecPrint (" Emu ResetSystem is called: ResetType = %s\n", mResetTypeStr[ResetType]);
@@ -233,6 +235,18 @@ WinReset (
exit (0);
} else {
//
+ // Unload all DLLs
+ //
+ for (Index = 0; Index < mPdbNameModHandleArraySize; Index++) {
+ if (mPdbNameModHandleArray[Index].PdbPointer != NULL) {
+ SecPrint (" Emu Unload DLL: %s\n", mPdbNameModHandleArray[Index].PdbPointer);
+ FreeLibrary (mPdbNameModHandleArray[Index].ModHandle);
+ HeapFree (GetProcessHeap (), 0, mPdbNameModHandleArray[Index].PdbPointer);
+ mPdbNameModHandleArray[Index].PdbPointer = NULL;
+ }
+ }
+
+ //
// Jump back to SetJump with jump code = ResetType + 1
//
LongJump (&mResetJumpBuffer, ResetType + 1);