Appendix 2: Trap Patches Required for PowerWeb


On several occasions during PowerWeb development, we found that System 7's default behavior was undesirable and needed to be changed. In some cases, a simple algorithmic change was all that was required; however, in some cases, the differences were more fundamental.

When PowerWeb Slave is started, it connects to a Master using an Apple Event using the command AESend(). This can conceivably have security implications. The Apple Event Manager determines if the AESend() target is on a separate machine; if so, then the Apple Event Manager determines if there is currently a valid connection between the two applications. If not, an authentication dialog is posed for the user to enter a user name and optional password. This raises issues with PowerWeb's philosophy of minimizing the impact on the local user. PowerWeb Slave is not too unobtrusive if it comes to the front and sits there, waiting for someone to enter a name and password. This could be the receptionist's word-processing machine! The receptionist probably doesn't know all the computer access codes, and shouldn't need to. PowerWeb addresses this problem by patching traps to make PowerWeb Slave connect to PowerWeb Master without posing these obtrusive dialogs. Two Macintosh traps must be patched to accomplish this:

GetNewDialog

GetNewDialog() is the routine that reads the definition of a dialog window from disk. By patching it, PowerWeb Slave can watch for the dialog ID of the authentication dialog. When it sees it, it moves the dialog off the screen (to location -9999, -9999) so it never interrupts anybody.

ModalDialog

ModalDialog() is the routine that gets called repeated when a dialog is being displayed and processed. The ModalDialog() patch checks to see if we're currently trying to use the authentication dialog. If so, it posts appropriate keyDown events so the user name and password are entered. After this, the authentication dialog goes away.

These two traps are patched immediately before an authentication dialog is possible, and the patches are de-installed immediately afterwards.

Resource-related traps

PowerWeb Master also patches two traps, GetResource() and Get1Resource(), two related routines that read resources from disk. When a plug-in is installed, all its resources are surreptitiously renumbered to ensure that no duplicate resource numbers occur. Then, when each MPiF is called, the trap patch surreptitiously renumbers the requested resource number to what the resource number has been changed to.