Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!mvb.saic.com!ncr-sd!ncrcae!opusc!jwwalker From: jwwalker@opusc.csd.scarolina.edu (Jim Walker) Newsgroups: comp.sys.mac.programmer Subject: Re: trap patches Message-ID: <1990Dec1.233546.20813@opusc.csd.scarolina.edu> Date: 1 Dec 90 23:35:46 GMT References: <1990Nov26.040223.8193@ucselx.sdsu.edu> <46831@apple.Apple.COM> <2818@polari.UUCP> Organization: Univ. of South Carolina, Columbia Lines: 77 In article <2818@polari.UUCP> robert@polari.UUCP (robert) writes: [stuff deleted] > > This example looks very useful, but my BIG problem right now is > that what I need to do requires patching routines in the Standard File > package. Pack3 is a complex trap. Apparently, calls to Pack3 involve > passing a routine "selector" of some kind. I haven't found any > documentation on this. Does anyone have any information? Any examples > or pointers to examples? A sharp razor? > > Robert Riebman (I tried to mail this reply, but it bounced.) Here is some THINK C code for the relevant parts of a Pack3 patch I wrote. typedef enum { SFPut = 1, SFGet, SFPPut, SFPGet }; pascal void my_SF() { int selector; register Point *where; int dlog_id; /* since this is a trap routine, we must preserve the registers */ asm { movem.l a1-a5/d0-d7, -(SP) ; a7 is SP LEA main, A4 ; set up globals move.w 8(A6), selector } switch (selector) { case SFGet: asm { lea 32(A6), where } dlog_id = getDlgID; break; case SFPut: asm { LEA 26(A6), where } dlog_id = putDlgID; break; case SFPPut: asm { lea 32(A6), where move.w 14(A6), dlog_id } break; case SFPGet: asm { LEA 38(A6), where move.w 14(A6), dlog_id } break; } /* Most of your patch goes here */ asm { move.l Old_SF, A0 movem.l (SP)+, a1-a5/d0-d7 ; restore registers unlk A6 JMP (A0) ; jump to Old_SF } } -- -- Jim Walker 76367.2271@compuserve.com