]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg/Win: Unload DLLs before reset
authorRay Ni <ray.ni@intel.com>
Mon, 5 Dec 2022 06:51:18 +0000 (14:51 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 8 Dec 2022 10:04:24 +0000 (10:04 +0000)
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>
EmulatorPkg/Win/Host/WinHost.c

index 096292f95a6fadc2e6ef3c1098212d63f5c40608..084cd4cbd7ec4a7a06802fb51c4312c7bba285eb 100644 (file)
@@ -226,12 +226,26 @@ WinReset (
   IN VOID            *ResetData OPTIONAL\r
   )\r
 {\r
+  UINTN  Index;\r
+\r
   ASSERT (ResetType <= EfiResetPlatformSpecific);\r
   SecPrint ("  Emu ResetSystem is called: ResetType = %s\n", mResetTypeStr[ResetType]);\r
 \r
   if (ResetType == EfiResetShutdown) {\r
     exit (0);\r
   } else {\r
+    //\r
+    // Unload all DLLs\r
+    //\r
+    for (Index = 0; Index < mPdbNameModHandleArraySize; Index++) {\r
+      if (mPdbNameModHandleArray[Index].PdbPointer != NULL) {\r
+        SecPrint ("  Emu Unload DLL: %s\n", mPdbNameModHandleArray[Index].PdbPointer);\r
+        FreeLibrary (mPdbNameModHandleArray[Index].ModHandle);\r
+        HeapFree (GetProcessHeap (), 0, mPdbNameModHandleArray[Index].PdbPointer);\r
+        mPdbNameModHandleArray[Index].PdbPointer = NULL;\r
+      }\r
+    }\r
+\r
     //\r
     // Jump back to SetJump with jump code = ResetType + 1\r
     //\r