Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Detecting Idle Message-ID: <7501@hoptoad.uucp> Date: 1 Jun 89 20:40:49 GMT References: <1560@cunixc.cc.columbia.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Distribution: usa Organization: Eclectic Software, San Francisco Lines: 31 As dwb has pointed out, this scheme is trivial to defeat using a system floppy disk. A Mac will always boot from a floppy disk before a hard disk if the floppy is seen early enough in the boot cycle. And as dwb also pointed out, another hard disk may be attached (though if the Mac has an internal hard disk, it will always boot from that first). So I don't know that what you're doing is all that valuable. Nonetheless, on to your keystroke problem. You didn't say *where* you are checking for the events being available. I assume it is from a trap patch, but which trap? You may be calling from a place that would generally see key-down events as already dequeued. I would recommend that you patch either PostEvent or GetNextEvent; if you do PostEvent, you can check the event type and change your global flags yourself if it's a key down event. (But be quick about it! PostEvent is called at the interrupt level.) If you patch GetNextEvent (at the start, mind you) your EventAvail approach should work fine. If you use the GetNextEvent low-memory global routine, I'm not sure, but the event may have already been dequeued by the time you get called. There is a way to do what you want securely, but not portably. You don't use an INIT; instead, you use the disk's boot blocks. That way, as soon as the hard disk is mounted, the code will get executed. I can't give you any pointers on how to do this, but I have seen a product which does it. It can still be broken by an expert using a debugger, but it's much better protection. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "I am of the opinion that my life belongs to the whole community, and as long as I live it is my privilege to do for it whatever I can." -- Shaw