From 7b518a6e0d00a2a414cb1ff0a8d52c6b7c4f008c Mon Sep 17 00:00:00 2001 From: Honfika Date: Tue, 21 Jan 2014 22:52:15 +0100 Subject: [PATCH] small fixes, but binary search still not working --- .../com/jpexs/decompiler/flash/BinarySWFBundle.java | 9 +++++---- trunk/src/com/jpexs/decompiler/flash/SWFSearch.java | 11 ++++++----- trunk/src/com/jpexs/helpers/FoundInputStream.java | 8 ++++---- trunk/src/com/jpexs/helpers/StreamSearch.java | 3 ++- trunk/src/com/jpexs/process/Process.java | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java b/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java index 9270c5e09..02fe4dab2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java +++ b/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java @@ -34,7 +34,8 @@ import java.util.Set; public class BinarySWFBundle implements SWFBundle { private final SWFSearch search; public BinarySWFBundle(InputStream is){ - search = new SWFSearch(new StreamSearch(is)); + search = new SWFSearch(new StreamSearch(is)); + search.process(); } @Override @@ -44,9 +45,9 @@ public class BinarySWFBundle implements SWFBundle { @Override public Set getKeys() { - Set ret=new HashSet<>(); - for(int i=0;i ret = new HashSet<>(); + for(int i = 0; i < length(); i++){ + ret.add("[" + i + "]"); } return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFSearch.java b/trunk/src/com/jpexs/decompiler/flash/SWFSearch.java index c55dd12fa..aadee35db 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFSearch.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFSearch.java @@ -78,12 +78,13 @@ public class SWFSearch { setProgress(pos * 100 / ret.size()); pos++; try { - PosMarkedInputStream pmi = new PosMarkedInputStream(ret.get(addr)); - ReReadableInputStream is = new ReReadableInputStream(pmi); - SWF swf = new SWF(is, null, false, true); + ReReadableInputStream ris = (ReReadableInputStream) ret.get(addr); + ris.reset(); + PosMarkedInputStream pmi = new PosMarkedInputStream(ris); + SWF swf = new SWF(pmi, null, false, true); long limit = pmi.getPos(); - is.seek(0); - is = new ReReadableInputStream(new LimitedInputStream(is, limit)); + ris.seek(0); + ReReadableInputStream is = new ReReadableInputStream(new LimitedInputStream(ris, limit)); if (swf.fileSize > 0 && swf.version > 0 && !swf.tags.isEmpty() && swf.version < 25/*Needs to be fixed when SWF versions reaches this value*/) { swfStreams.add(is); } diff --git a/trunk/src/com/jpexs/helpers/FoundInputStream.java b/trunk/src/com/jpexs/helpers/FoundInputStream.java index 1c1565db2..2ef878585 100644 --- a/trunk/src/com/jpexs/helpers/FoundInputStream.java +++ b/trunk/src/com/jpexs/helpers/FoundInputStream.java @@ -27,9 +27,9 @@ import java.io.InputStream; public class FoundInputStream extends ReReadableInputStream{ private final long startPos; - private boolean started=false; + private boolean started = false; - public FoundInputStream(long startPos,InputStream is) { + public FoundInputStream(long startPos, InputStream is) { super(is); this.startPos = startPos; } @@ -47,11 +47,11 @@ public class FoundInputStream extends ReReadableInputStream{ @Override public void seek(long pos) throws IOException { - super.seek(pos+startPos); + super.seek(pos + startPos); } @Override public long getPos() { - return super.getPos()-startPos; + return super.getPos() - startPos; } } diff --git a/trunk/src/com/jpexs/helpers/StreamSearch.java b/trunk/src/com/jpexs/helpers/StreamSearch.java index 43483dca1..cc415a7c2 100644 --- a/trunk/src/com/jpexs/helpers/StreamSearch.java +++ b/trunk/src/com/jpexs/helpers/StreamSearch.java @@ -83,7 +83,8 @@ public class StreamSearch implements Searchable { } } if (match) { - ret.put(pos+i, new FoundInputStream(pos+i,is)); + InputStream fis = new FoundInputStream(pos + i, is); + ret.put(pos + i, fis); continue loopdata; } } diff --git a/trunk/src/com/jpexs/process/Process.java b/trunk/src/com/jpexs/process/Process.java index 514ea73f6..3b98035c0 100644 --- a/trunk/src/com/jpexs/process/Process.java +++ b/trunk/src/com/jpexs/process/Process.java @@ -26,7 +26,7 @@ import java.util.Map; * * @author JPEXS */ -public interface Process extends Comparable, Searchable{ +public interface Process extends Comparable, Searchable { public String getFilePath();