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

📄 netinfo.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 5 页
字号:
/*********************************************************************
 * 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.
 *
 * NETINFO.C - Source file for obtaining network information.
 ********************************************************************/


/* Include Files */

#include "msd.h"

#define INCL_DOSERRORS 1
#include "bseerr.h"
#undef INCL_DOSERRORS

float flFloatFix = (float) 0.0;

/*********************************************************************
 * GetNetworkInfo - Gets the network information.
 *
 * pNetInfo     - Pointer to network information structure.
 *
 * Returns:  TRUE if an error occured.
 *********************************************************************/

BOOL GetNetworkInfo (NETWORK_STRUCT *pNetInfo, BOOL fMinimumInfo)
{
  WORD wIndex;                  /* Index to network name string array */
  static BOOL fFirstTime = 1;   /* Set so that network information is */
                                /*   only obtained once.              */

  /* Obtain network information only if this is the first time through */

/*if (fFirstTime)
    {                */
      fFirstTime = 0;

      /* Initialize NetInfo structure fields */
      memset (pNetInfo, '\0', sizeof (NETWORK_STRUCT));
#if HEAP_DEBUG
      HeapCheck ("After memset");
#endif


      /* Check for NetBIOS running */
      if (Netbios_Installed (pNetInfo))
        {
          pNetInfo->fNetworkActive     = TRUE;
          pNetInfo->fNetBiosCompatible = TRUE;
        }
      else
        pNetInfo->fNetBiosCompatible = FALSE;
#if HEAP_DEBUG
      HeapCheck ("After Netbios_Installed");
#endif


      /* Begin checking for the different networks */

      /* Check for Novell Netware running */
      if (Novell_Installed (pNetInfo))
        {
          pNetInfo->fNetworkActive = TRUE;
          pNetInfo->wNetworkType   = NET_NOVELL;
          Get_Novell_Info (pNetInfo);
        }
#if HEAP_DEBUG
      HeapCheck ("After Novell_Installed");
#endif


      /* Check for Banyan VINES running */
      if (BanyanRunning())
        {
          pNetInfo->fNetworkActive = TRUE;
          pNetInfo->wNetworkType   = NET_BANYAN;
        }
#if HEAP_DEBUG
      HeapCheck ("After BanyanRunning");
#endif


      /* Check for Artisoft LANtastic running */
      if (LANtasticRunning (pNetInfo))
        {
          pNetInfo->fNetworkActive = TRUE;
          pNetInfo->wNetworkType   = NET_LANTASTIC;
        }
#if HEAP_DEBUG
      HeapCheck ("After LANtasticRunning");
#endif


      /* Check for LanMan running */
      if (LanManager_Installed (pNetInfo) == 0)
        {
#if HEAP_DEBUG
      HeapCheck ("After LanManager_Installed");
#endif
          pNetInfo->wNetworkType = LAN_Basic_Enhanced (pNetInfo);

          if (fMinimumInfo == FALSE)
            {
              if (pNetInfo->fNetworkActive == TRUE)
                Adapter_Status (pNetInfo);

#if HEAP_DEBUG
      HeapCheck ("After Adapter_Status");
#endif
              pNetInfo->fServerConnection = Server_Connection();
#if HEAP_DEBUG
      HeapCheck ("After Server_Connection");
#endif

              if (pNetInfo->wNetworkMajor >= 2)
                {
                  if ((pNetInfo->wNetworkMajor == 2) &&
                      (pNetInfo->wNetworkMinor == 0))
                    {
                      Get_CSD_Info (pNetInfo);
#if HEAP_DEBUG
      HeapCheck ("After GetCSD_Info");
#endif
                    }
                  else
                    {
                      if (pNetInfo->wNetworkType == NET_LANMAN_ENHANCED)
                        GetLM_VersionInfo (pNetInfo);
#if HEAP_DEBUG
      HeapCheck ("After GetLM_VersionInfo");
#endif
                    }
                }
            }
        }


      /* Get Windows for Workgroups/Workgroup Connection information */
      if (pNetInfo->wNetworkType != NET_LANTASTIC && IsWorkgrpSysInstalled())

        {
          pNetInfo->wNetworkType  = NET_WORKGROUP_CLIENT;
          pNetInfo->wNetworkMajor = 0;
          pNetInfo->wNetworkMinor = 0;
        }


      /* Get MSNET information */
      if ((wDosMajor > 3) ||       /* Check to make sure we are running */
         ((wDosMajor == 3) &&      /*  at least DOS 3.1 for net support */
          (wDosMinor > 0)))        /*  before we do the MSNET testing   */
        {
          /* Check for MSNET running */
          if (Msnet_Installed())
            {
#if HEAP_DEBUG
      HeapCheck ("After Msnet_Installed");
#endif
              /* A network is running */
              pNetInfo->fNetworkActive   = TRUE;

              /* It is MSNET compatible */
              pNetInfo->fMsnetCompatible = TRUE;

              /* Get the machine name */
              Get_Msnet_Machine_Name (pNetInfo);
#if HEAP_DEBUG
      HeapCheck ("After Get_Msnet_Machine_Name");
#endif
            }
          else
            pNetInfo->fMsnetCompatible = FALSE;/* It is not MSNET compatible */
        }

      /* Check for the PC-NFS network */
      if (pNetInfo->fNetworkActive   == TRUE &&
          pNetInfo->fMsnetCompatible == TRUE &&
          pNetInfo->wNetworkType     == 0    &&
          PcNfsInstalled()           == TRUE)
        {
          pNetInfo->wNetworkType = NET_PC_NFS;
        }


/*  } */

  /* If the network was not determined yet, say it is unknown */
  if (pNetInfo->wNetworkType == 0 && pNetInfo->fNetworkActive == TRUE)
    if (pNetInfo->fMsnetCompatible == TRUE)
      pNetInfo->wNetworkType = NET_MS_NET_COMPATIBLE;
    else
      pNetInfo->wNetworkType = NET_UNKNOWN_NET;

  /* Set the network's name */
  wIndex = pNetInfo->wNetworkType;
  strcpy (pNetInfo->szNetworkType, paszNetworkTypes[wIndex]);
#if HEAP_DEBUG
      HeapCheck ("After strcpy network type");
#endif


  return (FALSE);
}


