From 460aad9dfceb26703e31b33c5fc903779b2e2315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 4 Dec 2016 08:21:45 +0100 Subject: [PATCH] Inluding offset and type info in index. Exact byte match of result file reached. --- .../flash/iggy/IggyDeclStrings.java | 2 +- .../jpexs/decompiler/flash/iggy/IggyFile.java | 8 +- .../flash/iggy/IggyFlashHeader64.java | 3 + .../decompiler/flash/iggy/IggySequence.java | 2 +- .../jpexs/decompiler/flash/iggy/IggySwf.java | 1 - .../jpexs/decompiler/flash/iggy/IggyText.java | 2 +- .../flash/iggy/streams/IggyIndexBuilder.java | 148 ++++++++++-------- .../flash/iggy/streams/IggyIndexParser.java | 32 +++- 8 files changed, 120 insertions(+), 78 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyDeclStrings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyDeclStrings.java index 9d229b8a4..c9c21b2c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyDeclStrings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyDeclStrings.java @@ -56,7 +56,7 @@ public class IggyDeclStrings implements StructureInterface { s.writeUI64(one); s.writeUI32(size); s.writeBytes(xxx); - ib.writeLengthSkipTwice(8 + 4 + 3, 0); + ib.writeLengthCustom(15, new int[]{0x00, 0x08}, new int[]{2, 5}); ib.writeLengthUI32(size); s.writeBytes(data); ib.writeConstLength(IggyIndexBuilder.CONST_SEQUENCE_SIZE); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFile.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFile.java index f490db013..26e5db0ac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFile.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFile.java @@ -197,8 +197,6 @@ public class IggyFile implements StructureInterface { extractIggyFile(inFile, extractDirOrig); IggySwf iswf = iggyFile.getSwf(0); iggyFile.replaceSwf(0, iswf); - //IggyFont ifont = iswf.fonts.get(0); - //iggyFile.replaceFontTag(0, 0, ifont); outFile.delete(); try (RandomAccessFileDataStream outputStream = new RandomAccessFileDataStream(outFile)) { iggyFile.writeToDataStream(outputStream); @@ -664,8 +662,7 @@ public class IggyFile implements StructureInterface { return false; } - IggyIndexParser.parseIndex(true, new TemporaryDataStream(replacementIndexData), new ArrayList<>(), new ArrayList<>()); - + //IggyIndexParser.parseIndex(true, new TemporaryDataStream(replacementIndexData), new ArrayList<>(), new ArrayList<>()); int swfIndex = 0; long offsetsChange = 0; for (int i = 0; i < subFileEntries.size(); i++) { @@ -704,6 +701,9 @@ public class IggyFile implements StructureInterface { if (entry.type == IggySubFileEntry.TYPE_FLASH) { iggySwfs.add(new IggySwf(new TemporaryDataStream(getEntryData(i)))); } + /*if (entry.type == IggySubFileEntry.TYPE_INDEX) { + IggyIndexParser.parseIndex(true, new TemporaryDataStream(getEntryData(i)), new ArrayList<>(), new ArrayList<>()); + }*/ } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFlashHeader64.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFlashHeader64.java index a2d35c3ee..fa433e1ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFlashHeader64.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFlashHeader64.java @@ -278,6 +278,9 @@ public class IggyFlashHeader64 implements IggyFlashHeaderInterface { stream.writeUI64(flags); stream.writeUI32(font_count); stream.writeUI32(zero2); + + stream.getIndexing().writeLengthCustom(184, new int[]{0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x34, 0x38, 0x3C, 0x40, 0x44, 0x48, 0x4C, 0x50, 0x58, 0x70, 0x78, 0x80, 0x84, 0x88, 0x90, 0x98, 0xA0, 0xB0}, new int[]{2, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 5, 5, 2, 2, 2, 2, 5}); + } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySequence.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySequence.java index 026af5b43..0c635183a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySequence.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySequence.java @@ -55,7 +55,7 @@ public class IggySequence implements StructureInterface { @Override public void writeToDataStream(WriteDataStreamInterface s) throws IOException { IggyIndexBuilder ib = s.getIndexing(); - ib.writeLengthSkipTwice(16, 0); + ib.writeLengthCustom(16, new int[]{0x00}, new int[]{2}); for (int i = 0; i < onepadd.length; i++) { s.writeUI64(onepadd[i]); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java index 8e63e8be9..16ab15e0a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java @@ -290,7 +290,6 @@ public class IggySwf implements StructureInterface { public void writeToDataStream(WriteDataStreamInterface s) throws IOException { IggyIndexBuilder ib = s.getIndexing(); hdr.writeToDataStream(s); - ib.writeLengthSkipTwice(184, 0); s.writeWChar(name); s.pad8bytes(); s.writeUI64(1); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyText.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyText.java index 0896d379b..fdce6f318 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyText.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyText.java @@ -115,7 +115,7 @@ public class IggyText implements StructureInterface { @Override public void writeToDataStream(WriteDataStreamInterface s) throws IOException { - s.getIndexing().writeConstLength(IggyIndexBuilder.CONST_IMPORTED_DATA_SIZE); + s.getIndexing().writeConstLength(IggyIndexBuilder.CONST_TEXT_DATA_SIZE); s.writeUI16(type); s.writeUI16(textIndex); s.writeBytes(zeroone); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexBuilder.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexBuilder.java index c8e077f0e..7b4322c4a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexBuilder.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexBuilder.java @@ -60,6 +60,8 @@ public class IggyIndexBuilder { private static final int CODE_FF_OFS32 = 0xFF; private List constTable = new ArrayList<>(); + private Map> constTableOffsets = new HashMap<>(); + private Map> constTableTypes = new HashMap<>(); private WriteDataStreamInterface indexStream; private static final int CONST_VAL_SHAPE_NODE_SIZE = IggyShapeNode.STRUCT_SIZE; @@ -70,22 +72,9 @@ public class IggyIndexBuilder { private static final int CONST_VAL_SHAPE_SIZE = IggyShape.STRUCT_SIZE; private static final int CONST_VAL_GENERAL_FONT_INFO_SIZE = 112; private static final int CONST_VAL_GENERAL_FONT_INFO2_SIZE = 240; - private static final int CONST_VAL_IMPORTED_DATA_SIZE = 104; + private static final int CONST_VAL_TEXT_DATA_SIZE = 104; private static final int CONST_VAL_SEQUENCE_SIZE = IggySequence.STRUCT_SIZE; - public static final int[] DEFAULT_CONST_TABLE = new int[]{ - CONST_VAL_SHAPE_NODE_SIZE, - CONST_VAL_KERNING_RECORD_SIZE, - CONST_VAL_CHAR_OFFSET_SIZE, - CONST_VAL_BIN_INFO_SIZE, - CONST_VAL_TYPE_INFO_SIZE, - CONST_VAL_SHAPE_SIZE, - CONST_VAL_GENERAL_FONT_INFO_SIZE, - CONST_VAL_GENERAL_FONT_INFO2_SIZE, - CONST_VAL_IMPORTED_DATA_SIZE, - CONST_VAL_SEQUENCE_SIZE - }; - public static final int CONST_SHAPE_NODE_SIZE = 0; public static final int CONST_KERNING_RECORD_SIZE = 1; public static final int CONST_CHAR_OFFSET_SIZE = 2; @@ -94,11 +83,11 @@ public class IggyIndexBuilder { public static final int CONST_SHAPE_SIZE = 5; public static final int CONST_GENERAL_FONT_INFO_SIZE = 6; public static final int CONST_GENERAL_FONT_INFO2_SIZE = 7; - public static final int CONST_IMPORTED_DATA_SIZE = 8; + public static final int CONST_TEXT_DATA_SIZE = 8; public static final int CONST_SEQUENCE_SIZE = 9; - //If these skipped numbers matter, this is sample - final byte[] STATIC_HDR = new byte[]{(byte) 0x0A, (byte) 0x18, (byte) 0x07, (byte) 0x00, (byte) 0x05, (byte) 0x04, (byte) 0x05, (byte) 0x08, (byte) 0x05, (byte) 0x0C, (byte) 0x05, (byte) 0x12, (byte) 0x04, (byte) 0x14, (byte) 0x04, (byte) 0x16, + /*final byte[] STATIC_HDR = new byte[]{ + (byte) 0x0A, (byte) 0x18, (byte) 0x07, (byte) 0x00, (byte) 0x05, (byte) 0x04, (byte) 0x05, (byte) 0x08, (byte) 0x05, (byte) 0x0C, (byte) 0x05, (byte) 0x12, (byte) 0x04, (byte) 0x14, (byte) 0x04, (byte) 0x16, (byte) 0x04, (byte) 0x06, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x04, (byte) 0x20, (byte) 0x03, (byte) 0x08, (byte) 0x04, (byte) 0x10, (byte) 0x08, (byte) 0x18, (byte) 0x02, (byte) 0x60, (byte) 0x0D, (byte) 0x00, (byte) 0x02, (byte) 0x09, (byte) 0x03, (byte) 0x0C, (byte) 0x05, (byte) 0x10, (byte) 0x05, (byte) 0x14, (byte) 0x05, (byte) 0x18, (byte) 0x05, (byte) 0x1C, (byte) 0x05, (byte) 0x20, (byte) 0x05, (byte) 0x24, (byte) 0x05, (byte) 0x28, (byte) 0x04, (byte) 0x30, (byte) 0x02, (byte) 0x38, (byte) 0x04, (byte) 0x3A, (byte) 0x04, (byte) 0x18, (byte) 0x02, (byte) 0x08, @@ -109,14 +98,40 @@ public class IggyIndexBuilder { (byte) 0x02, (byte) 0x68, (byte) 0x12, (byte) 0x01, (byte) 0x0C, (byte) 0x02, (byte) 0x04, (byte) 0x08, (byte) 0x05, (byte) 0x10, (byte) 0x02, (byte) 0x20, (byte) 0x05, (byte) 0x24, (byte) 0x05, (byte) 0x28, (byte) 0x05, (byte) 0x2C, (byte) 0x05, (byte) 0x30, (byte) 0x04, (byte) 0x32, (byte) 0x04, (byte) 0x38, (byte) 0x02, (byte) 0x44, (byte) 0x04, (byte) 0x46, (byte) 0x04, (byte) 0x48, (byte) 0x04, (byte) 0x4A, (byte) 0x04, (byte) 0x4C, (byte) 0x04, (byte) 0x4E, (byte) 0x04, (byte) 0x60, (byte) 0x02, (byte) 0x10, (byte) 0x02, (byte) 0x00, (byte) 0x02, (byte) 0x08, (byte) 0x05}; - + */ private long position = 0; public IggyIndexBuilder() throws IOException { indexStream = new TemporaryDataStream(); - for (int i = 0; i < DEFAULT_CONST_TABLE.length; i++) { - constTable.add(DEFAULT_CONST_TABLE[i]); + + addConst(CONST_VAL_SHAPE_NODE_SIZE, new int[]{0, 4, 8, 0xC, 0x12, 0x14, 0x16}, new int[]{5, 5, 5, 5, 4, 4, 4}); + addConst(CONST_VAL_KERNING_RECORD_SIZE, new int[]{0, 2, 4}, new int[]{4, 4, 4}); + addConst(CONST_VAL_CHAR_OFFSET_SIZE, new int[]{8, 0x10, 0x18}, new int[]{4, 8, 2}); + addConst(CONST_VAL_BIN_INFO_SIZE, new int[]{0, 9, 0xC, 0x10, 0x14, 0x18, 0x1C, 0x20, 0x24, 0x28, 0x30, 0x38, 0x3A}, new int[]{2, 3, 5, 5, 5, 5, 5, 5, 5, 4, 2, 4, 4}); + addConst(CONST_VAL_TYPE_INFO_SIZE, new int[]{8, 0x10}, new int[]{2, 5}); + addConst(CONST_VAL_SHAPE_SIZE, new int[]{0, 4, 8, 0xC, 0x10, 0x18, 0x20, 0x28, 0x30}, new int[]{5, 5, 5, 5, 2, 5, 2, 2, 2}); + addConst(CONST_VAL_GENERAL_FONT_INFO_SIZE, new int[]{0x1, 0x02, 0x08, 0x10, 0x20, 0x22, 0x24, 0x26, 0x2B, 0x30, 0x38, 0x40, 0x48, 0x4C, 0x50, 0x54, 0x58, 0x60}, new int[]{0xC, 4, 5, 2, 4, 4, 4, 4, 3, 2, 2, 2, 5, 5, 5, 5, 5, 2}); + addConst(CONST_VAL_GENERAL_FONT_INFO2_SIZE, new int[]{0x10}, new int[]{2}); + addConst(CONST_VAL_TEXT_DATA_SIZE, new int[]{0x01, 0x02, 0x08, 0x10, 0x20, 0x24, 0x28, 0x2C, 0x30, 0x32, 0x38, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E, 0x60}, new int[]{0x0C, 4, 5, 2, 5, 5, 5, 5, 4, 4, 2, 4, 4, 4, 4, 4, 4, 2}); + addConst(CONST_VAL_SEQUENCE_SIZE, new int[]{0, 8}, new int[]{2, 5}); + } + + private void addConst(int totalLength, int[] localOffsets, int[] types) { + if (localOffsets.length != types.length) { + throw new RuntimeException("Size of localOffsets does not match size of types on adding consts with total length " + totalLength); } + constTable.add(totalLength); + int newIndex = constTable.size() - 1; + List localOffsetsList = new ArrayList<>(); + for (int t : localOffsets) { + localOffsetsList.add(t); + } + List typesList = new ArrayList<>(); + for (int t : types) { + typesList.add(t); + } + constTableOffsets.put(newIndex, localOffsetsList); + constTableTypes.put(newIndex, typesList); } private byte[] getIndexTableBytes() { @@ -124,7 +139,11 @@ public class IggyIndexBuilder { baos.write(constTable.size()); for (int i = 0; i < constTable.size(); i++) { baos.write(constTable.get(i)); - baos.write(0); + baos.write(constTableOffsets.get(i).size()); + for (int j = 0; j < constTableOffsets.get(i).size(); j++) { + baos.write(constTableOffsets.get(i).get(j)); + baos.write(constTableTypes.get(i).get(j)); + } } return baos.toByteArray(); } @@ -141,14 +160,7 @@ public class IggyIndexBuilder { } public long writeConstLength(int constIndex) { - return writeIndex(constIndex, false, 0, 0); - } - - private long writeConstLengthArrayUpTo64(int constIndex, int cntUpTo64) { - if (cntUpTo64 == 1) { - return writeIndex(constIndex, false, 0, 0); - } - return writeIndex(0x80 + cntUpTo64 - 1, false, constIndex, 0); + return writeIndex(constIndex, false, 0); } /*private int indexOfConst(int val) { @@ -163,17 +175,18 @@ public class IggyIndexBuilder { long ret = 0; long rem = cnt; while (true) { + if (rem == 1) { + return writeIndex(constIndex, false, 0); + } if (rem <= 64) { - ret += writeConstLengthArrayUpTo64(constIndex, (int) rem); + ret += writeIndex(0x80 + (int) rem - 1, false, constIndex); break; } else { rem -= 64; - ret += writeConstLengthArrayUpTo64(constIndex, 64); - + ret += writeIndex(0x80 + 64 - 1, false, constIndex); } } return ret; - } public long pad8bytes() { @@ -210,52 +223,69 @@ public class IggyIndexBuilder { } public long writePaddingBytes(int twoPlusHowManyTwoBytes) { - return writeIndex(0xC0 + twoPlusHowManyTwoBytes, false, 0, 0); + return writeIndex(0xC0 + twoPlusHowManyTwoBytes, false, 0); } public long writePointerArray(boolean is64, long cnt) { - return writeIndex(0xD0 + 0x2, is64, cnt - 1, 0); + return writeIndex(0xD0 + 0x2, is64, cnt - 1); } public long write64bitPointerArray(long cnt) { - return writeIndex(0xD0 + 0x2, true, cnt - 1, 0); + return writeIndex(0xD0 + 0x2, true, cnt - 1); } public long write32bitPointerArray(long cnt) { - return writeIndex(0xD0 + 0x2, false, cnt - 1, 0); + return writeIndex(0xD0 + 0x2, false, cnt - 1); } public long write16bitArray(long cnt) { - return writeIndex(0xD0 + 0x4, false, cnt - 1, 0); + return writeIndex(0xD0 + 0x4, false, cnt - 1); } public long write32bitArray(long cnt) { - return writeIndex(0xD0 + 0x5, false, cnt - 1, 0); + return writeIndex(0xD0 + 0x5, false, cnt - 1); } public long write64bitArray(long cnt) { - return writeIndex(0xD0 + 0x6, false, cnt - 1, 0); + return writeIndex(0xD0 + 0x6, false, cnt - 1); } public long skipOneInIndex() { - return writeIndex(CODE_FC_SKIP1, false, 0, 0); + return writeIndex(CODE_FC_SKIP1, false, 0); } - public long writeLengthSkipTwice(int lenUI8, int skipTwice) { - return writeIndex(CODE_FD_OFS8_SKIP_TWICE8, false, lenUI8, skipTwice); + public long writeLengthCustom(int totalLen, int localOffsets[], int platformTypes[]) { + return writeIndex(CODE_FD_OFS8_SKIP_TWICE8, false, totalLen, localOffsets, platformTypes); } public long writeLengthBytePositive(int valUI8) { - return writeIndex(CODE_FE_OFS8_POSITIVE, false, valUI8, 0); + return writeIndex(CODE_FE_OFS8_POSITIVE, false, valUI8); } public long writeLengthUI32(long offset) { - return writeIndex(CODE_FF_OFS32, false, offset, 0); + return writeIndex(CODE_FF_OFS32, false, offset); } - private long writeIndex(int code, boolean is64, long val, long skipNum) { + public static int platformNumSize(boolean is64, int i) { + if (i <= 2) { + return is64 ? 8 : 4; + } else if (i <= 4) { + return 2; + } else if (i == 5) { + return 4; + } else if (i == 6) { + return 8; + } + throw new RuntimeException("Uknown platform num"); + } + + private long writeIndex(int code, boolean is64, long val) { + return writeIndex(code, is64, val, null, null); + } + + private long writeIndex(int code, boolean is64, long val, int localOffsets[], int platformTypes[]) { try { - LOGGER.finest(String.format("index offset: %d, %04X", STATIC_HDR.length + indexStream.position(), STATIC_HDR.length + indexStream.position())); + //LOGGER.finest(String.format("index offset: %d, %04X", STATIC_HDR.length + indexStream.position(), STATIC_HDR.length + indexStream.position())); LOGGER.finer(String.format("Code = 0x%02X", code)); indexStream.writeUI8(code); if (code < 0x80) // 0-0x7F @@ -366,31 +396,25 @@ public class IggyIndexBuilder { } else if (code == CODE_FC_SKIP1) { LOGGER.finest(String.format("0xFC: skip 1 ")); //indexStream.seek(1, SeekMode.CUR); + indexStream.write(0); //?? return 1; //seek 1 } else if (code == CODE_FD_OFS8_SKIP_TWICE8) { LOGGER.finest(String.format("0xFD: 0..255, skip 2 * 0..255 ")); int n, m; + n = (int) val; indexStream.writeUI8((int) val); - - if ((n = (int) val) < 0) { - LOGGER.severe(String.format("0xFD: Cannot read n.")); - return 0; - } - - indexStream.writeUI8((int) skipNum); - - if ((m = (int) skipNum) < 0) { - LOGGER.severe(String.format("0xFD: Cannot read m.")); - return 0; - } + m = localOffsets.length; + indexStream.writeUI8(localOffsets.length); long offset = n; position += n; LOGGER.finest(String.format("offset += %d", n)); - long skip = m * 2; - LOGGER.finest(String.format("skip %d", m * 2)); - return offset + skip; + for (int i = 0; i < localOffsets.length; i++) { + indexStream.writeUI8(localOffsets[i]); + indexStream.writeUI8(platformTypes[i]); + } + return offset; } else if (code == CODE_FE_OFS8_POSITIVE) { LOGGER.finest(String.format("0xFD: 0..255 + 1 ")); int n8; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexParser.java index 0de06a2c7..4a6a13c9f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/streams/IggyIndexParser.java @@ -18,12 +18,11 @@ public class IggyIndexParser { private static Logger LOGGER = Logger.getLogger(IggyIndexParser.class.getName()); - /* - static PrintWriter pw; + /*static PrintWriter pw; static { try { - pw = new PrintWriter("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_new\\index.txt"); + pw = new PrintWriter("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\index2.txt"); } catch (FileNotFoundException ex) { Logger.getLogger(IggyIndexParser.class.getName()).log(Level.SEVERE, null, ex); } @@ -44,8 +43,7 @@ public class IggyIndexParser { pw.close(); } }); - } - */ + }*/ /** * Parser for index data. It creates table of indices and table of offsets * @@ -63,7 +61,11 @@ public class IggyIndexParser { indexTable[i] = offset; indexTableEntry.add(offset); int num = indexStream.readUI8(); - indexStream.seek(num * 2, SeekMode.CUR); + for (int j = 0; j < num; j++) { + int locOffset = indexStream.readUI8(); + int type = indexStream.readUI8(); + LOGGER.finer(String.format("- local offset: %d, type: %d", locOffset, type)); + } } long offset = 0; @@ -190,8 +192,22 @@ public class IggyIndexParser { offset += n; LOGGER.finest(String.format("LENGTH = n = %d", n)); - indexStream.seek(m * 2, SeekMode.CUR); - LOGGER.finest(String.format("SKIP m * 2 = skip %d * 2 = %d", m, m * 2)); + StringBuilder locOffStr = new StringBuilder(); + StringBuilder platStr = new StringBuilder(); + for (int i = 0; i < m; i++) { + int localOffset = indexStream.readUI8(); + int platformType = indexStream.readUI8(); + if (i > 0) { + locOffStr.append(", "); + platStr.append(", "); + } + locOffStr.append(String.format("0x%02X", localOffset)); + platStr.append(platformType); + LOGGER.finest(String.format("- localOffset 0x%02X, platformType %d", localOffset, platformType)); + } + LOGGER.finer(String.format("stream.writeLengthCustom(%s,new int[]{%s},new int[]{%s}", n, locOffStr, platStr)); + //indexStream.seek(m * 2, SeekMode.CUR); + //LOGGER.finest(String.format("SKIP m * 2 = skip %d * 2 = %d", m, m * 2)); } else if (code == 0xFE) { LOGGER.finest(String.format("0xFD: 0..255 + 1 ")); int n8;