Usage limitations during the DllMain Attach and Detach process
Avoid calling LoadLibrary and related APIs.
In addition to Steve's link, here are some good relevant posts from Raymond Chen's The Old New Thing:
- https://devblogs.microsoft.com/oldnewthing/20040127-00/?p=40873
- https://devblogs.microsoft.com/oldnewthing/20040128-00/?p=40853
- https://devblogs.microsoft.com/oldnewthing/20070904-00/?p=25283
- https://devblogs.microsoft.com/oldnewthing/20100115-00/?p=15253
Most problems arise due to conflicts over the loader lock. DllMain
should not be long-running, or use locks if it's avoidable.
Good background here.