Working with the Microsoft Programmer’s Library

OS/2 Programmers Ref

Well recently I did manage to get some GREAT books on OS/2, going back to the Microsoft days.. And they contain a lot of information, which was actually quite substantial.

Although there is the impression after the fact that Microsoft really wasn’t that dedicated to OS/2 the wealth of information in these books seem to be otherwise..

Anyways there is four volumes in the set, 1-3 going over version 1.1, and volume 4 with the 1.2 release of OS/2.

As luck would have it, someone gave me a lead on an ISO that contained not only these, but all of the programming documentation of the time on a CD.  No doubt this was the predecessor to the excellent MSDN.

There of course, is just one catch.  It uses the .hlp files, but not from Windows 3.00 its something much earlier and the only way to view the files is with an MS-DOS program.

Glorious MS-DOS interface

I even tried it on OS/2 hoping it was a family api program (like so many of the era were) but no luck.  I was then hoping maybe I could just ‘print’ the files to a virtual printer, and spool the whole job.  BUT YOU CANT PRINT.

So I then wondered if I could put together a TSR that would scrape the screen, append it to a file, and just keep hitting page down.   A few hours of cobbling together some example programs, and remembering to compile with the LARGE memory model (FAR pointers! remember those?)  I could then finally unleash the TSR through the program and extract some of the texts.

For those wondering how to do this kind of thing from MS-DOS here is the source.  While I wanted to use Scott’s program, there was the one drawback that almost everything grabs printscreen now so doing a REAL printscreen that hits interrupt 5 seems like it’d actually require a physical PC in MS-DOS.  And my current ‘retro’ PC has no ethernet so I wasn’t going to go that route.

So there is a lot of hacks with this, you can’t even uninstall it, just reboot …. but this hooks the clock, gives you about a minute to go where you want to go, then it saves a portion of the screen to a file, waits a few seconds and hits pagedown, and repeats….

// Written by Scott Hall of the U. of Missouri - Columbia, USA.
// This program will redirect your print screen button so that
// it goes to a file.  The file name is at the beginning of the
// start() function.  It can easily be modified to print screens
// that are larger than 80x25.

#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <dos.h>

#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif

char far *scr=(char far*)0xb0008000L;
#define VIDMEM 0Xb0008000L
#define INTR 0x1c

int busy=0;                                     // mutual exclusion (MUTEX)
void interrupt (*oldhandler)(__CPPARGS);
char far *old_dta;
char fname[9];

void interrupt int_5();
void tsr(unsigned size);                        // standard tsr bios call
void write_char(int x, int y, char ch, int attrib);
void write_string(int x, int y, char *str, int attrib);

void start(void);
void interrupt handler(__CPPARGS);

int main(int argc, char*argv[])
{
   if(argc==2)
   sprintf(fname,argv[1]);
      else
   sprintf(fname,"log.txt");

   printf ("installing\n");
   disable();
   oldhandler=getvect(INTR);
   setvect(INTR,handler);
   setvect(32,oldhandler);
   enable();
   printf("done\n");
   tsr(1000);
return 0;
}

void tsr(unsigned size)                 // standard tsr bios call
{                                       // you can also use keep()
union REGS r;

r.h.ah = 49;                            // function 0x31
r.h.al = 0;
r.x.dx = size;
int86(0x21,&r, &r);                     // last line executed
}                                       // never get to this line

unsigned char j=0;
unsigned int tcount;
unsigned int dcount=0;

//void interrupt int_5()                  // print screen button starts here
void interrupt handler(__CPPARGS)
{

if(dcount>480)
   {
   if(!busy&&tcount>5)
      {
      char far *p;
      union REGS r;
      struct SREGS s;

      p=scr;
      *p+=6;
      *p++=j;
      *p++=0x4f;

      j++;

      busy = !busy;                   // mutex around tsr
      start();

      r.h.ah=0x5;
      r.h.ch=0x51;    //pagedown?
      r.h.cl=0x0;
      int86x(0x16,&r, &r, &s);

      busy = !busy;
      tcount=0;
      }
   tcount++;
   }
else
   dcount++;
}

void write_char(int x, int y, char ch, int attrib)
{                                       // displays 1 character at (x,y)
char far *v;

v = (char far *) VIDMEM;
v += y*160 + x*2;
*v++ = ch;
*v = attrib;
}

void write_string(int x, int y, char *str, int attrib)
{                                       // writes string str at (x,y)
for( ; *str; str++,x++)
   write_char(x, y, *str, attrib);
}

int firsttime=0;        //need to skip 3 lines after the first time we
//page down.

