[vlc-devel] [PATCH]Fixes for mozilla and activex plugins- ticket #2062

Geoffroy Couprie geo.couprie at gmail.com
Thu Oct 30 11:42:58 CET 2008


On Thu, Oct 30, 2008 at 9:40 AM, Rémi Denis-Courmont
<rdenis at simphalempin.com> wrote:
>
> On Wed, 29 Oct 2008 22:52:29 +0100, "Geoffroy Couprie"
> <geo.couprie at gmail.com> wrote:
>> They run in the same process as the browser. I could do a
>> SetDllDirectory(NULL) to come back to the original search path after
>> the plugin was used.
>
> That does not solve the case that the program actually set the DLL
> directory to something _else_.
> And it also fails if there are multiple threads in the process, which I
> assume to be the case here.
>
SetDllDirectory changes the _order_ in which the DLLs are loaded,
there's no such thing as "THE dll directory".  The standard search
order is:
1.The directory from which the application loaded.
2.The system directory. Use the GetSystemDirectory function to get the
path of this directory.
3.The 16-bit system directory. There is no function that obtains the
path of this directory, but it is searched.
4.The Windows directory. Use the GetWindowsDirectory function to get
the path of this directory.
5.The current directory.
6.The directories that are listed in the PATH environment variable.

And when you use SetDllDirectory(lpPathName), it becomes that:
1.The directory from which the application loaded.
2.The directory specified by the lpPathName parameter.
3.The system directory. Use the GetSystemDirectory function to get the
path of this directory. The name of this directory is System32.
4.The 16-bit system directory. There is no function that obtains the
path of this directory, but it is searched. The name of this directory
is System.
5.The Windows directory. Use the GetWindowsDirectory function to get
the path of this directory.
6.The directories that are listed in the PATH environment variable.

It removes the current directory from the DLL search path. I assume
the IE engineers use manifests or direct dependency between EXE and
DLLS, and no LoadLibrary. I don't know for Mozilla.

 There's a problem if somebody uses another activex or another mozilla
plugin that use SetDllDirectory. One thing we can do then is using
SetDllDirectory(NULL) right after all the plugins needing third party
libraries. We can use GetDllDirectory to save the old value (possibly
set by another plugin), use SetDllDirectory for the VLC plugins, then
re-set the old value (but that's obviously not thread-safe).

Using separate processes for the plugins is another solution, but it
needs a bit more code. The standard, recommended way is to use
manifests, but from what I saw, that's a really (insane) big task.



More information about the vlc-devel mailing list