Solved

DLL load path

Posted on 2011-09-21
5
432 Views
Last Modified: 2013-12-04

Hi,

I have an issue with the 'correct' DLL being loaded on a target machine(s).

In some of the target machines, different versions of a DLL may have ben registered or placed in multiple/different folders.

I need to specifically be able to load a certain DLL.

I beleive it used to be that the folder from where the app was launched was searched first, but this is no longer the case due to the need to prevent hacks??  Is this the case?

How do I specify a specific DLL to be loaded?

Code examples if you have them, please.

Thanks
Phil
0
Comment
Question by:BeerFizz
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 36574902
Take a look at http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx ("Dynamic-Link Library Search Order"), which is an in-depth explanation on how that works in Windows. You might want to use 'LoadLibraryEx()' (http://msdn.microsoft.com/en-us/library/ms684179%28v=VS.85%29.aspx) with LOAD_WITH_ALTERED_SEARCH_PATH: "If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded."
0
 

Author Comment

by:BeerFizz
ID: 36574965
Hi jkr,

thanks for the response.

This particular DLL which is ebing loaded is loaded from a DLL in my app.  

Does DELAYLOAD have to be invoked?
0
 

Author Comment

by:BeerFizz
ID: 36575064

I'm not sure I framed my initial question correctly.

The DLL in question uses 'COM'.

When my application fails because the incorrect DLL is regestered, it is because the CLSID cannot be found or some varient of that.

Is it possible to bypass the registered DLL/CLSID and load the correct DLL directly?

Not sure if I'm making a lot of sense here...

0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 36575600
COM is a whole different story. If the DLL in question is not registered properly, you should handle that as an error or register the DLL yourself either by calling regsvr32.exe or loading it using 'LoadLibrary()' and calling 'DllRegisterServer()' - see http://support.microsoft.com/kb/207132 ("INFO: How Regsvr32.exe Registers and Unregisters COM DLLs") for code that does that.
0
 

Author Closing Comment

by:BeerFizz
ID: 36910004
jkr,

thank you for your response and I apologize for how long it took me to get back.  I had to get info of the target machine and there were issues with that.

I am going to reframe my question and ask it again, if you would be so kind to look.

I will call it "C++ Com Problem".

Thanks
Phil
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

21 Experts available now in Live!

Get 1:1 Help Now