[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: dynamic loading of windows dll's in lua as plugins?
- From: Jeroen Janssen <japj@...>
- Date: Tue, 18 May 1999 12:51:29 +0200
At 06:27 5/18/99 -0300, you wrote:
>I'm not saying this is the most elegant method, but it worked for me, I
>managed to write an extension DLL which allowed LUA to run as a NT service.
is there a special reason you chose for this solution?
>The basic idea is to save the lua interface function addresses into a single
>control block structure, which is then passed to a function in the DLL which
>registers all the newly available extensions. As DLL's are considered part
>of the address space of the main exe this is simple. I have a slight worry
>about the global control blocks in the DLL and main program, do they
>reference the same memory, I don't think so, it would probably be better
>just to use a ptr here.
Don't know if this will work but exactly as I think but:
If I create a LUA.DLL that exports all lua functions I can let my main
application load the LUA.DLL (runtime or loadtime).
Extension DLL's can refer to functions from the LUA.DLL (using the import
.LIB from the DLL).
When I use LoadLibrary to load an extension DLL (from my main application
or from a LUA script) the extension dll will have access to the LUA DLL
functions (because the .LIB imports all functions of LUA.DLL and the
LUA.DLL is in memory). Also since every DLL has a DllMain function that
gets executed by LoadLibrary I can register luafunctions from the DllMain
of the extension DLL.
Thus in short extension DLLs will make C/C++ functions available to LUA
from their DllMain function and because the extension DLLs get linked with
the import LIB from LUA.DLL they have access to the LUA functions without
needing to have a control structure with all available LUA functions,etc
(and not having to call a "register" function yourself)
I haven't got a chance to try this explicitly because I'm currently busy
with some other things (altough I have got a LUA.DLL at the moment and I
did some test regarding DLLs and LoadLibrary), but I think it should
work... any suggestions or remarks if this idea would (not) work?