sonenbli@oxy.edu (Andrew D. Sonenblick) (08/26/89)
Ok, here's a problem that seems beyond me, so I'm asking all you major techies to tackle it, or at least take a look. I know (believe) my code is ok/correct: basically, I built a minor application that patched into CloseDeskAcc, replacing it with my routine, and ultimately restoring the trap to the original CloseDeskAcc. (If it matters, my routine simply compared the refNum passed to CloseDeskAcc with a known one from my own DA--if they match I do nothing (this is so that I can close the window (closebox) of my DA without closing the -i~?Ctself--if the numbers don't match (ie, some other DA) I call the original CloseDeskAcc. Here's the relavant code: nothing new. Setup: #define CLOSEDESKACC 0xA9B7 OldCloseDeskAcc = GetTrapAddress(CLOSEDESKACC); SetTrapAddress(&myCloseDeskAcc, CLOSEDESKACC); Yes, my routine was previously declared as: extern pascal void myCloseDeskAcc(); Here's my routine: pascal void myCloseDeskAcc(refNum) int refNum; { if (refNum != myKnownID) CallPascal(refNum, OldCloseDeskAcc); } Finally, my restoring procedure: restore() { SetTrapAddress(OldCloseDeskAcc,CLOSEDESKACC); } Ok, the root of the problem: within my application, This worked perfectly! HOWEVER, once I transfered the _identical_ code to my DA (the same one which the patched code checks for a match with...) Kablooie! Crash! @#$@!%&! In other words, total unfunness. (I got from Macsbug an ADDRERR7F7F7F7F at 409F54) Curiously, I simply changed the #define CLOSEDESKACC from 0xA9B7 ot 0xA9C8 (which is SysBeep) and made minor alterations to the code (nothing detailed above was changed besides the #define) and the thing worked fine--all calls to SysBeep were routed to my routine, and when I closed the DA, restoring the original trap, they went to the original trap. There is obviously something about CloseDeskAcc that I am missing! What and where is the discrepancy? If this dilemma proves insoluble or the solution too infeasable, can anyone suggest an alternative method of allowing a DA's window to be closed without the DA itself being closed. I would appreciate any and all comments, now matter how trivial or verbose, brainstormed or well calculated. Face it, I'm stuck and I need your help! Please help me out! Thank you much, much, much, much, much. -----Ando Moon------------------------------------------------------------------ I would also like to thank all those who replied to my "chalis-shaped" plea for some INIT source code. By the way, have you ever really wondered about Tim M? No, seriously... --------------------------------------------------------sonenbli@oxy.edu--------