home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / latrobe / f / fixrb2.arc / FIXRB.PAS < prev    next >
Pascal/Delphi Source File  |  1987-11-22  |  4KB  |  119 lines

  1. program FixRainbow(iosys,output);
  2.   { This program patches IO.SYS on the DEC Rainbow.  A bug in Rainbow MS-DOS
  3.    versions 2.05, 2.11, 2.11-1 and 3.10.17 prevents raw mode console output
  4.    from writing correctly.  The symptom is that the first letter of any write
  5.    sequence is repeated for the length of the string.  For example, instead
  6.    of writing "Dr. Pascal", a program would write "DDDDDDDDDDDD"
  7.    (two extra for CR LF). }
  8.   { On MS-DOS 2.05  the problem is at 128F and 1290, on MS-DOS 2.11 it is at
  9.    14DA and 14DB, and on MS-DOS 3.10.17 at 1569 and 156A.  In each case you
  10.    change 56 AC to AC 56.  It is essential for the file be changed in-place
  11.    ala DEBUG, not copied and changed ala PATCH.  }
  12.   { This patch must be done before running Dr. Pascal ver 2.0 on the Rainbow.
  13.    It is also known to be required for FinalWord.  It is not needed for
  14.    Dr. Pascal version 1.x  }
  15.   { This program was compiled by Prospero ProPascal version 3.1.  It was much
  16.    easier to do in ProPascal than in "hobby" Pascal systems! }
  17.   { Written by Willett Kempton, Visible Software. }
  18.   { Revised 22 Nov 87 by WK to also patch MS-DOS 3.10.17 }
  19.  
  20.   {$I DOSLIB.PAS ProPascal MS-DOS library }
  21.  
  22. type
  23.   Status = (unpatched, patched, unknown);
  24. var
  25.   iosys: file of byte;
  26.   version: integer;
  27.   byte1,byte2: byte;
  28.   done: boolean;
  29.  
  30.   procedure get2bytes(var b1,b2:byte);
  31.    begin
  32.     b1:= iosys^; get(iosys); b2:=iosys^;
  33.    end;
  34.  
  35.   function category: status;
  36.    begin
  37.     category := unknown;
  38.     if (byte1=56H) and (byte2=0acH) then category:=unpatched
  39.      else if (byte1=0acH) and (byte2=56H) then category:=patched;
  40.    end;
  41.  
  42.   procedure VerifyIf(ver:integer);
  43.   { The location of 56 AC in IO.SYS leads us to expect DOS version "ver" }
  44.    begin
  45.     if (category <> unknown) and (version<>ver) then
  46.       writeln('Strange, this IO.SYS is for MS-DOS ',ver/100:3:2,
  47.               ' ... I''ll attempt to patch it anyway.');
  48.    end;
  49.  
  50.   procedure PutNewValues;
  51.     { Do the patch }
  52.    begin
  53.     iosys^:=0acH; put(iosys);
  54.     iosys^:=56H; put(iosys);
  55.     writeln; writeln(' Fixed! ');
  56.    end;
  57.  
  58.  
  59.    procedure TryVersion(ver:integer;loc:integer;var done:boolean);
  60.    { Verify version "ver" via the 56 AC bytes at location loc }
  61.    { If it is the expected version, patch it or report if already patched. }
  62.    begin
  63.      done := true;
  64.      seek(iosys,loc);
  65.      get2bytes(byte1,byte2);
  66.      VerifyIf(ver);
  67.      case category of
  68.         unpatched:
  69.            begin seek(iosys,loc); PutNewValues; end;
  70.         patched:
  71.            begin writeln;writeln('This file has already been patched!'); end;
  72.         unknown:  done := false;
  73.      end { case };
  74.    end { TryVersion };     
  75.  
  76.  
  77.  begin { FixRainbow }
  78.   writeln;
  79.   writeln('This program fixes a bug in the DEC Rainbow 100 MS-DOS system.');
  80.   writeln('It must be run from each disk from which MS-DOS is booted up.');
  81.   writeln;
  82.   version:=VerNum;
  83.   writeln('You are now running MS-DOS version ',version/100:4:2);
  84.   writeln('Preparing to patch IO.SYS on drive ',GetDrive,':');
  85.   { initial attributes of IO.SYS are  [AttrReadOnly, AttrHidden, AttrSystem] }
  86.   SetFileAttr('\IO.SYS',[]);  { allow modification of file }
  87.   fbuffer(iosys,4096);  { big buffer, faster }
  88.   assign(iosys,'\IO.SYS');
  89.   update(iosys); { allow simultaneous reads and writes }
  90.   if eof(iosys)
  91.    then
  92.      begin
  93.       writeln;
  94.       writeln('ERROR: No file \IO.SYS on this drive.');
  95.       erase(iosys);  { erase the empty created file }
  96.      end
  97.    else
  98.      begin
  99.       TryVersion(205,118fH,done);   { 118fH = 128f in DEBUG }
  100.       if not done then
  101.          begin
  102.           TryVersion(211,13daH,done);  { 13daH = 14daH in DEBUG }
  103.           if not done then
  104.             begin
  105.               TryVersion(310,1469H,done);  { 1469H = 1569H in DEBUG }
  106.               if not done then
  107.                begin
  108.                 writeln;
  109.                 writeln('ERROR:  Cannot identify this IO.SYS file.');
  110.                 write('This program works only on DEC Rainbow MS-DOS');
  111.                 writeln(' 2.05, 2.11, 2.11-1 and 3.10');
  112.                end;
  113.             end;
  114.          end { if not done };
  115.       close(iosys,true);  { probably needed to write buffer prior to SetAttr }
  116.       SetFileAttr('\IO.SYS', [AttrReadOnly, AttrHidden, AttrSystem] );
  117.      end;
  118.  end {FixRainbow}.
  119.