Пример #1
0
 public String computeDataSizeAndType(RandomAccessFile fin) throws IOException {
   SinAddr a = map.get(0);
   byte[] res = new byte[(int) a.getDataLength()];
   fin.seek(getDataHeaderSize() + map.getSize() + a.getSrcOffset());
   fin.read(res);
   byte[] magic = new byte[4];
   int pos = 0;
   while (res[pos] == 0) pos++;
   int startpos = pos;
   pos = 0;
   System.arraycopy(res, startpos + pos, magic, 0, magic.length);
   if (new String(magic).contains("ELF")) return "elf";
   while (!HexDump.toHex(magic).startsWith("[FF, FF, 53, EF")) {
     pos++;
     try {
       System.arraycopy(res, startpos + pos, magic, 0, magic.length);
     } catch (Exception e) {
       return "unknown";
     }
     if (new String(magic).contains("ELF")) return "elf";
   }
   // if (pos>=500) return "unknown";
   pos = pos - 54;
   byte[] header = new byte[58];
   System.arraycopy(res, startpos + pos, header, 0, header.length);
   byte[] bcount = new byte[4];
   System.arraycopy(header, 4, bcount, 0, bcount.length);
   BytesUtil.revert(bcount);
   long blockcount = BytesUtil.getInt(bcount);
   outputsize = blockcount * 4L * 1024L;
   return "ext4";
 }
Пример #2
0
 public SinHashBlock(byte[] hashblock, int index) {
   this.spare = spare;
   byte[] offset = new byte[4];
   byte[] length = new byte[4];
   System.arraycopy(hashblock, 0, offset, 0, 4);
   System.arraycopy(hashblock, 4, length, 0, 4);
   boffset = BytesUtil.getLong(offset);
   blength = BytesUtil.getInt(length);
   hashsize = hashblock[8];
   blockindex = index;
 }
Пример #3
0
 private void processHeader(InputStream fileinputstream) throws X10FlashException {
   try {
     byte abyte0[] = new byte[6];
     int j = fileinputstream.read(abyte0);
     if (j != 6) {
       fileinputstream.close();
       throw new X10FlashException("Error in processHeader");
     }
     int k;
     byte abyte1[] = new byte[4];
     System.arraycopy(abyte0, 2, abyte1, 0, 4);
     k = BytesUtil.getInt(abyte1);
     abyte1 = new byte[k - 6];
     k = fileinputstream.read(abyte1);
     if (k != abyte1.length) {
       fileinputstream.close();
       throw new X10FlashException("Error in processHeader");
     }
     cmd.send(Command.CMD05, BytesUtil.concatAll(abyte0, abyte1), false);
     if (USBFlash.getLastFlags() == 0) getLastError();
   } catch (IOException ioe) {
     throw new X10FlashException("Error in processHeader : " + ioe.getMessage());
   }
 }
Пример #4
0
 public int getGptpLength() {
   return BytesUtil.getInt(gptplength);
 }
Пример #5
0
 public int getMmcfLength() {
   return BytesUtil.getInt(mmcflength);
 }