Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which functions are called before DllMain()?

Which functions are called prior to DllMain()? If more than one during the C runtime initialization, then the order is important.

like image 410
y2k Avatar asked Dec 21 '22 01:12

y2k


2 Answers

From the source:-

If your DLL is linked with the C run-time library (CRT), the entry point provided by the CRT calls the constructors and destructors for global and static C++ objects. Therefore, these restrictions for DllMain also apply to constructors and destructors and any code that is called from them.

like image 143
Rahul Tripathi Avatar answered Jan 03 '23 18:01

Rahul Tripathi


I think only _DllMainCRTStartup() is called, which in turns calls all constructors of global C++ objects (none in the case of C) and (I'm not sure of that last one) calls DllMain().

Of course, it also calls some Kernel32 functions to initialize the CRT (for starters, it needs to allocate some memory and a TLS slot).

like image 41
Medinoc Avatar answered Jan 03 '23 18:01

Medinoc