Re: calling application procedure from a dll
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Sun, 13 Nov 2005 13:31:23 -0600
J French wrote:
I wonder - a DLL takes a TStream as a parameter
In the main App I have a fancy decendant of TStream that reads its data from an abacus - the unit containing TAbacusStream is explicitly included in the DPR of the main App - and the DLL knows nothing about it
I suppose the DLL goes rooting around in the memory of the main App,
or does it ? The DLL knows all about TStream and has a copy of the TStream code
compiled into it
- I genuinely don't know how smart the VMTs are
- but I've a nasty feeling that some spectacular GPFs could turn up
A problem would only occur if the VMT from one module had a different layout from the VMT in the other module -- if the methods were declared in a different order, or if a new method were inserted between two others.
If the EXE were compiled in Delphi 2005, but the DLL was compiled in Delphi 5, then things would crash spectacularly. Between those two versions, TStream got several new virtual methods, in part to support 64-bit stream positions. The order of the methods' declarations determines the order of the slots in the VMT.
If the DLL tried to set the stream's Size property, it would actually end up calling the stream's GetSize method, not SetSize. GetSize wasn't virtual in Delphi 2005, so there's no VMT entry for it at all.
There is also the optimizing compiler to consider, I gather it pretty much gives up on trying to decide what VCL it needs to include/exclude - but ... it still makes me nervous ...
Delphi's optimizer really doesn't do much at all, when compared to what optimizers in Visual C++ or GCC do. Delphi never removes a virtual method, unless perhaps it's private, but then it might never have been made virtual in the first place.
When I create a new DLL, I rapidly snip out all that garbage about using the shared memory manager DLL, and assume that the host App is written in an as yet unwritten dialect.
If I want to call virtual methods across module boundaries, and I'm not using packages, then I make sure I use interfaces. COM interfaces are mostly just a formalized version of C++ and Delphi VMTs anyway.
-- Rob .
- References:
- calling application procedure from a dll
- From: bilox
- Re: calling application procedure from a dll
- From: J French
- Re: calling application procedure from a dll
- From: Maarten Wiltink
- Re: calling application procedure from a dll
- From: Rob Kennedy
- Re: calling application procedure from a dll
- From: Maarten Wiltink
- Re: calling application procedure from a dll
- From: J French
- calling application procedure from a dll
- Prev by Date: Re: calling application procedure from a dll
- Next by Date: TstringGrid - detect cell change
- Previous by thread: Re: calling application procedure from a dll
- Next by thread: Re: calling application procedure from a dll
- Index(es):
Relevant Pages
|
|