1 year ago

#202793

test-img

joepol

How to explicitly allocate TLS for existing threads when dynamically loading a DLL in Windows?

I have a DLL (Dynamic loaded library) that loads after some time the process been running, I explicitly allocate TLS (thread local storage) as defined in Using Thread Local Storage in a Dynamic-Link Library for threads in the DllMain() function for every DLL_THREAD_ATTACH case, but according to DllMain entry point

Note that a DLL's entry-point function is called with this value only by threads created after the DLL is loaded by the process. When a DLL is loaded using LoadLibrary, existing threads do not call the entry-point function of the newly loaded DLL.

some threads exist in the process's context before I load the library, is there a way to allocate TLS for them as well other than the DllMain entry point?

c++

multithreading

winapi

thread-local-storage

0 Answers

Your Answer

Accepted video resources