Loading plugins with additional DLLs from other folders

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Loading plugins with additional DLLs from other folders

Post by *gigaman »

Hello!

Sorry if this has already been discussed, but I didn't find any such post here.
Today, I was trying a number of plugins and encountered a problem with SymbolView plugin. The plugin WLX uses additional implicitly-imported DLL(s). I installed the plugin into a subdirectory of the Total Commander installation directory (i.e. not diretly where the TotalCmd.exe file is). Now, when I tried to activate the plugin, it succeeded only when this subdirectory was opened in the right panel when I tried to activate it for the first time in the Total Commander session. (I'm using Windows 98 SE, btw).

The problem seems to be related to the "search path" that is used when the plugin DLL is loaded (and its imports are searched). So, my question is: would it be possible to slightly change the way Total Commander loads the plugins? Replacing the LoadLibrary() call with LoadLibraryEx(.., .., LOAD_WITH_ALTERED_SEARCH_PATH) would help.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48107
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, interesting idea, I will check that.
Author of Total Commander
https://www.ghisler.com
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Post by *gigaman »

Just a little remark: today, I was made aware of the following remark from MSDN:
On Windows Me/98/95, if you are using LoadLibraryEx to load a module that does not contain a resource, the function fails and GetLastError returns ERROR_BAD_FORMAT.
If it were true, then it might be a problem of course (since the plugins aren't required to contain any resources); fortunatelly, it's wrong. This remark is only valid if also the parameter LOAD_LIBRARY_AS_DATAFILE is specified; if not, the function loads resource-less libraries without any problems (since in this case, LoadLibraryEx uses the same kernel32 code as LoadLibrary, which doesn't have this "remark"). Tested on Windows 98 SE, but I really doubt it would be different on other Win9x platforms.
Sven
Member
Member
Posts: 111
Joined: 2003-02-10, 21:32 UTC
Location: Varel, Germany
Contact:

Post by *Sven »

Maybe it is possible to set the directory where the plugin is located explicitly via SetCurrentDirectory before the plugin is loaded?
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Post by *gigaman »

Yes, I was thinking about it, too. It would probably work as well - I was just afraid about possible negative effects on plugins that really use the "current directory" for something (though it may not be very likely at the moment of the plugin loading).
The LoadLibraryEx should be OK.
Post Reply