4 ms·
> DllMain() is not really the way in which it's better on Windows. To expand on this, ELF shared libraries have this too: any function pointers in the .init_ar
by saagarjha 8y ago
> DllMain() is not really the way in which it's better on Windows.
To expand on this, ELF shared libraries have this too: any function pointers in the .init_array section will get executed when the library is loaded. You can get one of these in your library by marking a C function with __attribute__((constructor)) and compiling with compiler that understands this attribute.
- cryptonector 8y agoThe .init and .fini sections are run at object load and unload times, respectively, yes, but DllMain() also ets called for each thread at thread startup and teardown time. On Unix you can catch thread teardown with pthread keys, but you can't catch thread startup. Just an FYI.