jjoshua@topaz.rutgers.edu (Jon Joshua) (02/18/90)
I am trying to patch SetPort() to eventually do some neat things. Since this is my first attempt at something like this I decided to write a simple patch that does nothing except tell me that it is alive and well inside the machine. This is in LS C with standard headers turned off. --- void main (); header () /* not a function */ { asm { bra.s @start ;Jump over storage tAddr: dc.l 0 ;Save SetPort trap addr here start: jsr main ;Do neat stuff move.l @tAddr,a1 ;Load orig SetPort trap addr jmp (a1) ;Outa' here } } void main () { SysBeep (5); } --- Notes: It works under finder and not MF. MacsBug says it dies in the following way: 1111 ERR 850130: 6100 6100612A MOVE.W D7,D6 >WH In ROM @ 4175D2 A058 InsTime Question: Could someone please shed some light on what might be happening? Why only under MF and not finder. I tried booting with 0 INITs/CDEVs etc. and the same thing happened. Thanks, JOn. PS. Thanks to the few people who have been helping me so far. -- /\ ? ________________ jjoshua@topaz.rutgers.edu \ ____ __ fgu |.signature under| Anything is possible... \ | | / | orywlut- | construction | ========== gfgsdfsdfsd |________________| _____________________________OO_____O___hfdhksjdhfksjdfs_______||__________||__
6500stom@hub.UUCP (Josh Pritikin) (02/19/90)
From article <Feb.17.20.57.45.1990.11446@topaz.rutgers.edu>, by jjoshua@topaz.rutgers.edu (Jon Joshua): > I am trying to patch SetPort() to eventually do some neat things. >... I think its better to do it this way: asm { movem a0/a1/d0,-(sp) ;save the reg that you use bra.s @start ;Jump over storage tAddr: dc.l 0 ;Save SetPort trap addr here start: jsr main ;Do neat stuff movem (sp)+,a0/a1/d0 move.l @tAddr,-(sp) ;Load orig SetPort trap addr rts ;Outa' here } void main () { FlashMenuBar(0); /* sysbeep isn't such a hot idea */ FlashMenuBar(0); /* in some programs */ } > Question: Could someone please shed some light on what might be > happening? Why only under MF and not finder. I tried booting with 0 > INITs/CDEVs etc. and the same thing happened. Umm, I've no idea why it wouldn't work but try my changes and see what happens. > -- > /\ ? ________________ > jjoshua@topaz.rutgers.edu \ ____ __ fgu |.signature under| > Anything is possible... \ | | / | orywlut- | construction | > ========== gfgsdfsdfsd |________________| > _____________________________OO_____O___hfdhksjdhfksjdfs_______||__________||__ / Josh Pritikin T The C++ programming language \ | Internet: 6500stom@ucsbuxa.ucsb.edu | is at worst, the second best | | AppleLink: Josh.P | for a given application. | \ GEnie: J.Pritikin ! But usually, it is the best. /
d88-jwa@nada.kth.se (Jon Watte) (02/19/90)
>From article <>, by jjoshua@topaz.rutgers.edu (Jon Joshua): >> Question: Could someone please shed some light on what might be >> happening? Why only under MF and not finder. I tried booting with 0 >> INITs/CDEVs etc. and the same thing happened. In article <3991@hub.UUCP> 6500stom@hub.UUCP (Josh Pritikin) writes: >I think its better to do it this way: > asm { > movem a0/a1/d0,-(sp) ;save the reg that you use > bra.s @start ;Jump over storage > tAddr: dc.l 0 ;Save SetPort trap addr here > start: jsr main ;Do neat stuff > movem (sp)+,a0/a1/d0 > move.l @tAddr,-(sp) ;Load orig SetPort trap addr > rts ;Outa' here > } Why bother ? The THINK C linker automagically fixes this for you. Sort of. When compiling code resources, it sets up storage for globals, and has a jump instruction at relative location 0 within the code segment to the functino named main() (This is _always_ the main entry point) You should really do something like: long savedAddress; main() { asm { movem a0/a1/d0,-(sp) } do_neat_stuff(); asm { movem (sp)+,a0/a1/d0 unlk a6 move.l savedAddress,-(sp) rts } } This is my guess... h+ -- --- Stay alert ! - Trust no one ! - Keep your laser handy ! --- h+@nada.kth.se == h+@proxxi.se == Jon Watte longer .sig available on request