sa-jdi

HeaderImpl
  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;
  private final COFFFileParser.COFFFileImpl this$1;
  
  /* Error */
  COFFFileParser$COFFFileImpl$COFFHeaderImpl(COFFFileParser.COFFFileImpl arg1)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: putfield 1	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:this$1	Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl;
    //   5: aload_0
    //   6: invokespecial 2	java/lang/Object:<init>	()V
    //   9: aload_0
    //   10: new 3	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$1
    //   13: dup
    //   14: aload_0
    //   15: invokespecial 4	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$1:<init>	(Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl;)V
    //   18: putfield 5	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:stringTable	Lsun/jvm/hotspot/utilities/memo/MemoizedObject;
    //   21: aload_1
    //   22: aload_1
    //   23: invokestatic 6	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:access$000	(Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl;)J
    //   26: invokevirtual 7	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:seek	(J)V
    //   29: aload_0
    //   30: aload_1
    //   31: invokevirtual 8	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readShort	()S
    //   34: putfield 9	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:machine	S
    //   37: aload_0
    //   38: aload_1
    //   39: invokevirtual 8	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readShort	()S
    //   42: putfield 10	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSections	S
    //   45: aload_0
    //   46: aload_1
    //   47: invokevirtual 11	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readInt	()I
    //   50: putfield 12	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:timeDateStamp	I
    //   53: aload_0
    //   54: aload_1
    //   55: invokevirtual 11	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readInt	()I
    //   58: putfield 13	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:pointerToSymbolTable	I
    //   61: aload_0
    //   62: aload_1
    //   63: invokevirtual 11	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readInt	()I
    //   66: putfield 14	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSymbols	I
    //   69: aload_0
    //   70: aload_1
    //   71: invokevirtual 8	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readShort	()S
    //   74: putfield 15	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:sizeOfOptionalHeader	S
    //   77: aload_0
    //   78: aload_1
    //   79: invokevirtual 8	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:readShort	()S
    //   82: putfield 16	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:characteristics	S
    //   85: aload_0
    //   86: aload_0
    //   87: getfield 10	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSections	S
    //   90: anewarray 17	sun/jvm/hotspot/utilities/memo/MemoizedObject
    //   93: putfield 18	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:sectionHeaders	[Lsun/jvm/hotspot/utilities/memo/MemoizedObject;
    //   96: iconst_0
    //   97: istore_2
    //   98: iload_2
    //   99: aload_0
    //   100: getfield 10	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSections	S
    //   103: if_icmpge +47 -> 150
    //   106: aload_1
    //   107: invokestatic 6	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl:access$000	(Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl;)J
    //   110: ldc2_w 19
    //   113: ladd
    //   114: aload_0
    //   115: getfield 15	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:sizeOfOptionalHeader	S
    //   118: i2l
    //   119: ladd
    //   120: iload_2
    //   121: bipush 40
    //   123: imul
    //   124: i2l
    //   125: ladd
    //   126: l2i
    //   127: istore_3
    //   128: aload_0
    //   129: getfield 18	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:sectionHeaders	[Lsun/jvm/hotspot/utilities/memo/MemoizedObject;
    //   132: iload_2
    //   133: new 21	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$2
    //   136: dup
    //   137: aload_0
    //   138: aload_1
    //   139: iload_3
    //   140: invokespecial 22	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$2:<init>	(Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl;Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl;I)V
    //   143: aastore
    //   144: iinc 2 1
    //   147: goto -49 -> 98
    //   150: aload_0
    //   151: aload_0
    //   152: getfield 14	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSymbols	I
    //   155: anewarray 17	sun/jvm/hotspot/utilities/memo/MemoizedObject
    //   158: putfield 23	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:symbols	[Lsun/jvm/hotspot/utilities/memo/MemoizedObject;
    //   161: iconst_0
    //   162: istore_2
    //   163: iload_2
    //   164: aload_0
    //   165: getfield 14	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:numberOfSymbols	I
    //   168: if_icmpge +35 -> 203
    //   171: aload_0
    //   172: getfield 13	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:pointerToSymbolTable	I
    //   175: iload_2
    //   176: bipush 18
    //   178: imul
    //   179: iadd
    //   180: istore_3
    //   181: aload_0
    //   182: getfield 23	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl:symbols	[Lsun/jvm/hotspot/utilities/memo/MemoizedObject;
    //   185: iload_2
    //   186: new 24	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$3
    //   189: dup
    //   190: aload_0
    //   191: aload_1
    //   192: iload_3
    //   193: invokespecial 25	sun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl$3:<init>	(Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl$COFFHeaderImpl;Lsun/jvm/hotspot/debugger/win32/coff/COFFFileParser$COFFFileImpl;I)V
    //   196: aastore
    //   197: iinc 2 1
    //   200: goto -37 -> 163
    //   203: return
    // Line number table:
    //   Java source line #140	-> byte code offset #0
    //   Java source line #127	-> byte code offset #9
    //   Java source line #141	-> byte code offset #21
    //   Java source line #142	-> byte code offset #29
    //   Java source line #143	-> byte code offset #37
    //   Java source line #144	-> byte code offset #45
    //   Java source line #145	-> byte code offset #53
    //   Java source line #146	-> byte code offset #61
    //   Java source line #149	-> byte code offset #69
    //   Java source line #150	-> byte code offset #77
    //   Java source line #153	-> byte code offset #85
    //   Java source line #154	-> byte code offset #96
    //   Java source line #155	-> byte code offset #106
    //   Java source line #157	-> byte code offset #128
    //   Java source line #154	-> byte code offset #144
    //   Java source line #165	-> byte code offset #150
    //   Java source line #166	-> byte code offset #161
    //   Java source line #167	-> byte code offset #171
    //   Java source line #168	-> byte code offset #181
    //   Java source line #166	-> byte code offset #197
    //   Java source line #174	-> byte code offset #203
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	204	0	this	COFFHeaderImpl
    //   1	191	1	???	COFFFileParser.COFFFileImpl
    //   97	53	2	i	int
    //   162	36	2	i	int
    //   127	13	3	secHdrOffset	int
    //   180	13	3	symbolOffset	int
  }
  
  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)(COFFFileParser.COFFFileImpl.access$000(this$1) + 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)
    {
      this$1.seek(offset);
      magic = this$1.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;
      this$1.seek(offset);
      majorLinkerVersion = this$1.readByte();
      minorLinkerVersion = this$1.readByte();
      sizeOfCode = this$1.readInt();
      sizeOfInitializedData = this$1.readInt();
      sizeOfUninitializedData = this$1.readInt();
      addressOfEntryPoint = this$1.readInt();
      baseOfCode = this$1.readInt();
      if (!isPE32Plus) {
        baseOfData = this$1.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)
    {
      this$1.seek(offset);
      if (!isPE32Plus) {
        imageBase = maskInt(this$1.readInt());
      } else {
        imageBase = this$1.readLong();
      }
      sectionAlignment = this$1.readInt();
      fileAlignment = this$1.readInt();
      majorOperatingSystemVersion = this$1.readShort();
      minorOperatingSystemVersion = this$1.readShort();
      majorImageVersion = this$1.readShort();
      minorImageVersion = this$1.readShort();
      majorSubsystemVersion = this$1.readShort();
      minorSubsystemVersion = this$1.readShort();
      this$1.readInt();
      sizeOfImage = this$1.readInt();
      sizeOfHeaders = this$1.readInt();
      checkSum = this$1.readInt();
      subsystem = this$1.readShort();
      dllCharacteristics = this$1.readShort();
      if (!isPE32Plus)
      {
        sizeOfStackReserve = maskInt(this$1.readInt());
        sizeOfStackCommit = maskInt(this$1.readInt());
        sizeOfHeapReserve = maskInt(this$1.readInt());
        sizeOfHeapCommit = maskInt(this$1.readInt());
      }
      else
      {
        sizeOfStackReserve = this$1.readLong();
        sizeOfStackCommit = this$1.readLong();
        sizeOfHeapReserve = this$1.readLong();
        sizeOfHeapCommit = this$1.readLong();
      }
      loaderFlags = this$1.readInt();
      numberOfRvaAndSizes = this$1.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)
    {
      this$1.seek(offset);
      rva = this$1.readInt();
      size = this$1.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;
      this$1.seek(offset);
      exportFlags = this$1.readInt();
      timeDateStamp = this$1.readInt();
      majorVersion = this$1.readShort();
      minorVersion = this$1.readShort();
      nameRVA = this$1.readInt();
      ordinalBase = this$1.readInt();
      addressTableEntries = this$1.readInt();
      numberOfNamePointers = this$1.readInt();
      exportAddressTableRVA = this$1.readInt();
      namePointerTableRVA = this$1.readInt();
      ordinalTableRVA = this$1.readInt();
      
      dllName = new MemoizedObject()
      {
        public Object computeValue()
        {
          this$1.seek(rvaToFileOffset(getNameRVA()));
          return this$1.readCString();
        }
      };
      exportNamePointerTable = new MemoizedObject()
      {
        public Object computeValue()
        {
          int[] pointers = new int[getNumberOfNamePointers()];
          this$1.seek(rvaToFileOffset(getNamePointerTableRVA()));
          for (int i = 0; i < pointers.length; i++) {
            pointers[i] = this$1.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()];
          this$1.seek(rvaToFileOffset(getOrdinalTableRVA()));
          for (int i = 0; i < ordinals.length; i++) {
            ordinals[i] = this$1.readShort();
          }
          return ordinals;
        }
      };
      exportAddressTable = new MemoizedObject()
      {
        public Object computeValue()
        {
          int[] addresses = new int[getNumberOfAddressTableEntries()];
          this$1.seek(rvaToFileOffset(getExportAddressTableRVA()));
          for (int i = 0; i < addresses.length; i++) {
            addresses[i] = this$1.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)
    {
      this$1.seek(rvaToFileOffset(getExportAddress(ordinal)));
      return this$1.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()
          {
            this$1.seek(exportNamePointerTable[idx]);
            return this$1.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)
    {
      this$1.seek(offset);
      characteristics = this$1.readInt();
      timeDateStamp = this$1.readInt();
      majorVersion = this$1.readShort();
      minorVersion = this$1.readShort();
      type = this$1.readInt();
      sizeOfData = this$1.readInt();
      addressOfRawData = this$1.readInt();
      pointerToRawData = this$1.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();
        this$1.seek(offset);
        if ((this$1.readByte() == 78) && (this$1.readByte() == 66) && (this$1.readByte() == 49) && (this$1.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();
      }
      this$1.seek(getPointerToRawData() + i);
      return this$1.readByte();
    }
  }
  
  class DebugVC50Impl
    implements DebugVC50, DebugVC50TypeLeafIndices
  {
    private int lfaBase;
    private int subsectionDirectoryOffset;
    private MemoizedObject subsectionDirectory;
    
    DebugVC50Impl(int offset)
    {
      lfaBase = offset;
      this$1.seek(offset);
      this$1.readInt();
      subsectionDirectoryOffset = globalOffset(this$1.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()
    {
      this$1.seek(subsectionDirectoryOffset);
      int headerLength = this$1.readShort();
      int entryLength = this$1.readShort();
      int numEntries = this$1.readInt();
      int endOffset = subsectionDirectoryOffset + headerLength + numEntries * entryLength;
      this$1.seek(endOffset);
      if ((this$1.readByte() == 78) && (this$1.readByte() == 66) && (this$1.readByte() == 49) && (this$1.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;
        
        this$1.seek(offset);
        dirHeaderLength = this$1.readShort();
        dirEntryLength = this$1.readShort();
        numEntries = this$1.readInt();
      }
      
      public short getHeaderLength()
      {
        return dirHeaderLength;
      }
      
      public short getEntryLength()
      {
        return dirEntryLength;
      }
      
      public int getNumEntries()
      {
        return numEntries;
      }
      
      public DebugVC50Subsection getSubsection(int i)
      {
        this$1.seek(offset + dirHeaderLength + i * dirEntryLength);
        short ssType = this$1.readShort();
        short iMod = this$1.readShort();
        int lfo = COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this.globalOffset(this$1.readInt());
        int cb = this$1.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, ssType, iMod, cb, lfo);
        case 291: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSPublicSymImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 292: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSSymbolsImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 293: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSAlignSymImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 294: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSSrcLnSegImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 295: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSSrcModuleImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 296: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSLibrariesImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 297: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSGlobalSymImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 298: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSGlobalPubImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 299: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSGlobalTypesImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 300: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSMPCImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 301: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSSegMapImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 302: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSSegNameImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 303: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSPreCompImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 304: 
          return null;
        case 305: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSOffsetMap16Impl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 306: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSOffsetMap32Impl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
        case 307: 
          return new COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.DebugVC50SSFileIndexImpl(COFFFileParser.COFFFileImpl.COFFHeaderImpl.DebugVC50Impl.this, ssType, iMod, cb, lfo);
     
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