Solved

Unloading "load-time dynamic linked" DLLs

Posted on 1999-01-22
6
264 Views
Last Modified: 2010-04-02
I have created a DLL (say A.DLL) which loads another DLL (say B.DLL) dynamically using LoadLibrary call. B.DLL loads several other DLLs (say C.DLL, D.DLL ... so on) at load time. When I call FreeLibrary in A.DLL to unload the B.DLL, the DLLs C.DLL, D.DLL, .... are not unloaded. How do I unload these libraries?
0
Comment
Question by:sridhar_dvjs
6 Comments
 
LVL 4

Expert Comment

by:pellep
Comment Utility
I suggest you free c.dll, d.dll etc in the b.dll. i.e in the destructor or ExitInstance or in the
DllEntryPoint()/DLL_PROCESS_DETACH
of the b.dll you should free any library it loaded. this is can't
be done by a.dll, since you loaded the c and d.dll explicitly.

0
 

Author Comment

by:sridhar_dvjs
Comment Utility
C.DLL, D.DLL etc.. are not explicitly loaded by B.DLL (they are loaded at load time not run time!!) The only explicit load is B.DLL and I am calling FreeLibrary to unload it.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
Comment Utility
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:sridhar_dvjs
Comment Utility
I thought I already rejected AlexVirochovsky's answer. The suggested code in Q10097274 can not work on WIN32. The function GetModuleUsage is absolete. All my DLLs are WIN32 and I am using MSVC 5.0 on NT 4 Sp3.
0
 
LVL 3

Accepted Solution

by:
luisr earned 20 total points
Comment Utility
You could call GetModuleHandle("dll") and the FreeLibrary on that handle. That will unload the DLL.
0
 

Author Comment

by:sridhar_dvjs
Comment Utility
Please refer Q.10120210
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now