/*******************************************************************
*
* Function Netbios_Installed
*
* This function checks for the existence of a Netbios driver.
* It returns a 1 if NetBIOS is detected, 0 if not.
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
*                   registers.
* segments        : Used to read and write the segment registers.
* PresenceNcb     : The NCB used to issue the test NetBIOS request.
*
*******************************************************************/

int Netbios_Installed (NETWORK_STRUCT * pNetInfo)

{
  union REGS inregs, outregs;
  struct SREGS segments;
  struct Ncb PresenceNcb;

  /* Check the INT 5C vector to see if it's set to anything */

  inregs.x.ax = 0x355C;
  int86x (0x21, &inregs, &outregs, &segments);

  pNetInfo->wNetBIOSSegment = segments.es;
  pNetInfo->wNetBIOSOffset  = outregs.x.bx;

  /* If the INT 5C vector is set to either 0x0000 or 0xF000, */
  /*   the vector is not set, return a failure status        */

  if ((segments.es == 0x0000) || (segments.es == 0xF000))
    return (0);          /* No Netbios */

  /* INT 5C vector is set to something. Issue an invalid       */
  /*   NetBIOS request and check the return value to determine */
  /*   if NetBIOS is really installed                          */

  ClearNcb (&PresenceNcb);

  PresenceNcb.ncb_command = NETBIOS_INVALID_COMMAND;  /* Defined in netbios2.h    */

  NetbiosRequest(&PresenceNcb);

  if (PresenceNcb.ncb_retcode == 0x03)    /* The value returned by NetBIOS for an invalid command */
    return (1);      /* NetBIOS is really there */
  else
    return (0);      /* Something else is using INT 5C */
}


