Jun 00 Tips
Volume Number: 16 (2000)
Issue Number: 6
Column Tag: Tips and Tidbits
Tips and Tidbits
by Jeff Clites <firstname.lastname@example.org>
File Types and StandardGetFile
In Dan Parks Sydow's article, "Opening a File", in the April 2000 issue of MacTech, he mentions that, "The [StandardGetFilePreview] dialog box can readily display all types of files, or just files of up to four different types", and that if you want to specify a list of more than four types, you must use a file filter function. Actually, this isn't true.
The definition of SFTypeList as an array of 4 OSTypes is simply a quirk of the original Mac OS interfaces (perhaps a desire to use a Pascal "var" parameter and avoid the use of the "@" (address-of) operator, for some reason). The underlying Standard File routines never had any such restriction. For instance, my original 1985 edition of Inside Mac Vol. I says on page I-524, "Assembly-language note: If you need to specify more than four types, pass a pointer to an array with the desired number of entries."
And indeed, Apple has finally removed this strange quirk from its recent interface definitions. The declarations of StandardGetFile, StandardGetFilePreview and so on now use the type ConstSFTypeListPtr for the list of types, and StandardFile.h even includes the comment that "For Pascal, this will require client code to use the @ operator, but make it easier to specify long lists." This is from the version 3.2 Universal Interfaces, dated August 1998.
An annoying number of installers unnecessarily insist on quitting every running application before performing the installation. Specific offenders that I have encountered recently are the monthly virus definitions for Norton AntiVirus 6.0, and the updaters for CodeWarrior Pro 5.x. In neither case is this step necessary: one is only replacing some virus definition files, while the other is only upgrading an application.
Both these updaters use MindVision's Installer VISE (reviewed in the April issue), and it turns out it is easy to short-circuit its attempt to quit all applications. To do this, make sure you have MacsBug installed. Launch the offending installer. At some point early on, it will present you with a dialog saying it must quit all running applications, with "Cancel" and "Continue" buttons. Don't click on a button yet. Instead, position the mouse over an unused part of the menu bar, hold the mouse button down, and with your other hand hit the interrupt sequence to get into MacsBug.
In MacsBug, check that the current application is indeed the installer (its name should appear on the left, under the heading "CurApName"), which should be in the middle of processing a call to MenuSelect. You can let go of the mouse button now. Type the following command:
atba GetNextProcess "; t; sw sp #-600; g"
This will intercept all attempts by the updater to get a list of running processes, and immediately short-circuit them with a procNotFound error--effectively pretending that there are no running processes!
(Note that Installer VISE is 68K code, so this procedure is valid for Power Macs.)
Having set the above breakpoint, resume execution with command-G. Now you can click the "Continue" button to continue the update. You should see the MacsBug screen flash up momentarily 3 more times, corresponding to the 3 separate places where GetNextProcess is called. Then the installation will proceed, without any applications being forced to quit!
Once the progress bar for the installation appears, it should be possible to break back into MacsBug and type
to clear the A-trap breakpoint, and then resume. Otherwise, having an A-trap breakpoint set slows down all system calls somewhat. Or, if you're ultra-cautious, you can wait until the installation has finished before doing this.
Warning: both the vendors providing the updaters and MindVision will almos certainly frown on the above procedure. It could very well cause a crash and loss of data for somebody in some situation I haven't considered. USE AT YOUR OWN RISK.
But then, if they were a little more considerate in configuring their updaters, this hack wouldn't be necessary...