Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 8 - Trap Manager / Trap Manager Reference
Routines / Installing Patch Addresses Into the Trap Dispatch Tables


NSetTrapAddress

You can use the NSetTrapAddress procedure to install a patch address into either an Operating System trap dispatch table or a Toolbox trap dispatch table.

PROCEDURE NSetTrapAddress (trapAddr: LongInt; trapNum: Integer;
                           tTyp: TrapType);
trapAddr
The patch address.
trapNum
A-line instruction or a trap number. If you specify a A-line instruction, the function extracts the trap number you.
tTyp
The trap type. If you supply the tTyp parameter with the constant OSTrap, the NSetTrapAddress procedure installs the address into the Operating System trap dispatch table. If you supply the tTyp parameter with the constant ToolTrap, the NGetTrapAddress function installs the address into the Toolbox trap dispatch table.
DESCRIPTION
The NSetTrapAddress procedure places the patch address specified by the trapAddr parameter into a trap dispatch table. Use the tTyp parameter to specify whether the patch address belongs in the Operating System trap dispatch table or the Toolbox trap dispatch table. If tTyp is OSTrap, the NSetTrapAddress procedure installs the address into the Operating System trap dispatch table. If tTyp is ToolTrap, the NGetTrapAddress function installs the address into the Toolbox trap dispatch table. Use the trapNum parameter to specify the location of the patch address in the dispatch table. The trap number may be any word value; its irrelevant high-order bits are masked according to the value of the tTyp parameter.

Note
If the system software routine that is being patched has a come-from patch, the NSetTrapAddress procedure installs the address of the patch into the exit JMP instruction of the come-from patch (rather than into the trap dispatch table).
WARNING
If the first 4 bytes of the trapAddr parameter is $60064EF9 (indicating a come-from patch), NSetTrapAddress triggers a system error.
ASSEMBLY-LANGUAGE INFORMATION
The registers on entry for the _SetTrapAddress macro are
Registers on entry
D0An A-line trap word
A0Address of next routine in the daisy chain (a system software routine or a patch)

When calling the _SetTrapAddress macro, you set bit 9 of the A-line trap word to indicate a "new" system; that is, any version since the Macintosh Plus or Macintosh 512K. You use bit 10 to indicate whether the system software routine that is being patched is a Toolbox routine (by setting bit 10 to 1) or an Operating System routine (by setting bit 10 to 0).

Macintosh development environments provide the modifier words newTool and newOS to be used as arguments in the _SetTrapAddress macro.

Given an A-line instruction in register D0 and a system software address in register A0, you set the Toolbox routine with the trap number in register D0 to have the address in A0, you use the macro

_SetTrapAddress newTool
This is equivalent to calling NSetTrapAddress(trapAddr, trapNum, newTool). The trapAddr parameter is the address placed in register A0. The trapNum parameter is the A-line instruction placed in D0 for the assembly-language call. Similarly, to set the address of an Operating System trap whose A-line instruction is in register D0 to the address in register A0 you use the macro

_SetTrapAddress newOS
This is equivalent to calling NSetTrapAddress(trapAddr, trapNum, newOS).

SEE ALSO
The Unimplemented procedure is described next. For information about the NGetTrapAddress function, see page 8-27. For an example of how to use the NSetTrapAddress function, see Listing 8-5 on page 8-24.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice