PDA

View Full Version : Plugin load path problem / implicit dll linkage


focht
February 1st, 2004, 09:09
Greetings,

while working on plugin which is splitted into some dlls with implicit linkage, i'm facing the problem of OS loader dll search path.

Usually this wouldnt be a problem - if one puts _all_ the custom dlls into ollydbg main app directory.
But this is tedious.
Due to the increasing number of plugins i use a subdirectory ".\Plugins" and pointed ollydbg "plugin path" option to it.

This doesnt work on plugins which have additional custom dlls implicitly linked.
They dont get found by OS loader (of course).

Ollydbg iterates thru all the *.dll files in specified plugin directory and tries to load em using LoadLibrary().

LoadLibrary() uses the following paths to look for additional (implicit) modules :

- directory from which the application loaded.
- current directory.
- system directory.
- 16-bit system directory.
- windows directory.
- directories that are listed in the PATH environment variable.
- redirection file (which overrides given path to match app directory first)
- _BaseDllDirectory (using new Set/GetDllDirectory() APIs, XP SP1+)

As you see the "custom" plugin directory is never by searched by loader.

A (backwards) portable solution would be using SetCurrentDirectory() to plugin directory before calling LoadLibrary().
This gets the plugin the chance to resolve implicit dll references.
The current directory can be later be restored back to old value.
(any custom dll must not use delay load feature)

For now i have to use the "ugly" way to dump the additional dlls into ollydbg directory or modify PATH env variable for additional plugin path.

Would be nice if ollydbg has option to influence plugin loader mechanism to include plugin directory to resolve implicit references.

Regards,

A. Focht

PS: explicit dll linkage is _not_ an option for me.

blabberer
February 1st, 2004, 09:25
hey i think he has addressed this problem in 1.10 beta if i remember correctly
the whats new page one minute ill see

;(
dunno the points you raise are different it seems he wrote about .udd directory
OllyDbg haven't checked that .udd directory specified in .ini file really exists. Reported by Phong Tran;

focht
February 1st, 2004, 10:55
Hi again,

i just reviewed the 1.10b code.

Before the LoadLibrary() call ollydbg just prepends the full plugin directory path to the filename.
The working directory itself is not touched.

Hopefully next version there is an option to resolve the implicit loader issues. Temporary SetWorkingDirectory() while loading plugins preferred.

Regards,

A. Focht