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

📄 browse.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 2 页
字号:
  /* Load the Option ROM information into the listbox */
  for (i = 9; i >=0; --i)
    {
      switch (pRomMap->wOptRomLoc[i])
        {
          case 0x0000:
            continue;

          case 0xC000:
            /* Video ROM */
            sprintf (ppszStrings[wIndex],
                     "Video ROM BIOS        C000  %7lu",
                     pRomMap->dwOptRomSize[i]);
            ppszStrings[wIndex + 1] = ppszStrings[wIndex] +
                                      strlen (ppszStrings[wIndex]) + 1;
            ++wIndex;
            break;

          default:
            /* Generic Option ROM */
            sprintf (ppszStrings[wIndex],
                     "Option ROM            %04X  %7lu",
                     pRomMap->wOptRomLoc[i],
                     pRomMap->dwOptRomSize[i]);
            ppszStrings[wIndex + 1] = ppszStrings[wIndex] +
                                      strlen (ppszStrings[wIndex]) + 1;
            ++wIndex;
            break;
        }
    }

  /* Set the last one to NULL */
  ppszStrings[wIndex] = NULL;

  free (pRomMap);

  return (ppszStrings);
}


/*********************************************************************
 * ReportBrowseInfo - Writes the browser information to the file.
 *
 * fileReportFile - File handle for reporting.
 *
 * Returns: TRUE if an error occured.
 *********************************************************************/

BOOL ReportBrowseInfo (FILE *fileReportFile)
{
  QSZ * pqszStrings;            /* Browser Strings                     */
  PSZ * ppszRomStrings;         /* List of ROM Areas                   */
  WORD  wSearchSegment;         /* Segment to search                   */
  DWORD dwSearchLength;         /* Search Length                       */
  INT   i;                      /* Looping variable                    */
  BOOL  fReturnValue = FALSE;   /* Return value from various functions */
  CHAR  chBuffer[80];           /* sscanf buffer                       */


  /* Get the list of ROMs */
  ppszRomStrings = ListOptionRoms();
  if (ppszRomStrings == NULL)
    return (TRUE);


  /* Report the strings in each one */
  for (i = 0; ppszRomStrings[i] != NULL && fReturnValue == FALSE; ++i)
    {
      /* Obtain the search parameters */
      Qstrcpy (chBuffer, ppszRomStrings[i]);
      sscanf (&chBuffer[TSR_ADDRESS_COL], "%04X", &wSearchSegment);
      dwSearchLength = atol (&chBuffer[TSR_SIZE_COL]);

      /* Get the strings from that ROM area */
      pqszStrings = GetBrowseInfo (ppszRomStrings[i],
                                   NULL,
                                   (CHAR FAR *) ((DWORD) wSearchSegment << 16),
                                   dwSearchLength);

      /* Write out the strings */
      if (pqszStrings != NULL)
        {
          fReturnValue = WriteInfo (fileReportFile,
                                    chBuffer,
                                    pqszStrings);
        }
      else
        return (TRUE);

      /* Free up the allocated memory */
      FreeStringSpace (pqszStrings);
    }

  /* Free up the list of ROMs */
  free (ppszRomStrings[0]);
  free (ppszRomStrings);

  return (fReturnValue);
}


int iStringCount;               /* Total number of strings found */
int iLastNmbrFound;             /* Last number of strings found  */


/*************************************************************************
 * BrowseInit - Prepares for the browsing action.
 *
 * msdFoundStrings - MSD strings to be cleared out.
 *
 * iMaxMSDStrings  - Number of strings to clear.
 *************************************************************************/

VOID BrowseInit (char far *cfpSearchArea,
                 MEM_STRING_DATA *msdFoundStrings,
                 int iMaxMSDStrings)
{
  ClearMSDArray (msdFoundStrings, iMaxMSDStrings);

  iStringCount = 0;
  iLastNmbrFound = 0;
}


/*************************************************************************
 * Browse() - Browses through memory for strings.
 *
 * paszSearchString - Pointer to array of strings to search for in memory.
 *
 * cfpSearchArea - Far pointer to the area of memory to search.
 *
 * uiLengthOfSearch - Number of bytes to search at that cfpSearchArea.
 *
 * msdFoundStrings - Array to store the strings that were found.
 *
 * iMaxMSDStrings - Maximum number of strings to store in MSD array.
 *
 * Returns:  Number of strings found.
 *************************************************************************/

int Browse (char **paszSearchStrings,
            char far *cfpSearchArea,
            unsigned int uiLengthOfSearch,
            MEM_STRING_DATA *msdFoundStrings,
            int iMaxMSDStrings)
{
  register int i1;    /* Looping variables                 */
  int iSearchResult;  /* To store the result of the search */


  /* Get strings from memory browser */

  for (i1 = 0; paszSearchStrings[i1] != NULL; ++i1)
    {
      iStringCount = max((iSearchResult =
                         SingleStringMemSearch (msdFoundStrings,
                                                iMaxMSDStrings,
                                                paszSearchStrings[i1],
                                                cfpSearchArea,
                                                uiLengthOfSearch)),
                         iStringCount);

#if 0
      if (iSearchResult == SEARCH_CANCELED)
        return (SEARCH_CANCELED);
#endif

      iLastNmbrFound = iStringCount;
    }

  return (iStringCount);
}


