Path: utzoo!news-server.csri.toronto.edu!rpi!uupsi!sunic!news.funet.fi!ra!rosenber From: rosenber@ra.abo.fi (Robin Rosenberg INF) Newsgroups: comp.sys.amiga.programmer Subject: Re: Problem with SetFunction() Message-ID: Date: 18 Mar 91 18:12:25 GMT References: <13531@darkstar.ucsc.edu> Sender: rosenber@ra.abo.fi Organization: Abo Akademi University, Finland Lines: 32 In-reply-to: davids@ucscf.UCSC.EDU's message of 18 Mar 91 03:45:31 GMT In article <13531@darkstar.ucsc.edu> davids@ucscf.UCSC.EDU (Dave Schreiber) writes: >I've been trying to patch AllocMem() as an experiment, and haven't been >able to get it to work. I manage to patch it correctly with SetFunction(), >but when I try to print a carriage return using printf, the machine crashes >with a 8000 0006 error (CHK instruction). Here's the code: 1. Stack checking off 2. Make sure your global as accessible, either compile for absoulute addressing or declare your patch function using __saveds to get A4 right. 3. AllocMem has THREE parameters: size(d0),types(d1) and execbase(a6). Declared them properly when writing the patch. Something like. Declare the pointer to the old function the same way. void * (* __asm __saveds oldallocmem)( register __d0 ULONG size, register __d1 ULONG types, register __a6 struct ExecBase *SysBase); void *__asm __saveds myallocmem( register __d0 ULONG size, register __d1 ULONG types, register __a6 struct ExecBase *SysBase) { return (*oldallocmem)(size,types,SysBase); } ----- Robin