[comp.sys.amiga] Patch for Atom

carolyn@cbmvax.UUCP (03/12/87)

TITLE: Patch for Atom and other programs with bad 1.0 Lstartup code

   Atom and some other programs linked with 1.0 Lstartup.obj abort
during startup under 1.2 with an 00038007. Alert (can't open dos library).
This is caused by D0 (version) being uninitialized before the early
Lstartup's OpenLibrary call.  What follows is a list of patch locations
and values to correct executables such as Atom which have this problem.
The patch list is followed by a short program "LPatch.c" which automates
the patch process.  The usage is:  LPatch filename.  LPatch will only
modify the file if all of the patch locations contain the correct
old values.

Here's the patch list (all offsets and values in HEX):

File Offset   
===========

   $196    OLD = 01 4E         (BSR openDOS)
           NEW = 00 A8         (BSR 3rd patch)

   $213    OLD = D2            (BSR openDOS)
           NEW = 2C            (BSR 3rd patch)

   $23E    OLD = 24 3C 00 00 03 ED   (some unused code)  
           NEW = 70 00 60 00 00 A2   (MOVEQ #0,D0;  BRA.S openDOS)


And here's LPatch.c
--------------------------------------------------------------------------
/*
 * LPatch.c - C. Scheppner  03/87
 *
 *    Corrects the startup code of some 1.0/1.1 programs such as
 *    Atom so that they don't abort during startup with the Alert
 *    00038007. (can't open dos library).  The problem is caused
 *    by d0 (version) being uninitialized prior to the OpenLibrary.
 *
 *   LINKAGE INFO:
 *     Compile with -v flag on LC2
 *     Link with AStartup.obj ... LIBRARY Amiga.lib, LC.lib
 */

#include <exec/types.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>

/* Patch Offsets, Old Values, New Values */

ULONG  offset[] = {0x196,0x197, 0x213, 0x23E,0x23F,0x240,0x241,0x242,0x243};
UBYTE  oldval[] = {0x01, 0x4E,  0xD2,  0x24, 0x3C, 0x00, 0x00, 0x03, 0xED};
UBYTE  newval[] = {0x00, 0xA8,  0x2C,  0x70, 0x00, 0x60, 0x00, 0x00, 0xA2};

LONG file;

main(argc, argv)
int argc;
char **argv;
   {
   LONG            rLen, wLen;
   char            *filename;
   UBYTE  buf[4];
   int k;

   if (argc==0) cleanexit("");
   if ((argc==1)||(argc>2)||(*argv[1]=='?'))
      cleanexit("Usage: LPatch filename");

   filename = argv[1];

   if(!(file = Open(filename, MODE_OLDFILE)))
      cleanexit("File not found");

   for(k=0;k<9;k++)
      {
      Seek(file,offset[k],OFFSET_BEGINING);
      if((rLen = Read(file,buf,1)) < 1)  cleanexit("Read error");
      if(buf[0] != oldval[k])  cleanexit("File not correct for patch");
      }

   for(k=0;k<9;k++)
      {
      Seek(file,offset[k],OFFSET_BEGINING);
      if((wLen = Write(file,&newval[k],1)) < 1)  cleanexit("Write error");
      }

   cleanup();
   }


cleanexit(s)
   char  *s;
   {
   if (*s)
      {
      printf("%s \n",s);
      }
   cleanup();
   exit();
   }

cleanup()
   {
   if(file)  Close(file);
   }

/* end */
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CBM   >>Amiga Technical Support<<
                     UUCP  ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=