Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!husc6!endor!siegel From: siegel@endor.harvard.edu (Rich Siegel) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC debugging code resources Keywords: combining text and graphics. Message-ID: <906@husc6.harvard.edu> Date: 3 Jan 89 05:08:01 GMT References: <221@dalcsug.UUCP> <966@geowhiz.UUCP> <1235@viscous> <896@husc6.harvard.edu> <66569@ti-csl.CSNET> <900@husc6.harvard.edu> <1198@etive.ed.ac.uk> Sender: news@husc6.harvard.edu Reply-To: siegel@endor.UUCP (Rich Siegel) Organization: Symantec/THINK Technologies, Bedford, MA Lines: 52 In article <1198@etive.ed.ac.uk> nick@lfcs.ed.ac.uk (Nick Rothwell) writes: > (i) Can I do this for any code resource? The trick allows you to incorporate the code for any code resource as part of the program's source code, not as a separate resource. > (ii) What about the resource? Does it have to use A4 rather than A5, > if it's actually a bit of the same project? Any restrictions on > access to globals, or anything like that? Embedded code resources are actually more flexible than externally built code resources, since they can use external globals and data; the application context is much better defined. > (iii) What code do you use to perform the patch? Is it in-store, The code loads a dummy resource and fills it with the correct infomation. Suppose you have a procedyre MyDefProc(), which is the code for an LDEF, embedded in your program. If you wanted to install MyDefProc as LDEF 128, it would go like this: typedef struct { int jmpInstr; Ptr jmpAddr; } JmpRec, *JmpPtr, **JmpHandle; extern pascal void MyDefProc(); void InstallLDEF() { JmpHandle jH; jH = Get1Resource('LDEF', 128); (**jH).jmpInstr = 0x4EF9; (**jH).jmpAddr = &MyDefProc; HNoPurge(jH); } This loads the dummy defproc, patches it to your routine, and makes it nonpurgeable. You should be sure that the routine is in a segment that is loaded and will stay loaded. --Rich Rich Siegel Staff Software Developer THINK Technologies Division, Symantec Corp. Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel Phone: (617) 275-4800 x305 Any opinions stated in this article do not necessarily reflect the views or policies of Symantec Corporation or its employees.