⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 computer.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 4 页
字号:
/*********************************************************************
 * Microsoft Diagnostics Version 2.0
 *
 * A diagnostic utility to detect as much useful information about a
 *   customer's computer system as is possible.
 *
 * Microsoft Diagnostics:  We detect the World.
 *
 * COMPUTER.C - Source file for obtaining the computer data:  BIOS,
 *              Processor, and Keyboard.
 ********************************************************************/


/* Include Files */

#include "msd.h"


/* Computer names */

PSZ ppszComputerNames[] =
  {
    "Unknown",
    "Amstrad", "Wang", "Apricot", "Bull ", "Toshiba", "NEC ", "Texas Inst",
    "Austin", "Cumulus", "Ergo", "Hynudai", "Nokia", "Ogivar", "Siemens",
    "Tandem", "Tandon", "Mitsubishi", "Matsushita", "Sharp", "DEC ",
    "Hewlett Packard", "Hewlett-Packard", "Epson", "Leading Edge", "NCR ",
    "Acer", "ALR ", "Norsk", "Altec", "Altos", "Televideo", "Dell ",
    "Commodore", "CompuAdd", "Gateway", "Hauppauge", "Northgate", "Goldstar",
    "Laser", "Normerel", "Panasonic", "Swan", "Orange", "Xerox", "Zeos",
    "Parallan", "Ampro", "AT&T", "Club ", "Data General", "Sperry", "Unisys",
    "Arche", "PC Brand", "Elonex", "Emerson", "DFI", "SDI ", "AIR ", "CSS ",
    "Dolsh", "Mitsuba", "Osicom", "Polywell", "SAI ", "Micro Express",
    "Packard Bell", "PC Craft", "Headstart", "Telex", "Mitac", "Everex",
    "DTK ", "Koyro", "Tandy", "Wyse", "Zenith", "Amkly", "AST ", "Grid",
    "Cheetah", "Psion", "US Micro", "Smith Corona", "Reply", "Dolch",
    "Aquiline", "Comtrade", "Cardinal", "Compudyne", "Schmit", "Victor",
    "Chicony", "Brother", "Elonex"
  };


/* BIOS names */

PSZ ppszBiosNames[] =
  {
    "Unknown",
    "Phoenix", "AMI ", "American Megatrends", "Award", "DTK", "Micronics",
    "ERSO", "Datatech", "Data Tech", "Olivetti", "Intel", "Seiko", "Ultima",
    "Mylex", "Artek", "Zenith", "(C)ZDS ", "Western Digital",
    "Compaq", "Monolithic", "IBM",
    NULL
  };


COMPUTER_STRUCT FAR *fpComputer = NULL;   /* Stored computer info */

/*********************************************************************
 * GetComputerInfo - Gets the computer related information:  BIOS and
 *                   computer manufacturer, BIOS version, and
 *                   keyboard type.
 *
 * Returns:  TRUE if an error occured.
 *********************************************************************/

