mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 08:41:17 +00:00
Issue #513: allow skipping tag check on command line extract
This commit is contained in:
@@ -33,8 +33,8 @@ public class BinarySWFBundle implements SWFBundle {
|
||||
|
||||
private final SWFSearch search;
|
||||
|
||||
public BinarySWFBundle(InputStream is) {
|
||||
search = new SWFSearch(new StreamSearch(is));
|
||||
public BinarySWFBundle(InputStream is, boolean noCheck) {
|
||||
search = new SWFSearch(new StreamSearch(is), noCheck);
|
||||
search.process();
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ public final class SWF implements TreeItem {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, listener, parallelRead, false);
|
||||
this(is, listener, parallelRead, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +348,7 @@ public final class SWF implements TreeItem {
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException {
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean skipTagReading) throws IOException, InterruptedException {
|
||||
byte[] hdr = new byte[3];
|
||||
is.read(hdr);
|
||||
String shdr = new String(hdr, Utf8Helper.charset);
|
||||
@@ -411,8 +411,8 @@ public final class SWF implements TreeItem {
|
||||
sis.readUI8(); //tmpFirstByetOfFrameRate
|
||||
frameRate = sis.readUI8();
|
||||
frameCount = sis.readUI16();
|
||||
if (checkOnly) {
|
||||
//return;
|
||||
if (skipTagReading) {
|
||||
return;
|
||||
}
|
||||
tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx);
|
||||
if (!checkOnly) {
|
||||
|
||||
@@ -34,12 +34,14 @@ import java.util.Set;
|
||||
public class SWFSearch {
|
||||
|
||||
protected Searchable s;
|
||||
private boolean noCheck;
|
||||
private boolean processed = false;
|
||||
private final Set<ProgressListener> listeners = new HashSet<>();
|
||||
private final Map<Long, MemoryInputStream> swfStreams = new HashMap<>();
|
||||
|
||||
public SWFSearch(Searchable s) {
|
||||
public SWFSearch(Searchable s, boolean noCheck) {
|
||||
this.s = s;
|
||||
this.noCheck = noCheck;
|
||||
}
|
||||
|
||||
public void addProgressListener(ProgressListener l) {
|
||||
@@ -77,7 +79,7 @@ public class SWFSearch {
|
||||
MemoryInputStream mis = (MemoryInputStream) ret.get(addr);
|
||||
mis.reset();
|
||||
PosMarkedInputStream pmi = new PosMarkedInputStream(mis);
|
||||
SWF swf = new SWF(pmi, null, false, true);
|
||||
SWF swf = new SWF(pmi, null, false, true, noCheck);
|
||||
long limit = pmi.getPos();
|
||||
MemoryInputStream is = new MemoryInputStream(mis.getAllRead(), (int) (long) addr, (int) limit);
|
||||
if (swf.fileSize > 0 && swf.version > 0 && !swf.tags.isEmpty() && swf.version < 25/*Needs to be fixed when SWF versions reaches this value*/) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SWFSourceInfo {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SWFBundle getBundle() throws IOException {
|
||||
public SWFBundle getBundle(boolean noCheck) throws IOException {
|
||||
if (!isBundle()) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class SWFSourceInfo {
|
||||
case ".zip":
|
||||
return new ZippedSWFBundle(is);
|
||||
default:
|
||||
return new BinarySWFBundle(is);
|
||||
return new BinarySWFBundle(is, noCheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class CommandLineArgumentParser {
|
||||
System.out.println(" ...Compress SWF <infile> and save it to <outfile>");
|
||||
System.out.println(" 8) -decompress <infile> <outfile>");
|
||||
System.out.println(" ...Decompress <infile> and save it to <outfile>");
|
||||
System.out.println(" 9) -extract <infile> [(all|biggest)]");
|
||||
System.out.println(" 9) -extract <infile> [nocheck] [(all|biggest)]");
|
||||
System.out.println(" ...Extracts SWF files from ZIP or other binary files");
|
||||
System.out.println(" 10) -renameInvalidIdentifiers (typeNumber|randomWord) <infile> <outfil>e");
|
||||
System.out.println(" ...Renames the invalid identifiers in <infile> and save it to <outfile>");
|
||||
@@ -755,6 +755,15 @@ public class CommandLineArgumentParser {
|
||||
|
||||
String fileName = args.remove();
|
||||
ExtractMode mode = ExtractMode.ALL;
|
||||
|
||||
boolean noCheck = false;
|
||||
if (args.size() > 0) {
|
||||
if (args.peek().toLowerCase().equals("nocheck")) {
|
||||
noCheck = true;
|
||||
args.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() > 0) {
|
||||
String modeStr = args.remove().toLowerCase();
|
||||
switch (modeStr) {
|
||||
@@ -770,7 +779,7 @@ public class CommandLineArgumentParser {
|
||||
System.err.println("Error: <infile> should be a bundle. (ZIP or non SWF binary file)");
|
||||
System.exit(1);
|
||||
}
|
||||
SWFBundle bundle = sourceInfo.getBundle();
|
||||
SWFBundle bundle = sourceInfo.getBundle(noCheck);
|
||||
List<Map.Entry<String, SeekableInputStream>> streamsToExtract = new ArrayList<>();
|
||||
Map.Entry<String, SeekableInputStream> biggest = null;
|
||||
int biggestSize = 0;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
||||
try {
|
||||
PosMarkedInputStream pmi = new PosMarkedInputStream(ret.get(addr));
|
||||
ReReadableInputStream is = new ReReadableInputStream(pmi);
|
||||
SWF swf = new SWF(is, null, false, true);
|
||||
SWF swf = new SWF(is, null, false, true, false);
|
||||
long limit = pmi.getPos();
|
||||
is.seek(0);
|
||||
is = new ReReadableInputStream(new LimitedInputStream(is, limit));
|
||||
|
||||
@@ -230,7 +230,7 @@ public class Main {
|
||||
SWFBundle bundle = null;
|
||||
if (inputStream == null) {
|
||||
inputStream = new BufferedInputStream(new FileInputStream(sourceInfo.getFile()));
|
||||
bundle = sourceInfo.getBundle();
|
||||
bundle = sourceInfo.getBundle(false);
|
||||
logger.log(Level.INFO, "Load file: {0}", sourceInfo.getFile());
|
||||
} else if (inputStream instanceof SeekableInputStream
|
||||
|| inputStream instanceof BufferedInputStream) {
|
||||
|
||||
Reference in New Issue
Block a user