lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


DLLs in Windows have a dllEntry point which can be used for various customization of dynamic linking and resolution of dependencies. DllEntry points are normal C functions, comparable to the main function in C, but taking other arguments (not from a command line, but that can still use the environment if needed and can modify it, however it cannot load other modules/libaries itself due to possible deadlock conditions; as well it cannot start or terminate any thread or process, instead it returns a status that allows the loader to refuse to create or terminate a thread or process).

It is called when first loading the DLL but before actual linking to other programs (actually this is used not only at the per-process level but also for each thread). If the DLL does not need per-thread initialization (e.g. if it does not allocate any TLS data for each thread to keep track of external resources used by the thread when they use the exported DLL functions, they can disable these notifications and the DLL entry will only be called on process termination). The DLL entry point can control the search path and load other libraries itself.

Le dim. 25 nov. 2018 à 13:51, Viacheslav Usov <via.usov@gmail.com> a écrit :
On Sun, Nov 25, 2018 at 12:00 PM Sean Conner <sean@conman.org> wrote:

>  I did say that.   Twice.  Granted, they were in parentheticals but they are there.

One of them was "(for the record, it worked under Linux)", whence I could not deduce it produced the same output.

>                                         _The MS-DOS Encyclopedia_

When it comes to static linking, you might as well use a contemporary source:

"Object files on the command line are processed in the order they appear on the command line. Libraries are searched in command line order as well, with the following caveat: [...]"


My point was about PE DLLs, though. In PE, there is a clear distinction between imports and exports. To create an equivalent of an elfian public symbol in a shared library, a DLL export would also have to be an import and would need a body, which to my knowledge is impossible using Microsoft's tools. I am not sure whether one could do that with a special tool exploiting PE's dark corners, but then we would end up with the "original" DLL's having to be built in some weird (for Windows) way, which kind of nullifies the whole point of the exercise.

Cheers,
V.