Examples of BinaryParseException


Examples of org.jakstab.loader.BinaryParseException

            Integer.toHexString((int)sectionHeader.VirtualAddress));
      }
    }
    /////////////////////////////////////////////////////////////////
    if (codeSection < 0) {
      throw new BinaryParseException("No code section found in object file!");
    }
   
    /////////////////////////////////////////////////////////////////
    // Read string table for symbols
    Map<Integer,String> stringTable = new HashMap<Integer, String>();
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

   *  Parses an MSDOS_Stub from an input stream
   */
  public MSDOS_Stub(BinaryInputBuffer in) throws java.io.IOException, BinaryParseException {
    Magic = in.readWORD();
    if (Magic != MAGIC)
      throw new BinaryParseException("MSDOS_Stub: File does not start with magic number 0x4D5A");

    data1 = new byte[58];
    in.read(data1);
    NewFileHeaderAddress = in.readDWORD();
    try {
      data2 = new byte[(int)(NewFileHeaderAddress - 64)];
      in.read(data2);
    } catch (Exception e) {
      throw new BinaryParseException("No PE header found. MS-DOS executables are not supported.");
    }
  }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

      LoaderFlags                   = in.readDWORD();
      // obsolete, ==0

      NumberOfRvaAndSizes           = in.readDWORD();
    } else
      throw new BinaryParseException("PE_Header: Invalid magic number");

    DataDirectory = new ImageDataDirectory[(int)NumberOfRvaAndSizes];
    for (int i=0;i<NumberOfRvaAndSizes;i++)
      DataDirectory[i] = new ImageDataDirectory(in);
  }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

    PointerToSymbolTable = in.readDWORD();
    NumberOfSymbols      = (int)in.readDWORD();
    SizeOfOptionalHeader = in.readWORD();
    Characteristics      = in.readWORD();

    if (!isX86()) throw new BinaryParseException("Non-x86 COFF files currently not supported!");

    //    logger.debug("COFF Header: {");
    //    logger.debug("  Machine = " + "0x" + Integer.toHexString(Machine));
    //    logger.debug("  NumberOfSections = " + getNumberOfSections());
    //    logger.debug("  TimeDateStamp = " + "0x" + Long.toHexString(TimeDateStamp));
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

        if(len <= 0) {
          break;
        }
      }
    } catch (IOException e) {
      throw new BinaryParseException("IOException: " + e.getMessage());
    }

    return str.toString();
  }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

          off += Dynamic.DYN_ENT_SIZE_64;
        }
          break;
        case ELFhdr.ELFCLASSNONE :
        default :
          throw new BinaryParseException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$
      }

      if (dynEnt.d_tag != Dynamic.DT_NULL)
        dynList.add(dynEnt);
    }
    } catch (IOException e) {
      throw new BinaryParseException("IOException: " + e.getMessage());
    }
   
    return dynList.toArray(new Dynamic[0]);
  }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

      efile = new ERandomAccessFile(file, "r"); //$NON-NLS-1$
      efile.setFileOffset(offset);
      ehdr = new ELFhdr();
      this.file = file;
    } catch (IOException e) {
      throw new BinaryParseException("IOException: " + e.getMessage());
    } finally {
      if (ehdr == null) {
        dispose();
      }
    }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

            sections[i].sh_entsize = readUnsignedLong(efile);
          }
          break;
          case ELFhdr.ELFCLASSNONE :
          default :
            throw new BinaryParseException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$
          }
          if (sections[i].sh_type == Section.SHT_SYMTAB)
            syms = i;
          if (syms == 0 && sections[i].sh_type == Section.SHT_DYNSYM)
            syms = i;
        }
      } catch (IOException e) {
        throw new BinaryParseException("IOException: " + e.getMessage());
      }
    }
    return sections;
  }
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

          symbol.st_size = readUnsignedLong(efile);
        }
        break;
        case ELFhdr.ELFCLASSNONE :
        default :
          throw new BinaryParseException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$
        }
        // JK: We add also the non-symbol at index 0 to maintain the correct ordering
        /*if (symbol.st_info == 0)
        continue;*/
        symList.add(symbol);
      }
    } catch (IOException e) {
      throw new BinaryParseException("IOException: " + e.getMessage());
    }

    Symbol[] results = symList.toArray(new Symbol[0]);
    // JK: Don't sort, so we can use the symbol table indices
    //Arrays.sort(results);
View Full Code Here

Examples of org.jakstab.loader.BinaryParseException

    }

    protected ELFhdr(byte[] bytes) throws BinaryParseException {
     
      if (bytes.length <= e_ident.length) {
        throw new BinaryParseException("No ELF File"); //$NON-NLS-1$
      }
      System.arraycopy(bytes, 0, e_ident, 0, e_ident.length);
      if (e_ident[ELFhdr.EI_MAG0] != 0x7f || e_ident[ELFhdr.EI_MAG1] != 'E' || e_ident[ELFhdr.EI_MAG2] != 'L'
          || e_ident[ELFhdr.EI_MAG3] != 'F')
        throw new BinaryParseException("No ELF File"); //$NON-NLS-1$
      boolean isle = (e_ident[ELFhdr.EI_DATA] == ELFhdr.ELFDATA2LSB);
      int offset = e_ident.length;
      e_type = makeShort(bytes, offset, isle);
      offset += 2;
      e_machine = makeShort(bytes, offset, isle);
      offset += 2;
      e_version = makeInt(bytes, offset, isle);
      offset += 4;
      switch (e_ident[ELFhdr.EI_CLASS]) {
        case ELFhdr.ELFCLASS32 : {
          byte[] addrArray = new byte[ELF32_ADDR_SIZE];
          System.arraycopy(bytes, offset, addrArray, 0, ELF32_ADDR_SIZE);
          offset += ELF32_ADDR_SIZE;
          e_entry = new Addr32(addrArray);
          e_phoff = makeInt(bytes, offset, isle);
          offset += ELF32_OFF_SIZE;
          e_shoff = makeInt(bytes, offset, isle);
          offset += ELF32_OFF_SIZE;
        }
          break;
        case ELFhdr.ELFCLASS64 : {
          byte[] addrArray = new byte[ELF64_ADDR_SIZE];
          System.arraycopy(bytes, offset, addrArray, 0, ELF64_ADDR_SIZE);
          offset += ELF64_ADDR_SIZE;
          e_entry = new Addr64(addrArray);
          e_phoff = makeUnsignedLong(bytes, offset, isle);
          offset += ELF64_OFF_SIZE;
          e_shoff = makeUnsignedLong(bytes, offset, isle);
          offset += ELF64_OFF_SIZE;
        }
          break;
        case ELFhdr.ELFCLASSNONE :
        default :
          throw new BinaryParseException("Unknown ELF class " + e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$
      }
      e_flags = makeInt(bytes, offset, isle);
      offset += 4;
      e_ehsize = makeShort(bytes, offset, isle);
      offset += 2;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.