[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LoadLibrary and 5.2
- From: "Thomas Harning Jr." <harningt@...>
- Date: Tue, 12 Jan 2010 12:18:29 -0500
On Tue, Jan 12, 2010 at 11:57 AM, Antonio Scuri
<scuri@tecgraf.puc-rio.br> wrote:
> So you are saying that one possible solution is to call SetDllDirectory on the Lua interpreter?
>
> Checking its documentation it looks promising. The only drawback is that it needs Service Pack 1 in Windows XP.
Another possible solution is to somehow track down the dependent
libraries, load them w/ package.loadlib to get the DLL loaded in the
namespace... you don't even need to know a valid function in the
library from what it looks like... since once a library is loaded, it
looks like it will never be unloaded, unless you remove it from the
registry (indexed by LIBPREFIX .. path).
The basic algorithm for Windows dependent library loading is this:
* If a library with the same base filename is already loaded (ex:
MyLibrary.dll) use that
* Search for appropriate library in the search paths
... it doesn't matter if the MyLibrary.dll is the 'right' one, since
it just uses the base name... no path involved.
the package.loadlib trick would get the dependent library into the
namespace, then Windows would use that and increment the use count
since a DLL depended on it.
Use case:
* for each library module X depends on
* package.loadlib(library, "dontcare")
* load module X
* for each library module X depends on
* debug.getregistry()[PREFIX .. library] = nil
Nasty... but a possible solution to an ugly problem...
--
Thomas Harning Jr.