Search in sources :

Example 1 with ObjectInfoV3

use of info.ata4.junity.serialize.objectinfo.ObjectInfoV3 in project disunity by ata4.

the class AssetObjects method tableModel.

@Override
protected TableModel tableModel(SerializedFile serialized) {
    SerializedFileMetadata metadata = serialized.metadata();
    TableBuilder table = new TableBuilder();
    table.row("Path ID", "Offset", "Length", "Type ID", "Class ID");
    Class<ObjectInfo> factory = metadata.objectInfoTable().elementFactory();
    boolean typeTreePresent = metadata.typeTree().embedded();
    boolean v2 = ObjectInfoV2.class.isAssignableFrom(factory);
    boolean v3 = ObjectInfoV3.class.isAssignableFrom(factory);
    if (typeTreePresent) {
        table.append("Class Name");
    }
    if (v2) {
        table.append("Script Type ID");
    }
    if (v3) {
        table.append("Stripped");
    }
    metadata.objectInfoTable().infoMap().entrySet().stream().forEach(e -> {
        ObjectInfo info = e.getValue();
        table.row(e.getKey(), info.offset(), info.length(), info.typeID(), info.classID());
        if (typeTreePresent) {
            TypeRoot<Type> baseClass = metadata.typeTree().typeMap().get(info.typeID());
            String className = baseClass.nodes().data().typeName();
            table.append(className);
        }
        if (v2) {
            table.append(((ObjectInfoV2) info).scriptTypeIndex());
        }
        if (v3) {
            table.append(((ObjectInfoV3) info).isStripped());
        }
    });
    TableModel model = new TableModel("Objects", table.get());
    TextTableFormat format = model.format();
    format.columnFormatter(1, Formatters::hex);
    return model;
}
Also used : SerializedFileMetadata(info.ata4.junity.serialize.SerializedFileMetadata) Type(info.ata4.junity.serialize.typetree.Type) Formatters(info.ata4.disunity.cli.util.Formatters) TextTableFormat(info.ata4.disunity.cli.util.TextTableFormat) TableBuilder(info.ata4.disunity.cli.util.TableBuilder) ObjectInfo(info.ata4.junity.serialize.objectinfo.ObjectInfo) TableModel(info.ata4.disunity.cli.util.TableModel)

Example 2 with ObjectInfoV3

use of info.ata4.junity.serialize.objectinfo.ObjectInfoV3 in project disunity by ata4.

the class SerializedFileMetadata method read.

@Override
public void read(DataReader in) throws IOException {
    // load type tree
    if (version > 13) {
        typeTree = new TypeTreeV3(TypeV2.class);
    } else if (version > 6) {
        typeTree = new TypeTreeV2(TypeV1.class);
    } else {
        typeTree = new TypeTreeV1(TypeV1.class);
    }
    typeTreeBlock.markBegin(in);
    in.readStruct(typeTree);
    typeTreeBlock.markEnd(in);
    L.log(Level.FINER, "typeTreeBlock: {0}", typeTreeBlock);
    // load object info table
    if (version > 14) {
        objectInfoTable = new ObjectInfoTableV2(ObjectInfoV3.class);
    } else if (version > 13) {
        objectInfoTable = new ObjectInfoTableV2(ObjectInfoV2.class);
    } else {
        objectInfoTable = new ObjectInfoTableV1(ObjectInfoV1.class);
    }
    objectInfoBlock.markBegin(in);
    in.readStruct(objectInfoTable);
    objectInfoBlock.markEnd(in);
    L.log(Level.FINER, "objectInfoBlock: {0}", objectInfoBlock);
    // load object identifiers (Unity 5+ only)
    objectIDTable = new ObjectIdentifierTable();
    if (version > 10) {
        objectIDBlock.markBegin(in);
        in.readStruct(objectIDTable);
        objectIDBlock.markEnd(in);
        L.log(Level.FINER, "objectIDBlock: {0}", objectIDBlock);
    }
    // load external references
    if (version > 5) {
        externals = new FileIdentifierTable(FileIdentifierV2.class);
    } else {
        externals = new FileIdentifierTable(FileIdentifierV1.class);
    }
    externalsBlock.markBegin(in);
    in.readStruct(externals);
    externalsBlock.markEnd(in);
    L.log(Level.FINER, "externalsBlock: {0}", externalsBlock);
}
Also used : ObjectInfoTableV1(info.ata4.junity.serialize.objectinfo.ObjectInfoTableV1) ObjectInfoTableV2(info.ata4.junity.serialize.objectinfo.ObjectInfoTableV2) FileIdentifierTable(info.ata4.junity.serialize.fileidentifier.FileIdentifierTable) TypeTreeV3(info.ata4.junity.serialize.typetree.TypeTreeV3) TypeV2(info.ata4.junity.serialize.typetree.TypeV2) TypeTreeV2(info.ata4.junity.serialize.typetree.TypeTreeV2) TypeTreeV1(info.ata4.junity.serialize.typetree.TypeTreeV1) ObjectInfoV3(info.ata4.junity.serialize.objectinfo.ObjectInfoV3) ObjectIdentifierTable(info.ata4.junity.serialize.objectidentifier.ObjectIdentifierTable) FileIdentifierV2(info.ata4.junity.serialize.fileidentifier.FileIdentifierV2) FileIdentifierV1(info.ata4.junity.serialize.fileidentifier.FileIdentifierV1)

Aggregations

Formatters (info.ata4.disunity.cli.util.Formatters)1 TableBuilder (info.ata4.disunity.cli.util.TableBuilder)1 TableModel (info.ata4.disunity.cli.util.TableModel)1 TextTableFormat (info.ata4.disunity.cli.util.TextTableFormat)1 SerializedFileMetadata (info.ata4.junity.serialize.SerializedFileMetadata)1 FileIdentifierTable (info.ata4.junity.serialize.fileidentifier.FileIdentifierTable)1 FileIdentifierV1 (info.ata4.junity.serialize.fileidentifier.FileIdentifierV1)1 FileIdentifierV2 (info.ata4.junity.serialize.fileidentifier.FileIdentifierV2)1 ObjectIdentifierTable (info.ata4.junity.serialize.objectidentifier.ObjectIdentifierTable)1 ObjectInfo (info.ata4.junity.serialize.objectinfo.ObjectInfo)1 ObjectInfoTableV1 (info.ata4.junity.serialize.objectinfo.ObjectInfoTableV1)1 ObjectInfoTableV2 (info.ata4.junity.serialize.objectinfo.ObjectInfoTableV2)1 ObjectInfoV3 (info.ata4.junity.serialize.objectinfo.ObjectInfoV3)1 Type (info.ata4.junity.serialize.typetree.Type)1 TypeTreeV1 (info.ata4.junity.serialize.typetree.TypeTreeV1)1 TypeTreeV2 (info.ata4.junity.serialize.typetree.TypeTreeV2)1 TypeTreeV3 (info.ata4.junity.serialize.typetree.TypeTreeV3)1 TypeV2 (info.ata4.junity.serialize.typetree.TypeV2)1