sa-jdi

Record getAuxSectionDefinitionsRecord()
    {
      return (AuxSectionDefinitionsRecord)auxSectionDefinitionsRecord.getValue();
    }
  }
  
  class AuxFunctionDefinitionRecordImpl
    implements AuxFunctionDefinitionRecord
  {
    private int tagIndex;
    private int totalSize;
    private int pointerToLineNumber;
    private int pointerToNextFunction;
    
    AuxFunctionDefinitionRecordImpl(int offset)
    {
      this$1.seek(offset);
      tagIndex = this$1.readInt();
      totalSize = this$1.readInt();
      
      pointerToLineNumber = (this$1.readInt() - 1);
      pointerToNextFunction = this$1.readInt();
    }
    
    public int getTagIndex()
    {
      return tagIndex;
    }
    
    public int getTotalSize()
    {
      return totalSize;
    }
    
    public int getPointerToLineNumber()
    {
      return pointerToLineNumber;
    }
    
    public int getPointerToNextFunction()
    {
      return pointerToNextFunction;
    }
    
    public int getType()
    {
      return 0;
    }
  }
  
  class AuxBfEfRecordImpl
    implements AuxBfEfRecord
  {
    private short lineNumber;
    private int pointerToNextFunction;
    
    AuxBfEfRecordImpl(int offset)
    {
      this$1.seek(offset);
      this$1.readInt();
      lineNumber = this$1.readShort();
      this$1.readInt();
      this$1.readShort();
      pointerToNextFunction = this$1.readInt();
    }
    
    public short getLineNumber()
    {
      return lineNumber;
    }
    
    public int getPointerToNextFunction()
    {
      return pointerToNextFunction;
    }
    
    public int getType()
    {
      return 1;
    }
  }
  
  class AuxWeakExternalRecordImpl
    implements AuxWeakExternalRecord
  {
    private int tagIndex;
    private int characteristics;
    
    AuxWeakExternalRecordImpl(int offset)
    {
      this$1.seek(offset);
      tagIndex = this$1.readInt();
      characteristics = this$1.readInt();
    }
    
    public int getTagIndex()
    {
      return tagIndex;
    }
    
    public int getCharacteristics()
    {
      return characteristics;
    }
    
    public int getType()
    {
      return 2;
    }
  }
  
  class AuxFileRecordImpl
    implements AuxFileRecord
  {
    private String name;
    
    AuxFileRecordImpl(int offset)
    {
      this$1.seek(offset);
      byte[] tmpName = new byte[18];
      int numRead = this$1.readBytes(tmpName);
      if (numRead != 18) {
        throw new COFFException("Error reading auxiliary file record at offset " + offset);
      }
      try
      {
        name = new String(tmpName, "US-ASCII");
      }
      catch (UnsupportedEncodingException e)
      {
        throw new COFFException(e);
      }
    }
    
    public String getName()
    {
      return name;
    }
    
    public int getType()
    {
      return 3;
    }
  }
  
  class AuxSectionDefinitionsRecordImpl
    implements AuxSectionDefinitionsRecord
  {
    private int length;
    private short numberOfRelocations;
    private short numberOfLineNumbers;
    private int checkSum;
    private short number;
    private byte selection;
    
    AuxSectionDefinitionsRecordImpl(int offset)
    {
      this$1.seek(offset);
      length = this$1.readInt();
      numberOfRelocations = this$1.readShort();
      numberOfLineNumbers = this$1.readShort();
      checkSum = this$1.readInt();
      number = this$1.readShort();
      selection = this$1.readByte();
    }
    
    public int getLength()
    {
      return length;
    }
    
    public short getNumberOfRelocations()
    {
      return numberOfRelocations;
    }
    
    public short getNumberOfLineNumbers()
    {
      return numberOfLineNumbers;
    }
    
    public int getCheckSum()
    {
      return checkSum;
    }
    
    public short getNumber()
    {
      return number;
    }
    
    public byte getSelection()
    {
      return selection;
    }
    
    public int getType()
    {
      return 4;
    }
  }
  
  class COFFRelocationImpl
    implements COFFRelocation
  {
    private int virtualAddress;
    private int symbolTableIndex;
    private short type;
    
    COFFRelocationImpl(int offset)
    {
      this$1.seek(offset);
      virtualAddress = this$1.readInt();
      symbolTableIndex = this$1.readInt();
      type = this$1.readShort();
    }
    
    public int getVirtualAddress()
    {
      return virtualAddress;
    }
    
    public int getSymbolTableIndex()
    {
      return symbolTableIndex;
    }
    
    public short getType()
    {
      return type;
    }
  }
  
  class COFFLineNumberImpl
    implements COFFLineNumber
  {
    private int type;
    private short lineNumber;
    
    COFFLineNumberImpl(int offset)
    {
      this$1.seek(offset);
      type = this$1.readInt();
      lineNumber = this$1.readShort();
    }
    
    public int getType()
    {
      return type;
    }
    
    public short getLineNumber()
    {
      return lineNumber;
    }
  }
  
  class StringTable
  {
    COFFString[] strings;
    
    class COFFString
    {
      String str;
      int offset;
      
      COFFString(String str, int offset)
      {
        this.str = str;this.offset = offset;
      }
    }
    
    StringTable(int offset)
    {
      if (offset == 0)
      {
        strings = new COFFString[0];
        return;
      }
      this$1.seek(offset);
      int length = this$1.readInt();
      byte[] data = new byte[length - 4];
      int numBytesRead = this$1.readBytes(data);
      if (numBytesRead != data.length) {
        throw new COFFException("Error reading string table (read " + numBytesRead + " bytes, expected to read " + data.length + ")");
      }
      int numStrings = 0;
      int ptr = 0;
      for (ptr = 0; ptr < data.length; ptr++) {
        if (data[ptr] == 0) {
          numStrings++;
        }
      }
      strings = new COFFString[numStrings];
      int lastPtr = 0;
      ptr = 0;
      for (int i = 0; i < numStrings; i++)
      {
        while (data[ptr] != 0) {
          ptr++;
        }
        try
        {
          strings[i] = new COFFString(new String(data, lastPtr, ptr - lastPtr, "US-ASCII"), offset + ptr + 4);
        }
        catch (UnsupportedEncodingException e)
        {
          throw new COFFException(e);
        }
        ptr++;
        lastPtr = ptr;
      }
    }
    
    int getNum()
    {
      return strings.length;
    }
    
    String get(int i)
    {
      return strings[i].str;
    }
    
    String getAtOffset(int offset)
    {
      int i = Arrays.binarySearch(strings, new COFFString(null, offset), new Comparator()
      {
        public int compare(Object o1, Object o2)
        {
          COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable.COFFString s1 = (COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable.COFFString)o1;
          COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable.COFFString s2 = (COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable.COFFString)o2;
          if (offset == offset) {
            return 0;
          }
          if (offset < offset) {
            return -1;
          }
          return 1;
        }
      });
      if (i < 0) {
        throw new COFFException("No string found at file offset " + offset);
      }
      return strings[i].str;
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.win32.coff.COFFFileParser.COFFFileImpl.COFFHeaderImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.win32.coff;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.NoSuchElementException;
import sun.jvm.hotspot.debugger.DataSource;
import sun.jvm.hotspot.utilities.Assert;
import sun.jvm.hotspot.utilities.memo.MemoizedObject;

class COFFFileParser$COFFFileImpl
  implements COFFFile
{
  private DataSource file;
  private long filePos;
  private boolean isImage;
  private long imageHeaderOffset;
  private MemoizedObject header = new MemoizedObject()
  {
    public Object computeValue()
    {
      return new COFFFileParser.COFFFileImpl.COFFHeaderImpl(COFFFileParser.COFFFileImpl.this);
    }
  };
  private final COFFFileParser this$0;
  
  COFFFileParser$COFFFileImpl(COFFFileParser paramCOFFFileParser, DataSource file)
    throws COFFException
  {
    this.file = file;
    initialize();
  }
  
  public boolean isImage()
  {
    return isImage;
  }
  
  public COFFHeader getHeader()
  {
    return (COFFHeaderImpl)header.getValue();
  }
  
  class COFFHeaderImpl
    implements COFFHeader
  {
    private short machine;
    private short numberOfSections;
    private int timeDateStamp;
    private int pointerToSymbolTable;
    private int numberOfSymbols;
    private short sizeOfOptionalHeader;
    private short characteristics;
    private MemoizedObject[] sectionHeaders;
    private MemoizedObject[] symbols;
    private MemoizedObject stringTable = new MemoizedObject()
    {
      public Object computeValue()
      {
        int ptr = getPointerToSymbolTable();
        if (ptr == 0) {
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, 0);
        }
        return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.StringTable(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, ptr + 18 * getNumberOfSymbols());
      }
    };
    
    COFFHeaderImpl()
    {
      seek(imageHeaderOffset);
      machine = readShort();
      numberOfSections = readShort();
      timeDateStamp = readInt();
      pointerToSymbolTable = readInt();
      numberOfSymbols = readInt();
      
      sizeOfOptionalHeader = readShort();
      characteristics = readShort();
      
      sectionHeaders = new MemoizedObject[numberOfSections];
      for (int i = 0; i < numberOfSections; i++)
      {
        final int secHdrOffset = (int)(imageHeaderOffset + 20L + sizeOfOptionalHeader + i * 40);
        
        sectionHeaders[i = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.SectionHeaderImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, secHdrOffset);
          }
        };
      }
      symbols = new MemoizedObject[numberOfSymbols];
      for (int i = 0; i < numberOfSymbols; i++)
      {
        final int symbolOffset = pointerToSymbolTable + i * 18;
        symbols[i = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.COFFSymbolImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, symbolOffset);
          }
        };
      }
    }
    
    public short getMachineType()
    {
      return machine;
    }
    
    public short getNumberOfSections()
    {
      return numberOfSections;
    }
    
    public int getTimeDateStamp()
    {
      return timeDateStamp;
    }
    
    public int getPointerToSymbolTable()
    {
      return pointerToSymbolTable;
    }
    
    public int getNumberOfSymbols()
    {
      return numberOfSymbols;
    }
    
    public short getSizeOfOptionalHeader()
    {
      return sizeOfOptionalHeader;
    }
    
    public OptionalHeader getOptionalHeader()
      throws COFFException
    {
      if (getSizeOfOptionalHeader() == 0) {
        return null;
      }
      return new OptionalHeaderImpl((int)(imageHeaderOffset + 20L));
    }
    
    public short getCharacteristics()
    {
      return characteristics;
    }
    
    public boolean hasCharacteristic(short characteristic)
    {
      return (characteristics & characteristic) != 0;
    }
    
    public SectionHeader getSectionHeader(int index)
    {
      return (SectionHeader)sectionHeaders[(index - 1)].getValue();
    }
    
    public COFFSymbol getCOFFSymbol(int index)
    {
      return (COFFSymbol)symbols[index].getValue();
    }
    
    public int getNumberOfStrings()
    {
      return getStringTable().getNum();
    }
    
    public String getString(int i)
    {
      return getStringTable().get(i);
    }
    
    StringTable getStringTable()
    {
      return (StringTable)stringTable.getValue();
    }
    
    int rvaToFileOffset(int rva)
    {
      if (rva == 0) {
        return 0;
      }
      for (int i = 1; i <= getNumberOfSections(); i++)
      {
        SectionHeader sec = getSectionHeader(i);
        int va = sec.getVirtualAddress();
        int sz = sec.getSize();
        if ((va <= rva) && (rva < va + sz)) {
          return sec.getPointerToRawData() + (rva - va);
        }
      }
      throw new COFFException("Unable to find RVA 0x" + Integer.toHexString(rva) + " in any section");
    }
    
    class OptionalHeaderImpl
      implements OptionalHeader
    {
      private short magic;
      private MemoizedObject standardFields;
      private MemoizedObject windowsSpecificFields;
      private MemoizedObject dataDirectories;
      private static final int STANDARD_FIELDS_OFFSET = 2;
      private static final int PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET = 28;
      private static final int PE32_DATA_DIRECTORIES_OFFSET = 96;
      private static final int PE32_PLUS_WINDOWS_SPECIFIC_FIELDS_OFFSET = 24;
      private static final int PE32_PLUS_DATA_DIRECTORIES_OFFSET = 112;
      
      OptionalHeaderImpl(int offset)
      {
        seek(offset);
        magic = readShort();
        
        final boolean isPE32Plus = magic == 523;
        final int standardFieldsOffset = offset + 2;
        final int windowsSpecificFieldsOffset = offset + (isPE32Plus ? 24 : 28);
        
        final int dataDirectoriesOffset = offset + (isPE32Plus ? 112 : 96);
        
        standardFields = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.OptionalHeaderStandardFieldsImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, standardFieldsOffset, isPE32Plus);
          }
        };
        windowsSpecificFields = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.OptionalHeaderWindowsSpecificFieldsImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, windowsSpecificFieldsOffset, isPE32Plus);
          }
        };
        dataDirectories = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.OptionalHeaderDataDirectoriesImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, dataDirectoriesOffset, getWindowsSpecificFields().getNumberOfRvaAndSizes());
          }
        };
      }
      
      public short getMagicNumber()
      {
        return magic;
      }
      
      public OptionalHeaderStandardFields getStandardFields()
      {
        return (OptionalHeaderStandardFields)standardFields.getValue();
      }
      
      public OptionalHeaderWindowsSpecificFields getWindowsSpecificFields()
      {
        return (OptionalHeaderWindowsSpecificFields)windowsSpecificFields.getValue();
      }
      
      public OptionalHeaderDataDirectories getDataDirectories()
      {
        return (OptionalHeaderDataDirectories)dataDirectories.getValue();
      }
    }
    
    class OptionalHeaderStandardFieldsImpl
      implements OptionalHeaderStandardFields
    {
      private boolean isPE32Plus;
      private byte majorLinkerVersion;
      private byte minorLinkerVersion;
      private int sizeOfCode;
      private int sizeOfInitializedData;
      private int sizeOfUninitializedData;
      private int addressOfEntryPoint;
      private int baseOfCode;
      private int baseOfData;
      
      OptionalHeaderStandardFieldsImpl(int offset, boolean isPE32Plus)
      {
        this.isPE32Plus = isPE32Plus;
        seek(offset);
        majorLinkerVersion = readByte();
        minorLinkerVersion = readByte();
        sizeOfCode = readInt();
        sizeOfInitializedData = readInt();
        sizeOfUninitializedData = readInt();
        addressOfEntryPoint = readInt();
        baseOfCode = readInt();
        if (!isPE32Plus) {
          baseOfData = readInt();
        }
      }
      
      public byte getMajorLinkerVersion()
      {
        return majorLinkerVersion;
      }
      
      public byte getMinorLinkerVersion()
      {
        return minorLinkerVersion;
      }
      
      public int getSizeOfCode()
      {
        return sizeOfCode;
      }
      
      public int getSizeOfInitializedData()
      {
        return sizeOfInitializedData;
      }
      
      public int getSizeOfUninitializedData()
      {
        return sizeOfUninitializedData;
      }
      
      public int getAddressOfEntryPoint()
      {
        return addressOfEntryPoint;
      }
      
      public int getBaseOfCode()
      {
        return baseOfCode;
      }
      
      public int getBaseOfData()
        throws COFFException
      {
        if (isPE32Plus) {
          throw new COFFException("Not present in PE32+ files");
        }
        return baseOfData;
      }
    }
    
    class OptionalHeaderWindowsSpecificFieldsImpl
      implements OptionalHeaderWindowsSpecificFields
    {
      private long imageBase;
      private int sectionAlignment;
      private int fileAlignment;
      private short majorOperatingSystemVersion;
      private short minorOperatingSystemVersion;
      private short majorImageVersion;
      private short minorImageVersion;
      private short majorSubsystemVersion;
      private short minorSubsystemVersion;
      private int sizeOfImage;
      private int sizeOfHeaders;
      private int checkSum;
      private short subsystem;
      private short dllCharacteristics;
      private long sizeOfStackReserve;
      private long sizeOfStackCommit;
      private long sizeOfHeapReserve;
      private long sizeOfHeapCommit;
      private int loaderFlags;
      private int numberOfRvaAndSizes;
      
      OptionalHeaderWindowsSpecificFieldsImpl(int offset, boolean isPE32Plus)
      {
        seek(offset);
        if (!isPE32Plus) {
          imageBase = maskInt(readInt());
        } else {
          imageBase = readLong();
        }
        sectionAlignment = readInt();
        fileAlignment = readInt();
        majorOperatingSystemVersion = readShort();
        minorOperatingSystemVersion = readShort();
        majorImageVersion = readShort();
        minorImageVersion = readShort();
        majorSubsystemVersion = readShort();
        minorSubsystemVersion = readShort();
        readInt();
        sizeOfImage = readInt();
        sizeOfHeaders = readInt();
        checkSum = readInt();
        subsystem = readShort();
        dllCharacteristics = readShort();
        if (!isPE32Plus)
        {
          sizeOfStackReserve = maskInt(readInt());
          sizeOfStackCommit = maskInt(readInt());
          sizeOfHeapReserve = maskInt(readInt());
          sizeOfHeapCommit = maskInt(readInt());
        }
        else
        {
          sizeOfStackReserve = readLong();
          sizeOfStackCommit = readLong();
          sizeOfHeapReserve = readLong();
          sizeOfHeapCommit = readLong();
        }
        loaderFlags = readInt();
        numberOfRvaAndSizes = readInt();
      }
      
      public long getImageBase()
      {
        return imageBase;
      }
      
      public int getSectionAlignment()
      {
        return sectionAlignment;
      }
      
      public int getFileAlignment()
      {
        return fileAlignment;
      }
      
      public short getMajorOperatingSystemVersion()
      {
        return majorOperatingSystemVersion;
      }
      
      public short getMinorOperatingSystemVersion()
      {
        return minorOperatingSystemVersion;
      }
      
      public short getMajorImageVersion()
      {
        return majorImageVersion;
      }
      
      public short getMinorImageVersion()
      {
        return minorImageVersion;
      }
      
      public short getMajorSubsystemVersion()
      {
        return majorSubsystemVersion;
      }
      
      public short getMinorSubsystemVersion()
      {
        return minorSubsystemVersion;
      }
      
      public int getSizeOfImage()
      {
        return sizeOfImage;
      }
      
      public int getSizeOfHeaders()
      {
        return sizeOfHeaders;
      }
      
      public int getCheckSum()
      {
        return checkSum;
      }
      
      public short getSubsystem()
      {
        return subsystem;
      }
      
      public short getDLLCharacteristics()
      {
        return dllCharacteristics;
      }
      
      public long getSizeOfStackReserve()
      {
        return sizeOfStackReserve;
      }
      
      public long getSizeOfStackCommit()
      {
        return sizeOfStackCommit;
      }
      
      public long getSizeOfHeapReserve()
      {
        return sizeOfHeapReserve;
      }
      
      public long getSizeOfHeapCommit()
      {
        return sizeOfHeapCommit;
      }
      
      public int getLoaderFlags()
      {
        return loaderFlags;
      }
      
      public int getNumberOfRvaAndSizes()
      {
        return numberOfRvaAndSizes;
      }
      
      private long maskInt(long arg)
      {
        return arg & 0xFFFFFFFF;
      }
    }
    
    class OptionalHeaderDataDirectoriesImpl
      implements OptionalHeaderDataDirectories
    {
      private int numberOfRvaAndSizes;
      private MemoizedObject[] dataDirectories;
      private MemoizedObject exportDirectoryTable;
      private MemoizedObject debugDirectory;
      private static final int DATA_DIRECTORY_SIZE = 8;
      
      OptionalHeaderDataDirectoriesImpl(int offset, int numberOfRvaAndSizes)
      {
        this.numberOfRvaAndSizes = numberOfRvaAndSizes;
        dataDirectories = new MemoizedObject[numberOfRvaAndSizes];
        for (int i = 0; i < numberOfRvaAndSizes; i++)
        {
          final int dirOffset = offset + i * 8;
          dataDirectories[i = new MemoizedObject()
          {
            public Object computeValue()
            {
              return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DataDirectoryImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, dirOffset);
            }
          };
        }
        exportDirectoryTable = new MemoizedObject()
        {
          public Object computeValue()
          {
            DataDirectory dir = getExportTable();
            if ((dir.getRVA() == 0) || (dir.getSize() == 0)) {
              return null;
            }
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.ExportDirectoryTableImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, dir.getRVA(), dir.getSize());
          }
        };
        debugDirectory = new MemoizedObject()
        {
          public Object computeValue()
          {
            DataDirectory dir = getDebug();
            if ((dir.getRVA() == 0) || (dir.getSize() == 0)) {
              return null;
            }
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugDirectoryImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, rvaToFileOffset(dir.getRVA()), dir.getSize());
          }
        };
      }
      
      public DataDirectory getExportTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(0)].getValue();
      }
      
      public DataDirectory getImportTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(1)].getValue();
      }
      
      public DataDirectory getResourceTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(2)].getValue();
      }
      
      public DataDirectory getExceptionTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(3)].getValue();
      }
      
      public DataDirectory getCertificateTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(4)].getValue();
      }
      
      public DataDirectory getBaseRelocationTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(5)].getValue();
      }
      
      public DataDirectory getDebug()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(6)].getValue();
      }
      
      public DataDirectory getArchitecture()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(7)].getValue();
      }
      
      public DataDirectory getGlobalPtr()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(8)].getValue();
      }
      
      public DataDirectory getTLSTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(9)].getValue();
      }
      
      public DataDirectory getLoadConfigTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(10)].getValue();
      }
      
      public DataDirectory getBoundImportTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(11)].getValue();
      }
      
      public DataDirectory getImportAddressTable()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(12)].getValue();
      }
      
      public DataDirectory getDelayImportDescriptor()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(13)].getValue();
      }
      
      public DataDirectory getCOMPlusRuntimeHeader()
        throws COFFException
      {
        return (DataDirectory)dataDirectories[checkIndex(14)].getValue();
      }
      
      public ExportDirectoryTable getExportDirectoryTable()
        throws COFFException
      {
        return (ExportDirectoryTable)exportDirectoryTable.getValue();
      }
      
      public DebugDirectory getDebugDirectory()
        throws COFFException
      {
        return (DebugDirectory)debugDirectory.getValue();
      }
      
      private int checkIndex(int index)
        throws COFFException
      {
        if ((index < 0) || (index >= dataDirectories.length)) {
          throw new COFFException("Directory " + index + " unavailable (only " + numberOfRvaAndSizes + " tables present)");
        }
        return index;
      }
    }
    
    class DataDirectoryImpl
      implements DataDirectory
    {
      int rva;
      int size;
      
      DataDirectoryImpl(int offset)
      {
        seek(offset);
        rva = readInt();
        size = readInt();
      }
      
      public int getRVA()
      {
        return rva;
      }
      
      public int getSize()
      {
        return size;
      }
    }
    
    class ExportDirectoryTableImpl
      implements ExportDirectoryTable
    {
      private int exportDataDirRVA;
      private int offset;
      private int size;
      private int exportFlags;
      private int timeDateStamp;
      private short majorVersion;
      private short minorVersion;
      private int nameRVA;
      private int ordinalBase;
      private int addressTableEntries;
      private int numberOfNamePointers;
      private int exportAddressTableRVA;
      private int namePointerTableRVA;
      private int ordinalTableRVA;
      private MemoizedObject dllName;
      private MemoizedObject exportNameTable;
      private MemoizedObject exportNamePointerTable;
      private MemoizedObject exportOrdinalTable;
      private MemoizedObject exportAddressTable;
      
      ExportDirectoryTableImpl(int exportDataDirRVA, int size)
      {
        this.exportDataDirRVA = exportDataDirRVA;
        offset = rvaToFileOffset(exportDataDirRVA);
        this.size = size;
        seek(offset);
        exportFlags = readInt();
        timeDateStamp = readInt();
        majorVersion = readShort();
        minorVersion = readShort();
        nameRVA = readInt();
        ordinalBase = readInt();
        addressTableEntries = readInt();
        numberOfNamePointers = readInt();
        exportAddressTableRVA = readInt();
        namePointerTableRVA = readInt();
        ordinalTableRVA = readInt();
        
        dllName = new MemoizedObject()
        {
          public Object computeValue()
          {
            seek(rvaToFileOffset(getNameRVA()));
            return readCString();
          }
        };
        exportNamePointerTable = new MemoizedObject()
        {
          public Object computeValue()
          {
            int[] pointers = new int[getNumberOfNamePointers()];
            seek(rvaToFileOffset(getNamePointerTableRVA()));
            for (int i = 0; i < pointers.length; i++) {
              pointers[i] = readInt();
            }
            for (int i = 0; i < pointers.length; i++) {
              pointers[i] = rvaToFileOffset(pointers[i]);
            }
            return pointers;
          }
        };
        exportNameTable = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.ExportNameTable(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, COFFFileParser.COFFFileImpl.COFFHeaderImpl.ExportDirectoryTableImpl.this.getExportNamePointerTable());
          }
        };
        exportOrdinalTable = new MemoizedObject()
        {
          public Object computeValue()
          {
            short[] ordinals = new short[getNumberOfNamePointers()];
            seek(rvaToFileOffset(getOrdinalTableRVA()));
            for (int i = 0; i < ordinals.length; i++) {
              ordinals[i] = readShort();
            }
            return ordinals;
          }
        };
        exportAddressTable = new MemoizedObject()
        {
          public Object computeValue()
          {
            int[] addresses = new int[getNumberOfAddressTableEntries()];
            seek(rvaToFileOffset(getExportAddressTableRVA()));
            for (int i = 0; i < addresses.length; i++) {
              addresses[i] = readInt();
            }
            return addresses;
          }
        };
      }
      
      public int getExportFlags()
      {
        return exportFlags;
      }
      
      public int getTimeDateStamp()
      {
        return timeDateStamp;
      }
      
      public short getMajorVersion()
      {
        return majorVersion;
      }
      
      public short getMinorVersion()
      {
        return minorVersion;
      }
      
      public int getNameRVA()
      {
        return nameRVA;
      }
      
      public String getDLLName()
      {
        return (String)dllName.getValue();
      }
      
      public int getOrdinalBase()
      {
        return ordinalBase;
      }
      
      public int getNumberOfAddressTableEntries()
      {
        return addressTableEntries;
      }
      
      public int getNumberOfNamePointers()
      {
        return numberOfNamePointers;
      }
      
      public int getExportAddressTableRVA()
      {
        return exportAddressTableRVA;
      }
      
      public int getNamePointerTableRVA()
      {
        return namePointerTableRVA;
      }
      
      public int getOrdinalTableRVA()
      {
        return ordinalTableRVA;
      }
      
      public String getExportName(int i)
      {
        return getExportNameTable().get(i);
      }
      
      public short getExportOrdinal(int i)
      {
        return getExportOrdinalTable()[i];
      }
      
      public boolean isExportAddressForwarder(short ordinal)
      {
        int addr = getExportAddress(ordinal);
        return (exportDataDirRVA <= addr) && (addr < exportDataDirRVA + size);
      }
      
      public String getExportAddressForwarder(short ordinal)
      {
        seek(rvaToFileOffset(getExportAddress(ordinal)));
        return readCString();
      }
      
      public int getExportAddress(short ordinal)
      {
        return getExportAddressTable()[ordinal];
      }
      
      private COFFFileParser.COFFFileImpl.COFFHeaderImpl.ExportNameTable getExportNameTable()
      {
        return (COFFFileParser.COFFFileImpl.COFFHeaderImpl.ExportNameTable)exportNameTable.getValue();
      }
      
      private int[] getExportNamePointerTable()
      {
        return (int[])exportNamePointerTable.getValue();
      }
      
      private short[] getExportOrdinalTable()
      {
        return (short[])exportOrdinalTable.getValue();
      }
      
      private int[] getExportAddressTable()
      {
        return (int[])exportAddressTable.getValue();
      }
    }
    
    class ExportNameTable
    {
      private MemoizedObject[] names;
      
      ExportNameTable(final int[] exportNamePointerTable)
      {
        names = new MemoizedObject[exportNamePointerTable.length];
        for (int i = 0; i < exportNamePointerTable.length; i++)
        {
          final int idx = i;
          names[idx = new MemoizedObject()
          {
            public Object computeValue()
            {
              seek(exportNamePointerTable[idx]);
              return readCString();
            }
          };
        }
      }
      
      String get(int i)
      {
        return (String)names[i].getValue();
      }
    }
    
    class DebugDirectoryImpl
      implements DebugDirectory
    {
      private int offset;
      private int size;
      private int numEntries;
      private static final int DEBUG_DIRECTORY_ENTRY_SIZE = 28;
      
      DebugDirectoryImpl(int offset, int size)
      {
        this.offset = offset;
        this.size = size;
        if (size % 28 != 0) {
          throw new COFFException("Corrupt DebugDirectory at offset 0x" + Integer.toHexString(offset));
        }
        numEntries = (size / 28);
      }
      
      public int getNumEntries()
      {
        return numEntries;
      }
      
      public DebugDirectoryEntry getEntry(int i)
      {
        if ((i < 0) || (i >= getNumEntries())) {
          throw new IndexOutOfBoundsException();
        }
        return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugDirectoryEntryImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, offset + i * 28);
      }
    }
    
    class DebugDirectoryEntryImpl
      implements DebugDirectoryEntry, DebugTypes
    {
      private int characteristics;
      private int timeDateStamp;
      private short majorVersion;
      private short minorVersion;
      private int type;
      private int sizeOfData;
      private int addressOfRawData;
      private int pointerToRawData;
      
      DebugDirectoryEntryImpl(int offset)
      {
        seek(offset);
        characteristics = readInt();
        timeDateStamp = readInt();
        majorVersion = readShort();
        minorVersion = readShort();
        type = readInt();
        sizeOfData = readInt();
        addressOfRawData = readInt();
        pointerToRawData = readInt();
      }
      
      public int getCharacteristics()
      {
        return characteristics;
      }
      
      public int getTimeDateStamp()
      {
        return timeDateStamp;
      }
      
      public short getMajorVersion()
      {
        return majorVersion;
      }
      
      public short getMinorVersion()
      {
        return minorVersion;
      }
      
      public int getType()
      {
        return type;
      }
      
      public int getSizeOfData()
      {
        return sizeOfData;
      }
      
      public int getAddressOfRawData()
      {
        return addressOfRawData;
      }
      
      public int getPointerToRawData()
      {
        return pointerToRawData;
      }
      
      public DebugVC50 getDebugVC50()
      {
        try
        {
          if (getType() != 2) {
            return null;
          }
          int offset = getPointerToRawData();
          seek(offset);
          if ((readByte() == 78) && (readByte() == 66) && (readByte() == 49) && (readByte() == 49)) {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.this, offset);
          }
        }
        catch (COFFException e)
        {
          e.printStackTrace();
        }
        return null;
      }
      
      public byte getRawDataByte(int i)
      {
        if ((i < 0) || (i >= getSizeOfData())) {
          throw new IndexOutOfBoundsException();
        }
        seek(getPointerToRawData() + i);
        return readByte();
      }
    }
    
    class DebugVC50Impl
      implements DebugVC50, DebugVC50TypeLeafIndices
    {
      private int lfaBase;
      private int subsectionDirectoryOffset;
      private MemoizedObject subsectionDirectory;
      
      DebugVC50Impl(int offset)
      {
        lfaBase = offset;
        seek(offset);
        readInt();
        subsectionDirectoryOffset = globalOffset(readInt());
        
        verify();
        
        subsectionDirectory = new MemoizedObject()
        {
          public Object computeValue()
          {
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SubsectionDirectoryImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, getSubsectionDirectoryOffset());
          }
        };
      }
      
      public int getSubsectionDirectoryOffset()
      {
        return subsectionDirectoryOffset;
      }
      
      public DebugVC50SubsectionDirectory getSubsectionDirectory()
      {
        return (DebugVC50SubsectionDirectory)subsectionDirectory.getValue();
      }
      
      private int globalOffset(int offset)
      {
        return offset + lfaBase;
      }
      
      private void verify()
      {
        seek(subsectionDirectoryOffset);
        int headerLength = readShort();
        int entryLength = readShort();
        int numEntries = readInt();
        int endOffset = subsectionDirectoryOffset + headerLength + numEntries * entryLength;
        seek(endOffset);
        if ((readByte() == 78) && (readByte() == 66) && (readByte() == 49) && (readByte() == 49)) {
          return;
        }
        throw new COFFException("Did not find NB11 signature at end of debug info");
      }
      
      class DebugVC50SubsectionDirectoryImpl
        implements DebugVC50SubsectionDirectory, DebugVC50SubsectionTypes
      {
        private int offset;
        private short dirHeaderLength;
        private short dirEntryLength;
        private int numEntries;
        
        DebugVC50SubsectionDirectoryImpl(int offset)
        {
          this.offset = offset;
          
          seek(offset);
          dirHeaderLength = readShort();
          dirEntryLength = readShort();
          numEntries = readInt();
        }
        
        public short getHeaderLength()
        {
          return dirHeaderLength;
        }
        
        public short getEntryLength()
        {
          return dirEntryLength;
        }
        
        public int getNumEntries()
        {
          return numEntries;
        }
        
        public DebugVC50Subsection getSubsection(int i)
        {
          seek(offset + dirHeaderLength + i * dirEntryLength);
          short ssType = readShort();
          short iMod = readShort();
          int lfo = COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this.globalOffset(readInt());
          int cb = readInt();
          switch (ssType)
          {
          case 288: 
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSModuleImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
          case 289: 
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSTypesImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
          case 290: 
            return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSPublicImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd