[comp.sys.amiga] Dos library/SetFunction

rouaix@inria.UUCP (Francois Rouaix) (05/07/87)

I would like to change some functions in dos.library, adding new features
to CurrentDir() for example.
The best way to do this on a library is:
	- write a piece of code that does what you want, and then call the 
old function.
	- SetFunction() to your new code,  getting the old pointer.

The problem is:
for most libraries, the 'vector table' looks like:
	JMP address1
	JMP address2
	....
LibBase {some code}

I believe the SetFunction() is returning {address1}.

BUT: for dos.library the vector table looks like:
	MOVEQ #x,d0
	BRA entry_point
	(repeated)
where the code at entry_point is doing some standard stack manipulations,
and then computes some address from x and goes to it.
(BTW this reminds me of ProDOS)

My question is: how can you use SetFunction on dos.library ??
-------------------------------------------------------------

page@ulowell.cs.ulowell.edu (Bob Page) (05/08/87)

rouaix@inria.UUCP (Francois Rouaix) wrote in article <455@inria.UUCP>:
>I would like to change some functions in dos.library, adding new features
>to CurrentDir() for example.

Sorry, no can do.  For one reason, the dos.library jump table ISN'T one.
I mean, it is, but it's more than that.  It's not a Exec (RKM) library.

The other reason: It's a BCPL library.  If you call a BCPL "function"
with a C string, it first converts it into a BSTR, then calls its
"internal" function.  Some might do the conversion directly if they
know nobody will be calling it from within the BCPL environment, but
I bet most call a CSTR -> BSTR conversion routine first.

So how DO you do it?  You have to poke around the guts of DOS and find
the "internal" function - the one that does all the work.  Find its
address, and change the location to your own location.

Remember if you're passing string params in, you'd better be accepting
BSTR params, not C.

Oh -- this is not supported by anybody, and will probably break in a
future release of the system.  But then again, maybe by then we'll
have a real process manager and file system.

..Bob
-- 
Bob Page, U of Lowell CS Dept.   page@ulowell.{uucp,edu,csnet} 

jmsynge@sqm.dec.com (James M Synge, DTN 381-1545) (05/10/87)

inria!rouaix writes:

> BUT: for dos.library the vector table looks like:
> 	MOVEQ #x,d0
> 	BRA entry_point
> 	(repeated)
> where the code at entry_point is doing some standard stack manipulations,
> and then computes some address from x and goes to it.
> My question is: how can you use SetFunction on dos.library ??

SetFunction can NOT be used on dos.library!  If you wish to do this, you
need to determine the address to which the BRA jumps to, record this, then
insert your own JMP YOUR_ROUTINE in the jump table (not just the address
as does SetFunction), set the appropriate flag in the Library lib_Flags field,
then set your routine so it prepares D0 correctly and JMPs to the location
which you determined earlier.

Bon chance,

James Synge

USENET:  {decvax, ucbvax, allegra}!decwrl!sqm.dec.com!jmsynge
ARPAnet: jmsynge%sqm.DEC@decwrl.DEC.COM

#include <disclaimer.h>
"Ken Olsen can speak for Digital, not me!"