| M E M _ I M P O R T J U M P T A B L E ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_importjumptable() - Prepares/copies jump table
off source object.
SYNOPSIS
slots = mem_importjumptable(dst, src);
LONG mem_importjumptable(
struct Library **, struct Library **);
FUNCTION
This func. prepares destination jump table using
information contained in source jump table.
INPUTS
dst - Destination jump table as created with alloc
function.
src - Source jump table. Can be any valid library
base. Real bases have to be vectorized first
(&SysBase). Local jump tables are vectors
already.
RETURNS
Returns 0 if all slots have been copied/prepped or
number of slots that did not fit in 'dst'.
BASES
SysBase
NOTES
Warning! No arbitration is applied during copying!
The func. will return -slots if 'dst' is not local
jump table.
In fact this routine does not raw copy jump tables
but does call-table-referencing for each offset.
What that means is, you can messup jump table and
easily fix it using 'mem_filljumptable()' without
knowing op code nor address!
If QDEV_MEM_LBS_FABSCALL flag was specified at the
time of allocation of 'dst' and if 'src' is a real
lib. base then all its offsets will be resolved!
This will cache 'src' function pointers in other
words. With QDEV_MEM_LBS_FRELCALL offsets will be
resolved during function call.
SEE ALSO
mem_allocjumptable(), mem_freejumptable(),
mem_swapjumptable(), mem_filljumptable(),
mem_setdatajtslot(), mem_setaddrjtslot(),
mem_addrfrombase()
EXAMPLE
#include <qlbs.h>
#include <qdev.h>
#include <proto/exec.h>
...
struct Library **jt;
struct Library **old;
/*
* Allocate number of slots OS 3.1 SysBase has. To
* remind you QBASESLOTS() accepts second optional
* argument that allows to enlarge number of slots
* by some amount (expressed in %), say 25.
*/
if ((jt =
mem_allocjumptable(QBASESLOTS(SysBase), 0)))
{
if (mem_importjumptable(
jt, (struct Library **)&SysBase) == 0)
{
if ((old =
mem_swapjumptable(QBASEPOINTER(SysBase), jt)))
{
/*
* Any 'exec' calls will now be attempted
* through local jump table.
*/
...
mem_swapjumptable(QBASEPOINTER(SysBase), old);
}
}
}
...
BUGS
None known.
----------------------------------------------------------------------------
| |
| |