/*******************************************************************
*
* Function ClearNcb
*
* This function clears out a Ncb structure setting all fields to
* 0x00.
*
*
* Local Variables Used
* --------------------
*
* index   : Used for loop control.
* CharPtr : Used to point to the NCB.
*
*******************************************************************/

VOID ClearNcb (struct Ncb * pNcbPtr)

{
  /* memset (pNcbPtr, '\0', sizeof (ZeroNcb)); */
  memset (pNcbPtr, '\0', sizeof (struct Ncb));
}


/*******************************************************************
*
* Function NetbiosRequest
*
* This function issues a NetBIOS request.
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
*                   registers.
* segments        : Used to read and write the segment registers.
* NcbPtr          : A far pointer to a structure of type NCB used
*                   to issue the NetBIOS request.
*
*******************************************************************/

VOID NetbiosRequest (struct Ncb * NcbPointer)

{
  union REGS inregs, outregs;
  struct SREGS segments;
  struct Ncb FAR *NcbPtr = (struct Ncb FAR *) NcbPointer;

  segread (&segments);

  /* Load ES:BX with the address of the NCB */

  segments.es = FP_SEG (NcbPtr);
  inregs.x.bx = FP_OFF (NcbPtr);

  /* Issue the NetBIOS request */

  int86x (NetbiosInt5C, &inregs, &outregs, &segments);
}


/*******************************************************************
*
* Function Novell_Installed
*
* This function checks for the existence of a Novell Netware
* network. It returns 1 if Netware is detected, 0 if not
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
*                   registers.
*
*******************************************************************/

BOOL Novell_Installed (NETWORK_STRUCT *pNetInfo)

{
  union REGS inregs, outregs;

  inregs.x.ax = 0x7A00;
  inregs.x.bx = 0x0000;
  int86(0x2F, &inregs, &outregs);

  if (outregs.h.al == 0xFF)
    {
      /* Novell is installed */

      pNetInfo->fIpxInstalled = TRUE;
      return (TRUE);
    }
  else
    {
      /* Novell is not installed */

      pNetInfo->fIpxInstalled = FALSE;
      return (FALSE);
    }
}


/*******************************************************************
*
* Function Get_Novell_Info
*
* This function gets the DOS environment type and machine type as
* Novell sees it.
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
*                   registers.
* segments        : Used to read and write the segment registers.
* SourceIndex     : Used to parse the string returned from Novell
*                   for the environment information.
*
*******************************************************************/

VOID Get_Novell_Info (NETWORK_STRUCT *pNetInfo)

{
  union REGS inregs, outregs;   /* Registers for int86x             */
  struct SREGS segs;            /* Segments for int86x              */
  CHAR chBuffer[80];            /* Local string buffer              */
  PSZ  pszString = chBuffer;    /* String pointer to chBuffer       */


  /* Get the string information */

  inregs.h.ah = 0xEA;
  inregs.h.al = 0x01;
  segread (&segs);
  segs.es = segs.ds;
  inregs.x.di = (unsigned int) FP_OFF ((CHAR FAR *) pszString);

  int86x(0x21, &inregs, &outregs, &segs);

  /* Set the operating system string */
  strcpy (pNetInfo->szNovellShellOs, pszString);

  /* Set the shell OS version string */
  pszString += strlen (pszString) + 1;
  strcpy (pNetInfo->szNovellShellOsVersion, pszString);

  /* Set the hardware type */
  pszString += strlen (pszString) + 1;
  strcpy (pNetInfo->szNovellHdwType, pszString);


  /* Get the numeric information */

  inregs.h.ah = 0xEA;
  inregs.h.al = 0x00;
  segread (&segs);
  segs.es = (unsigned int) FP_SEG (pszString);
  inregs.x.di = (unsigned int) FP_OFF (pszString);

  int86x(0x21, &inregs, &outregs, &segs);

  /* Set the operating system type */
  pNetInfo->wNovellShellOs = (WORD) outregs.h.ah;

⌨️ 快捷键说明

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