View Full Version : why _DllMainCRTStartup not dllmain
10th August 2005, 02:18
being a noob or just dumb, why does the sample code create
instead of the MS suggested dllmain
10th August 2005, 07:45
because using dllmain includes the crt (c runtime) in the plugin and when you're creating a really small plugin (like a few k) then is a 30-40kb size overhead for a few functions is not worth it. so by using DllMainCRTStartup you can get around this and have a nice small dll in size (or just dynamically link to msvcrt.lib and that will work as well). i've probably badly explained it but basically it makes the dll smaller without the unwanted extra size of the c run time library
10th August 2005, 10:10
This is a good read on this:
check out the links at the bottom too. Esp Matt Pietrek's article.
Keep in mind though, libctiny isnt as good as the default crt, doesnt have buffer overrun protection, threading support etc. And by just dynamically linking to msvcrt, you aren't actually consuming any more memory, because this dll is pretty much always in memory anyway. The only reason to really do this is to create small .exe's for saving on bandwidth. As far as memory is concerned, you actually consume more memory by statically using your own 'crt', cause every plugin would have its own copy instead of sharing it.
11th August 2005, 23:42
I'll check out that link.
I've only touched on this in my past experience. But when I read the docs, I was understanding it is not responsible for bringing in the crt it just initializes it and it is linked with the included default libs and appropriate switch.
I was afraid not initializing the crt already in place would not be good.
Changing my entrypoint to either function still gives the same 20k size.
Anyway, thanks for replies. I'll ck out that link.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.