public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s) { ms.ReadInt(); ms.ReadInt(); ms.ReadInt(); ms.ReadInt(); }
public override void Read(IOMemoryStream ms) { if (length != 8) { throw new Exception("Unexpected ObjectProperty length: " + length); } //Check type int linkType = ms.ReadInt(); if (linkType != 0 && linkType != 1) { throw new Exception("Unexepcted link type: " + linkType); } //Read isLocalLink = linkType == 0; if (isLocalLink) { localLinkIndex = ms.ReadInt(); } else { gameLinkIndex = ms.ReadUEString(); //Not tested } }
public InlineProperty(IOMemoryStream ms) { startPos = ms.position; name = ms.ReadInlineArkClassname(); type = ms.ReadInlineArkClassname(); length = ms.ReadInt(); index = ms.ReadInt(); }
public static FObjectImport ReadEntry(IOMemoryStream ms, UassetFile f) { //Read in FObjectImport g = new FObjectImport(); g.startPos = ms.position; g.coreType = ms.ReadNameTableEntry(f); g.unknown1 = ms.ReadInt(); g.objectType = ms.ReadNameTableEntry(f); g.unknown2 = ms.ReadInt(); g.index = ms.ReadInt(); g.name = ms.ReadNameTableEntry(f); g.unknown4 = ms.ReadInt(); return(g); }
public static ArkClassName ReadFromFile(IOMemoryStream ms) { ArkClassName cn = new ArkClassName(); cn.classname = ms.ReadUEString(); cn.index = ms.ReadInt(); return(cn); }
public override void Read(IOMemoryStream ms, UAssetFile f) { if (length == 0 || length == 8) { data = ms.ReadNameTableEntry(f); unknown = ms.ReadInt(); } else { data = ms.ReadNameTableEntry(f); } }
public static string[] ReadStringArray(IOMemoryStream ms) { //Read a standard array. First, read the Int32 of the length int length = ms.ReadInt(); //Create an array and read in strings string[] array = new string[length]; for (int i = 0; i < length; i++) { array[i] = ms.ReadUEString(); } return(array); }
public override void Read(IOMemoryStream ms, UAssetFile f) { source = f; //If this is an array, assume 4 if (isArray) { length = 4; } //If the length is four (only seems to happen on version 5), this is an integer. if (length == 4) { objectRefType = ObjectPropertyType.TypeID; objectIndex = ms.ReadInt(); } else if (length >= 8) { //Read type int type = ms.ReadInt(); if (type > 1 || type < 0) { throw new Exception($"Unknown ref type! Expected 0 or 1, but got {type} instead!"); } //Convert this to our enum objectRefType = (ObjectPropertyType)type; //Depending on the type, read it in. if (objectRefType == ObjectPropertyType.TypeID) { objectIndex = ms.ReadInt(); } if (objectRefType == ObjectPropertyType.TypePath) { className = ms.ReadNameTableEntry(f); } } else { throw new Exception($"Unknown object ref length! Expected 4 or >= 8, but got {length} instead."); } }
public DotArkEmbededBinaryData(IOMemoryStream ms) { //First, read the path. path = ms.ReadUEString(); //Now, read the parts. This seems to be split up into part -> blob -> inner blob int parts = ms.ReadInt(); data = new byte[parts][][]; //Loop through each of the parts for (int i = 0; i < parts; i++) { int blobs = ms.ReadInt(); byte[][] partData = new byte[blobs][]; for (int j = 0; j < blobs; j++) { int blobSize = ms.ReadInt() * 4; //Array of 32 bit integers. partData[j] = ms.ReadBytes(blobSize); } data[i] = partData; } }
public byte byteValue; //Use ONLY if the above boolean is true public override void Read(IOMemoryStream ms, UAssetFile f) { if (length == 1) { //Read in the enum name enumName = ms.ReadNameTableEntry(f); //That can be None, but cannot be null. if (enumName == null) { throw new Exception("Tried to read enum type, but got null!"); } isNormalByte = enumName == "None"; //If that type is a None, this is not an enum. If it is, this is an enum. Read the name. if (isNormalByte) { byteValue = ms.ReadByte(); ms.ReadInt(); } else { enumValue = ms.ReadNameTableEntry(f); } } else if (length == 8) { //If the length is 8, this is an enum. It seems to follow like this... //Enum name //Int, usually 0 //Enum value //Int, usually 0 enumType = ms.ReadNameTableEntry(f); ms.position += 4; enumValue = ms.ReadNameTableEntry(f); ms.position += 4; } else if (length == 0) { //Just skip. throw new NotImplementedException(); ms.position += 4; } else { throw new Exception($"Warning: Unknown ByteProperty length '{length}'."); } }
public override void Read(IOMemoryStream ms, UAssetFile f) { //Read the array type arrayType = ms.ReadNameTableEntry(f); unknownArray = ms.ReadInt(); props = new List <UProperty>(); //Skip if this is a ByteProperty if (arrayType == "ByteProperty") { f.Warn("ArrayProperty", "Warning: ArrayProperty is skipping array because ByteProperty arrays are not supported at this time."); ms.position += length; return; } long begin = ms.position; try { //Now, read the count. This cuts into the length int count = ms.ReadInt(); //Read items f.Debug("Read Array", $"====READ ARRAY BEGIN @ {ms.position} ({arrayType}, {unknownArray})====", ConsoleColor.Yellow); for (int i = 0; i < count; i += 1) { //Read value props.Add(UProperty.ReadProp(ms, f, arrayType, false)); } f.Debug("Read Array", $"====READ ARRAY END @ {ms.position}====", ConsoleColor.Yellow); } catch (Exception ex) { f.Warn("ArrayProperty", $"Warning: Failed to read array '{name}' with type '{type}' in class '{f.classname}' for '{ex.Message}'. It will now be skipped."); ms.position = begin + length; } }
public InlineArrayProperty(IOMemoryStream ms) : base(ms) { //Read type arrayType = ms.ReadInlineArkClassname(); if (arrayType.classname == "StrProperty") { //Read string array int count = ms.ReadInt(); data = new string[count]; for (int i = 0; i < count; i += 1) { data[i] = ms.ReadUEString(); } } else { //Skip ms.position += length; } }
public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s) { //Read into array List <UProperty> sprops = UProperty.ReadProperties(ms, f, null, true); count = sprops.Count; propsList = sprops; props = new Dictionary <string, UProperty>(); //Convert to dict foreach (UProperty p in sprops) { if (!props.ContainsKey(p.name)) { props.Add(p.name, p); } } //Read two unknown ints u1 = ms.ReadInt(); }
public static ARKDinoDataObject[] ReadData(byte[] content) { //Open stream IOMemoryStream stream = new IOMemoryStream(new System.IO.MemoryStream(content), true); //Read number of values int objectCount = stream.ReadInt(); //Read object headers ARKDinoDataObject[] objects = new ARKDinoDataObject[objectCount]; for (int i = 0; i < objectCount; i++) { objects[i] = ARKDinoDataObject.ReadFromFile(stream); } //Now, read payloads for all of these objects foreach (ARKDinoDataObject o in objects) { stream.position = o.payloadStart; o.properties = new List <BaseProperty>(); BaseProperty prop = BaseProperty.ReadProperty(stream); while (prop != null) { o.properties.Add(prop); prop = BaseProperty.ReadProperty(stream); } } //Now, link all of the properties foreach (ARKDinoDataObject o in objects) { foreach (BaseProperty prop in o.properties) { prop.Link(objects); } } return(objects); }
public InlineFile ReadInlineFile(MemoryStream mms) { //Open IO ms IOMemoryStream ms = new IOMemoryStream(mms, true); //Skip the unknown header of 24 bytes ms.position = 24; //Read in the additional header ms.ReadUEString(); //PrimalPlayerDataBP_C ms.ReadInt(); ms.ReadInt(); ms.ReadUEString(); //PrimalPlayerDataBP_C_5 ms.ReadUEString(); //ArkGameMode ms.ReadUEString(); //PersistentLevel ms.ReadUEString(); //Extinction (or map name) ms.ReadUEString(); //(Game map path) ms.ReadInt(); ms.ReadInt(); ms.ReadInt(); ms.ReadInt(); ms.ReadInt(); //Start reading props List <InlineProperty> props = new List <InlineProperty>(); InlineProperty p = InlineProperty.ReadProperty(ms); while (p != null) { props.Add(p); p = InlineProperty.ReadProperty(ms); } return(new InlineFile { props = props }); }
public static ARKDinoDataObject ReadFromFile(IOMemoryStream ms) { //Skip some unknown data, not even sure if this is part of the struct ms.position += 4 * 4; //Read ARKDinoDataObject h = new ARKDinoDataObject(); h.name = ms.ReadUEString(); h.unknown1 = ms.ReadInt(); h.unknown2 = ms.ReadInt(); h.type = ms.ReadUEString(); h.unknown3 = ms.ReadUEString(); h.unknown4 = ms.ReadUEString(); h.unknown5 = ms.ReadUEString(); if (h.unknown2 == 5) //Don't know why { h.unknown52 = ms.ReadUEString(); } //Don't understand any of this section, but seems to work h.unknown6 = ms.ReadInt(); h.unknown7 = ms.ReadInt(); int test = ms.ReadInt(); if (test == 1) { ms.position += 6 * 4; } //Read more h.payloadStart = ms.ReadInt(); h.unknown8 = ms.ReadInt(); return(h); }
public ArkStructUniqueNetId(IOMemoryStream ms, ArkClassName structType) { unk = ms.ReadInt(); netId = ms.ReadUEString(); }
public static FObjectExport ReadEntry(IOMemoryStream ms, UassetFile f) { //Read in FObjectExport g = new FObjectExport(); g.entryLocation = ms.position; g.id = ms.ReadInt(); g.unknown1 = ms.ReadInt(); g.unknown2 = ms.ReadInt(); g.unknown3 = ms.ReadInt(); g.type = ms.ReadNameTableEntry(f); g.unknown4 = ms.ReadInt(); g.unknown5 = ms.ReadInt(); g.LengthOffset = (int)ms.position; g.dataLength = ms.ReadInt(); g.dataLocation = ms.ReadInt(); g.unknown6 = ms.ReadInt(); g.unknown7 = ms.ReadInt(); g.unknown8 = ms.ReadInt(); g.unknown9 = ms.ReadInt(); g.unknown10 = ms.ReadInt(); g.unknown11 = ms.ReadInt(); g.unknown12 = ms.ReadInt(); g.unknown13 = ms.ReadInt(); g.unknown14 = ms.ReadInt(); g.unknown15 = ms.ReadInt(); g.unknown16 = ms.ReadInt(); g.unknown17 = ms.ReadInt(); g.unknown18 = ms.ReadInt(); g.unknown19 = ms.ReadInt(); g.unknown20 = ms.ReadInt(); g.unknown21 = ms.ReadInt(); g.unknown22 = ms.ReadInt(); long lastPos = ms.position; ms.position = g.dataLocation; g.data = ms.ReadBytes(g.dataLength); ms.position = lastPos; g.uassetFile = f; return(g); }
public static BaseProperty ReadProperty(IOMemoryStream ms) { //Read name string name; try { name = ms.ReadUEString(); if (name == "None") { return(null); } } catch (Exception ex) { throw ex; } //Read type string type = ms.ReadUEString(); if (name == "None") { return(null); } //Create type BaseProperty p; switch (type) { case "FloatProperty": p = new FloatProperty(); break; case "BoolProperty": p = new BoolProperty(); break; case "IntProperty": p = new IntProperty(); break; case "ObjectProperty": p = new ObjectProperty(); break; case "StrProperty": p = new StrProperty(); break; case "UInt32Property": p = new UInt32Property(); break; case "ByteProperty": p = new ByteProperty(); break; case "DoubleProperty": p = new DoubleProperty(); break; case "UInt64Property": p = new UInt64Property(); break; case "UInt16Property": p = new UInt16Property(); break; case "ArrayProperty": p = new ArrayProperty(); break; case "Int8Property": p = new Int8Property(); break; case "StructProperty": p = new StructProperty(); break; default: throw new Exception("Unexpected type " + type + "!"); } //Set values p.name = name; p.type = type; //Read additional parts p.length = ms.ReadInt(); p.index = ms.ReadInt(); //Now, read data p.Read(ms); return(p); }
public override void Read(IOMemoryStream ms) { value = ms.ReadInt(); }
public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s) { unk = ms.ReadInt(); netId = ms.ReadUEString(); }
public override void Read(IOMemoryStream ms, UAssetFile f) { //Is we're in an array, this will **ALWAYS** be a prop list struct. UStruct st; if (isArray) { structType = "(array)"; unknown = 0; st = new PropListStruct(); f.Debug("Read Array", $"====READ STRUCT BEGIN @ {ms.position} ({structType}, {unknown})====", ConsoleColor.Yellow); } else { structType = ms.ReadNameTableEntry(f); unknown = ms.ReadInt(); f.Debug("Read Array", $"====READ STRUCT BEGIN @ {ms.position} ({structType}, {unknown})====", ConsoleColor.Yellow); //Find the struct type. Unknown if real: ItemStatInfo if (structType == "ItemStatInfo" || structType == "ItemNetID" || structType == "ItemNetInfo" || structType == "Transform" || structType == "PrimalPlayerDataStruct" || structType == "PrimalPlayerCharacterConfigStruct" || structType == "PrimalPersistentCharacterStatsStruct" || structType == "TribeData" || structType == "TribeGovernment" || structType == "TerrainInfo" || structType == "ArkInventoryData" || structType == "DinoOrderGroup" || structType == "ARKDinoData") { //Open this as a struct property list. st = new PropListStruct(); } else if (structType == "Vector" || structType == "Rotator") { //3d vector or rotor st = new Vector3Struct(); } else if (structType == "Vector2D") { //2d vector st = new Vector2Struct(); } else if (structType == "Quat") { //Quat st = new QuatStruct(); } else if (structType == "Color") { //Color st = new ColorStruct(); } else if (structType == "LinearColor") { //Linear color st = new LinearColorStruct(); } else if (structType == "UniqueNetIdRepl") { //Some net stuff st = new UniqueNetIdStruct(); } else if (structType == "Guid") { //Some net stuff st = new GuidStruct(); } else if (structType == "IntPoint") { //Some net stuff st = new IntPointStruct(); } else if (structType == "StringAssetReference") { st = new StringAssetReferenceStruct(); } else { //Interpet this as a struct property list. Maybe raise a warning later? f.Warn("Struct Warning", $"Unknown type '{structType}'. Interpeting as a struct property list..."); st = new PropListStruct(); } } //Read st.ReadStruct(ms, f, this); data = st; f.Debug("Read Struct", $"====READ STRUCT END @ {ms.position}====", ConsoleColor.Yellow); }
public override void Read(IOMemoryStream ms, UAssetFile f) { data = ms.ReadInt(); }
public UassetFile(byte[] data, string fullPath) { Fullpath = fullPath; Filename = Path.GetFileNameWithoutExtension(Fullpath); //Create a stream stream = new IOMemoryStream(new MemoryStream(data), true); stream.position = 0; var signature = stream.ReadUInt(); // Check for the file's signature. if (signature != UNREAL_ASSET_MAGIC) { TKContext.LogError("The file provided is not a valid uasset file."); return; } Version = stream.ReadUInt(); stream.ReadBytes(0x10); UnkOffset = stream.ReadInt(); stream.ReadInt(); PackageGroup = Encoding.ASCII.GetString(stream.ReadBytes(0x4)); stream.ReadBytes(0x1); PackageFlags = stream.ReadUInt(); NamesCount = stream.ReadInt(); NamesOffset = stream.ReadInt(); stream.ReadBytes(0x8); ExportsCount = stream.ReadInt(); ExportsOffset = stream.ReadInt(); ImportsCount = stream.ReadInt(); ImportsOffset = stream.ReadInt(); stream.ReadBytes(0x8); UnkOffset2 = stream.ReadInt(); stream.ReadBytes(0x1C); NamesCount2 = stream.ReadInt(); stream.ReadBytes(0x2C); UnkOffset3 = stream.ReadInt(); EndOfFileOffset = stream.ReadInt(); stream.ReadBytes(0x10); UnkOffset4 = stream.ReadInt(); stream.position = NamesOffset; NamesTable = stream.ReadFNameEntries(NamesCount, UE4Version.UE4__4_14); for (int i = 0; i < NamesCount; i++) { TKContext.DebugLog("UassetFile", $"Name Table Entry {i}", NamesTable[i].Name, ConsoleColor.Yellow); } TKContext.LogInner("INFO", $"Uasset names count is {NamesCount}"); //Starts directly after the name table. Assume we're already there ImportsTable = new FObjectImport[ImportsCount]; for (int i = 0; i < ImportsCount; i++) { FObjectImport h = FObjectImport.ReadEntry(stream, this); ImportsTable[i] = h; DebugDump($"FObjectImport {i} @ {h.startPos}", ConsoleColor.Blue, "cType", h.coreType, "u1", h.unknown1.ToString(), "oType", h.objectType, "u2", h.unknown2.ToString(), "i", h.index.ToString(), "name", h.name, "u4", h.unknown4.ToString()); } TKContext.LogInner("INFO", $"Uasset import table size is {ImportsCount}"); //Starts directly after the referenced GameObject table. Assume we're already there ExportsTable = new FObjectExport[ExportsCount]; for (int i = 0; i < ExportsCount; i++) { ExportsTable[i] = FObjectExport.ReadEntry(stream, this); DebugDump($"FObjectExport {i} @ {ExportsTable[i].entryLocation}", ConsoleColor.Magenta, "id", ExportsTable[i].id.ToString(), "u2", ExportsTable[i].unknown2.ToString(), "u3", ExportsTable[i].unknown3.ToString(), "type", ExportsTable[i].type, "u4", ExportsTable[i].unknown4.ToString(), "u5", ExportsTable[i].unknown5.ToString(), "length", ExportsTable[i].dataLength.ToString(), "location", ExportsTable[i].dataLocation.ToString(), "u6", ExportsTable[i].unknown6.ToString(), "u7", ExportsTable[i].unknown7.ToString(), "u8", ExportsTable[i].unknown8.ToString(), "u9", ExportsTable[i].unknown9.ToString(), "u10", ExportsTable[i].unknown10.ToString(), "u11", ExportsTable[i].unknown11.ToString(), "u12", ExportsTable[i].unknown12.ToString(), "u13", ExportsTable[i].unknown13.ToString(), "u14", ExportsTable[i].unknown14.ToString(), "u15", ExportsTable[i].unknown15.ToString(), "u16", ExportsTable[i].unknown16.ToString(), "u17", ExportsTable[i].unknown17.ToString(), "u18", ExportsTable[i].unknown18.ToString(), "u19", ExportsTable[i].unknown19.ToString(), "u20", ExportsTable[i].unknown20.ToString(), "u21", ExportsTable[i].unknown21.ToString(), "u22", ExportsTable[i].unknown22.ToString()); } TKContext.LogInner("INFO", $"Uasset export table size is {ExportsCount}"); using (MemoryStream ms = new MemoryStream()) { stream.position = 0; stream.ms.CopyTo(ms); stream.Close(); FileData = ms.ToArray(); } }
public static FObjectExport ReadEntry(IOMemoryStream ms, UassetFile f) { //Read in FObjectExport g = new FObjectExport(); g.entryLocation = ms.position; g.id = ms.ReadInt(); g.unknown1 = ms.ReadInt(); g.unknown2 = ms.ReadInt(); g.unknown3 = ms.ReadInt(); g.type = ms.ReadNameTableEntry(f); g.unknown4 = ms.ReadInt(); g.unknown5 = ms.ReadInt(); g.dataLength = ms.ReadInt(); g.dataLocation = ms.ReadInt(); g.unknown6 = ms.ReadInt(); g.unknown7 = ms.ReadInt(); g.unknown8 = ms.ReadInt(); g.unknown9 = ms.ReadInt(); g.unknown10 = ms.ReadInt(); g.unknown11 = ms.ReadInt(); g.unknown12 = ms.ReadInt(); g.unknown13 = ms.ReadInt(); g.unknown14 = ms.ReadInt(); g.uassetFile = f; return(g); }
void ReadMysteryFlags() { //Read length int length = ms.ReadInt(); //Initialize the array mysteryFlagData = new DotArkIntroMysteryFlags[length]; //Read in for (int i = 0; i < length; i++) { mysteryFlagData[i] = DotArkIntroMysteryFlags.ReadFromFile(this); } }
public InlineIntProperty(IOMemoryStream ms) : base(ms) { value = ms.ReadInt(); }