Skip to content

Commit 248d6df

Browse files
authored
Add documentation on dllmain restrictions (#389)
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 44fba79 commit 248d6df

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

source/layers/tracing/windows/tracing_init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
#include <windows.h>
1010

1111
namespace tracing_layer {
12+
/*
13+
* DllMain is called by the OS when the DLL is loaded or unloaded.
14+
* When modifying the code here, be aware of the restrictions on what can be done
15+
* inside DllMain. See https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices
16+
* for more information.
17+
*/
1218
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1319
if (fdwReason == DLL_PROCESS_DETACH) {
1420
delete pGlobalAPITracerContextImp;

source/lib/windows/lib_init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
namespace ze_lib
1515
{
1616
#ifndef L0_STATIC_LOADER_BUILD
17+
/*
18+
* DllMain is called by the OS when the DLL is loaded or unloaded.
19+
* When modifying the code here, be aware of the restrictions on what can be done
20+
* inside DllMain. See https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices
21+
* for more information.
22+
*/
1723
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1824
if (fdwReason == DLL_PROCESS_DETACH) {
1925
delete context;

source/loader/windows/loader_init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
namespace loader
1212
{
1313
#ifdef L0_STATIC_LOADER_BUILD
14+
/*
15+
* DllMain is called by the OS when the DLL is loaded or unloaded.
16+
* When modifying the code here, be aware of the restrictions on what can be done
17+
* inside DllMain. See https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices
18+
* for more information.
19+
*/
1420
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1521
if (fdwReason == DLL_PROCESS_DETACH) {
1622
delete context;

0 commit comments

Comments
 (0)