[edk2-devel] [PATCH] EmulatorPkg/Win: Unload DLLs before reset

Ni, Ray ray.ni at intel.com
Wed Dec 7 08:07:39 UTC 2022


Zhiguang, can you please help to review this patch? I guess Andrew is busy on something.

> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Monday, December 5, 2022 2:59 PM
> To: devel at edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu at intel.com>; Andrew Fish <afish at apple.com>
> Subject: [edk2-devel] [PATCH] 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 at intel.com>
> Cc: Zhiguang Liu <zhiguang.liu at intel.com>
> Cc: Andrew Fish <afish at apple.com>
> ---
>  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
> 
>    )
> 
>  {
> 
> +  UINTN  Index;
> 
> +
> 
>    ASSERT (ResetType <= EfiResetPlatformSpecific);
> 
>    SecPrint ("  Emu ResetSystem is called: ResetType = %s\n", mResetTypeStr[ResetType]);
> 
> 
> 
>    if (ResetType == EfiResetShutdown) {
> 
>      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
> 
>      //
> 
> --
> 2.37.2.windows.2
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#96943): https://edk2.groups.io/g/devel/message/96943
> Mute This Topic: https://groups.io/mt/95464183/1712937
> Group Owner: devel+owner at edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni at intel.com]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97068): https://edk2.groups.io/g/devel/message/97068
Mute This Topic: https://groups.io/mt/95464183/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list