Handmade Hero » Forums » Code » Windows preventing game code dll unloading
MrPr3sident
2 posts
#11365 Windows preventing game code dll unloading
7 months, 1 week ago Edited by on March 18, 2017, 11:38 p.m.

Hi there,

I just wanted to spread awareness about a problem I had while coding along the live code editing episodes just in case others are having trouble with this like I had.
The problem is that the game code DLL doesn't get unloaded when calling FreeLibrary().

This is actually caused by windows creating a registry entry. It can be found at HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers and has the form IgnoreFreeLibrary<YourDLLName>. And this entry does exactly what it says, ignoring your FreeLibrary call on that DLL. If you delete it, everything is working as intended.

Thanks windows

Best regards,
MrPr3sident
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#11366 Windows preventing game code dll unloading
7 months, 1 week ago

More interesting question is who and when added this registry entry? Does it gets added always or only on special event?
MrPr3sident
2 posts
#11367 Windows preventing game code dll unloading
7 months, 1 week ago Edited by on March 19, 2017, 7:04 a.m.

Those flags are usually set by the Application Compatibility Wizard that may appear after a program exits with an error.


Sadly, this is the only thing I can find concerning this issue. (Apart from a pissed off game developer on twitter)