BOOL GetComputerInfo (COMPUTER_STRUCT *pComputer, BOOL fMinimumInfo)
{
  union  REGS inregs, outregs;  /* Register structures   */
  BYTE FAR * fbByte = NULL;     /* Far pointer to a byte */
  PSZ pszString     = NULL;     /* String pointer        */
  WORD i;                       /* Looping variable      */


  /* We obtain the computer information only once, then store the    */
  /*   computer information for later requests.  If a second request */
  /*   is made (ie., for IRQ info, etc.), this routine will copy the */
  /*   stored computer information to pComputer and return           */
  /*   immediately.  This is done because obtaining the computer     */
  /*   information after obtaining information about a serial mouse  */
  /*   hard hangs the computer.                                      */

  if (fpComputer != NULL)
    {
      _fmemcpy ((COMPUTER_STRUCT FAR *) pComputer, fpComputer,
                 sizeof (COMPUTER_STRUCT));
      return (FALSE);
    }


  {
    /* Get Computer Name */

    i = GetRomName (GET_COMPUTER_NAME, ppszComputerNames);
    strcpy (pComputer->szComputerName, ppszComputerNames[i]);
    pComputer->wComputerName = i;
  }

  {
    /* Get BIOS Manufacturer */

    i = GetRomName (GET_BIOS_MFGR, ppszBiosNames);
    strcpy (pComputer->szBiosMfgr, ppszBiosNames[i]);
    pComputer->wBiosMfgr = i;
  }

  {
    /* Get IRQ and related Information */

    GetComputerIrqInfo (pComputer);
  }

  {
    /* If mimimum information requested, return now */

    /* Removed */
    /*
    if (fMinimumInfo)
      return (FALSE);
    */
  }

  {
    /* Get BIOS Version */

    GetRomVersion (pComputer->aszBiosVersion,
                   (CHAR FAR *) 0xF0000000, 0xFFFF);
  }

  {
    /* Get the BIOS Date */

    GetRomDate ((CHAR FAR *) 0xF0000000, 0xFFFF, pComputer->szBiosDate);
  }

  {
    /* Determine the BIOS Category */

    GetBiosCategory (pComputer);
  }


  {
    /* Determine Keyboard type */

    /* 0040:0096 is keyboard status byte 3:               */
    /*   If bit 4 is set, an enhanced keyboard is present */

    fbByte = (BYTE FAR *) 0x00400096;

    pszString = (*fbByte & 0x10) ? pszEnhanced : pszNonEnhanced;

    strcpy (pComputer->szKeyboardType, pszString);
  }

  {
    /* Determine the presence of a DMA Controller Chip */

    int86 (0x11, &inregs, &outregs);

    /* If the AX register, bit 8 == 0, then there is a DMA controller. */
    /*   Since AX bit 8 == AH bit 0, I use regs.h.ah.                  */

    pComputer->fDmaChipPresent = !(outregs.h.ah & 1);
  }

  /* Store the computer structure for future use */
  fpComputer = _fmalloc (sizeof (COMPUTER_STRUCT));
  if (fpComputer != NULL)
    {
      _fmemcpy (fpComputer, (COMPUTER_STRUCT FAR *) pComputer,
                sizeof (COMPUTER_STRUCT));
    }

  return (FALSE);
}


/*********************************************************************
 * GetComputerIrqInfo - Gets the IRQ related computer information,
 *                      (Cascaded IRQ2, Co-processor, Real Time
 *                      Clock).
 *
 * pComputer - Computer information structure.
 *********************************************************************/

