Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!labrea!decwrl!nsc!csi!csib!jwhitnel From: jwhitnel@csib.UUCP Newsgroups: comp.sys.mac Subject: Re: article about jGNEFilter in MacTuto Message-ID: <1172@csib.UUCP> Date: Fri, 14-Aug-87 12:43:46 EDT Article-I.D.: csib.1172 Posted: Fri Aug 14 12:43:46 1987 Date-Received: Thu, 20-Aug-87 01:30:00 EDT References: <164500042@uiucdcsb> <164500043@uiucdcsb> Reply-To: jwhitnel@csib.UUCP (Jerry Whitnell) Organization: Communications Solutions Inc., San Jose, Ca Lines: 61 In article <164500043@uiucdcsb> kkim@uiucdcsb.cs.uiuc.edu writes: | therefore, if i can modify keydown events within a desk acc without patching |GetNextEvent, i will be happy to hear the method. if i have to patch, i |would like to know how to patch it (probably using these two traps). I'm writting this without reference to IM, so take it with a small grain of salt. This is in C, translation to Pascal or other lanaguages is left as an exercise for the reader. #define GNE_TRAP 0xa??? /* Trap number for GetNextEvent (from IM) */ typedef int (*funcptr)(); /* Pointer to function returning an int */ functptr oldGetNextEvent; /* initlization code */ oldGetNextEvent = NGetTrapAddr( GNE_TRAP ); NSetTrapAddr( myGetNextEvent ); /* This is the patch itself, parameters must match GetNextEvent */ pascal Boolean myGetNextEvent( event, mask ) EventRecord *event; int mask; { Boolean retCode; /* First call real GetNextEvent to get the event. CallPascalW calls ** indirectly a pascal function from C. Your glue may differ here */ retCode = CallPascalW( event, mask, oldGetNextEvent ); if ( retCode ) { /* We have an event, so preprocess it */ } return( retCode ); } /* termination code. Must be executed before application termination or ** bad things will happen, not the least of which is your mac will crash */ SetTrapAddr( GNE_TRAP, oldGetNextEvent ); That's it. The initilzation code is executed once when your DA initlizes, the termination code is executed once when your DA is closed and the patch code is what is executed when the application calls GetNextEvent. Caveat, this method works only on Mac+ or newer system, it will not work on 64K ROM systems (and no flames about that, please). | | thanks. | |Kyongsok KIM |arpanet/csnet: kkim@a.cs.uiuc.edu |usenet/uucp : {seismo, pur-ee, ihnp4}!uiucdcs!kkim Jerry Whitnell It's a damn poor mind that can only Communication Solutions, Inc. think of one way to spell a word. -- Andrew Jackson