Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!dkuug!imada!micro From: micro@imada.ou.dk (Klaus Pedersen) Newsgroups: comp.sys.atari.st.tech Subject: How to intercept TOS vectores Keywords: XBRA Message-ID: <1991May19.185424.18475@imada.ou.dk> Date: 19 May 91 18:54:24 GMT Sender: news@imada.ou.dk (USENET News System) Organization: Dept. of Math. & Computer Science, Odense University, Denmark Lines: 88 I have collected the following BAD things from the Overscan driver at atari.archive. I post this in the hope that this can stop BAD things! - move SR,Dx - the instruction was used to check if the CPU was in USER or SUPER mode!!! The instruction can be used to that on all 680x0 cpus, but cpu's later than the 68000 will tell you, that the cpu is in user mode with a PRIVILEGE VIALTION exception. - the new 68K cpus put more on the stack when processing an exception this means that the offsets to parameters from within the trap dispatchers are diffrend on new (10/20...) cpus. To fix this it is possible to use the new system variable 'longframe'. - remember that GEMDOS, XBIOS, BIOS is documented to change D0-D2/A0-A2, this means that you should be able to use them too, If is wasn't for TurboC and many other applications, that consider A2 safe! (use as few registers as possible and don't use D3-D7/ A2-A6)! AES and the VDI are special! Here you can't even A0 and A1 and D0 and D1 is used to pass parameters! (Save all registers!) The next don't have anything thing to do with Overscan: - Remember to use the XBRA protocol, when taking a vector, there is nothing to it. Put the following just about the entry point XBRA_ID: DC.B 'XBRA' ; Tell that the XBRA is used. APPL_ID: DC.B 'name' ; your identifyer (like cookies) OLD_VEC: DS.L 1 ; Save the old vector here! entry: - When you use the VDI, then remember to get the handle for the Screen from the AES, with graf_handle(). It is really painfull to use a program that don't, when AMCGDOS is installed: "Your application uses illigal handles!", SFX_PAK, CAL4.7 (or something) and many DC-utilities comes to mind. Do you have any things that you would hope people stopped doing, besides minding their own business. LINK INTO GEMDOS ===================== longframe EQU $059E DC.B "XBRAnnnn" ; This is all XBRA is about OldDos: DC.L 0 ; place the old address here! MyDos: move USP,A0 btst #5,(SP) ; called from Supervisor- or User-mode? beq.s tst_funcs ; Parameter is on USER stack lea 6(SP),A0 ; Old (small) stack frame. tst.w longframe.w ; Is this running on a CPU beq.s tst_funcs ; with a long stackframe? addq.w #2,A0 ; -then add 2 more bytes. tst_funcs: cmpi.w #Pterm0,(A0) ; Check the FUNCTION numbers! bne.s notmine ... here do the stuff you need to do ... notmine: movea.l OldDos(PC),A0 ; Now return to the original! jmp (A0) LINK INTO VDI/AES ====================== magicAES EQU 200 magicVDI EQU 115 DC.B "XBRAnnnn" OldVec: DC.L 0 MyGem: cmpi.w #magicVDI,D0 ; Is it a [VDI]-call ? bne.s NotMyGem1 ; no -> continue movem.l A0-A1,-(SP) ; preserve all A-Regs! movea.l D1,A1 ; Address of VDI-Parameters movea.l (A1)+,A0 ; Control[0] = function number cmpi.w #func,(A0) ; Check the FUNCTION numbers! bne.s NotMyGem ; not mine -> next; ... here do the stuff you need to do ... NotMyGem: movem.l (SP)+,A0-A1 NotMyGem1: move.l OldVec(PC),-(SP) ; call Orginal GEM-dispatcher rts ; ... call --- Klaus, micro@imada.ou.dk