mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 22:07:02 +00:00
Fixed Error messages during SWF/ABC reading have correct error icon and title, are translatable
Properly handle ABC reading errors
This commit is contained in:
@@ -1711,7 +1711,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public static SWFHeader decodeHeader(byte[] headerData) throws IOException {
|
||||
String signature = new String(headerData, 0, 3, Utf8Helper.charset);
|
||||
if (!swfSignatures.contains(signature)) {
|
||||
throw new SwfOpenException("Invalid SWF file, wrong signature.");
|
||||
throw new SwfOpenException(AppResources.translate("error.swf.invalid"));
|
||||
}
|
||||
|
||||
int version = headerData[3];
|
||||
@@ -1733,7 +1733,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
// SWFheader: signature, version and fileSize
|
||||
if (is.read(hdr) != 8) {
|
||||
throw new SwfOpenException("SWF header is too short");
|
||||
throw new SwfOpenException(AppResources.translate("error.swf.headerTooShort"));
|
||||
}
|
||||
|
||||
SWFHeader header = decodeHeader(hdr);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.AppResources;
|
||||
import com.jpexs.decompiler.flash.DeobfuscationListener;
|
||||
import com.jpexs.decompiler.flash.EndOfStreamException;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
@@ -513,6 +514,20 @@ public class ABC implements Openable {
|
||||
if (file != null) {
|
||||
isOpenable = true;
|
||||
}
|
||||
|
||||
try {
|
||||
read(ais, swf);
|
||||
} catch (IOException ie) {
|
||||
throw new ABCOpenException(AppResources.translate("error.abc.invalid"), ie);
|
||||
}
|
||||
//this will read all method body codes. TODO: make this ondemand
|
||||
refreshMultinameNamespaceSuffixes();
|
||||
getMethodIndexing();
|
||||
|
||||
SWFDecompilerPlugin.fireAbcParsed(this, swf);
|
||||
}
|
||||
|
||||
private void read(ABCInputStream ais, SWF swf) throws IOException {
|
||||
int minor_version = ais.readU16("minor_version");
|
||||
int major_version = ais.readU16("major_version");
|
||||
version = new ABCVersion(major_version, minor_version);
|
||||
@@ -735,12 +750,6 @@ public class ABC implements Openable {
|
||||
|
||||
SWFDecompilerPlugin.fireMethodBodyParsed(this, mb, swf);
|
||||
}
|
||||
|
||||
//this will read all method body codes. TODO: make this ondemand
|
||||
refreshMultinameNamespaceSuffixes();
|
||||
getMethodIndexing();
|
||||
|
||||
SWFDecompilerPlugin.fireAbcParsed(this, swf);
|
||||
}
|
||||
|
||||
public void saveToStream(OutputStream os) throws IOException {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ABCOpenException extends IOException {
|
||||
|
||||
public ABCOpenException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ABCOpenException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -42,4 +42,8 @@ trait.instanceinitializer = instance initializer
|
||||
trait.classinitializer = class initializer
|
||||
|
||||
#after 16.3.1
|
||||
package.default = <default package>
|
||||
package.default = <default package>
|
||||
|
||||
error.swf.invalid = Invalid SWF file, wrong signature.
|
||||
error.swf.headerTooShort = SWF header is too short.
|
||||
error.abc.invalid = Invalid ABC file.
|
||||
@@ -40,4 +40,8 @@ trait.instanceinitializer = inicializ\u00e1tor instance
|
||||
trait.classinitializer = inicializ\u00e1tor t\u0159\u00eddy
|
||||
|
||||
#after 16.3.1
|
||||
package.default = <v\u00fdchoz\u00ed bal\u00ed\u010dek>
|
||||
package.default = <v\u00fdchoz\u00ed bal\u00ed\u010dek>
|
||||
|
||||
error.swf.invalid = Neplatn\u00fd SWF soubor, \u0161patn\u00e1 signatura.
|
||||
error.swf.headerTooShort = SWF hlavi\u010dka je p\u0159\u00edli\u0161 kr\u00e1tk\u00e1.
|
||||
error.abc.invalid = Neplatn\u00fd ABC soubor.
|
||||
Reference in New Issue
Block a user