mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 17:28:07 +00:00
DumpInfo in AMF3
PlaceObject4 read/write AMF data
This commit is contained in:
@@ -118,6 +118,8 @@ import com.jpexs.decompiler.flash.action.swf7.ActionExtends;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionImplementsOp;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionThrow;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionTry;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.Amf3InputStream;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||
import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag;
|
||||
@@ -758,6 +760,23 @@ public class SWFInputStream implements AutoCloseable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AMF3 encoded value from the stream
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public Object readAmf3Object(String name) throws IOException {
|
||||
Amf3InputStream ai = new Amf3InputStream(is);
|
||||
ai.dumpInfo = this.dumpInfo;
|
||||
try {
|
||||
return ai.readValue("amfData");
|
||||
} catch (NoSerializerExistsException nse) {
|
||||
return nse.getIncompleteData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads byte range from the stream
|
||||
*
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.amf.amf3.Amf3OutputStream;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.ObjectTypeSerializeHandler;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
@@ -81,7 +84,9 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.Deflater;
|
||||
@@ -1946,4 +1951,31 @@ public class SWFOutputStream extends OutputStream {
|
||||
writeUB(5, (value >> 11) & 0xff);
|
||||
writeUB(5, (value >> 3) & 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes AMF3 encoded value. Warning: Correct serializer needs to be passed
|
||||
* as second parameter when using IExternalizable
|
||||
*
|
||||
* @param value
|
||||
* @param serializers Map className=>Serializer for classes implementing
|
||||
* IExternalizable
|
||||
* @throws IOException
|
||||
* @throws NoSerializerExistsException
|
||||
*/
|
||||
public void writeAmf3Object(Object value, Map<String, ObjectTypeSerializeHandler> serializers) throws IOException, NoSerializerExistsException {
|
||||
Amf3OutputStream ao = new Amf3OutputStream(os);
|
||||
ao.writeValue(value, serializers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes AMF3 encoded value. Warning: When the object implements
|
||||
* IExternalizable, you need to pass serializer as second parameter
|
||||
*
|
||||
* @param value
|
||||
* @throws IOException
|
||||
* @throws NoSerializerExistsException
|
||||
*/
|
||||
public void writeAmf3Object(Object value) throws IOException, NoSerializerExistsException {
|
||||
writeAmf3Object(value, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.EndOfStreamException;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
@@ -37,10 +38,13 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
import com.jpexs.decompiler.flash.types.filters.FILTER;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Same as PlaceObject3Tag except additional AMF data
|
||||
@@ -230,7 +234,8 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
|
||||
@Reserved
|
||||
public boolean reserved;
|
||||
|
||||
public byte[] amfData; //TODO: Parse AMF data?
|
||||
//public byte[] amfData; //TODO: Parse AMF data?
|
||||
public Object amfData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -241,7 +246,7 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
|
||||
super(swf, ID, NAME, null);
|
||||
}
|
||||
|
||||
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, byte[] amfData) {
|
||||
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, Object amfData) {
|
||||
super(swf, ID, NAME, null);
|
||||
this.placeFlagHasClassName = className != null;
|
||||
this.placeFlagHasFilterList = surfaceFilterList != null;
|
||||
@@ -353,8 +358,9 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
|
||||
if (placeFlagHasClipActions) {
|
||||
clipActions = sis.readCLIPACTIONS(swf, this, "clipActions");
|
||||
}
|
||||
|
||||
amfData = sis.readBytesEx(sis.available(), "amfData");
|
||||
if (sis.available() > 0) {
|
||||
amfData = sis.readAmf3Object("amfValue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,6 +430,14 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
|
||||
if (placeFlagHasClipActions) {
|
||||
sos.writeCLIPACTIONS(clipActions);
|
||||
}
|
||||
if (amfData != null) {
|
||||
//sos.write(Helper.readFile("d:\\Dropbox\\Programovani\\JavaSE\\FFDec\\libsrc\\ffdec_lib\\testdata\\amf3\\generated\\all.bin"));
|
||||
try {
|
||||
sos.writeAmf3Object(amfData);
|
||||
} catch (NoSerializerExistsException ex) {
|
||||
throw new IOException("Class \"" + ex.getClassName() + "\" implements IExternalizable, it cannot be saved");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user