| M E M _ A D D R F R O M L V O ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
INDEP - MEM_#?
----------------------------------------------------------------------------
NAME
mem_addrfromlvo() - Allows to determine an absolute address
of a function in opened, shared lib.
SYNOPSIS
funcaddr = mem_addrfromlvo(libbase, offset);
APTR mem_addrfromlvo(void *, LONG);
FUNCTION
This function can be very helpful if an absolute address of
certain shared library function is needed.
INPUTS
libbase - Base of a shared library, like: SysBase, DOSBase,
...
offset - Negative offset of particular function as seen in
LVO's or 'RKM' offsets.
RETURNS
An absolute address to a function.
BASES
None.
NOTES
Important! If you intend to use this function to call LVO
functions then you must declare the base locally and setup
the relative jump register! This is typically to be A6.
Important! Local function pointers must include proper arg
registers! Refer to FD files.
SEE ALSO
mem_addrfrombase()
EXAMPLE
...
/*
* As long as you do not intend to call the function this
* will work even with global bases.
*/
LONG (*_Output)();
_Output = mem_addrfromlvo(DOSBase, -60);
/* -60 == Output() */
...
/*
* But if you want to call something then local base must
* be register assisted and no middle code can be called!
*/
LONG res;
res =
({
register struct ExecBase *SysBase asm("a6") =
(*((struct ExecBase **) 4));
ULONG (*_AvailMem)(register ULONG asm("d1")) =
mem_addrfromlvo(SysBase, -216);
/* -216 == AvailMem() */
register ULONG amount asm("d0");
amount = _AvailMem(MEMF_CHIP);
amount;
})
...
BUGS
None known.
----------------------------------------------------------------------------
| |
| |