📄 browse.c
字号:
/*********************************************************************
* 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.
*
* BROWSE.C - Source file for the memory browsing functions.
********************************************************************/
/* Include Files */
#include "msd.h"
PSZ paszBiosSearchStrings[] =
{
"VERSION",
"COPYRIGHT",
"TECH",
"INC.",
"LTD",
"COPR.",
"COMPA",
"BIOS",
"CCOO",
"(C)",
"ALL RIGHTS RESERVED",
"REV ",
"RESI",
NULL
};
/*********************************************************************
* GetBrowseInfo - Gets the browser strings and stores them in the
* structure.
*
* pwndCaller - PWND of the calling dialog box.
* pszSearchString - String to search for
* fpSearchArea - Area to search
* wSearchLength - Length of search
*
* Returns: PSZ * to strings that were found, or NULL if an error
* occured.
*********************************************************************/
QSZ * GetBrowseInfo (PSZ pszTitle,
PSZ pszSearchString,
CHAR FAR *fpSearchArea,
DWORD dwSearchLength)
{
MEM_STRING_DATA /* Structure for storing located strings */
msdStrings[MAX_MSD_STRINGS + 1];
int iBrowseResult; /* Result of the video browse */
QSZ *pqszStrings = NULL; /* Array of string pointers to display */
PSZ *ppszSearchStrings = NULL; /* Array of search strings */
WORD wSearchLength; /* Actual search length */
PSZ paszUserSearchStrings[2]; /* Local array of search strings. */
/* Used for user provided string. */
/* Set the search length */
if (dwSearchLength > 0xFFFF)
wSearchLength = 0xFFFF;
else
wSearchLength = (WORD) dwSearchLength;
/* Determine if a search string was given to us */
if (pszSearchString == NULL || pszSearchString[0] == '\0')
ppszSearchStrings = paszBiosSearchStrings;
else
{
paszUserSearchStrings[0] = pszSearchString;
paszUserSearchStrings[1] = NULL;
ppszSearchStrings = paszUserSearchStrings;
}
/* Prepare for the search */
BrowseInit (fpSearchArea, msdStrings, MAX_MSD_STRINGS);
/* Perform the search */
iBrowseResult = Browse (ppszSearchStrings,
fpSearchArea,
wSearchLength,
msdStrings,
MAX_MSD_STRINGS);
/* Convert the info to displayable strings */
pqszStrings = SprintBrowseInfo (msdStrings);
return (pqszStrings);
}
/*********************************************************************
* SprintBrowseInfo - Converts browsed strings into a form displayable
* within an info window.
*
* pmsdStrings - The collection of strings and lengths to convert
*
* Returns: String array for display or printing, or NULL on error.
*********************************************************************/
QSZ * SprintBrowseInfo (MEM_STRING_DATA *pmsdData)
{
WORD wNmbrStrings; /* Number of strings */
WORD wNmbrChars; /* Number of characters in the strings */
WORD i, wMsdIndex; /* Index variables */
INT iLength; /* Length of far string */
WORD wLength; /* Copy of string length */
INT c; /* Character from far memory location */
INT iLineCount; /* Number of lines in this browse string */
CHAR FAR *fpString = NULL;/* Far pointer to the string */
QSZ *pqszStrings = NULL; /* Location for storing string pointers */
CHAR chBuffer[40]; /* sprintf buffer */
/* Overestimate the amount of space this will require */
for (i = 0; i < MAX_MSD_STRINGS && pmsdData[i].cfpString != NULL; ++i)
;
wNmbrStrings = (i * MAX_BROWSE_LINES) + 1;
wNmbrChars = wNmbrStrings * 72;
/* Allocate space for the pointer area and string area */
pqszStrings = AllocStringSpace (wNmbrStrings, wNmbrChars);
if (pqszStrings == NULL)
return (NULL);
/* Put the information in place */
for (i = 0, wMsdIndex = 0;
wMsdIndex < MAX_MSD_STRINGS && pmsdData[wMsdIndex].cfpString != NULL;
++wMsdIndex)
{
sprintf (chBuffer, "%04X:%04X ",
FP_SEG (pmsdData[wMsdIndex].cfpString),
FP_OFF (pmsdData[wMsdIndex].cfpString));
Qstrcpy (pqszStrings[i], chBuffer);
iLength = pmsdData[wMsdIndex].iStringLen;
fpString = pmsdData[wMsdIndex].cfpString;
iLineCount = 1;
while (iLength--)
{
c = *(fpString++);
switch (c)
{
case '\n':
break;
case '\r':
/* Are we at the maximum number of lines */
if (++iLineCount > MAX_BROWSE_LINES)
{
/* No more lines for this one */
iLength = 0;
}
else
{
PrepNextString (pqszStrings, i++);
Qmemset (pqszStrings[i], ' ', 10);
pqszStrings[i][10] = '\0';
}
break;
/* This is a printing character */
default:
wLength = Qstrlen (pqszStrings[i]);
/* Is the line too long to add the character */
if (wLength >= REPORT_WIDTH)
{
/* Are we at the maximum number of lines */
if (++iLineCount > MAX_BROWSE_LINES)
{
/* No more lines for this one */
iLength = 0;
break;
}
else
{
PrepNextString (pqszStrings, i++);
Qmemset (pqszStrings[i], ' ', 10);
pqszStrings[i][10] = '\0';
wLength = 10;
}
}
pqszStrings[i][wLength] = (CHAR) c;
pqszStrings[i][wLength + 1] = '\0';
break;
}
}
PrepNextString (pqszStrings, i++);
}
pqszStrings[i] = NULL;
return (pqszStrings);
}
/*********************************************************************
* ListOptionRoms - Creates a list of the option ROMs installed in
* the system.
*
* Returns: Array of strings with Option ROM names, addresses, and
* sizes, or NULL on an error.
*********************************************************************/
PSZ * ListOptionRoms (VOID)
{
WORD wNmbrStrings; /* Number of strings */
WORD wNmbrChars; /* Number of characters in the strings */
ROM_MAP *pRomMap = NULL; /* ROM area locations and sizes */
INT i; /* Looping variable */
WORD wIndex = 0; /* Index to ppszStrings */
WORD wSize; /* Size of various structs */
PSZ *ppszStrings = NULL; /* String buffer */
COMPUTER_STRUCT *pCpu = NULL; /* For getting BUS type (PS/2) */
WORD wBusType; /* Stores the BUS type */
/* Get the computer IRQ info (contains bus type) */
wSize = GetInfoSize (IDI_COMPUTER_RECORD, FALSE);
if (wSize == 0)
return (NULL);
/* Allocate enough room for the info structure */
pCpu = malloc (wSize);
if (pCpu == NULL)
{
OutOfMemory();
return (NULL);
}
/* Zero out the structure */
memset (pCpu, '\0', wSize);
/* Fill the structure with the information */
if (GetComputerIrqInfo (pCpu))
{
free (pCpu);
return (NULL);
}
/* Store the bus type */
wBusType = pCpu->wBusType;
free (pCpu);
/* Make room for the ROM Map */
pRomMap = malloc (sizeof (ROM_MAP));
if (pRomMap == NULL)
{
OutOfMemory();
return (NULL);
}
memset (pRomMap, '\0', sizeof (ROM_MAP));
/* Get the ROM Map */
GetRomMap (pRomMap, wBusType);
/* Allocate space for the pointer area and string area */
wNmbrStrings = 10;
wNmbrChars = wNmbrStrings * 34;
if ((ppszStrings = calloc (wNmbrStrings + 1, sizeof (PSZ))) != NULL)
ppszStrings[0] = malloc (wNmbrChars);
if (ppszStrings == NULL || ppszStrings[0] == NULL)
{
free (ppszStrings);
free (pRomMap);
OutOfMemory();
return (NULL);
}
/* Load the ROM BIOS information into ppszStrings */
for (i = 0; i < 2 && pRomMap->wRomBiosLoc[i] != 0; ++i)
{
/* BIOS information */
if (i == 0)
{
if (pRomMap->wRomBiosLoc[1] == 0)
{
sprintf (ppszStrings[wIndex],
"ROM BIOS %04X %6lu",
pRomMap->wRomBiosLoc[i],
pRomMap->dwRomBiosSize[i]);
ppszStrings[wIndex + 1] = ppszStrings[wIndex] +
strlen (ppszStrings[wIndex]) + 1;
++wIndex;
}
else
{
sprintf (ppszStrings[wIndex],
"ROM BIOS part 1 %04X %6lu",
pRomMap->wRomBiosLoc[i],
pRomMap->dwRomBiosSize[i]);
ppszStrings[wIndex + 1] = ppszStrings[wIndex] +
strlen (ppszStrings[wIndex]) + 1;
++wIndex;
}
}
else
{
sprintf (ppszStrings[wIndex],
"ROM BIOS part 2 %04X %6lu",
pRomMap->wRomBiosLoc[i],
pRomMap->dwRomBiosSize[i]);
ppszStrings[wIndex + 1] = ppszStrings[wIndex] +
strlen (ppszStrings[wIndex]) + 1;
++wIndex;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -