[edk2-devel] EmulatorPkg does not unload DLL after exit
Tim Lewis
tim.lewis at insyde.com
Wed Aug 21 21:13:45 UTC 2019
When running a shell app twice, I ran into an interesting problem: global variables that had initializers were not initialized to the defaults specified in the source. Running the same shell app under the old NT32 seems to work. It turns out that the shell app was not being reloaded, but rather being relaunched. I deduced this from the following behavior:
1. The value of the global variables was the same as the last known value from the previous invocation.
2. The following line in WinHost.c was returning the exact same value for the DLL being loaded
Library = LoadLibraryEx (DllFileName, NULL, DONT_RESOLVE_DLL_REFERENCES); (around line 901)
3. The corresponding code in Nt32’s PeCoffExtractionLib had the following lines in PeCoffLoaderUnloadImageExtraAction
VOID *ModHandle;
ASSERT (ImageContext != NULL);
ModHandle = RemoveModeHandle (ImageContext);
if (ModHandle != NULL) {
mWinNt->FreeLibrary (ModHandle);
}
However, the same function in EmulatorPkg’s WinHost.c has:
ASSERT (ImageContext != NULL);
So it appears that the DLL is never being unloaded and the subsequent invocation of the shell app uses the same instance of the DLL, leaving the global variables with the previous values. There are two related functions: AddModHandle and RemoveModHandle.
Am I missing something? Or heading in the right direction?
Thanks,
Tim
From: devel at edk2.groups.io <devel at edk2.groups.io>
Sent: Saturday, August 17, 2019 6:30 PM
To: devel at edk2.groups.io
Subject: [edk2-devel] Upcoming Event: TianoCore Design Meeting - APAC/NAMO - Thu, 08/22/2019 6:30pm-7:30pm #cal-reminder
Reminder: TianoCore Design Meeting - APAC/NAMO
When: Thursday, 22 August 2019, 6:30pm to 7:30pm, (GMT-07:00) America/Los Angeles
Where:https://zoom.us/j/969264410
View Event <https://edk2.groups.io/g/devel/viewevent?eventid=470780>
Organizer: Stephano Cetola stephano.cetola at intel.com <mailto:stephano.cetola at intel.com?subject=Re:%20Event:%20TianoCore%20Design%20Meeting%20-%20APAC%2FNAMO>
Description:
Join Zoom Meeting
https://zoom.us/j/969264410
One tap mobile
+16465588656,,969264410# US (New York)
+17207072699,,969264410# US
Dial by your location
+1 646 558 8656 US (New York)
+1 720 707 2699 US
Meeting ID: 969 264 410
Find your local number: https://zoom.us/u/abOtdJckxL
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#46177): https://edk2.groups.io/g/devel/message/46177
Mute This Topic: https://groups.io/mt/32983160/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20190821/b596bbb7/attachment.htm>
More information about the edk2-devel-archive
mailing list