|Column Tag:||Assembler Workshop
A tiny file-launching hack for those emergencies...
By Lee David Rimar
Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.
What with it being April and the call of April Fools Day echoing in the breezes, it seems an appropriate time to put before the public this little horror that arrived at our desks a while back. Please bear in mind that when we say, Kids, dont try this at home, this is one case where we mean it. It really does work, but the publisher, editors and staff of MacTech Magazine categorically refuse to stand behind or endorse it in any way, and will not be held responsible for what happens to you or anyone else as a result of your assembling this code or downloading the alternate Finder app. In fact, we cant even be held responsible for what may happen to you if you read the article! Why not just turn the page now? Hey, I said turn the page! Okay, you asked for it
What It Is and
Why You Might Want It
With current releases of the Mac OS, its sometimes hard to build a useful emergency boot diskette. If your hard-drive wont boot, you can usually use the Disk Tools floppy to bring up your system. But if you want other diagnostic and/or system recovery programs on your emergency diskette, there usually isnt enough space. Enter FakeFinder.
FakeFinder is a tiny program (under 800 bytes) that simply launches other programs. On emergency boot diskettes, FakeFinder replaces the real Finder, and frees a lot of space.
How To Use It
To create an emergency boot disk with FakeFinder:
Format a diskette and label it Emergency.
Copy the following file(s) from your Disk Tools diskette to the root directory of Emergency:
1) the System file
2) optional: the Apple CD-ROM Extension
If your Mac requires any system enablers, copy these also to the root directory of Emergency.
Copy the Finder application from the FakeFinder package to the root directory of Emergency.
You now have a bootable diskette with considerable free space on it. Go ahead and add any other programs you want in the root directory of this disk, anything that will fit. My personal preference is to keep most of whats on the Disk Tools floppy, and add my tape backup/restore software.
When you reboot with this diskette, FakeFinder loads and creates a File menu with only two items on it: Open and Quit.
To launch any program(s), select Open. This will let you select any applications, aliases to applications, and even a real Finder on any mounted drive - including CDs, if you copied the Apple CD-ROM Extension to the diskette.
To shut down your Mac, select Quit, and also quit any other applications you may have launched. Your Mac will then shut down normally.
(or, This Aint No Swiss Army Knife)
To be so small, FakeFinder leaves a lot of stuff out. The most important limitations:
No desk accesories/Apple Menu items.
Without a real Finder present, you cant use File Sharing.
Programs needing to find a Blessed Folder, containing a real Finder and System, may not work.
The point of FakeFinder was to make it as small as possible, so I dont plan to solve any of these problems.
By The Way: How Did It Get So Small?
Normally, to create an application this small, you would start in assembly language. But I dont grok 68K assembler well enough to write anything from the ground up. So I wrote, compiled, linked, and tested FakeFinder using FORTRAN, a language I do know. Then I disassembled the compilers output, modified it to reduce the code size, and re-assembled it.
(or, Anything Free Comes With No Guarantee)
Though FakeFinder works properly on every system I have tested so far, it may not work on tomorrows systems. This is because it uses the _Launch trap to sublaunch applications, and Apple says this functionality may go away in future OS releases. If and when that time comes, it will be necessary to rewrite any applications using the sublaunch facility.
Macintosh Tech Notes #126, #180, #205 (old numbering system).
; system routines used in this module
_AppendMenu OPWORD $A933
_DrawMenuBar OPWORD $A937
_ExitToShell OPWORD $A9F4
_FindWindow OPWORD $A92C
_HFSDispatch OPWORD $A260
_HiliteMenu OPWORD $A938
_InitCursor OPWORD $A850
_InitDialogs OPWORD $A97B
_InitFonts OPWORD $A8FE
_InitGraf OPWORD $A86E
_InitMenus OPWORD $A930
_InitWindows OPWORD $A912
_InsertMenu OPWORD $A935
_Launch OPWORD $A9F2
_MenuSelect OPWORD $A93D
_NewMenu OPWORD $A931
_StdFile OPWORD $A9EA
_SetVol OPWORD $A015
_WaitNextEvent OPWORD $A860
; make a stack, initialize managers, and set up menus
lea (266,a7),a2 ; qd.grafport
; If (.NOT. WaitNextEvent(
; VAL2(-1),event,VAL(15),VAL(0))) Loop
; If (event.what != mouseDown) Loop
; If (FindWindow(
; VAL(event.where),dummy) != inMenuBar) Loop
; pick = MenuSelect(VAL(event.where))
; Call HiliteMenu(VAL2(0))
; If (pick == z'00810001') GetFile
; If (pick != z'00810002') Loop
; Call ExitToShell
; Call SFGetFile(
; If (.NOT. reply.good) Loop
; myPB.p_ioName = LOC(reply.fName)
; myPB.ioVRefNum = reply.vRefNum
; myPB.ioFDirIndex = 0
; myPB.ioDirID = 0
; If (PBGetCatInfoSync(myPB) != 0) Loop
; params.ioCompletion = 0
; params.ioResult = 0
; params.p_ioName = 0
; params.ioVRefNum = reply.vRefNum
; If(PBSetVolSync(params).LT.0) Loop
; ap.pfName = LOC(reply.fName)
; ap.param = 0
; ap.LC = z'4C43'
; ap.extBlockLen = 6
; ap.fFlags = myPB.ioFlFndrInfo.fdFlags
; ap.launchFlags = z'C0000000'
; ignore = launch(ap)
final: bra Loop
; some constants embedded in code section
types: ; file types for getfile, what you can launch with FakeFinder
dc.l $4150504c ; APPL
dc.l $464e4452 ; FNDR
dc.l $61647270 ; adrp (application aliases)
AppleMenu: ; Apple Menu character, for appearances only!
FileMenu: ; Pascal String File
dc.b 0 ; pad so next lands on even address
MenuItems: ; Pascal string Open;Quit