use of info.ata4.junity.serialize.typetree.TypeRoot in project disunity by ata4.
the class SerializedFileReader method readObjects.
private void readObjects(DataReader in) throws IOException {
long ofsMin = Long.MAX_VALUE;
long ofsMax = Long.MIN_VALUE;
SerializedFileHeader header = serialized.header();
SerializedFileMetadata metadata = serialized.metadata();
Map<Long, ObjectInfo> objectInfoMap = metadata.objectInfoTable().infoMap();
Map<Integer, TypeRoot<Type>> typeTreeMap = metadata.typeTree().typeMap();
List<SerializedObjectData> objectData = serialized.objectData();
for (Map.Entry<Long, ObjectInfo> infoEntry : objectInfoMap.entrySet()) {
ObjectInfo info = infoEntry.getValue();
long id = infoEntry.getKey();
long ofs = header.dataOffset() + info.offset();
ofsMin = Math.min(ofsMin, ofs);
ofsMax = Math.max(ofsMax, ofs + info.length());
SerializedObjectData object = new SerializedObjectData(id);
object.info(info);
// create and read object data buffer
ByteBuffer buf = ByteBufferUtils.allocate((int) info.length());
in.position(ofs);
in.readBuffer(buf);
object.buffer(buf);
// get type tree if possible
TypeRoot typeRoot = typeTreeMap.get(info.typeID());
if (typeRoot != null) {
object.typeTree(typeRoot.nodes());
}
objectData.add(object);
}
DataBlock objectDataBlock = serialized.objectDataBlock();
objectDataBlock.offset(ofsMin);
objectDataBlock.endOffset(ofsMax);
L.log(Level.FINER, "objectDataBlock: {0}", objectDataBlock);
}
use of info.ata4.junity.serialize.typetree.TypeRoot 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;
}
use of info.ata4.junity.serialize.typetree.TypeRoot in project disunity by ata4.
the class TypeTreeV3 method read.
@Override
public void read(DataReader in) throws IOException {
revision = new UnityVersion(in.readStringNull(255));
attributes = in.readInt();
embedded = in.readBoolean();
int numBaseClasses = in.readInt();
for (int i = 0; i < numBaseClasses; i++) {
int classID = in.readInt();
TypeRoot typeRoot = new TypeRoot();
typeRoot.classID(classID);
if (classID < 0) {
UnityHash128 scriptID = new UnityHash128();
in.readStruct(scriptID);
typeRoot.scriptID(scriptID);
}
UnityHash128 oldTypeHash = new UnityHash128();
in.readStruct(oldTypeHash);
typeRoot.oldTypeHash(oldTypeHash);
if (embedded) {
Node<T> node = new Node<>();
readNode(in, node);
typeRoot.nodes(node);
}
typeMap.put(classID, typeRoot);
}
}
Aggregations