[comp.sys.mac] Edit breaks!

mystone@caen.engin.umich.edu (Dean Yu) (01/16/89)

  For those of you out there who thought that MDS Edit (or just Edit) would
never break, (I know you're out there; I used to be of that opinion myself)
I must tell you something that's on the level of learning that there is
no Santa Claus. (Sorry if I spoiled this, too...)  Edit DOES break under
certain conditions, namely, if you have more than 31 fonts.  If you have more
than 31 fonts in your system and you try to use Edit, it'll hang and hang
and hang.  Believe me.  I just spend the last half hour mixing and matching
INITs trying to figure out which one was causing the crash.  Then I realized
that I installed about ten more fonts the other day, and hadn't run Edit since.
  Obviously, Edit's doing something funky with the enableFlags field of the
menu resource.  Now the question is, does anyone know how to patch it?
 
______________________________________________________________________________
Dean Yu                            |  E-mail:    mystone@caen.engin.umich.edu
University of Michigan             |  Real-mail: Dean Yu
Computer Aided Engineering Network |             2413 Kelsey House
===================================|             600 E Madison
"These are MY opinions." (My       |             Ann Arbor, MI 48109
 employer doesn't want them.       |==========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
------------------------------------------------------------------------------  

earleh@eleazar.dartmouth.edu (Earle R. Horton) (01/18/89)

In article <40e53258.1285f@maize.engin.umich.edu> 
	mystone@caen (Dean Yu) writes:
>
...
>If you have more than 31 fonts in your system and you try to use Edit,
>it'll hang and hang and hang.  Believe me.  I just spend the last half
>hour mixing and matching INITs trying to figure out which one was
>causing the crash.  Then I realized that I installed about ten more
>fonts the other day, and hadn't run Edit since.

>  Obviously, Edit's doing something funky with the enableFlags field of the
>menu resource.  Now the question is, does anyone know how to patch it?
> 

Edit is not doing anything funny with the enableFlags field of the
menu resource.  In fact, this particular menu isn't even kept in a
resource, but is built on the fly!  Pretty good guess, though.

I have MDS Edit version 2.1, according to the "About Edit..." box.  It
calls NewMenu() to get a new font menu, then calls AddResMenu() to
fill the menu with font names.  Then, it gets the font names from the
menu using GetItem(), and fills a local stack frame array with the
corresponding font numbers, which it gets from GetFNum().  Finally, it
checks the item with the name of the font it is using.  The font
numbers are stored in a 31-word array.  When it gets to menu item 32,
guess what happens?  Yeah, it overwrites the counter it is using to
keep track of what menu item to look at next, and this puts it in an
infinite loop.

The offending function is about 3328 bytes into CODE resource #5.  It
can be patched by making the stack frame bigger, and by moving the
font number array to the bottom of the new stack frame.  If you make
the stack frame 1024 bytes larger, and move the font number array down
to the bottom of it, then you get room for 512 fonts, which is probably
enough.  That should fix it for a while.  I patched mine, and it runs
OK with 52 fonts installed.



Oh, you wanted the patch in hex?  Sorry, here it is.

Find the first 4E56FE8C in CODE resource 5.  Replace it with 4E56FA8C.
Replace 41EEFFB4 with 41EEFBB8 twice.  These three changes are within
142 bytes of each other.

Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755--Graduate student.
He who puts his hand to the plow and looks back is not fit for the kingdom
of winners.  In any case, 'BACK' doesn't work.