/**********************************************************************
 * ClearMSDArray - Clears out MEM_STRING_DATA structures
 *
 * msd           - Pointer to the structure to clear
 *
 * iStringCount  - Number of elements in the structure
 **********************************************************************/

void ClearMSDArray (MEM_STRING_DATA *msd, int iStringCount)
{
  register int i;

  for (i = 0; i < iStringCount; ++i)
    {
      msd[i].cfpString = NULL;
      msd[i].iStringLen = 0;
    }
}


/***********************************************************************
 * SingleStringMemSearch - Returns the number of strings found
 *                         during the memory search.
 *
 * MEM_STRING_DATA *msdFoundArray
 *              - This is the pointer to the array that will hold
 *                the strings that are found.
 *
 * int iMaxArray
 *              - The total number of strings msdFoundArray can hold.
 *
 * char *pszSearchString
 *              - Pointer to the strings to search for.
 *
 * char far *cfpAreaToSearch
 *              - Area of memory to search (ie 0xF0000000).
 *
 * unsigned int uiLengthOfSearch
 *              - Total number of bytes to search (ie, 0xFFFF).
 ***********************************************************************/

int SingleStringMemSearch (MEM_STRING_DATA *msdFoundArray,
                           int iMaxArray,
                           char *pszSearchString,
                           char far *cfpAreaToSearch,
                           unsigned int uiLengthOfSearch)
{
  int iLength;                         /* Length of string returned */
                                       /*   from fbiInstr() */
  int iMaxInArray = 0;                 /* Holds the count of strings */
                                       /*   stored in the structure */
  unsigned int uiLengthToEndOfSearch;  /* As strings are found, */
                                       /*   uiSizeOfSearch will look ahead */
                                       /*   only as far as is necessary */
  char far *pszfMatch;                  /* Pointer to the matched character */
  char far *pszfString;                 /* Pointer to the true beginning of */
                                        /*   the string */

  if (pszSearchString == NULL || pszSearchString[0] == '\0')
    return (-1);

  uiLengthToEndOfSearch = uiLengthOfSearch;

  while ((pszfMatch = fbiInstr (cfpAreaToSearch,
                                pszSearchString,
                                uiLengthToEndOfSearch)) != NULL)
    {
#if 0
      if (KbHit())
        {
          if ((c = GetCh()) == ESC)
            return (SEARCH_CANCELED);
          else if (c == '\0')
            GetCh();
        }
#endif

      pszfString = fbMemString (pszfMatch, &iLength);

      iMaxInArray = max (AddToFoundArray (pszfString, iLength,
                                          msdFoundArray, iMaxArray),
                         iMaxInArray);

      /* Begin searching one byte after the found string */

      cfpAreaToSearch = pszfMatch + 1;

      /* If a string was found, set uiLengthToEndOfSearch to the */
      /* number of bytes left to search */

      uiLengthToEndOfSearch  =
          uiLengthOfSearch -
          ((unsigned) ((long int) cfpAreaToSearch & 0x0000ffff));
    }

#if 0
  if (KbHit())
    {
      if ((c = GetCh()) == ESC)
        return (SEARCH_CANCELED);
      else if (c == '\0')
        GetCh();
    }
#endif

  return (iMaxInArray);
}

/***********************************************************************
 * AddToFoundArray - Adds pszfString and iLength to the msdArray if
 *                   msdArray does not already contain this string.
 *
 * char far *pszfString - Far pointer to the area of memory containing
 *                       the string to store.
 *
 * int iStringLength   - Length of the string in memory.
 *
 * MEM_STRING_DATA *msdArray
 *                     - Pointer to structure for storing the
 *                       far string pointers and lengths.
 *
 * int iMaxArray       - Maximum size of the array (so we don't go
 *                       outside the bounds of the array.
 *
 * Global Variable:
 * fIncludeDuplicates  - Flag to determine wether to include duplicate
 *                       strings in the found array.
 *
 * Returns:  The element the string was stored in, or iMaxArray if the
 *           array was full.
 ***********************************************************************/

int AddToFoundArray (char far *pszfString,
                     int iStringLength,
                     MEM_STRING_DATA *msdArray,
                     int iMaxArray)
{
  register int i = 0;    /* Looping variable */

  /* Search to see if this pointer is already in the array */
  while (i < iMaxArray &&
         msdArray[i].cfpString != NULL &&
         msdArray[i].cfpString != pszfString)
    ++i;

  if (i == iMaxArray)
    return (iMaxArray);

  i = 0;

  /* Check to see if this string's contents has already been recorded */

  while (i < iMaxArray &&
         msdArray[i].cfpString != NULL &&
         _fmemcmp (msdArray[i].cfpString, pszfString,
                   max (msdArray[i].iStringLen, iStringLength)))
    ++i;

  /* Add the string if it was not already in the array */

  if (i < iMaxArray && msdArray[i].cfpString == NULL)
    {
      msdArray[i].cfpString  = pszfString;
      msdArray[i].iStringLen = iStringLength;
    }

  return (i + 1);
}

⌨️ 快捷键说明

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