views:

376

answers:

3
+2  Q: 

DLL entry point

The standard DLL entry point is called DllMain. The second param is DWORD ul_reason_for_call.

I have looked up on the MSDN to find all the values this can have, the following are obvious:

DLL_PROCESS_ATTACH:
DLL_THREAD_ATTACH:
DLL_THREAD_DETACH:
DLL_PROCESS_DETACH:

But what about :

DLL_PROCESS_VERIFIER

When will the entry point be called with this flag and should I worry about it during 'normal' operation of the DLL?

UPDATE: I only see DLL_PROCESS_VERIFIER in headers files from Visual Studio 2005, not 2008.

+4  A: 

I guess in theory Microsoft could invent new usages and flags any time they feel they need a new one. So the simple rule is to ensure that your code tolerates unexpected values: i.e. write it to handle the cases that you need to handle and ignore the rest, by returning zero.

Chris Becke
Agreed. Currently my code is { case DLL_PROCESS_VERIFIER: default: return 0; } However my question relates to when / why this would currently happen.
Konrad
The general consensus seems to be its probably sent as a result of dlls being invoked in a process being measured by Application Verifier. Which is shipped as part of visual studio Im sure, so it should be "easy" to put some kind of logging code, and test to see if it is. during normal operation? obviously never.
Chris Becke
I advise *against* mentioning it explicitly in your switch statement, @Whyam. It gives the false impression that you've given thought to how your program should handle that value, when you obviously couldn't have since you don't know what it's for. By including it in your code, you're inviting future maintainers of the code to ask you what it's for, which will waste your time and theirs. It's best to just pretend it doesn't exist at all.
Rob Kennedy
A: 

I think it can have then value if it is run through Application Verifier. Kind of guessing :)

Adam Driscoll
+1  A: 

This is really obscure. It is not ever documented in the SDK and doesn't appear in the SDK header files. Google produces only a few hits, most sites are down or untrusted. The only decent hit I get is XBox code, it only declares it but doesn't actually use it.

I'm not sufficiently convinced that this is a real code that you'd ever encounter in a regular Windows program.

Hans Passant
+1 for the msdn link. I didn't actually see that one because I was simply googling for 'DLL_PROCESS_VERIFIER'. The only reason I found it was because I was poking around in the header files.
Konrad