BOOL GetComputerIrqInfo (COMPUTER_STRUCT *pComputer)
{
  union  REGS inregs, outregs;  /* Register structures         */
  struct SREGS sregs;           /* Segement register structure */
  BYTE FAR * fbByte = NULL;     /* Far pointer to a byte       */
  PSZ pszString     = NULL;     /* String pointer              */


  /* We obtain the computer information only once, then store the    */
  /*   computer information for later requests.  If a second request */
  /*   is made (ie., for IRQ info, etc.), this routine will copy the */
  /*   stored computer information to pComputer and return           */
  /*   immediately.  This is done because obtaining the computer     */
  /*   information after obtaining information about a serial mouse  */
  /*   hard hangs the computer.                                      */

  if (fpComputer != NULL)
    {
      _fmemcpy ((COMPUTER_STRUCT FAR *) pComputer, fpComputer,
                 sizeof (COMPUTER_STRUCT));
      return (FALSE);
    }


  {
    /* Get System Configuration Call */

    segread (&sregs);
    inregs.x.ax = 0;
    inregs.x.bx = 0;
    inregs.x.cx = 0;
    inregs.x.dx = 0;
    inregs.x.si = 0;
    inregs.x.di = 0;
    inregs.x.cflag = 0;
    inregs.h.ah = 0xC0;
    int86x (0x15, &inregs, &outregs, &sregs);

    /* Set the flag if this call is not supported on this BIOS */
    pComputer->fConfigCallSupported = !outregs.x.cflag;

    if (!pComputer->fConfigCallSupported)
      {
        /* If the "System Configuration Call" is not supported, */
        /*   the Computer Type byte is at F000:FFFE.            */

        fbByte = (BYTE FAR *) 0xF000FFFE;
        pComputer->bComputerType      = *fbByte;
        pComputer->bSubModel          = 0;
        pComputer->bRevisionLevel     = 0;
        pComputer->wComputerClass     = COMPUTER_CLASS_XT;
        pComputer->fFixedDiskUsesDMA3 = FALSE;
        pComputer->fCascadeIntLvl2    = FALSE;
        pComputer->fRealTimeClock     = FALSE;
      }
    else
      {
        /* Otherwise, get the information */

        fbByte = (BYTE FAR *)
                   (((DWORD) sregs.es << 16) + (DWORD) outregs.x.bx);

        pComputer->bComputerType      = fbByte[2];
        pComputer->bSubModel          = fbByte[3];
        pComputer->bRevisionLevel     = fbByte[4];
        pComputer->fFixedDiskUsesDMA3 = (fbByte[5] & 0x80) ? TRUE : FALSE;
        pComputer->fCascadeIntLvl2    = (fbByte[5] & 0x40) ? TRUE : FALSE;
        pComputer->fRealTimeClock     = (fbByte[5] & 0x20) ? TRUE : FALSE;


        /* Determine Bus type and computer category */

        if (fbByte[5] & 0x02)
          {
            strcpy (pComputer->szBusType, pszMicroChannel);
            pComputer->wBusType  = MICRO_CHANNEL;
            pComputer->wComputerClass = COMPUTER_CLASS_PS2;
          }
        else
          {
            /* Is this an EISA bus? */

            segread (&sregs);
            inregs.x.ax = 0;
            inregs.x.bx = 0;
            inregs.x.cx = 0;
            inregs.x.dx = 0;
            inregs.x.si = 0;
            inregs.x.di = 0;
            inregs.x.cflag = 0;
            inregs.x.ax = 0xD804;
            inregs.x.cx = 0x0000;
            int86 (0x15, &inregs, &outregs);
            if (outregs.h.ah != 0x86)
              {
                strcpy (pComputer->szBusType, pszEisaBus);
                pComputer->wBusType  = EISA_BUS;
                pComputer->wComputerClass = COMPUTER_CLASS_AT;
              }
            else
              {
                if (pComputer->fCascadeIntLvl2)
                  {
                    strcpy (pComputer->szBusType, pszAtBus);
                    pComputer->wBusType  = AT_BUS;
                    pComputer->wComputerClass = COMPUTER_CLASS_AT;
                  }
                else
                  {
                    strcpy (pComputer->szBusType, pszXtBus);
                    pComputer->wBusType  = XT_BUS;
                    pComputer->wComputerClass = COMPUTER_CLASS_XT;
                  }
              }
          }
      }

    /* Get Extended BIOS Data Segment */

    if (fbByte[5] & 0x04)
      {
        segread (&sregs);
        inregs.x.ax = 0;
        inregs.x.bx = 0;
        inregs.x.cx = 0;
        inregs.x.dx = 0;
        inregs.x.si = 0;
        inregs.x.di = 0;
        inregs.x.cflag = 0;
        inregs.h.ah = 0xC1;
        int86x (0x15, &inregs, &outregs, &sregs);

        if (outregs.x.cflag || sregs.es < 0x1000)
          {
            pComputer->wExtAreaSeg = 0;
            pComputer->wExtAreaLen = 0;
          }
        else
          {
            /* The first byte in the extended BIOS data segment */
            /*   tells the size (in K) of the segment           */
            pComputer->wExtAreaSeg = sregs.es;
            fbByte = (BYTE FAR *) ((DWORD) pComputer->wExtAreaSeg << 16);
            pComputer->wExtAreaLen = *fbByte;

            /* Assume it doesn't exist if it's too large */

          }
      }
  }

  {
    WORD wChipTypes;    /* Stores the chip types                    */
    WORD wProcessor;    /* "chips()" encoding for processor type    */
    WORD wCoProcessor;  /* "chips()" encoding for co-processor type */


    /* Determine Processor and Co-processor Types */

    wChipTypes   = chips();

    wProcessor   = wChipTypes / 10;
    wCoProcessor = wChipTypes % 10;


    /* Set the values for the processor */

    switch (wProcessor)
      {
      case 8:
          pComputer->wProcessor = _8088;
          pszString = pszIntel8088;
          break;

        case 18:
          pComputer->wProcessor = _80186;
          pszString = pszIntel80186;
          break;

        case 28:
          pComputer->wProcessor = _80286;
          pszString = pszIntel80286;
          break;

        case 38:
          pComputer->wProcessor = _80386;
          pszString = pszIntel80386;
          break;

        case 48:
          /* If a 80837 was detected, it is a i486 */
          /*   If not, it was a 486SX              */

          if (wCoProcessor == 3)
            {
              pComputer->wProcessor = _80486;
              pszString = pszInteli486;
            }
          else
            {
              pComputer->wProcessor = _80486SX;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -