🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #13510

Re: SetFunction()ing Dos.library

#13510
From: John Bickers
Date: Mon, 05 Feb 1990 22:27
30 lines
2211 bytes
In article <1472@jimi.cs.unlv.edu> maniac@hubert.cs.unlv.edu (Eric J. Schwertfeger) writes:
>   Is it possible to setfunction dos.library?  I have been told that the
> normal setfunction
> call willnot, but is it possible to do a work-around?

    Yes, the normal SetFunction() expects a library entry (6 bytes in the
    library table) to be:
                jmp     32-bit address
    So when you SetFunction a library vector it returns the top four bytes of
    the 6 as the function point it's supposed to return, and plugs in the
    4-byte pointer you provide. It also seems to re-write the jmp instruction
    code.

    This works fine for most libraries, but the DOS library doesn't have that
    type of entry. Instead of a jmp to a 32-bit address it has:
                moveq   nn,d0           ; nn is some value DOS understands
                bra.w   DOS routine
    The DOS routine is usually the same for all the different "vectors", and
    it must somehow work out from the value in d0 which DOS function you are
    calling (go BCPL! :).

    So to emulate SetFunction(), you have to write your own code that will
    replace the moveq,bra sequence with a 32-bit jump to your intercept code,
    and your intercept code must, at the end, move nn into d0 and then jmp to
    the destination of the original branch instruction.

    You can determine the value of nn and the destination of the original
    branch instruction by taking a debugger to the DOSBase vector. For
    example, a do-nothing program in Lattice C was enough for CodeProbe to
    pick up DOSBase from.
Technical Details
Message-ID: <1990Feb5.222754.2239@actrix.co.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!comp.vuw.ac.nz!dsiramd!actrix!jbickers
References: <783@kunivv1.sci.kun.nl> <1472@jimi.cs.unlv.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!comp.vuw.ac.nz!dsiramd!actrix!jbickers
From: jbickers@actrix.co.nz (John Bickers)
Newsgroups: comp.sys.amiga.tech
Subject: Re: SetFunction()ing Dos.library
Summary: DOSBase vectors aren't jmp instructions
Message-ID: <1990Feb5.222754.2239@actrix.co.nz>
Date: 5 Feb 90 22:27:54 GMT
References: <783@kunivv1.sci.kun.nl> <1472@jimi.cs.unlv.edu>
Reply-To: jbickers@actrix.co.nz (John Bickers)
Organization: Actrix Public Access UNIX, Wellington, New Zealand
Lines: 30