void start(void)
{
int fd,x,y;
char cr=0x0D, lf=0x0A;

old_dta=getdta();
setdta((char far *)MK_FP(_psp,0x80));

//if((fd =_open("c:\\temp\\log.txt",O_WRONLY))<0) // open the file
//        if((fd =_creat("c:\\temp\\log.txt",_A_NORMAL))<0) // try to make new
//                write_string(1,1,"OOPS--write error1",0x8F);

if((fd =_open(fname,O_WRONLY))<0) // open the file
   if((fd =_creat(fname,_A_NORMAL))<0) // try to make new
   write_string(1,1,"OOPS--write error1",0x8F);

lseek (fd,0,SEEK_END);                          // jump to end of file

//for(y=0;y<25;y++)                               // grab lines 0 to 24
for(y=2+firsttime;y<24;y++)
   {
   //for(x=0;x<80;x++)                       // grab rows 0 through 79
   for(x=1;x<79;x++)                       //cut the bars from msl

   if(_write(fd,(char far *)(VIDMEM+160*y+2*x),1)==-1)
      write_string(1,2,"OOPS--write error2",0x8F);

   if(_write (fd,&cr,1)==-1)               // put a cr and lf at end
      write_string(1,3,"OOPS--write error3",0x8F); // of line

   if(_write (fd,&lf,1)==-1)
      write_string(1,4,"OOPS--write error4",0x8F);
   }

_close(fd);                                     // close the file

setdta(old_dta);
if(firsttime==0)
firsttime=1;
}

Hopefully this will help someone in the distant future, maybe it’ll just serve as a warning on how not to build stuff … lol

Oh and I used Borland C++ 3.1, but compiled this as C for the LARGE memory model.

More CDROM madness.

Well I found that one of the things that was preventing me from booting up this “Solaris 1.1.2” AKA SunOS 4.1.4 CD is that Qemu on Win32 using raw devices has issues with all these slices and whatnot.

Slices you say?

Yeah, back in the ISO9660 Rock Ridge days, CD-ROMS were basically given a common format for the “LCD” of the day. In that case MS-DOS. Naturally people like Unix vendors were not to keen on that, as they wanted file attributes, long file names, symbolic links etc… So a *LOT* of people started to split up their CD’s into partitions like hard disks, and slap down actual filesystems on the disks. NeXT just used one giant partition on the CD-ROM, but their exe format let them ‘bind’ all the CISC machines onto one CD, and all the RISC machines on another. Meanwhile SUN decided to make all these ‘boot’ partitions for various machines, a miniroot, then an I9660 partition for basic tar files of the OS…

Like this:

2,998,272 DEBUGGING
4,161,536 DEMO
3,219,456 GAMES
1,826,816 GRAPHICS
999,424 INSTALL
1,073,152 NETWORKING
7,815,168 OPENWINDOWS_DEMO
9,748,480 OPENWINDOWS_FONTS
23,756,800 OPENWINDOWS_PROGRAMMERS
34,316,288 OPENWINDOWS_USERS
925,696 RFS
327,680 SECURITY
1,409,024 SHLIB_CUSTOM
524,288 SUNVIEW_DEMO
1,884,160 SUNVIEW_PROGRAMMERS
2,727,936 SUNVIEW_USERS
4,104,192 SYSTEM_V
729,088 TEXT
49,152 TLI
7,872,512 USER_DIAG
29,638,656 USR
622,592 UUCP
6,103,040 VERSATEC

Which is kind of funny seeing how some BSD derived OS’s still keep some of these package names alive.

Anyways, the problem is that I tried to use \\.\d: for the cdrom, and booting didn’t work at all. I even tried reading an ISO from the CD, but all it ended up doing was skipping to the ISO9660 part, and dumping that, ignoring the slices, giving me this:

243,599,360 sol14.iso

So after googling around, trying to at least find a way to back up this CD (it was a souvenir from Japan!) I found someone mentioning to backup their Solaris CD, they had to use the “readcd” program.

Well, I’d never explored that much with the cdrtools, but behold there is a readcd program that’ll dump an entire CD out!

So running it with –scan-bus to find your CD drive…

readcd -scanbus
scsibus0:
0,0,0 0) *
0,1,0 1) ‘HL-DT-ST’ ‘BDDVDRW GBC-H20L’ ‘1.B8’ Removable CD-ROM
0,2,0 2) *

We can go on to dump a full image of the CD.

readcd -dev=0,1,0 f=sunos.iso

Which now gives us a much larger ISO image…

329,605,120 sunos.iso

Sadly it crashes on bootup… But on Win32 it’s a lot better then not reading *ANYTHING* at all!

ok boot disk1:d -vs
Boot device: /iommu/sbus/espdma@5,8400000/esp@5,8800000/sd@1,0:d File and args: -vs
Boot Release 4.1.4 (sun4m) #2: Fri Oct 14 11:07:52 PDT 1994
Copyright (c) 1983-1990, Sun Microsystems, Inc.
Boot: Romvec version 3.
root on /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@1,0:d fstype 4.2
Boot: vmunix
.Size: 868352…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………+2319136+75288 bytes
Statistics:

–edit

I should also add that Qemu’s CDROM (like 99% in the world) are fixed block, while SUN (and other vendors) had these CD ROM’s that could change block size… So in Qemu you have to use the DISK driver vs the CDROM driver….

ie use -hdb sunos.iso instead of -cdrom sunos.iso