mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 16:28:10 +00:00
Fixing header fields, fields printer
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.jpexs.decompiler.flash.iggy;
|
||||
|
||||
import com.jpexs.decompiler.flash.iggy.annotations.FieldPrinter;
|
||||
import com.jpexs.decompiler.flash.iggy.streams.ReadDataStreamInterface;
|
||||
import com.jpexs.decompiler.flash.iggy.streams.WriteDataStreamInterface;
|
||||
import com.jpexs.decompiler.flash.iggy.annotations.IggyFieldType;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,17 +16,17 @@ import java.io.IOException;
|
||||
public class IggyFlashHeader64 implements IggyFlashHeaderInterface {
|
||||
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long main_offset; // 0 Relative offset to first section (matches sizeof header);
|
||||
long off_start; // 0 Relative offset to first section (matches sizeof header);
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long as3_section_offset; // 8 Relative offset to as3 file names table...
|
||||
long off_seq_end; // 8 Relative offset to as3 file names table...
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset; // 0x10 relative offset to something
|
||||
long off_font_end; // 0x10 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset2; // 0x18 relative offset to something
|
||||
long off_seq_start1; // 0x18 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset3; // 0x20 relative offset to something
|
||||
long pad_to_match; // 0x20 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset4; // 0x28 names_offset; 0x50 relative pointer to the names/import section of the file
|
||||
long off_seq_start2; // 0x28 names_offset; 0x50 relative pointer to the names/import section of the file
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long xmin; // 0x30 in pixels
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
@@ -49,32 +51,34 @@ public class IggyFlashHeader64 implements IggyFlashHeaderInterface {
|
||||
float frame_rate;
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long unk_5C;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long fonts_offset;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_68;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long names_offset; // 0x70 relative offset to the names/import section of the file - end of fonts
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset5; // 0x78 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_80; // Maybe number of imports/names pointed by names_offset
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long last_section_offset; // 0x88 relative offset, points to the small last section of the file
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_offset6; // 0x90 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long as3_code_offset; // 0x98 relative offset to as3 code (16 bytes header + abc blob)
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long as3_names_offset; // 0xA0 relative offset to as3 file names table (or classes names or whatever)
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long unk_A8;
|
||||
@IggyFieldType(DataType.uint32_t) //font_main_off
|
||||
long unk_AC; //font_main_size
|
||||
@IggyFieldType(DataType.uint32_t) //font_info_off
|
||||
long font_count; // Maybe number of classes / as3 names //font_info_size
|
||||
long additional_import1;
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long unk_B4; //zero (?)
|
||||
long zero1;
|
||||
//boolean imported = false;
|
||||
//if( additional_import1 > 0 ) imported = true
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long unk_guid; // same for some fonts (eng + chinese)
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_names; // 0x70 relative offset to the names/import section of the file - end of fonts
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_unk8C; // 0x78 relative offset to something
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_unk80;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_last_section;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_flash_filename;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_decl_strings;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long off_type_of_fonts;
|
||||
@IggyFieldType(DataType.uint64_t)
|
||||
long flags;
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long font_count;
|
||||
@IggyFieldType(DataType.uint32_t)
|
||||
long zero2;
|
||||
|
||||
// Offset 0xB8 (outside header): there are *unk_40* relative offsets that point to flash objects.
|
||||
// The flash objects are in a format different to swf but there is probably a way to convert between them.
|
||||
@@ -86,14 +90,80 @@ public class IggyFlashHeader64 implements IggyFlashHeaderInterface {
|
||||
readFromDataStream(stream);
|
||||
}
|
||||
|
||||
private long base_address;
|
||||
private long sequence_end_address;
|
||||
private long font_end_address;
|
||||
private long sequence_start_address;
|
||||
private long names_address;
|
||||
private long unk8C_address;
|
||||
private long unk80_address;
|
||||
private long last_section_address;
|
||||
private long flash_filename_address;
|
||||
private long decl_strings_address;
|
||||
private long type_fonts_address;
|
||||
|
||||
public long getBaseAddress() {
|
||||
return base_address;
|
||||
}
|
||||
|
||||
public long getSequenceEndAddress() {
|
||||
return sequence_end_address;
|
||||
}
|
||||
|
||||
public long getFontEndAddress() {
|
||||
return font_end_address;
|
||||
}
|
||||
|
||||
public long getSequenceStartAddress() {
|
||||
return sequence_start_address;
|
||||
}
|
||||
|
||||
public long getNamesAddress() {
|
||||
return names_address;
|
||||
}
|
||||
|
||||
public long getUnk8CAddress() {
|
||||
return unk8C_address;
|
||||
}
|
||||
|
||||
public long getUnk80Address() {
|
||||
return unk80_address;
|
||||
}
|
||||
|
||||
public long getLastSectionAddress() {
|
||||
return last_section_address;
|
||||
}
|
||||
|
||||
public long getFlashFilenameAddress() {
|
||||
return flash_filename_address;
|
||||
}
|
||||
|
||||
public long getDeclStringsAddress() {
|
||||
return decl_strings_address;
|
||||
}
|
||||
|
||||
public long getTypeFontsAddress() {
|
||||
return type_fonts_address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromDataStream(ReadDataStreamInterface stream) throws IOException {
|
||||
main_offset = stream.readUI64();
|
||||
as3_section_offset = stream.readUI64();
|
||||
unk_offset = stream.readUI64();
|
||||
unk_offset2 = stream.readUI64();
|
||||
unk_offset3 = stream.readUI64();
|
||||
unk_offset4 = stream.readUI64();
|
||||
off_start = stream.readUI64();
|
||||
base_address = off_start + stream.position() - 8;
|
||||
off_seq_end = stream.readUI64();
|
||||
sequence_end_address = off_seq_end + stream.position() - 8;
|
||||
off_font_end = stream.readUI64();
|
||||
font_end_address = off_font_end + stream.position() - 8;
|
||||
off_seq_start1 = stream.readUI64(); //to 1 padd occurence (2 times)
|
||||
pad_to_match = stream.readUI64();
|
||||
if (pad_to_match != 1) {
|
||||
throw new IOException("Wrong iggy file - no pad to match 1");
|
||||
}
|
||||
off_seq_start2 = stream.readUI64();
|
||||
if (off_seq_start1 != off_seq_start2) {
|
||||
throw new IOException("Wrong iggy font format (sequence_start)!\n");
|
||||
}
|
||||
sequence_start_address = off_seq_start2 + stream.position() - 8;
|
||||
xmin = stream.readUI32();
|
||||
ymin = stream.readUI32();
|
||||
xmax = stream.readUI32();
|
||||
@@ -106,30 +176,38 @@ public class IggyFlashHeader64 implements IggyFlashHeaderInterface {
|
||||
unk_54 = stream.readUI32();
|
||||
frame_rate = stream.readFloat();
|
||||
unk_5C = stream.readUI32();
|
||||
fonts_offset = stream.readUI64();
|
||||
unk_68 = stream.readUI64();
|
||||
names_offset = stream.readUI64();
|
||||
unk_offset5 = stream.readUI64();
|
||||
unk_80 = stream.readUI64();
|
||||
last_section_offset = stream.readUI64();
|
||||
unk_offset6 = stream.readUI64();
|
||||
as3_code_offset = stream.readUI64();
|
||||
as3_names_offset = stream.readUI64();
|
||||
unk_A8 = stream.readUI32();
|
||||
unk_AC = stream.readUI32();
|
||||
font_count = stream.readUI32();
|
||||
unk_B4 = stream.readUI32();
|
||||
additional_import1 = stream.readUI32();
|
||||
zero1 = stream.readUI32();
|
||||
unk_guid = stream.readUI64();
|
||||
|
||||
off_names = stream.readUI64();
|
||||
names_address = off_names + stream.position() - 8;
|
||||
off_unk8C = stream.readUI64();
|
||||
unk8C_address = off_unk8C + stream.position() - 8;
|
||||
off_unk80 = stream.readUI64();
|
||||
unk80_address = off_unk80 + stream.position() - 8;
|
||||
off_last_section = stream.readUI64();
|
||||
last_section_address = off_last_section + stream.position() - 8;
|
||||
off_flash_filename = stream.readUI64();
|
||||
flash_filename_address = off_flash_filename + stream.position() - 8;
|
||||
off_decl_strings = stream.readUI64();
|
||||
decl_strings_address = off_decl_strings + stream.position() - 8;
|
||||
off_type_of_fonts = stream.readUI64();
|
||||
type_fonts_address = off_type_of_fonts + stream.position() - 8;
|
||||
|
||||
flags = stream.readUI64();
|
||||
font_count = stream.readUI32();
|
||||
zero2 = stream.readUI32();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToDataStream(WriteDataStreamInterface stream) throws IOException {
|
||||
stream.writeUI64(main_offset);
|
||||
stream.writeUI64(as3_section_offset);
|
||||
stream.writeUI64(unk_offset);
|
||||
stream.writeUI64(unk_offset2);
|
||||
stream.writeUI64(unk_offset3);
|
||||
stream.writeUI64(unk_offset4);
|
||||
stream.writeUI64(off_start);
|
||||
stream.writeUI64(off_seq_end);
|
||||
stream.writeUI64(off_font_end);
|
||||
stream.writeUI64(off_seq_start1);
|
||||
stream.writeUI64(pad_to_match);
|
||||
stream.writeUI64(off_seq_start2);
|
||||
stream.writeUI32(xmin);
|
||||
stream.writeUI32(ymin);
|
||||
stream.writeUI32(xmax);
|
||||
@@ -142,77 +220,24 @@ public class IggyFlashHeader64 implements IggyFlashHeaderInterface {
|
||||
stream.writeUI32(unk_54);
|
||||
stream.writeFloat(frame_rate);
|
||||
stream.writeUI32(unk_5C);
|
||||
stream.writeUI64(fonts_offset);
|
||||
stream.writeUI64(unk_68);
|
||||
stream.writeUI64(names_offset);
|
||||
stream.writeUI64(unk_offset5);
|
||||
stream.writeUI64(unk_80);
|
||||
stream.writeUI64(last_section_offset);
|
||||
stream.writeUI64(unk_offset6);
|
||||
stream.writeUI64(as3_code_offset);
|
||||
stream.writeUI64(as3_names_offset);
|
||||
stream.writeUI32(unk_A8);
|
||||
stream.writeUI32(unk_AC);
|
||||
stream.writeUI32(additional_import1);
|
||||
stream.writeUI32(zero1);
|
||||
stream.writeUI64(unk_guid);
|
||||
stream.writeUI64(off_names);
|
||||
stream.writeUI64(off_unk8C);
|
||||
stream.writeUI64(off_unk80);
|
||||
stream.writeUI64(off_last_section);
|
||||
stream.writeUI64(off_flash_filename);
|
||||
stream.writeUI64(off_decl_strings);
|
||||
stream.writeUI64(off_type_of_fonts);
|
||||
stream.writeUI64(flags);
|
||||
stream.writeUI32(font_count);
|
||||
stream.writeUI32(unk_B4);
|
||||
stream.writeUI32(zero2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[\r\n");
|
||||
sb.append("main_offset ").append(main_offset).append("\r\n");
|
||||
sb.append("as3_section_offset ").append(as3_section_offset);
|
||||
sb.append(" global: ").append(main_offset + as3_section_offset);
|
||||
sb.append("\r\n");
|
||||
sb.append("unk_offset ").append(unk_offset);
|
||||
if (unk_offset != 1) {
|
||||
sb.append(" global: ").append(main_offset + unk_offset);
|
||||
}
|
||||
sb.append("\r\n");
|
||||
sb.append("unk_offset2 ").append(unk_offset2);
|
||||
if (unk_offset2 != 1) {
|
||||
sb.append(" global: ").append(main_offset + unk_offset2);
|
||||
}
|
||||
sb.append("\r\n");
|
||||
sb.append("unk_offset3 ").append(unk_offset3);
|
||||
if (unk_offset3 != 1) {
|
||||
sb.append(" global: ").append(main_offset + unk_offset3);
|
||||
}
|
||||
sb.append("\r\n");
|
||||
sb.append("unk_offset4 ").append(unk_offset4);
|
||||
if (unk_offset4 != 1) {
|
||||
sb.append(" global: ").append(main_offset + unk_offset4);
|
||||
}
|
||||
sb.append("\r\n");
|
||||
sb.append("xmin ").append(xmin).append("\r\n");
|
||||
sb.append("ymin ").append(ymin).append("\r\n");
|
||||
sb.append("xmax ").append(ymax).append("\r\n");
|
||||
sb.append("ymax ").append(ymax).append("\r\n");
|
||||
sb.append("unk_40 ").append(unk_40).append("\r\n");
|
||||
sb.append("unk_44 ").append(unk_44).append("\r\n");
|
||||
sb.append("unk_48 ").append(unk_48).append("\r\n");
|
||||
sb.append("unk_4C ").append(unk_4C).append("\r\n");
|
||||
sb.append("unk_50 ").append(unk_50).append("\r\n");
|
||||
sb.append("unk_54 ").append(unk_54).append("\r\n");
|
||||
sb.append("frame_rate ").append(frame_rate).append("\r\n");
|
||||
sb.append("unk_5C ").append(unk_5C).append("\r\n");
|
||||
sb.append("fonts_offset ").append(fonts_offset).append("\r\n");
|
||||
sb.append("unk_68 ").append(unk_68).append("\r\n");
|
||||
sb.append("names_offset ").append(names_offset).append("\r\n");
|
||||
sb.append("unk_offset5 ").append(unk_offset5).append("\r\n");
|
||||
sb.append("unk_80 ").append(unk_80).append("\r\n");
|
||||
sb.append("last_section_offset ").append(last_section_offset).append("\r\n");
|
||||
sb.append("unk_offset6 ").append(unk_offset6).append("\r\n");
|
||||
sb.append("as3_code_offset ").append(as3_code_offset).append("\r\n");
|
||||
sb.append("as3_names_offset ").append(as3_names_offset).append("\r\n");
|
||||
sb.append("unk_A8 ").append(unk_A8).append("\r\n");
|
||||
sb.append("unk_AC ").append(unk_AC).append("\r\n");
|
||||
sb.append("font_count ").append(font_count).append("\r\n");
|
||||
sb.append("unk_B4 ").append(unk_B4).append("\r\n");
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
|
||||
return FieldPrinter.getObjectSummary(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.jpexs.decompiler.flash.iggy.annotations;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FieldPrinter {
|
||||
|
||||
public static String getObjectSummary(Object val) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("/---" + val.getClass().getSimpleName() + "---\r\n");
|
||||
for (Field f : val.getClass().getDeclaredFields()) {
|
||||
sb.append(f.getName()).append(": ");
|
||||
IggyFieldType an = f.getAnnotation(IggyFieldType.class);
|
||||
if (an != null) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
switch (an.value()) {
|
||||
case float_t:
|
||||
sb.append(f.getFloat(val));
|
||||
break;
|
||||
case uint8_t:
|
||||
case uint16_t:
|
||||
sb.append(f.getInt(val));
|
||||
break;
|
||||
case uint32_t:
|
||||
case uint64_t:
|
||||
sb.append(f.getLong(val));
|
||||
break;
|
||||
case widechar_t:
|
||||
sb.append("\"").append(f.get(val)).append("\"");
|
||||
break;
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
sb.append("\r\n");
|
||||
}
|
||||
sb.append("---/");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getObjectWriteTo(Class<?> cls) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Field f : cls.getDeclaredFields()) {
|
||||
sb.append("stream.write");
|
||||
IggyFieldType an = f.getAnnotation(IggyFieldType.class);
|
||||
if (an != null) {
|
||||
switch (an.value()) {
|
||||
case float_t:
|
||||
sb.append("Float");
|
||||
break;
|
||||
case uint8_t:
|
||||
sb.append("UI8");
|
||||
break;
|
||||
case uint16_t:
|
||||
sb.append("UI16");
|
||||
break;
|
||||
case uint32_t:
|
||||
sb.append("UI32");
|
||||
break;
|
||||
case uint64_t:
|
||||
sb.append("UI64");
|
||||
break;
|
||||
case widechar_t:
|
||||
sb.append("//FIXME");
|
||||
break;
|
||||
}
|
||||
sb.append("(").append(f.getName()).append(");\r\n");
|
||||
if (an.count() > 0) {
|
||||
sb.append("//FIXME count");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user