79624494

Date: 2025-05-16 04:54:03
Score: 1.5
Natty:
Report link

I know this is an old thread but there is now a very good way to determine when DllMain has exited.

In the DllMain, or if you are using MFC, in InitIntance, create a waitable timer and give it a due time of about 1 millisecond in the future and, this is important, give it a completion routine. Your completion routine is queued as an APC but it can't run until the thread is done initializing.

The loader code checks for queued APCs right after it releases the loader lock, so your completion routine will gets executed almost immediately after DllMain returns to the loader.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Glenn Dobratz