home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks96 / InstantUpgradePro.sit / InstantUpgradePro / InstantUpgradeProINIT.c < prev    next >
C/C++ Source or Header  |  1996-06-22  |  17KB  |  589 lines

  1. /*
  2. Written by Steve Bollinger and Cameron Esfahani at MacHack '96
  3. */
  4.  
  5. #include <A4Stuff.h>
  6. #include <SetUpA4.h>
  7. #include <Menus.h>
  8. #include <Resources.h>
  9. #include <LowMem.h>
  10. #include <Windows.h>
  11. #include <Traps.h>
  12.  
  13. #define    kDialogUserItem1            1
  14. #define    kDialogUserItem2            2
  15. #define    kDialogUserItem3            3
  16. #define    kDialogUserItem4            4
  17. #define    kDialogUserItem5            5
  18. #define    kDialogUserItem6            6
  19. #define    kDialogUserItem7            7
  20. #define    kDialogUserItem8            8
  21.  
  22.  
  23. #define    kTextBoxes                    8
  24.  
  25. Handle ReturnA0(void) = {0x2008};
  26.  
  27. typedef pascal WindowPtr (*NewCWindowProcPtr)(void *wStorage, const Rect *boundsRect,
  28.     ConstStr255Param title, Boolean visible, short procID, WindowRef behind,
  29.     Boolean goAwayFlag, long refCon);
  30. typedef pascal void (*ShowWindowProcPtr)(WindowPtr window);
  31. typedef pascal long (*MenuSelectProcPtr)(Point select);
  32. typedef pascal unsigned short (*IsDialogEventProcPtr)(const EventRecord* theEvent);
  33. typedef pascal Boolean (*DialogSelectProcPtr)(const EventRecord* theEvent, DialogPtr* theDialog, short* itemHit);
  34. typedef pascal void (*DisposeWindowProcPtr)(WindowPtr window);
  35. //typedef pascal void (*StdTextProcPtr)(short count, const void* textAddr, Point numer, Point denom);
  36.  
  37. pascal static long MenuSelectPatch(Point select);
  38. //pascal static asm long MenuSelectPatch(Point select);
  39. pascal static void TEInitPatch(void);
  40. pascal static WindowPtr NewCWindowPatch(void *wStorage, const Rect *boundsRect,
  41.     ConstStr255Param title, Boolean visible, short procID, WindowRef behind,
  42.     Boolean goAwayFlag, long refCon);
  43. pascal static void ShowWindowPatch(WindowPtr window);
  44. pascal static unsigned short IsDialogEventPatch(const EventRecord* theEvent);
  45. pascal static Boolean DialogSelectPatch(const EventRecord* theEvent, DialogPtr* theDialog, short* itemHit);
  46. pascal static void DisposeWindowPatch(WindowPtr whichWindow);
  47. pascal static void UserItemHandler(WindowRef theWindow, short item);
  48. pascal static void ReplStdText(short count, char* textAddr, Point numer, Point denom);
  49. pascal static void ReplRect(GrafVerb verb, Rect *r);
  50.  
  51.  
  52. UniversalProcPtr    gOldTEInit;
  53.  
  54. MenuSelectProcPtr        gOldMenuSelect;
  55. NewCWindowProcPtr        gOldNewCWindow;
  56. ShowWindowProcPtr        gOldShowWindow;
  57. IsDialogEventProcPtr    gOldIsDialogEvent;
  58. //DialogSelectProcPtr        gOldDialogSelect;
  59. DisposeWindowProcPtr    gOldDisposeWindow;
  60. WindowPtr            gAboutMacWindow;
  61. DialogPtr            gFakeAboutMacWindow;
  62. Handle                gFakeWindowUserItemDITL;
  63. //Handle                gFakeWindowEditTextItemDITL;
  64. Rect                gFakeWindowTextRect;
  65. DialogRecord        gFakeAboutMacWindowStorage;
  66. Boolean                gShouldCreateWindow;
  67. short                gFakeItems;
  68. Boolean                gEditTextItemIsEnabled;
  69. CQDProcs            gReplacementProcs;
  70. QDTextUPP            gOldStdTextProc;
  71. QDRectUPP            gOldRectProc;
  72. Str255                gReplacementLines[kTextBoxes];
  73. Handle                gFakeWindowUserItemsDITL[kTextBoxes];
  74. Handle                gFakeWindowEditTextItemsDITL[kTextBoxes];
  75. short                gOccludeItem;
  76. short                gLastOldItem;
  77. short                gKiboshErase;
  78. short                gEditingItem;
  79. void
  80. main(void)
  81. {
  82.     Handle                initHandle;
  83.  
  84.     initHandle = ReturnA0();
  85.  
  86.     {
  87.     int                            i;
  88.  
  89.         EnterCodeResource();
  90.         PrepareCallback();
  91.  
  92.         DetachResource(initHandle);
  93.  
  94.         HLock(initHandle);
  95.  
  96.         gFakeWindowUserItemDITL = GetResource('DITL', 129);
  97.         DetachResource(gFakeWindowUserItemDITL);
  98.         HLock(gFakeWindowUserItemDITL);
  99.  
  100.         for (i = 0; i < kTextBoxes; i++)
  101.             {
  102.             gFakeWindowEditTextItemsDITL[i] = GetResource('DITL', 512 + i);
  103.             DetachResource(gFakeWindowEditTextItemsDITL[i]);
  104.             HLock(gFakeWindowEditTextItemsDITL[i]);
  105.  
  106.             gReplacementLines[i][0] = 0;
  107.             }
  108.  
  109.         gOldTEInit = GetToolTrapAddress(_TEInit);
  110.         SetToolTrapAddress((UniversalProcPtr) TEInitPatch, _TEInit);
  111.  
  112.         gAboutMacWindow = nil;
  113.         gFakeAboutMacWindow = nil;
  114.         gShouldCreateWindow = 0;
  115.         gEditTextItemIsEnabled = 0;
  116.         gOccludeItem = 0;
  117.         gKiboshErase = 0;
  118.         gEditingItem = 0;
  119.  
  120.         ExitCodeResource();
  121.     }
  122. }
  123.  
  124.  
  125. pascal static void TEInitPatch(void)
  126.     {
  127.     UniversalProcPtr        oldTEInit;
  128.     StringPtr                curApName;
  129.  
  130.     EnterCallback();
  131.  
  132.     curApName = LMGetCurApName();
  133.  
  134.     if (*(OSType *) curApName == 0x0646696E)
  135.         {
  136.         gOldMenuSelect = (MenuSelectProcPtr) GetToolTrapAddress(_MenuSelect);
  137.         gOldNewCWindow = (NewCWindowProcPtr) GetToolTrapAddress(_NewCWindow);
  138. //        gOldShowWindow = (ShowWindowProcPtr) GetToolTrapAddress(_ShowWindow);
  139.         gOldIsDialogEvent = (IsDialogEventProcPtr) GetToolTrapAddress(_IsDialogEvent);
  140. //        gOldDialogSelect = (DialogSelectProcPtr) GetToolTrapAddress(_DialogSelect);
  141.         gOldDisposeWindow = (DisposeWindowProcPtr) GetToolTrapAddress(_DisposeWindow);
  142.  
  143.         SetToolTrapAddress((UniversalProcPtr) MenuSelectPatch, _MenuSelect);
  144.         SetToolTrapAddress((UniversalProcPtr) NewCWindowPatch, _NewCWindow);
  145. //        SetToolTrapAddress((UniversalProcPtr) ShowWindowPatch, _ShowWindow);
  146.         SetToolTrapAddress((UniversalProcPtr) IsDialogEventPatch, _IsDialogEvent);
  147. //        SetToolTrapAddress((UniversalProcPtr) DialogSelectPatch, _DialogSelect);
  148.         SetToolTrapAddress((UniversalProcPtr) DisposeWindowPatch, _DisposeWindow);
  149.         }
  150.  
  151.     oldTEInit = gOldTEInit;
  152.     (*oldTEInit)();
  153.  
  154.     ExitCallback();
  155.     }
  156.  
  157.  
  158. pascal static long MenuSelectPatch(Point select)
  159. {
  160.     long     retMenu;
  161.  
  162.     EnterCallback();
  163.  
  164.     retMenu = (*gOldMenuSelect)(select);
  165.     gShouldCreateWindow = (retMenu == 0x01000001 && !gFakeAboutMacWindow);
  166.  
  167.     ExitCallback();
  168.  
  169.     return retMenu;
  170. }
  171.  
  172. pascal static WindowPtr NewCWindowPatch(void *wStorage, const Rect *boundsRect,
  173.     ConstStr255Param title, Boolean visible, short procID, WindowRef behind,
  174.     Boolean goAwayFlag, long refCon)
  175. {
  176.     register WindowPtr                    newWindow;
  177.     Boolean                                inProgress = 0;
  178.     EnterCallback();
  179.  
  180.     if (gShouldCreateWindow != 0)
  181.     {
  182.         inProgress = 1;
  183.         gShouldCreateWindow = 0;
  184.  
  185.         newWindow = gFakeAboutMacWindow = NewColorDialog(&gFakeAboutMacWindowStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, gFakeWindowUserItemDITL);
  186.         SetStdCProcs(&gReplacementProcs);
  187.         gOldStdTextProc = gReplacementProcs.textProc;
  188.         gReplacementProcs.textProc = ReplStdText;
  189.         gOldRectProc = gReplacementProcs.rectProc;
  190.         gReplacementProcs.rectProc = ReplRect;
  191.         ((CGrafPtr) gFakeAboutMacWindow)->grafProcs = &gReplacementProcs;
  192.  
  193. //        GetDialogItem(newWindow, kDialogUserItem1, &itemType, &itemHandle, &itemRect);
  194.  
  195. //        itemHandle = (Handle) UserItemHandler;
  196.  
  197. //        SetDialogItem(newWindow, kDialogUserItem, itemType, itemHandle, &itemRect);
  198.  
  199. //        gFakeWindowTextRect = itemRect;
  200.     }
  201.     else
  202.         newWindow = (*gOldNewCWindow)(wStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon);
  203.  
  204.     if (inProgress)
  205.         gAboutMacWindow = newWindow;
  206.  
  207.     ExitCallback();
  208.     return(newWindow);
  209. }
  210.  
  211.  
  212. pascal static unsigned short IsDialogEventPatch(const EventRecord* theEvent)
  213. {
  214.     short                    savedWindowKind;
  215.     register unsigned short    result;
  216.     short                    makeADialog = true;
  217.     short                    callDialogSelect = false;
  218.  
  219.     EnterCallback();
  220.  
  221.  
  222.     if (makeADialog && gFakeAboutMacWindow)
  223.     {
  224.         savedWindowKind = ((WindowRecord *) gFakeAboutMacWindow)->windowKind;
  225.         ((WindowRecord *) gFakeAboutMacWindow)->windowKind = kDialogWindowKind;
  226.     }
  227.  
  228.         result = (*gOldIsDialogEvent)(theEvent);
  229.  
  230.         if (gFakeAboutMacWindow && result)
  231.         {
  232.             switch (theEvent->what)
  233.             {
  234.                 case nullEvent:
  235.                     callDialogSelect = true;
  236.                 break;
  237.                 case updateEvt:
  238.                 case activateEvt:
  239.                     callDialogSelect = ((WindowPtr) theEvent->message == gFakeAboutMacWindow);
  240.                 break;
  241.                 case mouseDown:
  242.                 case mouseUp:
  243.                 {
  244.                     WindowPtr        whatWindow;
  245.  
  246.                     if (FindWindow(theEvent->where,&whatWindow) && whatWindow == gFakeAboutMacWindow)
  247.                     {
  248.                         callDialogSelect = true;
  249.                     }
  250.                 }
  251.                 break;
  252.                 case keyDown:
  253.                 case keyUp:
  254.                 case autoKey:
  255.                 case app4Evt:            // suspend/resume
  256.                     callDialogSelect = (FrontWindow() == gFakeAboutMacWindow);
  257.                 break;
  258.             }
  259.  
  260.             if (callDialogSelect)
  261.             {
  262.                 DialogPtr            ourDialog;
  263.                 short                ourItem;
  264.                 RgnHandle            savedUpdate = 0;
  265.  
  266.                 if (theEvent->what == updateEvt)
  267.                 {
  268.                     savedUpdate = NewRgn();
  269.                     if (savedUpdate)
  270.                         CopyRgn(((WindowPeek) gFakeAboutMacWindow)->updateRgn,savedUpdate);
  271.                 }
  272.  
  273.                 // callDialogSelect for our window
  274.                 if (DialogSelect(theEvent,&ourDialog,&ourItem))
  275.                 {
  276.  
  277.                     // This is an event for our window.  Is it a mousedown?
  278.                     if ((ourItem >= kDialogUserItem1) && (ourItem <= kDialogUserItem8) && (!gEditTextItemIsEnabled))
  279.                         {
  280.                         GrafPtr                    savedPort;
  281.                         RGBColor                savedBack;
  282.                         RGBColor                whiteColor;
  283.                         short                    oldCount;
  284.                         short                    itemType;
  285.                         Handle                    itemHandle;
  286.                         Rect                    itemRect;
  287.                         Style                    faceStyle;
  288.  
  289. //                        GetPort(&savedPort);
  290. //                        SetPort(ourDialog);
  291.  
  292. //                        GetBackColor(&savedBack);
  293. //                        whiteColor.red = whiteColor.blue = whiteColor.green = 0xFFFF;
  294. //                        RGBBackColor(&whiteColor);
  295.  
  296. //                        GetDialogItem(ourDialog, ourItem, &itemType, &itemHandle, &itemRect);
  297.  
  298.                         gLastOldItem = oldCount = CountDITL(ourDialog);
  299.                         gEditingItem = ourItem;
  300.  
  301. //                        EraseRect(&itemRect);
  302.  
  303. //                        RGBBackColor(&savedBack);
  304.  
  305.                         AppendDITL(ourDialog, gFakeWindowEditTextItemsDITL[ourItem - kDialogUserItem1], overlayDITL);
  306.  
  307.                         gFakeItems = CountDITL(ourDialog) - oldCount;
  308.  
  309.                         (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txFont = 1;    // geneva
  310.  
  311.                         faceStyle = normal;
  312.                         switch (ourItem)
  313.                             {
  314.                             case    1:
  315.                             case    2:
  316.                             case    5:
  317.                             case    7:
  318.                                 faceStyle = bold;
  319.                                 break;
  320.                             case    3:
  321.                                 faceStyle = bold + condense;
  322.                                 break;
  323.                             }
  324.  
  325.                         (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txFace = faceStyle;
  326.                         (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txSize = 9;
  327. //                        gOccludeLine1 = 1; // turn off first line for now
  328.                         gEditTextItemIsEnabled = true;
  329.  
  330. //                        SetPort(savedPort);
  331.                         }
  332. /*
  333.                     if (ourItem == kDialogUserItem)
  334.                     {
  335.                         if (!gEditTextItemIsEnabled)
  336.                             {
  337.                             GrafPtr                    savedPort;
  338.                             RGBColor                savedBack;
  339.                             RGBColor                whiteColor;
  340.                             short                    oldCount;
  341.  
  342.                             Debugger();
  343.  
  344.                             GetPort(&savedPort);
  345.                             SetPort(ourDialog);
  346.  
  347.                             GetBackColor(&savedBack);
  348.                             whiteColor.red = whiteColor.blue = whiteColor.green = 0xFFFF;
  349.                             RGBBackColor(&whiteColor);
  350.  
  351.                             EraseRect(&gFakeWindowTextRect);
  352.  
  353.                             RGBBackColor(&savedBack);
  354.  
  355.                             SetPort(savedPort);
  356.  
  357.                             gLastOldItem = oldCount = CountDITL(ourDialog);
  358.                             AppendDITL(ourDialog, gFakeWindowEditTextItemDITL, overlayDITL);
  359.                             gFakeItems = CountDITL(ourDialog) - oldCount;
  360.                             (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txFont = 1;    // geneva
  361.                             (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txFace = bold;
  362.                             (*(((DialogPeek) gFakeAboutMacWindow)->textH))->txSize = 9;
  363.                             gOccludeLine1 = 1; // turn off first line for now
  364.                             gEditTextItemIsEnabled = true;
  365.                             }
  366.                     }
  367. */
  368.                     if (ourItem == gLastOldItem+1)
  369.                         {
  370.                         if (theEvent->what == keyDown)
  371.                             {
  372.                             if (((theEvent->message & charCodeMask)) == 13)
  373.                                 {
  374.                                 if (gEditTextItemIsEnabled)
  375.                                     {
  376.                                     short            iType;
  377.                                     Handle            iHandle;
  378.                                     Rect            iRect;
  379.  
  380.                                     GetDItem(ourDialog,gLastOldItem+1,&iType,&iHandle,&iRect);
  381.                                     GetIText(iHandle,gReplacementLines[gEditingItem - kDialogUserItem1]);
  382.  
  383.                                     ShortenDITL(ourDialog, gFakeItems);
  384.                                     gEditingItem = 0;
  385.                                     gEditTextItemIsEnabled = false;
  386.                                     gOccludeItem = 0;
  387.                                     }
  388.                                 }
  389.                             }
  390.                         }
  391.                 }
  392.                 else
  393.                 {
  394. /*                Debugger();
  395.                 if (gEditTextItemIsEnabled)
  396.                     {
  397.                     ShortenDITL(ourDialog, gFakeItems);
  398.                     gEditTextItemIsEnabled = false;
  399.                     }
  400. */                }
  401.  
  402.                 if (ourDialog == gFakeAboutMacWindow && savedUpdate)
  403.                     CopyRgn(savedUpdate,((WindowPeek) gFakeAboutMacWindow)->updateRgn);
  404.  
  405.                 if (savedUpdate)
  406.                     DisposeRgn(savedUpdate);
  407.  
  408.                 result = false;            // we handled it already
  409.             }
  410.         }
  411. // Now we override stuff
  412. //    if (result)
  413. //    {
  414. //        if (theEvent->what == keyDown && (theEvent->modifiers & cmdKey))
  415. //            result = false;            // command keys go to the finder, override ZXCV back later 
  416. //    }
  417.  
  418.     if (makeADialog && gFakeAboutMacWindow)
  419.     {
  420.         ((WindowRecord *) gFakeAboutMacWindow)->windowKind = savedWindowKind;
  421.     }
  422.  
  423.     ExitCallback();
  424.     return(result);
  425. }
  426.  
  427.  
  428. /*pascal static Boolean DialogSelectPatch(const EventRecord* theEvent, DialogPtr* theDialog, short* itemHit)
  429. {
  430.     short                savedWindowKind;
  431.     register Boolean    result;
  432.     short                realItem;
  433.     DialogPtr            realDialog;
  434.     RgnHandle            savedUpdate = 0;
  435.  
  436.     EnterCallback();
  437.  
  438.     if (gFakeAboutMacWindow)
  439.         {
  440.         savedWindowKind = ((WindowRecord *) gFakeAboutMacWindow)->windowKind;
  441.         ((WindowRecord *) gFakeAboutMacWindow)->windowKind = kDialogWindowKind;
  442.  
  443.         if (theEvent->what == updateEvt)
  444.             {
  445.             savedUpdate = NewRgn();
  446.             if (savedUpdate)
  447.                 CopyRgn(((WindowPeek) gFakeAboutMacWindow)->updateRgn,savedUpdate);
  448.             }
  449.         }
  450.  
  451.     realDialog = *theDialog;
  452.     realItem = *itemHit;
  453.  
  454.     result = (*gOldDialogSelect)(theEvent, &realDialog, &realItem);
  455.  
  456.     if (gFakeAboutMacWindow && realDialog == gFakeAboutMacWindow)
  457.     {
  458.         result = false;            // you never saw me, I was never here
  459.     }
  460.     else
  461.     {
  462.         *theDialog = realDialog;
  463.         *itemHit = realItem;
  464.     }
  465.  
  466.     if (gFakeAboutMacWindow)
  467.     {
  468.         if (realDialog == gFakeAboutMacWindow && savedUpdate)
  469.             CopyRgn(savedUpdate,((WindowPeek) gFakeAboutMacWindow)->updateRgn);
  470.  
  471.         if (savedUpdate)
  472.             DisposeRgn(savedUpdate);
  473.  
  474.         ((WindowRecord *) gFakeAboutMacWindow)->windowKind = savedWindowKind;
  475.     }
  476.  
  477.     ExitCallback();
  478.     return(result);
  479. }
  480. */
  481. pascal static void DisposeWindowPatch(WindowPtr whichWindow)
  482. {
  483.     EnterCallback();
  484.  
  485.     if (gFakeAboutMacWindow && whichWindow == gFakeAboutMacWindow)
  486.     {
  487.         gFakeAboutMacWindow = 0;
  488.  
  489.         CloseDialog(whichWindow);
  490.     }
  491.     else
  492.     {
  493.         (*gOldDisposeWindow)(whichWindow);
  494.     }
  495.  
  496.     ExitCallback();
  497. }
  498.  
  499. /*pascal static void
  500. UserItemHandler(WindowRef theWindow, short item)
  501.     {
  502.     Debugger();
  503.     }
  504. */
  505.  
  506. pascal static void ReplStdText(short count, char* textAddr, Point numer, Point denom)
  507. {
  508.     Point                startPoint;
  509.     EnterCallback();
  510.  
  511. //    if (gFakeAboutMacWindow->pnLoc.h > 100 &&
  512. //        gFakeAboutMacWindow->pnLoc.v < 20)
  513.     // {0x14, 0xc0, 0x14, 0x162}        "system software"
  514.     // 0x120, 0x14 is "7.5.3"
  515.     // {0x23, 0xc0, 0x23, 0x162}        "rev 2"
  516.     // {0x32, 0x35, 0x32, 0x90}            "Power Mac"
  517.     // {0x32, 0xc0, 0x32, 0x162}        "Copyright"
  518.     // {0x4e, 0x11, 0x4e, 0x61}            "Total Memory"
  519.     // {0x4e, 0x87, 0x4e, 0xaf}            "value of Total Memory"
  520.     // {0x4e, 0xc0, 0x4e, 0x138}        "Largest Unused Block"
  521.     // {0x4e, 0x142, 0x4e, 0x16a}        "value of Largest Unused Block"
  522.     // To handle ascender and descender, we will take a constant height of each
  523.     // line, this has been empiracally determined to be 14 pixels.  So, we distribute
  524.     // 11 to above, 3 below
  525.     
  526.  
  527.     startPoint = gFakeAboutMacWindow->pnLoc;
  528.  
  529.     // "system software"
  530.     if (startPoint.h == 0xc0 &&
  531.         startPoint.v == 0x14 &&
  532.         gReplacementLines[0][0])
  533.     {
  534. //        Debugger();
  535.         (*gOldStdTextProc)(gReplacementLines[0][0],(char*) &gReplacementLines[0][1],numer,denom);
  536.         gKiboshErase = 1;
  537.     }
  538.     else if (startPoint.h == 0x120 &&
  539.               startPoint.v == 0x14 &&
  540.               gReplacementLines[0][0])
  541.     { // "7.5.3"
  542.         // nothing
  543. //        Debugger();
  544.         gKiboshErase = 0;
  545.     }
  546.     else if ((startPoint.v == 0x23) && (startPoint.h == 0xc0) && gReplacementLines[1][0]) // "rev 2"
  547.     {
  548.         (*gOldStdTextProc)(gReplacementLines[1][0], (char *) &gReplacementLines[1][1],numer,denom);
  549.     }
  550.     else if ((startPoint.v == 0x32) && (startPoint.h == 0x35) && gReplacementLines[2][0])    // "Power Mac" 
  551.     {
  552.         (*gOldStdTextProc)(gReplacementLines[2][0], (char *) &gReplacementLines[2][1],numer,denom);
  553.     }
  554.     else if ((startPoint.v == 0x32) && (startPoint.h == 0xc0) && gReplacementLines[3][0]) // "Copyright"
  555.     {
  556.         (*gOldStdTextProc)(gReplacementLines[3][0], (char *) &gReplacementLines[3][1],numer,denom);
  557.     }
  558.     else if ((startPoint.v == 0x4e) && (startPoint.h == 0x11) && gReplacementLines[4][0])    // "Total Memory"
  559.     {                    
  560.         (*gOldStdTextProc)(gReplacementLines[4][0], (char *) &gReplacementLines[4][1],numer,denom);
  561.     }
  562.     else if ((startPoint.v == 0x4e) && (startPoint.h == 0x87) && gReplacementLines[5][0])    // "value of Total Memory"
  563.     {
  564.         (*gOldStdTextProc)(gReplacementLines[5][0], (char *) &gReplacementLines[5][1],numer,denom);
  565.     }
  566.     else if ((startPoint.v == 0x4e) && (startPoint.h == 0xc0) && gReplacementLines[6][0])    // "Largest Unused Block"
  567.     {
  568.         (*gOldStdTextProc)(gReplacementLines[6][0], (char *) &gReplacementLines[6][1],numer,denom);
  569.     }
  570.     else if ((startPoint.v == 0x4e) && (startPoint.h == 0x142) && gReplacementLines[7][0])    // "value of Largest Unused Block"
  571.     {
  572.         (*gOldStdTextProc)(gReplacementLines[7][0], (char *) &gReplacementLines[7][1],numer,denom);
  573.     }
  574.     else
  575.         (*gOldStdTextProc)(count,textAddr,numer,denom);                // sick, sick!
  576.  
  577.     ExitCallback();
  578. }
  579.  
  580. pascal static void ReplRect(GrafVerb verb, Rect *r)
  581. {
  582.     EnterCallback();
  583.  
  584.     if (!gKiboshErase || (verb != erase))
  585.         (*gOldRectProc)(verb,r);
  586.  
  587.     ExitCallback();
  588. }
  589.