[Lazarus] "Running" a library

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sat Sep 15 08:54:26 CEST 2012

Rolf Grunsky wrote:

> It's been a very long time since I looked at this, and this is specific 
> to Windows. An exe and dll have the same basic structure, the difference 
> is that an exe can not export entry points and part of the startup will 
> initialize the stack and data segments. On the other hand, any procedure 
> called in a dll will assume that the stack pointer and segment registers 
> have been already set up. Also, I believe that there is only a single 
> entry point in an exe. Windows does provide a method to run a dll as a 
> program but I would assume that you have to pass the procedure in the 
> dll that you want to run. As I said this is from vague memory so the 
> details are fuzzy. At a minimum, to run a procedure in the dll you will 
> need some code to set up stack and data segments.

I can't speak for the current PE format, but working from memory (i.e. 
stuff I've done) an NE-format .exe could be built exposing multiple 
named entry points: I've used that facility with older tools to generate 
a file which could then be bound with descriptors etc. for a '386 
running in protected mode.

Whether such a hybrid format actually makes sense to a standard 
operating system is, of course, a different question. And whether 
there's a methodology which would allow a hybrid program/library to be 
useful (e.g. by having the program entry point test the functionality of 
the library entry points) is another.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the Lazarus mailing list