Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site tolerant.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!hplabs!oliveb!tolerant!berry From: berry@tolerant.UUCP (David W. Berry) Newsgroups: net.micro.mac Subject: Re: INIT Resources Message-ID: <333@tolerant.UUCP> Date: Mon, 14-Apr-86 18:58:44 EST Article-I.D.: tolerant.333 Posted: Mon Apr 14 18:58:44 1986 Date-Received: Thu, 17-Apr-86 01:12:27 EST References: <8604110030.AA22220@kim.berkeley.edu> Reply-To: berry@handel.UUCP (David W. Berry) Organization: Tolerant Systems, Inc. San Jose, CA Lines: 106 Summary: An INIT resource is a piece of code which gets executed automatically at system boot time. I believe they are executed in numerical order just before the startup application is executed. They are executable code with an entry point at offset 0. An INIT installer is an application which copies an INIT resource into the system file, presumably after checking for conflicts with existing resources. As a sample, the following is an INIT resource to patch a problem I was having with programs passing NULL to EnableItem and DisableItem: (-- Cut Here for Usable sample. Assemble with MDS Asm ) include mactraps.d include sysequ.d resource 'INIT' 4 '{Enable,Disable}Item(NIL)' start: ; save registers movem.l d0-d1/d7/a0-a4,-(sp) ; fill in all the old address vectors lea patch_table,a4 lea start_p,a3 move 4(a4),d7 @2: move 0(a4),d0 _GetTrapAddress move.l a0,0(a3,d7.w) add.l #6,a4 move 4(a4),d7 bne.s @2 ; allocate the patch block and copy the patch into it move.l #end_p-start_p,d0 _NewPtr,SYS move.l a0,a1 move.l #end_p-start_p,d0 lea start_p,a0 _BlockMove ; set the new trap address to point into the patch block lea patch_table,a4 move.l a1,a3 move 2(a4),d7 @4: lea 0(a3,d7.w),a0 move (a4),d0 _SetTrapAddress add.l #6,a4 move 2(a4),d7 bne.s @4 ; restore registers and return movem.l (sp)+,d0-d1/d7/a0-a4 rts patch_table: dc.w $a939 dc.w patch1-start_p dc.w trap1-start_p dc.w $a93a dc.w patch2-start_p dc.w trap2-start_p dc.w 0,0,0 start_p: patch1: move.l $6(a7),d0 bne.s @1 move.l (a7)+,a0 add.l #6,a7 jmp (a0) @1: move.l trap1(pc),-(a7) rts trap1: dc.l 0 patch2: move.l $6(a7),d0 bne.s @1 move.l (a7)+,a0 add.l #6,a7 jmp (a0) @1: move.l trap2(pc),-(a7) rts trap2: dc.l 0 end_p: (-- End of Sample ) Hope this answers your questions. -- David W. Berry dwb@well.UUCP Delphi: dwb {ucbvax,pyramid,idsvax,bene,oliveb}!tolerant!berry I'm only here for the beer.