Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!gargoyle!ddsw1!obdient!gagme!essam From: essam@gagme.chi.il.us (Essam Khairullah) Newsgroups: comp.sys.mac.programmer Subject: Need jGNEFilter help Message-ID: <917@gagme.chi.il.us> Date: 28 Nov 90 06:43:52 GMT Distribution: na Organization: GAGME Public Access UNIX, Chicago, Illinois, USA Lines: 80 I'm writing an INIT that patches GetNextEvent to show the user an alert at a specified time. Unfortunately, it causes problems. For instance, if I'm in the Finder and I activate my screen saver and then deactivate it, my patch doesn't notify the Finder to redraw its screen. I called Symantec (I'm using THINK C 4.0) and they suggested I try using the low-memory global jGNEFilter instead of actually patching GNE. I must be doing something wrong, because now even worse problems occur than when I just patched GNE itself. In the original INIT, I patched SystemTask and it worked just fine, but I allocate memory and SystemTask is marked as not moving memory, so I figured it would be safer to patch something that is allowed to move memory. Here's a sample of the code I'm using: void main( void) { ProcPtr oldJGNEFilter; Handle myHandle; /* Get handle to my routine... */ asm { move.L A0, myPtr; } RememberA0(); SetUpA4(); /* Allow use of global variables */ myHandle = RecoverHandle( myPtr); DetachResource( myHandle); ..... /* Allocate and initialize global data */ oldJGNEFilter = JGNEFilter; /* Save original JGNEFilter value */ JGNEFilter = ( ProcPtr) newJGNEFilter; /* Install my own filter */ RestoreA4(); } pascal void newJGNEFilter ( void) { long saveD0, saveD1, saveA1, saveA7; asm /* Save certain registers used by JGNEFilter */ { move.L D0, saveD0; move.L D1, saveD1; move.L A1, saveA1; move.L A7, saveA7; } SetUpA4(); /* Allow use of global variables */ ..... /* Check if it's time to call my routine, call it if neccessary */ asm /* Restore saved registers */ { move.L saveD0, D0; move.L saveD1, D1; move.L saveA1, A1; move.L saveA7, A7; } oldJGNEFilter; /* Call original JGNEFilter */ RestoreA4(); /* Clean things up and return */ } And that's it! I hope that I'm just doing something stupid and obvious so it's easily fixed. Like I said, it worked just fine when I was patching SystemTask, but I wanted to be safe. BTW, if I call NewDialog and give it storage for the DialogRecord and also provide a handle of the itemList, does it allocate memory, and if so, can I do something to avoid it? If it's not too much trouble, I may just keep on patching SystemTask if I can do it without allocating memory. Anyhow, thanks in advance for any help anyone can offer. -- Essam Khairullah essam@gagme.chi.il.us I don't got no fancy signature.