Added code to get all DOS information and separated code.

This commit is contained in:
2000-07-15 01:07:00 +01:00
parent c1af9606fd
commit bee975cc66
3 changed files with 460 additions and 79 deletions

261
int21h.c Normal file
View File

@@ -0,0 +1,261 @@
/************************************************************************
T h e O p e n W i n d o w s P r o j e c t
------------------------------------------------------------------------
Filename : int21h.c
Version : 0.03
Author(s) : Natalia Portillo
Component : OWP DOS subsystem - VER command
--[ Description ]-------------------------------------------------------
Says the DOS type and version.
--[ History ] ----------------------------------------------------------
0.00: Original file by Natalia Portillo. No DOS type.
0.01: Tested with following DOSes obtaining:
DOS DOS Version DOS OEM Code
DR-DOS 7.03 6.0 0x00
FreeDOS Beta 4 6.22 0xFD
MS-DOS 3.20 3.20 0x00
MS-DOS 3.30 3.30 0x00
MS-DOS 4.01 4.0 0xFF
MS-DOS 5.00 5.0 0xFF
PC-DOS 3.30 3.30 0x00
Windows 98 S.E. 7.10 0xFF
Windows 2000 5.0 0xFF
0.02: Tested with the following DOSes obtaining:
DOS DOS Version DOS OEM Code
PTS-DOS 2000 6.22 0x66
RxDOS 7.1.5 7.0 0x5E
0.03: Almost remade from zero.
Now uses four functions of INT-21h to get almost all
DOS version information.
All detect stuff moved to int21h.c.
All defines moved to ver.h
--[ How to compile ]----------------------------------------------------
Recommended compiler Borland Turbo C++ 1.01
http://community.borland.com/museum
--[ Where to get help/information ]-------------------------------------
This archaic and abandoned software is opensource with no warranty
or help of any kind.
For inquiries contact claunia@claunia.com.
--[ License ] ----------------------------------------------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License,or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not,write to the Free Software
Foundation,Inc.,59 Temple Place - Suite 330,Boston,MA 02111-1307,USA.
------------------------------------------------------------------------
Copyright (c) 2000 The Open Windows Project
*************************************************************************/
#include <dos.h>
void getdosver (int *DOS_FLAVOR, int *major, int *minor, int *sim_major, int *sim_minor, int *dos_oem)
{
union REGS regs;
int dos_temp, nt_flag;
nt_flag=0;
*DOS_FLAVOR=0;
regs.x.ax = 0x3306; /* Set function 3306h */
int86 (0x21,&regs,&regs); /* Call INT 21h */
if(regs.h.al!=255) /* If DOS >= 5.0 */
{
*major = regs.h.bl; /* Major True version */
*minor = regs.h.bh; /* Minor True version */
if(regs.h.bh==50)
{
*minor = 0;
nt_flag = 1;
}
regs.h.ah = 0x30;
regs.h.al = 0x00;
int86 (0x21,&regs,&regs);
dos_temp = regs.h.bh; /* Set DOS type */
if(dos_temp == 253) /* Checks for FreeDOS */
{
*major = regs.h.bl; /* Get FreeDOS kernel version */
*minor = 0; /* Put minor version to zero */
}
*sim_major = regs.h.al; /* Set the simulated major version */
*sim_minor = regs.h.ah; /* Set the simulated minor version */
}
else {
regs.h.ah = 0x30;
regs.h.al = 0x00;
int86 (0x21,&regs,&regs);
dos_temp = regs.h.bh; /* Set DOS type */
*major = regs.h.al; /* Set the simulated major version */
*minor = regs.h.ah; /* Set the simulated minor version */
*sim_major = 0;
*sim_minor = 0;
}
/* Set DOS to DOS type */
if(dos_temp == 0 && *major <= 3)
{
*DOS_FLAVOR=12;
}
if(dos_temp == 0 && *major >= 4)
{
*DOS_FLAVOR=2;
}
if(dos_temp == 0xff && *major <= 6)
{
*DOS_FLAVOR=1;
}
if(dos_temp == 0xff && *major == 7)
{
if(*minor == 0)
{
*DOS_FLAVOR=5;
}
if(*minor == 10)
{
*DOS_FLAVOR=13;
}
}
if(dos_temp == 253)
{
*DOS_FLAVOR=4;
}
if(dos_temp == 0xff && nt_flag == 1)
{
*DOS_FLAVOR=6;
}
if(dos_temp == 0x66)
{
*DOS_FLAVOR=8;
}
if(dos_temp == 0x5E)
{
*DOS_FLAVOR=9;
}
/* Check for Concurrent DOS versions */
regs.x.ax = 0x4451; /* Set function 4451h */
int86 (0x21,&regs,&regs); /* Call INT 21h */
if(regs.h.al==0x32)
{
*major=3;
*minor=2;
*DOS_FLAVOR=10;
}
if(regs.h.al==0x41)
{
*major=4;
*minor=1;
*DOS_FLAVOR=10;
}
if(regs.h.al==0x50)
{
*major=5;
*minor=0;
*DOS_FLAVOR=10;
}
if(regs.h.al==0x60)
{
*major=6;
*minor=0;
*DOS_FLAVOR=10;
}
if(regs.h.al==0x62)
{
*major=6;
*minor=2;
*DOS_FLAVOR=10;
}
if(regs.h.al==0x66)
{
*major=5;
*minor=1;
*DOS_FLAVOR=6;
}
if(regs.h.al==0x67)
{
*major=5;
*minor=1;
*DOS_FLAVOR=10;
}
/* End of check for Concurrent DOS versions */
/* Check for DR-DOS versions */
regs.x.ax = 0x4452; /* Set function 4452h */
int86 (0x21,&regs,&regs); /* Call INT 21h */
if(regs.h.al==0x41)
{
*major=1;
*minor=2;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x60)
{
*major=2;
*minor=0;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x63)
{
*major=3;
*minor=41;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x64)
{
*major=3;
*minor=42;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x65)
{
*major=5;
*minor=0;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x67)
{
*major=6;
*minor=0;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x71)
{
*major=6;
*minor=0;
*DOS_FLAVOR=3;
}
if(regs.h.al==0x72)
{
*major=7;
*minor=0;
*DOS_FLAVOR=11;
}
if(regs.h.al==0x73)
{
*major=7;
*minor=0;
*DOS_FLAVOR=3;
}
/* End of check for DR-DOS_FLAVOR versions */
*dos_oem=dos_temp;
}

