From e72c0ec7b68e65db0ef07b3dc4e10c57b740dfd4 Mon Sep 17 00:00:00 2001 From: Jason E <31452365+jasonepperly@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:35:52 -0400 Subject: [PATCH] Update dllmain.md Moving warning above sample code. We continue to have developers open this page, copy the sample code, but never scroll down enough to see the warning, and then they don't follow all the guidelines outlined in the warning document. --- desktop-src/Dlls/dllmain.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop-src/Dlls/dllmain.md b/desktop-src/Dlls/dllmain.md index ca63c5ce211..5d3a4882710 100644 --- a/desktop-src/Dlls/dllmain.md +++ b/desktop-src/Dlls/dllmain.md @@ -19,6 +19,9 @@ api_location: An optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. The system also calls the entry-point function for a DLL when it is loaded or unloaded using the [**LoadLibrary**](/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya) and [**FreeLibrary**](/windows/win32/api/libloaderapi/nf-libloaderapi-freelibrary) functions. +> [!WARNING] +> There are significant limits on what you can safely do in a DLL entry point. See [General Best Practices](dynamic-link-library-best-practices.md) for specific Windows APIs that are unsafe to call in DllMain. If you need anything but the simplest initialization then do that in an initialization function for the DLL. You can require applications to call the initialization function after DllMain has run and before they call any other functions in the DLL. + ## Example ```cpp @@ -60,9 +63,6 @@ BOOL WINAPI DllMain( This is an example from the [Dynamic-Link Library Entry-Point Function](dynamic-link-library-entry-point-function.md). -> [!WARNING] -> There are significant limits on what you can safely do in a DLL entry point. See [General Best Practices](dynamic-link-library-best-practices.md) for specific Windows APIs that are unsafe to call in DllMain. If you need anything but the simplest initialization then do that in an initialization function for the DLL. You can require applications to call the initialization function after DllMain has run and before they call any other functions in the DLL. - ## Syntax