DLL chaining? : LoadLibrary()

  • Thread starter Thread starter Bit byte
  • Start date Start date
B

Bit byte

I want to write a an application A, which calls LoadLibrary to load a
DLL (B).

However DLL (B), also calls LoadLibray (NOT IN DLLMain) to laod another
DLL (library C)

Is this kind of Dll chaining possible?

Are there any gotchas I have to be aware of?
 
I want to write a an application A, which calls LoadLibrary to load a
DLL (B).

However DLL (B), also calls LoadLibray (NOT IN DLLMain) to laod another
DLL (library C)

Is this kind of Dll chaining possible?

Are there any gotchas I have to be aware of?

Be aware that global (namespace scope) objects in DLLs are constructed in
DllMain context, and static duration objects (namespace scope and local
static) in DLLs are destroyed in DllMain context. So you don't want to call
LoadLibrary from their ctors or dtors.

Otherwise, DLLs are owned by the process, and it's fine if one DLL calls
LoadLibrary to load another. In fact, it happens all the time, and it's
really the process making the call, not the DLL.
 
Back
Top