180
ver.c
View File

@@ -3,10 +3,10 @@
------------------------------------------------------------------------ ------------------------------------------------------------------------
Filename : ver.c Filename : ver.c
Version : 0.01 Version : 0.03
Author(s) : Natalia Portillo Author(s) : Natalia Portillo
Component : OWP DOS subsystem Component : OWP DOS subsystem - VER command
--[ Description ]------------------------------------------------------- --[ Description ]-------------------------------------------------------
@@ -30,7 +30,11 @@
DOS DOS Version DOS OEM Code DOS DOS Version DOS OEM Code
PTS-DOS 2000 6.22 0x66 PTS-DOS 2000 6.22 0x66
RxDOS 7.1.5 7.0 0x5E RxDOS 7.1.5 7.0 0x5E
0.03: Almost remade from zero.
Now uses four functions of INT-21h to get almost all
DOS version information.
All detect stuff moved to int21h.c.
All defines moved to ver.h
--[ How to compile ]---------------------------------------------------- --[ How to compile ]----------------------------------------------------
@@ -63,94 +67,112 @@
Copyright (c) 2000 The Open Windows Project Copyright (c) 2000 The Open Windows Project
*************************************************************************/ *************************************************************************/
#ifndef OWP_DOS_SUBSYSTEM
#define OWP_DOS_SUBSYSTEM
#endif
#define SYSTEM "OWP"
#define PROGRAM "VER"
#define MAJOR_VERSION 0
#define MINOR_VERSION_STRING "02"
#define SUB_VERSION_STRING ""
#define COPYRIGHT "2000 Open Windows Project"
#include <stdio.h> #include <stdio.h>
#include <dos.h> #include "ver.h" /* Include definitions */
void getdosver (int *major,int *minor,int *oem_code)
{
union REGS regs;
regs.x.ax = 0x3000;
int86 (0x21,&regs,&regs);
*major = regs.h.al;
*minor = regs.h.ah;
*oem_code = regs.h.bh;
}
main() main()
{ {
int dos_major,dos_minor,dos_oem_code; /* Declare variables */
int dos_major,dos_minor,dostype,dos_sim_major,dos_sim_minor,dos_oem;
/* Put copyright info */
printf("%s %s %d.%s%s",SYSTEM,PROGRAM,MAJOR_VERSION,MINOR_VERSION_STRING,SUB_VERSION_STRING); printf("%s %s %d.%s%s",SYSTEM,PROGRAM,MAJOR_VERSION,MINOR_VERSION_STRING,SUB_VERSION_STRING);
printf("\nCopyright (c) %s\n\n",COPYRIGHT); printf("\nCopyright (c) %s\n\n",COPYRIGHT);
getdosver (&dos_major,&dos_minor,&dos_oem_code);
if(dos_oem_code==0xFD) /* Get DOS version stuff */
{ getdosver(&dostype, &dos_major, &dos_minor, &dos_sim_major, &dos_sim_minor, &dos_oem);
printf("FreeDOS simulating DOS %d.%d",dos_major,dos_minor);
} /* Put version info */
else if(dos_oem_code==0x00) if(dostype == 0)
{ {
if(dos_major<=3) printf("\nUnknown DOS version %d.%d, that is simulating DOS %d.%d",dos_major,dos_minor,dos_sim_major,dos_sim_minor);
{ printf("\nDOS OEM code %x",dos_oem);
printf("MS-DOS / PC-DOS %d.%d",dos_major,dos_minor); printf("\nPlease send this info and the O.S. name and version to\niosglpgc@teleline.es");
} }
else if(dos_major>=4) if(dostype == 1)
{
printf("\nMS-DOS version %d.%d\n",dos_major,dos_minor);
if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{ {
printf("DR-DOS simulating DOS %d.%d",dos_major,dos_minor); printf(" simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
} }
} }
else if(dos_oem_code==0xFF && dos_major>=4 && dos_major <=6) if(dostype == 2)
{
printf("\nPC-DOS version %d.%d\n",dos_major,dos_minor);
if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{ {
printf("MS-DOS / PC-DOS %d.%d",dos_major,dos_minor); printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
if(dos_major==5)
{
printf("\nNOTE: May be OS/2 / Windows NT simulating DOS 5.0");
}
} }
else if(dos_oem_code==0xFF && dos_major>=7) }
{ if(dostype == 3)
if(dos_minor==0) {
{ printf("\nDR-DOS version %d.%d\n",dos_major,dos_minor);
printf("Windows 95 simulating DOS 7.00"); if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
printf("\nNOTE: May be PC-DOS 7.0"); {
} printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
else if(dos_minor==10) }
{ }
printf("Windows 95 OSR 2 or upper simulating DOS 7.10"); if(dostype == 4)
printf("\nNOTE: May be PC-DOS 7.1"); {
} printf("\nFreeDOS version 1.1.%d\n",dos_major);
else printf(" simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
{ }
printf("PC-DOS %d.%d",dos_major,dos_minor); if(dostype == 5)
} {
} printf("\nWindows 95\n",dos_major,dos_minor);
else if(dos_oem_code==0xFF && dos_major==3) if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{ {
printf("MS-DOS %d.%d",dos_major,dos_minor); printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
} }
else if(dos_oem_code==0x5E) }
{ if(dostype == 6)
printf("RxDOS %d.%d",dos_major,dos_minor); {
} printf("\nWindows NT or Windows 2000\n",dos_major,dos_minor);
else if(dos_oem_code==0x66) if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{ {
printf("PTS-DOS simulating DOS %d.%d",dos_major,dos_minor); printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
} }
else }
{ if(dostype == 8)
printf("Unknown DOS version %d.%d,OEM code %x",dos_major,dos_minor,dos_oem_code); {
printf("\nPlease send this info and the DOS name and version to iosglpgc@teleline.es"); printf("\nPTS-DOS, unknown version\n");
} printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
}
if(dostype == 9)
{
printf("\nRxDOS version %d.%d\n",dos_major,dos_minor);
if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{
printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
}
}
if(dostype == 10)
{
printf("\nConcurrent DOS version %d.%d\n",dos_major,dos_minor);
if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{
printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
}
}
if(dostype == 11)
{
printf("\nNovell DOS version %d.%d\n",dos_major,dos_minor);
if(dos_major != dos_sim_major || dos_minor != dos_sim_minor)
{
printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
}
}
if(dostype == 12)
{
printf("\nMS-DOS / PC-DOS version %d.%d\n",dos_major,dos_minor);
}
if(dostype == 13)
{
printf("\nWindows 95 OSR 2 or upper\n");
if(dos_major!=dos_sim_major || dos_minor!=dos_sim_minor)
{
printf("simulating DOS version %d.%d\n",dos_sim_major,dos_sim_minor);
}
}
} }

98
ver.h Normal file
View File

@@ -0,0 +1,98 @@
/************************************************************************
T h e O p e n W i n d o w s P r o j e c t
------------------------------------------------------------------------
Filename : ver.h
Version : 0.03
Author(s) : Natalia Portillo
Component : OWP DOS subsystem - VER command
--[ Description ]-------------------------------------------------------
Says the DOS type and version.
--[ History ] ----------------------------------------------------------
0.00: Original file by Natalia Portillo. No DOS type.
0.01: Tested with following DOSes obtaining:
DOS DOS Version DOS OEM Code
DR-DOS 7.03 6.0 0x00
FreeDOS Beta 4 6.22 0xFD
MS-DOS 3.20 3.20 0x00
MS-DOS 3.30 3.30 0x00
MS-DOS 4.01 4.0 0xFF
MS-DOS 5.00 5.0 0xFF
PC-DOS 3.30 3.30 0x00
Windows 98 S.E. 7.10 0xFF
Windows 2000 5.0 0xFF
0.02: Tested with the following DOSes obtaining:
DOS DOS Version DOS OEM Code
PTS-DOS 2000 6.22 0x66
RxDOS 7.1.5 7.0 0x5E
0.03: Almost remade from zero.
Now uses four functions of INT-21h to get almost all
DOS version information.
All detect stuff moved to int21h.c.
All defines moved to ver.h
--[ How to compile ]----------------------------------------------------
Recommended compiler Borland Turbo C++ 1.01
http://community.borland.com/museum
--[ Where to get help/information ]-------------------------------------
This archaic and abandoned software is opensource with no warranty
or help of any kind.
For inquiries contact claunia@claunia.com.
--[ License ] ----------------------------------------------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License,or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not,write to the Free Software
Foundation,Inc.,59 Temple Place - Suite 330,Boston,MA 02111-1307,USA.
------------------------------------------------------------------------
Copyright (c) 2000 The Open Windows Project
*************************************************************************/
/* OWP DOS Subsystem general definition */
#ifndef OWP_DOS_SUBSYSTEM
#define OWP_DOS_SUBSYSTEM
#endif
/* Program general definitions */
#define SYSTEM "OWP"
#define PROGRAM "VER"
#define MAJOR_VERSION 0
#define MINOR_VERSION_STRING "03"
#define SUB_VERSION_STRING ""
#define COPYRIGHT "2000 Open Windows Project"
/* DOS types definition */
#define UNKNOWN 0
#define MS_DOS 1
#define PC_DOS 2
#define DR_DOS 3
#define FreeDOS 4
#define Win95 5
#define WinNT 6
#define OS2 7 /* Not tested yet, so not implemented yet */
#define PTS_DOS 8
#define RxDOS 9
#define ConDOS 10 /* Concurrent DOS, not tested yet */
#define NVDOS 11 /* Novell version of DR_DOS, not tested yet */
#define OLD 12
#define Win98 13
#define ERROR 255