PC-MOS 2012 date bug fix

1 view
Skip to first unread message

T. Ment

unread,
Feb 28, 2019, 1:36:46 AM2/28/19
to
Here's a binary patch (2012.fc) and program (pamo.c) to apply it:

pamo <2012.fc.

The patch is in "fc /b" format, with extra human annotations, which pamo
ignores.

Make a copy of $$mos.sys, and patch the copy. Then you can run "fc /b"
on the original vs. the copy to see what changed. You can also modify
the pamo.c source to create an unpatch utility. Just reverse the order
of &old, &new in the two while lines.

This is compatible only with $$mos.sys 5.01 file size 128,880. It worked
with a file dated 1993-01-29. I don't know about others.


file name: 2012.fc
---------------- cut here ---------------
2012 date bug

0000C5A4: 84 A4

--- na/kernel/mosfutl4.asm Sun Dec 15 14:43:06 1991
+++ nx/kernel/mosfutl4.asm Tue Feb 12 02:50:24 2019
@@ -1253,7 +1253,7 @@
; mark file with null class

xor al,al ; default to space
- mov al,byte ptr [si+dbbbuf+dclass0]
+ mov ah,byte ptr [si+dbbbuf+dclass0]
cmp ah,'A'
jb mgfbc1
cmp ah,'Z'



mosliman argument typo

00010881: B0 B4

--- na/kernel/mosddint.asm Sun Dec 15 14:42:14 1991
+++ nx/kernel/mosddint.asm Thu Feb 28 03:35:26 2019
@@ -871,7 +871,7 @@
mosbd2:
pop es ; address of bdb
push ax ; save error code
- mov al,1
+ mov ah,01h
mov al,'B'
call mosliman ; call mosliman
pop ax

----------------- end 2012.fc -----------



file name: pamo.c (patch mos) bcc 3.1
usage: pamo <2012.fc
---------------- cut here ---------------
# include <stdio.h>
# include <stdlib.h>
# include <fcntl.h>
# include <io.h>

# define MOS51 128880

long fz, loc, rvl;
int fd, old, new, rv;
char *fn = "$$mos.sys";
char fmt[] = "%lx: %x %x%*[ \t]%1[^\n]";
char data[1];

void
main ()
{
if ((fd = open (fn, O_RDWR | O_BINARY | O_DENYALL)) == -1) {
fprintf (stderr, "failure opening %s: %s", fn, strerror (errno));
exit (1);
}

if ((fz = filelength (fd)) == -1) {
fprintf (stderr, "failure getting size of %s: %s", fn, strerror (errno));
exit (1);
}

if (fz != MOS51) {
fprintf (stderr, "wrong %s file, size must be %ld\n", fn, MOS51);
exit (1);
}

while ((rv = scanf (fmt, &loc, &old, &new, data)) != EOF) {

if (rv != 3) {
scanf ("%*[^\n]");
continue;
}

if ((unsigned long) loc > MOS51 - 1) {
fprintf (stderr, "offset %lx exceeds file size\n", loc);
exit (1);
}
if ((rvl = lseek (fd, loc, SEEK_SET)) == -1L) {
fprintf (stderr, "failure seeking %s offset %lx: %s", fn, loc, strerror (errno));
exit (1);
}
if ((rv = read (fd, data, 1)) == -1) {
fprintf (stderr, "failure reading %s offset %lx: %s", fn, loc, strerror (errno));
exit (1);
}
if ((char) old != data[0]) {
fprintf (stderr, "patch mismatch at %lx\n", loc);
exit (1);
}
printf ("%lx %x %x\n", loc, old, new);

}

rewind (stdin);

while ((rv = scanf (fmt, &loc, &old, &new, data)) != EOF) {

if (rv != 3) {
scanf ("%*[^\n]");
continue;
}

data[0] = (char) new;
if ((rvl = lseek (fd, loc, SEEK_SET)) == -1L) {
fprintf (stderr, "failure seeking %s offset %lx: %s", fn, loc, strerror (errno));
exit (1);
}
if ((rv = write (fd, data, 1)) == -1) {
fprintf (stderr, "failure writing %s offset %lx: %s", fn, loc, strerror (errno));
exit (1);
}

}

exit (0);
}

----------------- end pamo.c ------------

Reply all
Reply to author
Forward
0 new messages