📄 computer.c
字号:
"v 5",
"v 6",
"v 7",
"v 8",
"v 9",
NULL
};
/* Clear out the strings */
for (i = 0; i < MAX_BIOS_VERSION_STRINGS; ++i)
pachVersionStrings[i][0] = '\0';
/* Search for a period with a digit on either side */
while (iIndex < MAX_BIOS_VERSION_STRINGS && fFoundFlag)
{
_asm
{
push di ; Save DI
les di,fpSearchArea ; Point to search area
mov cx,wSearchLength ; Search the entire distance
mov al,chSearchChar ; For a period
ContinueSearch:
repnz scasb ; Search
jnz not_found ; If we went to the end, drop out
mov ah,es:[di] ; Is the next character a number
cmp ah,'9' ; Is the next character a number
jg keep_looking ; If > '9', keep looking
cmp ah,'0'
jl keep_looking ; If < '0', keep looking
mov ah,es:[di-2] ; Is the previous character a number
cmp ah,'9'
jg keep_looking ; If > '9', keep looking
cmp ah,'0'
jl keep_looking ; If < '0', keep looking
jmp was_found ; Otherwise, we found it
keep_looking: ; This isn't a version/date, keep looking
inc di
dec cx
jnz ContinueSearch
not_found:
mov fFoundFlag,FALSE ; Set the flag saying we didn't find it
jmp done
was_found:
mov fFoundFlag,TRUE ; We found it
mov wSearchLength,cx ; Set the variables to continue the search
mov wStringOffset,di
mov wStringSegment,es
done:
pop di
}
if (iIndex < MAX_BIOS_VERSION_STRINGS && fFoundFlag)
{
/* Set the pointer for continuing the search */
fpSearchArea = (CHAR FAR *)
((DWORD) wStringSegment << 16) +
(DWORD) wStringOffset;
/* Set the pointer for printing the string */
fpChars = fpSearchArea;
wRomLength = 0;
/* Search for the beginning of the string */
while (wRomLength < MAX_BIOS_VERSION_LEN - 8 &&
*fpChars >= ' ' && *fpChars <= 127 && *fpChars != '$')
--fpChars, ++wRomLength;
++fpChars;
/* Can one of the search strings be found */
for (u = 0;
paszSearchStrings[u] != NULL &&
(fpMatch = fbiInstr (fpChars,
paszSearchStrings[u],
wRomLength)) == 0;
++u)
;
/* If fpMatch is non-zero, we found a match */
if (fpMatch)
{
/* Skip leading whitespace */
for (; *fpChars == ' '; ++fpChars)
;
/* Copy the string into the pachVersionStrings */
for (i = 0; i < MAX_BIOS_VERSION_LEN - 1 &&
*fpChars >= ' ' && *fpChars <= 127 && *fpChars != '$';
++i, ++fpChars)
pachVersionStrings[iIndex][i] = *fpChars;
pachVersionStrings[iIndex][i] = '\0';
/* Bump the index to the version strings */
++iIndex;
}
}
}
return (TRUE);
}
/*********************************************************************
* GetRomDate - Finds the most recent date in the computer/video
* card's ROM. When GetRomDate encounters a date, it
* checks the previously found date to see if the new
* date is more recent.
*
* fpSearchArea - Area to search for a date (ie., F000:0000).
* wSearchLength - Length of search (ie., FFFFH).
* pchDateString - Location to store the date.
*
* Returns: TRUE if a date was found, FALSE otherwise
*********************************************************************/
BOOL GetRomDate (CHAR FAR * fpSearchArea,
WORD wSearchLength,
CHAR * pchDateString)
{
BOOL fFoundFlag = TRUE; /* Set to TRUE if the item was found */
WORD wStringSegment = 0; /* Segment of the string that was found */
WORD wStringOffset = 0; /* Offset of the string that was found */
CHAR FAR *fpChars = NULL;/* Far pointer to the string of characters */
CHAR chSearchChar = '/'; /* Date separator character */
CHAR chPrevDate[MAX_BIOS_DATE]; /* First date found */
CHAR chCurrDate[MAX_BIOS_DATE]; /* Date currently being examined */
WORD i; /* Looping variable */
WORD wLength; /* Number of characters to move */
/* Clear out the previous date */
memset (chPrevDate, '\0', MAX_BIOS_DATE);
while (fFoundFlag)
{
{
_asm
{
cld
push di ; Save DI
les di,fpSearchArea ; Point to search area
mov cx,wSearchLength ; Search the entire distance
mov al,chSearchChar ; for the date separator
ContinueSearch:
repnz scasb ; Search
jnz not_found ; If we went to the end, drop out
cmp al,es:[di + 2] ; Is a date separator 2 chars away
jne keep_looking ; If not, keep looking
mov ah,es:[di] ; Is the next character a number
cmp ah,'9'
jg keep_looking ; If > '9', keep looking
cmp ah,'0'
jl keep_looking ; If < '0', keep looking
mov ah,es:[di - 2] ; Is the previous character a number
cmp ah,'9'
jg keep_looking ; If > '9', keep looking
cmp ah,'0'
jl keep_looking ; If < '0', keep looking
jmp was_found ; Otherwise, we found it
keep_looking: ; This isn't a version/date, keep looking
; ----- This is added in case the BIOS ends with a '/'
or cx,cx ; Are we at the end
jz not_found ; If we are, drop out.
; -----
inc di
dec cx
jnz ContinueSearch
not_found:
mov fFoundFlag,FALSE ; Set the flag saying we didn't find it
jmp done
was_found:
mov fFoundFlag,TRUE ; We found it
mov wSearchLength,cx ; Set the variables to continue the search
mov wStringOffset,di
mov wStringSegment,es
done:
pop di
}
}
if (fFoundFlag)
{
/* Set the pointer for continuing the search */
fpSearchArea = (CHAR FAR *)
((DWORD) wStringSegment << 16) +
(DWORD) wStringOffset;
/* Set the pointer to the beginning of the date */
fpChars = fpSearchArea - 3;
/* Copy the year into chCurrDate */
chCurrDate[0] = fpChars[6];
chCurrDate[1] = fpChars[7];
chCurrDate[2] = chSearchChar; /* The 1st "/" for YY/MM/DD */
/* Copy the month & day into chCurrDate */
/* (Process properly if this is a one digit month) */
if (*fpChars > '9' || *fpChars < '0')
{
++fpChars;
chCurrDate[3] = '0';
i = 4;
wLength = 4;
}
else
{
i = 3;
wLength = 5;
}
_fmemcpy ((CHAR FAR *) &chCurrDate[i], fpChars, wLength);
/* Compare the dates, to see which is more recent */
if (memcmp (chPrevDate, chCurrDate, MAX_BIOS_DATE - 1) < 0)
memcpy (chPrevDate, chCurrDate, MAX_BIOS_DATE - 1);
}
}
/* If we did not find a date */
if (chPrevDate[0] == '\0')
{
pchDateString[0] = '\0';
return (FALSE);
}
/* Put the date from chPrevDate's YY/MM/DD format */
/* into pchDateString's MM/DD/YY format */
pchDateString[5] = chSearchChar;
pchDateString[6] = chPrevDate[0];
pchDateString[7] = chPrevDate[1];
memcpy (pchDateString, &chPrevDate[3], 5);
pchDateString[8] = '\0';
return (TRUE);
}
/*********************************************************************
* fbiInstr - far, buffer, case-insensitive, INSTR function
*
* fpSearchArea Far pointer to the area of memory to search
* (ie, 0xF0000000 for ROM BIOS area)
*
* pszSearchString String you are looking for in the distant
* memory area pointed to by cfpAreaToSearch
* (ie, "COPYRIGHT")
*
* wSearchLength How much memory to search through
* (ie, 0x8000 or 0xFFFF)
*
* Returns: Far pointer to the string if it was found, NULL if the
* string was not found.
*********************************************************************/
CHAR FAR *fbiInstr (CHAR FAR *fpSearchArea,
PSZ pszSearchString,
WORD wSearchLength)
{
BOOL fFoundFlag = TRUE; /* Set to TRUE if the item was found */
CHAR chSearchChar1; /* First character of search string */
CHAR chSearchChar2; /* Second character of search string */
CHAR chSearchChar3; /* Third character of search string */
CHAR chSearchChar4; /* Fourth character of search string */
WORD wStringSegment; /* Segment of the string that was found */
WORD wStringOffset; /* Offset of the string that was found */
WORD wLength; /* Length of search string */
/* Set wLength to the length of the search string */
wLength = strlen (pszSearchString);
/* Get the first four characters to scan for */
chSearchChar1 = pszSearchString[0];
chSearchChar2 = pszSearchString[1];
chSearchChar3 = pszSearchString[2];
chSearchChar4 = pszSearchString[3];
/* Search for the first two characters */
while (fFoundFlag)
{
_asm
{
mov cx,wSearchLength ; Search the entire distance
mov bh,chSearchChar1 ; for the first four characters
mov bl,chSearchChar2
mov dh,chSearchChar3
mov dl,chSearchChar4
and bx,0xDFDF ; Fast "toupper()" all 4 characters
and dx,0xDFDF
push ds ; Save DS
push si ; Save SI
lds si,fpSearchArea ; Point to search area
push si
ContinuePop: ; For continuing searches
pop si
ContinueSearch:
lodsb ; Search
and al,0xDF ; Fast "toupper()"
cmp bh,al ; Is it a match?
loopne ContinueSearch ; Loop if not found
push si ; Save SI, in case this didn't match.
; (DS remains the same, so preserving
; it is not necessary).
and cx,cx ; Is CX == 0?
jz not_found ; If so, we're done
and bl,bl ; Is the 2nd character a NULL?
jz was_found ; If so, we found it
lodsb ; Otherwise, check the 2nd character
and al,0xDF ; Fast "toupper()"
cmp bl,al ; Is it a match?
loopne ContinuePop ; Loop if not found
and cx,cx ; Is CX == 0 (end of search length)?
jz not_found ; We're done (no match)
and dh,dh ; Is the 3rd character a NULL?
jz was_found ; If so, we found it
lodsb ; Otherwise, check the 3rd character
and al,0xDF ; Fast "toupper()"
cmp dh,al ; Is it a match?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -