Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!bagate!cbmvax!cbmehq!cbmfra!swinjm!forgeas From: forgeas@swinjm.UUCP (Jean-Michel Forgeas) Newsgroups: comp.sys.amiga.programmer Subject: Re: Problem with SetFunction() Message-ID: <18d9ce4e.ARN0bdc@swinjm.UUCP> Date: 19 Mar 91 13:08:30 GMT References: <13531@darkstar.ucsc.edu> Reply-To: forgeas@swinjm.UUCP (Jean-Michel Forgeas) Followup-To: comp.sys.amiga.programmer Organization: The Software Winery Lines: 41 In article <13531@darkstar.ucsc.edu>, Dave Schreiber writes: > APTR __regargs newAllocMem(ULONG size,ULONG types); > [...] > oldAllocMem=SetFunction(ExecBase,NEG_AM_OFFSET,newAllocMem); > [...] > APTR __regargs newAllocMem(ULONG size,ULONG types) > { > return(oldAllocMem(size,types)); > } Just an idea: when it sees __regargs, the compiler assigns registers to parameters, and in your case should use D0/D1. But did you verify it with a small disassembly of newAllocMem() ? > temp=(APTR)AllocMem(1000,0L); /*Goes to my routine & allocates*/ > /*the memory without a problem*/ How are you sure that 'temp' is something valid ? > If I change newAllocMem() so that it just returns NULL, the call to > AllocMem() in main() returns NULL; i.e. I know that calls to AllocMem() are > being routed to my module. newAllocMem() as it is above also works without > a hitch. But when I printf() an '\n' (or when I Permit() without undoing the > patch), it crashes. Any suggestions? BTW, I'm using a 3000 under 2.02 > (under 1.3 it crashes as well, but it gives a 8000 0003 error). Seems that it crashes every time newAllocMem() calls oldAllocMem(). 1 - Either you call oldAllocMem with bad values into registers, don't forget that the a6 register must stay with ExecBase value. 2 - Either you don't call oldAllocMem() at all but jump into the 5th dimension. Best regards, Jean-Michel -- \___/ Jean-Michel Forgeas \-/ cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery -^- And, where is the universe ?