Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rtl, replacement memory manager concern, misc related ?s

12 views
Skip to first unread message

dhoke

unread,
Aug 14, 2007, 10:42:38 PM8/14/07
to
The B/CG provided memmgr.lib is constructed to force linking by ordinal.

The routine __CRTL_VCL_Init() is apparently called somewhere as part of a
program's startup initialization.

That routine, when built with "_BUILDRTLDLL" defined, calls
"__CRTL_VCL_Sharemem().

(As an aside - in an earlier post, I inquired regarding building RTL with
MAGIC to get replacement library functionality for static library. It
appears that would probably not be sufficient, as this item which is
apparently involved in the replacement hooking, requires "_BUILDRTLDLL" to
be defined.)

__CRTL_VCL_Sharemem(), at its end, calls GetAllocMemCount().

Since this distributed code is apparently linked to import by ordinal, that
call (to GetAllocMemCount()) appears to call whatever routine is ordinal 2
in the loaded borlndmm.dll (whether distributed or replacement), which is
_not_ necessarily GetAllocMemCount().

FastMM replacement .dll (well version 476 anyway) has
"Borlndmm::HeapRelease()" at ordinal 2, _not_ GetAllocMemCount(). (It has
GetAllocMemCount() at ordinal 19.) My replacement .dll has something else
at ordinal 2. FastMM's HeapRelease seems to be mostly a no-op, and thus
probably still works "OK". (My replacement is not quite as lucky.)

Observation:
delphimm.pas appears to define the MM names
sharemem.pas appears to define the MM names

Conclusion: Replacement borlndmm.dll's must have the ordinal values of
their exported functions be the same as those in B/CG distributed versions
of borlndmm.dll to best ensure compatibility.

Related questions (yes I know this isn't the right group but...):
Does the "index" clause in delphi's exports clause specify the ordinal value
to associate with the exported function?

If so, can someone provide a sample of how it should be coded? (The docs
mention it, but don't seem to give any syntax definitions anywhere including
it.)

(Or,) What ways are there to specify ordinal value to associate with
exported function for/from delphi/pascal module?

Can someone explain why the distributed memmgr.lib, and distributed
library/support code, are built to reference borlndmm.dll sometimes by
ordinal (memmgr.lib, prob. referenced by the code containing
__CRTL_VCL_Sharemem()), and sometimes by name (various loadlibrary calls
involved in mm hooking/replacement)?

Other Comments?


0 new messages