Python bindings tutorial
Alf P. Steinbach
alfps at start.no
Fri Mar 19 08:01:46 CET 2010
* Tim Roberts:
> Dave Angel <davea at ieee.org> wrote:
>> There's no real reason parts of an exe cannot be exported, same as a
>> dll. They are in fact the same structure. And in fact many other files
>> in the Windows environment are also the same structure, from fonts to ocx's
This is a bit off-topic, but your explanation is incorrect in some key respects,
so (no offense) to avoid readers getting an incorrect impression:
> Well, there IS a fundamental difference. EXEs and DLLs and the like do all
> have the same format. They all have a "transfer address"
Commonly called an "entry point".
This is the term you need to know about when e.g. linking object files.
>, where execution
> begins. That's the key problem. With a DLL, the transfer address goes to
> a DllMain, where certain DLL initialization is done, preparing the other
> entry points for use.
Right, modulo terminology: there's only one "entry point" in a PE format file.
> With an EXE, the transfer address goes to "main".
Sorry, no, the EXE entry point goes to a routine of no arguments.
Typically, in C and C++ that's a run time library routine (e.g. with Microsoft's
run time library mainCRTStartup or one of its cousins) which in turn calls the
C/C++ "main", while in Pascal it runs the main program, so on.
Note that the EXE entry point is probably still incorrectly documented as
requiring WinMain signature -- it's the most infamous Microsoft documentation
> So, when you load an EXE as a DLL, you will be RUNNING the program.
Sorry, no, that's not what happens.
The Windows API LoadLibrary(Ex) knows the difference between an EXE and a DLL.
It's documented as handling both sub-formats, and it does.
> That's is usually not what you want.
If that had happened then it would be a problem, yes. Happily it doesn't happen.
I've discussed the real problems else-thread.
Cheers & hth.,
More information about the Python-list