DLL Best Practices
This is Microsoft's original document laying out the DLL best practices, namely regarding DllMain.
The "DLL Best Practices" document was created by the product manager (PM) who owns (or at least owned) the DLL loader. In my opinion, the document was good for its time except for the "General Best Practices" section which just throws rules at you without any structure or reasoning. People reading the old DllMain "General Best Practices" today (on Microsoft's documentation website; which has undergone a few updates) tend to come out more confused about DllMain safety after than they were before. So, let's rewrite it with the the perspective of an ecosystem where DllMain (module initializer/deinitializer) problems don't happen to begin with. Enter... Unix-like operating systems!
Be mindful of the fact that my critiques apply only to the software or company itself and not to the people who help write the software, create informative articles on the software, or manage the company. I appreciate and respect the people who put hard work into creating the technologies. Thank you!
Note: This old document states the following about loader lock: "Any function that must read or modify the per-process library-loader data structures must acquire this lock before performing such an operation" (in addition to protecting module initialization/deinitialization). This fact was only true of the legacy Windows loader (e.g. see ReactOS code based on the reverse engineered Windows Server 2003 loader). The modern Windows loader protects library-loader data structures using the LdrpModuleDatatableLock lock. The age of this document also makes it inapplicable to the modern Windows loader in other ways (the previous amendment is by no means comprehensive).
Current official Microsoft download. Legacy download page archived.