Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!uw-beaver!microsoft!t-benw From: t-benw@microsoft.UUCP (Benjamin Waldmin) Newsgroups: comp.sys.mac.programmer Subject: sharing data between cdevs and INITs Keywords: INIT cdev Message-ID: <1739@microsoft.UUCP> Date: 18 Aug 88 18:51:59 GMT Reply-To: t-benw@microsoft.uucp (Benjamin Waldman) Organization: Microsoft Corporation, Redmond, WA Lines: 38 Does anyone out there have a suggestion for sharing data between a cdev and a patch installed as an INIT? To be more precise, I have a cdev which a user uses to set options which change the behavior of an INIT. For example, in a screen saver, the user sets the time until screen blanking in the control panel, and then the screen saver (presumably an INIT which patched a trap) changes its behavior accordingly. So, the problem is: how does the cdev know where to put the data so that the INIT can find it, or how does the INIT know where the cdev put the data? The cdev can either put data in some block or change the patch that the INIT has installed, but there's no way for the cdev to find the patch either (using GetTrapAddress won't work, since another patch may have been installed on top of mine). I've thought of allocating space for the variables (in the system heap) when the INIT is loaded, then saving the address of this space in a resource on the disk, and having the cdev read this resource. The problem with this is that I have to write to disk, which I'd prefer not to do (What if the user has the disk locked - then the cdev crashes, since the address it reads from disk will br bogus). Alternatively, I could have the cdev try to find the patch in the system heap (looking for a certain byte pattern to identify it). The problem with this is that I can't just traverse blocks in the heap to look for my block, since I can't assume memory manager data structure formats, since Apple says not to (I don't know why - I can't imagine Apple changing these). Thus, I'd have to look through every byte in the heap, which would be slow. So, after all this, does anyone have any suggestions? Thanks a lot in advance! Ben Waldman uw-beaver!microsoft!t-benw