Windows 2008 and wrong BPL loading

565 views Asked by At

I have an application builded with Run-time Packages. When the executable starts it auto loads the required packages (.bpl).

Recently we has installed an Windows 2008 R2 server to use as Terminal Services.

We maintain some old compiled versions of our application in different paths, like this:

c:\app\version_1\common.bpl
c:\app\version_1\app.exe

c:\app\version_2\common.bpl
c:\app\version_2\app.exe

Common.bpl is the a run-time package what app.exe depends on.

THE PROBLEM:

I start "c:\app\version_2\app.exe" and it loads "c:\app\version_2\common.bpl". When I start the "c:\app\version_1\app.exe" it loads the WRONG bpl (from version_2).

The path "c:\app\version_2\" isn't at the system search path.

At Windows2003 server this problem doesn't occurs.

What can I do to solve this?

Thanks!


I have downloaded the Process Explorer (microsoft sysinternals), and checked the loaded modules of each executable, all they are correct!

But I noticed another problem. After start the second version, an entry-not-found-error occurs, telling me what a initialization entry point, of an unit what only exists in one of the versions, could not be found.

Something is very strange. The ProcessExplorer is telling me that the process is loading the correct modoles, but when they are running this seems not be happening.

Seems the applications are sharing the loaded modules.


SOLVED

There was a MouseHook using FindVCLWindow, this was generating the AV.

Sorry about inconvenience guys, and thanks!

1

There are 1 answers

8
Remy Lebeau On

If the BPLs are statically linked into the EXEs, and if the version_2 BPL is already in memory when the version_1 EXE is run, Windows will re-use the existing BPL in memory, it will not re-load a new copy of the other BPL. This is documented behavior:

If lpFileName does not include a path and there is more than one loaded module with the same base name and extension, the function returns a handle to the module that was loaded first.

When using static linking, there is no path information, so the OS loader has to go off of the file names by themselves.

To do what you are attempting, you need to create a .local file for each EXE to isolate them from each other so they can load their respective DLLs in parallel.

DLL/COM Redirection on Windows

Dynamic-Link Library Redirection