📄 netinfo.c
字号:
/* Set the hardware type */
pNetInfo->wNovellHdwType = (WORD) outregs.h.al;
/* Set the shell version number */
pNetInfo->wShellMajor = (WORD) outregs.h.bh;
pNetInfo->wShellMinor = (WORD) outregs.h.bl;
pNetInfo->wShellRevision = (WORD) outregs.h.cl;
/* Set the shell type (XMS/EMS/Conv) */
if (pNetInfo->wShellMajor * 100 + pNetInfo->wShellMinor >= 301)
pNetInfo->wShellType = (WORD) outregs.h.ch;
/* Get the station number */
inregs.h.ah = 0xDC;
int86 (0x21, &inregs, &outregs);
pNetInfo->wStationNmbr = (WORD) outregs.h.al;
/* Get the physical station number */
inregs.h.ah = 0xEE;
int86 (0x21, &inregs, &outregs);
pNetInfo->wPhysicalStaNmbr1 = (WORD) outregs.x.cx;
pNetInfo->wPhysicalStaNmbr2 = (WORD) outregs.x.bx;
pNetInfo->wPhysicalStaNmbr3 = (WORD) outregs.x.ax;
/* Is SPX installed */
inregs.x.bx = 0x0010;
inregs.h.al = 0x00;
int86 (0x7A, &inregs, &outregs);
pNetInfo->fSpxInstalled = (outregs.h.al == 0xFF) ? TRUE : FALSE;
/* Is ODI/LSL.COM installed */
inregs.x.ax = 0xC000;
inregs.x.bx = 0x0000;
int86 (0x2F, &inregs, &outregs);
pNetInfo->fOdiLslInstalled = (outregs.h.al == 0xFF) ? TRUE : FALSE;
}
/*******************************************************************
*
* Function BanyanRunning()
*
* This function detects Banyan VINES if it is running. It returns a
* 1 if VINES was detected, 0 if not.
*
* Detection scheme
* ----------------
*
* To detect if VINES is currently running:
*
* MOV AX,D701h
* MOV BX,0
* INT 2F
*
* Returns: AX = 0 if workstation VINES software is enabled
* BX = interrupt number being used (60 - 66)
*
*
* To get the VINES version number, use the interrupt number returned
* in BX above <banint> and do the following:
*
* MOV AX, 0700h
* LDS DX, <ptr-to-ULONG>
* INT <banint>
*
* Returns: AX = 0
*
* The version number is returned as:
*
* (VINES rev * 10000) + edit level - 50.
*
* If the edit level is < 50, it is a beta level. For example:
*
* 31505 = VINES 3.10 (0)
* 31051 = VINES 3.10 (1)
* 40010 = VINES 4.00 (Beta-10)
* 40050 = VINES 4.00 (0)
*
*
* NOTE: The version detection is currently commented out because it
* hangs after returning the version number correctly. More on
* this later.
*
*******************************************************************/
int BanyanRunning (VOID)
{
unsigned int uiVinesIsThere;
/* int iVinesINTNumber; */
/* unsigned long *pulVersion; */
_asm
{
mov ax,0D701h
mov bx,0h
int 2Fh
mov uiVinesIsThere,ax
}
/* This is commented out because it does not currently work
if (uiVinesIsThere == 0)
{
_asm
{
mov ax,0D701h
mov bx,0h
int 2Fh
mov uiVinesIsThere,ax
mov iVinesINTNumber,bx
}
if (!uiVinesIsThere)
_asm
{
mov ax,0700h
lds dx,pulVersion
int <banint>
}
}
*/
return (!uiVinesIsThere);
}
/***********************************************************************
*
* Artisoft LANtastic detection
*
* Run-time testing for LANtastic NOS (all versions). Returns 1 if
* LANtastic is present, 0 if not.
*
* Detection scheme
* ----------------
*
* First, determine whether or not a NOS is running (may not be LANtastic)
* by issuing a multiplex interrupt (2Fh). This will tell if redirector,
* server, or LANPUP software is installed:
*
* INPUT AX B800h
*
* OUTPUT AL 0 If neither redirector or server is running
* NZ Redirector, server, or LANPUP is running
*
* BL Contains bits indicating which software is running
* (Multiple bits will be set when several are running):
*
* 10000000b Redirector has popup receive message capability
* 01000000b Server software is running
* 00001000b Redirector software is running
* 00000010b LANPUP software is running
*
* At a minimum, the redirector bit will be set if LANtastic
* is running.
*
* After it has been determined if a NOS is running, determine if it is
* LANtastic by issuing one of LANtastic's extended DOS calls:
*
* mov ax, 5F9Ah ; Get message processing flags in DL
* int 21h
* jc not_LANtastic
* jmp is_LANtastic
*
* If LANtastic is running, determine what the version number is by
* issuing the following multiplex interrupt:
*
* INPUT AX B809h
*
* OUTPUT AH Major version number
* AL Minor version number
*
* The version numbers are returned as decimal numbers. For example,
* version 2.53 would be returned as:
*
* AL 2
* AH 53 decimal or 35 hex
*
****************************************************************************/
int LANtasticRunning (NETWORK_STRUCT *pNetInfo)
{
int iRedirMask = 0x08; /* 00001000b */
int iServerMask = 0x40; /* 01000000b */
int iPopUpMask = 0x02; /* 00000010b */
union REGS inregs, outregs;
int iFalse = 0, iTrue = 1;
/* Issue multiplex interrupt 2fH to determine if some type
of a NOS is running */
inregs.x.ax = 0xB800;
int86 (0x2F, &inregs, &outregs);
/* If AL is non-zero (something is running) see if BL has bit 4
turned on (00001000b) to see if it is possibly LANtastic. If
it is possibly LANtastic, issue an extended DOS call to see
if the NOS is LANtastic. */
if ((outregs.h.al) && (outregs.h.bl & iRedirMask))
{
/* redirector software is running. Check for server and LANPUP
software */
pNetInfo->fLANtasticRedir = TRUE;
if (outregs.h.bl & iServerMask)
pNetInfo->fLANtasticServer = TRUE;
if (outregs.h.bl & iPopUpMask)
pNetInfo->fLANtasticPopUp = TRUE;
/* Issue an extended DOS call to determine if LANtastic is running. */
inregs.x.ax = 0x5F9A;
intdos (&inregs, &outregs);
/* If the carry flag is set this is not LANtastic, otherwise it is */
if (outregs.x.cflag)
pNetInfo->fLANtasticPresent = FALSE;
else
{
/* LANtastic is running, get the version number */
pNetInfo->fLANtasticPresent = TRUE;
inregs.x.ax = 0xB809;
int86 (0x2F, &inregs, &outregs);
pNetInfo->wLANtasticVersionMajor = outregs.h.ah;
pNetInfo->wLANtasticVersionMinor = outregs.h.al;
}
}
return (pNetInfo->fLANtasticPresent);
}
/*******************************************************************
*
* Function Msnet_Installed
*
* This function checks for the existence of a Microsoft Network
* compatible network. It returns 1 if MSNET is detected, 0 if not.
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
* registers.
*
*******************************************************************/
BOOL Msnet_Installed (VOID)
{
union REGS inregs, outregs;
inregs.h.ah = 0x00;
int86 (0x2A, &inregs, &outregs);
if (outregs.h.ah != 0)
return (TRUE); /* MSNet is installed */
else
return (FALSE); /* MSNet is not installed */
}
/*******************************************************************
*
* Function Get_Msnet_Machine_Name
*
* This function gets the name of the local computer running MSNet.
*
*
* Local Variables Used
* --------------------
*
* inregs, outregs : Used to read and write the general purpose
* registers.
* segments : Used to read and write the segment registers.
*
* Returns: TRUE if an error occured
*
*******************************************************************/
BOOL Get_Msnet_Machine_Name (NETWORK_STRUCT *pNetInfo)
{
union REGS inregs, outregs;
struct SREGS segments;
CHAR FAR *pszMachineName = NULL;
/* After this interrupt call, the MSNet machine name will be in
a null terminated string in MsnetMachine */
/* Set a pointer to the place in the structure */
pszMachineName = (CHAR FAR *) pNetInfo->szMsnetMachineName;
inregs.x.ax = 0x5E00;
segments.ds = (unsigned int) FP_SEG (pszMachineName);
inregs.x.dx = (unsigned int) FP_OFF (pszMachineName);
int86x (0x21, &inregs, &outregs, &segments);
if (outregs.x.cflag) /* an error was returned */
{
pNetInfo->szMsnetMachineName[0] = -1;
pNetInfo->szMsnetMachineName[0] = '\0';
return (TRUE);
}
return (FALSE);
}
/*******************************************************************
*
* This Function calls NetWkstaGetInfo. If the call gives back an error
* other than 0, NERR_WkstaNotStarted, NERR_NotLoggedOn, or NERR_buftosmall
* then either Lan Manager is not running or Lan Manager is in a state we don't
* want to mess with. For example, the lanman.ini file isn't there.
*
* LOCAL vars
* err - holds return error of netwkstagetinfo
* ta - contains total available bytes from netwkstagetinfo
* wkstabuf - buffer info for netwkstagetinfo
* wksta0 - stuct mapping to wkstabuf which hold info from netwkstagetinfo
**********************************************************************/
int LanManager_Installed (NETWORK_STRUCT * pNetInfo)
{
unsigned short int err=0, ta=0;
char wkstabuf[BUFSIZ];
struct wksta_info_0 *wksta0;
/* Get wksta info - if error we still could be a basic workstation */
err = NetWkstaGetInfo (NULL, 0, wkstabuf, BUFSIZ, &ta);
/* if we get an error, just fill in stuff incase we try to print this */
if (err != 0)
{
#if 0
strcpy (pNetInfo->szLanRoot, pszUnknown);
strcpy (pNetInfo->szUserName, "Not Logged on");
strcpy (pNetInfo->szPrimaryDomain, pszNone);
pNetInfo->wNetworkMajor = 0x00;
pNetInfo->wNetworkType = NET_UNKNOWN_NET;
/* Net work may not be running, try autoexec.bat - this is */
/* for basic test, too. */
/* GetLanAutoexec will fill in version & lanroot if it can */
err = GetLanAutoexec (pNetInfo);
#endif
return err;
}
else
{
/* there was no error so fill in netinfo struct */
pNetInfo->fNetworkActive = TRUE;
wksta0 = (struct wksta_info_0 *) wkstabuf;
_fmemcpy (pNetInfo->szLanRoot, wksta0->wki0_root, _MAX_PATH);
if (wksta0->wki0_username[0] != '\0')
_fmemcpy (pNetInfo->szUserName, wksta0->wki0_username, 16);
if (wksta0->wki0_langroup[0] != '\0')
_fmemcpy (pNetInfo->szPrimaryDomain, wksta0->wki0_langroup, 16);
pNetInfo->wNetworkMajor = wksta0->wki0_ver_major;
pNetInfo->wNetworkMinor = wksta0->wki0_ver_minor;
pNetInfo->wNetworkType = NET_LANMAN;
pNetInfo->fAPI_Support = TRUE;
if (wksta0->wki0_mailslots != 0)
pNetInfo->fMailslot_Support = TRUE;
return 0;
}
}
/*******************************************************************
*
* GetLanAutoexec function gets c:\autoexec.bat and searches for lanman info
* Possible info is LAN version & LAN ROOT. This function is only called
* if NetWkstaGetInfo fails which it will always do if LAN is basic.
*
**********************************************************************/
int GetLanAutoexec (NETWORK_STRUCT * pNetInfo)
{
FILE * fileAuto; /* File handle for AUTOEXEC.BAT */
FILE_INFO FAR * ffi; /* Stores File Info structs */
FILE_INFO FAR * ffi2; /* 2nd copy of File Info structs */
CHAR chBuffer[_MAX_PATH]; /* Filled with ReadLine */
CHAR szFilePath[_MAX_PATH]; /* Stores path to AUTOEXEC.BAT */
CHAR * pBuffer; /* Needed with strstr */
CHAR * pCase; /* Needed with strupr on buffer */
CHAR * pRem; /* Needed with strupr on buffer */
INT i; /* Looping variable */
INT iVersion; /* Version Number */
/* Find the AUTOEXEC.BAT file */
ffi = FindFile ("AUTOEXEC.BAT", NULL, SEARCH_BOOT_DRIVE, '\0');
if (ffi == NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -