Decompiler improvement, compiler improvement x3
This commit is contained in:
parent
68c221eb32
commit
ad70af4279
@ -17,7 +17,7 @@ import java.nio.file.StandardOpenOption;
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
FlashDecompiler decompiler = new FlashDecompiler();
|
||||
ShockwaveFile file = decompiler.loadFromFile(new File("catalogs.swf")); // D:\Documents\FlashProjects\Untitled-2.swf
|
||||
ShockwaveFile file = decompiler.loadFromFile(new File("D:\\Documents\\FlashProjects\\Untitled-2.swf")); //
|
||||
|
||||
DoAction da = (DoAction) file.getTags()
|
||||
.stream()
|
||||
@ -30,6 +30,6 @@ public class Main {
|
||||
if( out.exists() ) out.delete();
|
||||
//objectMapper.writeValue(out, new Flash2Java(da).convert());
|
||||
var j2f = new Java2Flash().convert(new Flash2Java(da).convert());
|
||||
Files.write(Path.of("./export1.swf"), new FlashCompiler(j2f).compile(), StandardOpenOption.CREATE);
|
||||
Files.write(Path.of("export1.swf"), new FlashCompiler(j2f).compile(), StandardOpenOption.CREATE);
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class FlashCompiler {
|
||||
d1.addAll(new End().compile());
|
||||
// fileSize u32
|
||||
log.info("fileSize u32: {}", d1.size());
|
||||
data.addAll(ByteUtil.intToBytes32(d1.size()));
|
||||
data.addAll(ByteUtil.intToBytes32(d1.size()+data.size()+4));
|
||||
data.addAll(d1);
|
||||
return ByteUtil.toPrimitive(data);
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ public class DoAction extends ShockwaveTag implements CompileObject {
|
||||
List<Byte> bytes = new ArrayList<>();
|
||||
this.actions.forEach(action -> {
|
||||
bytes.add(action.getType().id);
|
||||
List<Byte> data = new ArrayList<>();
|
||||
switch(action.getType()) {
|
||||
case Push:
|
||||
ActionPush push = (ActionPush) action;
|
||||
List<Byte> data = new ArrayList<>();
|
||||
push.getItems().forEach(item -> {
|
||||
data.add((byte) item.getType().type);
|
||||
switch (item.getType()) {
|
||||
@ -65,17 +65,19 @@ public class DoAction extends ShockwaveTag implements CompileObject {
|
||||
break;
|
||||
case ConstantPool:
|
||||
ActionConstantPool pool = (ActionConstantPool) action;
|
||||
bytes.addAll(ByteUtil.intToBytes(pool.getPool().size())); // maybe there should also be u8 size of data
|
||||
data.addAll(ByteUtil.intToBytes(pool.getPool().size()));
|
||||
pool.getPool().forEach(s -> {
|
||||
bytes.addAll(fromString(s));
|
||||
data.addAll(fromString(s));
|
||||
});
|
||||
bytes.addAll(ByteUtil.intToBytes(data.size()));
|
||||
bytes.addAll(data);
|
||||
break;
|
||||
}
|
||||
});
|
||||
bytes.add((byte) 0x0);
|
||||
int val = getType().getId() << 6;
|
||||
val |= 63; // 265955
|
||||
return Stream.of( ByteUtil.intToBytes(val), ByteUtil.intToBytes32(bytes.size()+6), bytes ).flatMap(Collection::stream).collect(Collectors.toList());
|
||||
return Stream.of( ByteUtil.intToBytes(val), ByteUtil.intToBytes32(bytes.size()), bytes ).flatMap(Collection::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<Byte> fromString(String s) {
|
||||
|
@ -69,10 +69,10 @@ public class ByteUtil {
|
||||
}
|
||||
|
||||
public static List<Byte> doubleToBytes(double d) {
|
||||
byte[] b = ByteBuffer.allocate(8).putDouble(d).array();
|
||||
byte[] b = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putDouble(d).array();
|
||||
byte[] b1 = new byte[8];
|
||||
System.arraycopy(b, 0, b1, 4, 4);
|
||||
System.arraycopy(b, 4, b1, 0, 4);
|
||||
System.arraycopy(b, 0, b1, 4, 4);
|
||||
return fromPrimitive(b1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user