Ignore:
Timestamp:
Jun 5, 2001, 6:46:01 PM (24 years ago)
Author:
phaller
Message:

Fix for the ordinal exports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/winimagepeldr.cpp

    r5859 r5909  
    1 /* $Id: winimagepeldr.cpp,v 1.80 2001-06-01 08:10:48 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.81 2001-06-05 16:44:46 phaller Exp $ */
    22
    33/*
     
    18871887
    18881888    curexport = ordexports;
    1889 
     1889 
     1890#if 1
     1891  /* accelerated resolving of ordinal exports
     1892   * is based on the assumption the ordinal export
     1893   * table is always sorted ascending.
     1894   *
     1895   * When the step size is too small, we continue
     1896   * with the linear search.
     1897   */
     1898 
     1899  // start in the middle of the tree
     1900  i = nrOrdExports >> 1;
     1901  int iStep = i;
     1902 
     1903  for(;;)
     1904  {
     1905    int iThisExport = curexport[i].ordinal;
     1906   
     1907    iStep >>= 1;                    // next step will be narrower
     1908
     1909    if (iThisExport < ordinal)
     1910      i += iStep;                   // move farther down the list
     1911    else
     1912      if (iThisExport == ordinal)   // found the export?
     1913        return curexport[i].virtaddr;
     1914      else
     1915        i -= iStep;                 // move farther up the list
     1916
     1917    // if we're in the direct neighbourhood search linearly
     1918    if (iStep <= 1)
     1919    {
     1920      // decide if we're to search backward or forward
     1921      if (ordinal > curexport[i].ordinal)
     1922      {
     1923        // As a certain number of exports are 0 at the end
     1924        // of the array, this case will hit fairly often.
     1925        // the last comparison will send the loop off into the
     1926        // wrong direction!
     1927        if (curexport[i].ordinal == 0)
     1928        {
     1929          // start over with plain dump search
     1930          for(i = 0; i < nrOrdExports; i++)
     1931          {
     1932            if(curexport[i].ordinal == ordinal)
     1933              return(curexport[i].virtaddr);
     1934          }
     1935          break; // not found yet!
     1936        }
     1937       
     1938        for (;i<nrOrdExports;i++) // scan forward
     1939        {
     1940          iThisExport = curexport[i].ordinal;
     1941          if(iThisExport == ordinal)
     1942            return(curexport[i].virtaddr);
     1943          else
     1944            if (iThisExport > ordinal)
     1945            {
     1946              // Oops, cannot find the ordinal in the sorted list
     1947              break;
     1948            }
     1949        }
     1950      }
     1951      else
     1952      {
     1953        for (;i>=0;i--) // scan backward
     1954        {
     1955          iThisExport = curexport[i].ordinal;
     1956          if(curexport[i].ordinal == ordinal)
     1957            return(curexport[i].virtaddr);
     1958          else
     1959            if (iThisExport < ordinal)
     1960              // Oops, cannot find the ordinal in the sorted list
     1961              break;
     1962        }
     1963      }
     1964     
     1965      // not found yet.
     1966      break;
     1967    }
     1968  }
     1969#endif
     1970 
     1971 
     1972#if 0
    18901973    i = 0;   
    18911974    if(nrOrdExports > 1000) {
     
    19272010        if(i >= nrOrdExports) i -= 10;
    19282011    }
     2012#endif
     2013 
     2014#if 0
    19292015    for(i;i<nrOrdExports;i++) {
    19302016        if(curexport[i].ordinal == ordinal)
    19312017            return(curexport[i].virtaddr);
    19322018    }
     2019#endif
    19332020
    19342021    //Name exports also contain an ordinal, so check this
Note: See TracChangeset for help on using the changeset viewer.