Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

FreeLibrary API behavior change in Windows 8

$
0
0

We've recently noticed a problem on Windows 8 for our application. The analysis shows that the root cause is the behavior change of FreeLibrary API change in Windows 8.

Prior to Windows 8, if FreeLibrary is called for Dll A during a DllUnload of Dll B and the ref cout for A is 1, the DllMain of A will not be called until the unload of B finishes. However, on Windows 8, the DllMain of A will called immediately when FreeLibrary is called for A. This has messed up the MFC module state stuff as both A and B are MFC extension DLL.

I understand we should not call FreeLibrary when unloading DLL is in progress. However, it's a behavior we don't have much control. The FreeLibrary is actually called by COM runtime as we're unloading a COM module which uses a helpstringdll. When the COM dll is unloading and as we're using ATL COM Module class, it will delete all the type info holders which will result in a FreeLibrary call for the helpstringdll.

My question is, why is the behavior change and how we might fix our problem?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>