public override void Read(EndianBinReader reader) { var pageNameOffset = reader.ReadUInt32(); var pairUnitCount = reader.ReadUInt32(); var pairUnitOffset = reader.ReadUInt32(); reader.BaseStream.Position = pageNameOffset; Name = reader.ReadNullTerminatedString(); reader.BaseStream.Position += reader.BaseStream.Position % 0x10; // Padding with 0x5E for (int i = 0; i < pairUnitCount; i++) { reader.BaseStream.Position = pairUnitOffset + (i * EntrySize); int id = reader.ReadInt32(); uint labelOffset = reader.ReadUInt32(); uint valueOffset = reader.ReadUInt32(); reader.BaseStream.Position = labelOffset; string label = reader.ReadNullTerminatedString(); reader.BaseStream.Position = valueOffset; string value = reader.ReadNullTerminatedString(); var pair = new RTextPairUnit(id, label, value); PairUnits.Add(label, pair); } }
public override void Read(EndianBinReader reader) { var pageNameOffset = _gt7 ? reader.ReadInt64() : reader.ReadUInt32(); var pairUnitCount = reader.ReadUInt32(); reader.ReadUInt32(); // Unk var pairUnitOffset = _gt7 ? reader.ReadInt64() : reader.ReadUInt32(); reader.BaseStream.Position = (int)pageNameOffset; Name = reader.ReadNullTerminatedString(); for (int i = 0; i < pairUnitCount; i++) { reader.BaseStream.Position = pairUnitOffset + (i * (_gt7 ? EntrySizeGT7 : EntrySize)); int id = reader.ReadInt32(); ushort labelLen = reader.ReadUInt16(); ushort valueLen = reader.ReadUInt16(); long labelOffset = _gt7 ? reader.ReadInt64() : reader.ReadUInt32(); long valueOffset = _gt7 ? reader.ReadInt64() : reader.ReadUInt32(); reader.BaseStream.Position = labelOffset; string label = ReadString(reader, labelLen); reader.BaseStream.Position = valueOffset; string value = ReadString(reader, valueLen); var pair = new RTextPairUnit(id, label, value); PairUnits.Add(label, pair); } }
public override void Read(byte[] data) { using (var ms = new MemoryStream(data)) using (var reader = new EndianBinReader(ms, EndianType.LITTLE_ENDIAN)) { reader.BaseStream.Position = 0; if (reader.ReadString(4) != Magic) { throw new Exception($"Invalid magic, doesn't match {Magic}."); } int entryCount = reader.ReadInt32(); // Relocation ptr is at 0x10 // Data starts at 0x20 for (int i = 0; i < entryCount; i++) { ms.Position = HeaderSize + (i * (_gt7 ? 0x18 : 0x10)); var page = new RT05Page(_logWriter, gt7: _gt7); page.Read(reader); _pages.Add(page.Name, page); } } }
public override void Read(byte[] data) { using (var ms = new MemoryStream(data)) using (var reader = new EndianBinReader(ms, EndianType.LITTLE_ENDIAN)) { reader.BaseStream.Position = 0; if (reader.ReadString(4) != Magic) { throw new Exception("Invalid magic, doesn't match RT03."); } reader.ReadInt32(); // Relocation Ptr reader.ReadUInt32(); // Empty - skipped by GT4 int entryCount = reader.ReadInt32(); for (int i = 0; i < entryCount; i++) { ms.Position = HeaderSize + (i * 0x10); var page = new RT03Page(_logWriter); page.Read(reader); _pages.Add(page.Name, page); } } }
static void Main(string[] args) { if (args.Count() == 1) { // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(args[0]); //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { byte[] tmp = null; if (IsEncrypted(File.ReadAllBytes(Path.Combine(args[0], "REPLAY.0")))) { tmp = Decrypt(args[0]); } else { tmp = File.ReadAllBytes(Path.Combine(args[0], "REPLAY.0")); } if (tmp == null) { Console.WriteLine("Decryption Failed!"); return; } int pos = ContainsTED(tmp); if (pos < 4) { Console.WriteLine("Couldn't find GT6TED file!"); return; } using (MemoryStream ms = new MemoryStream(tmp)) { EndianBinReader reader = new EndianBinReader(ms); reader.BaseStream.Position = (pos - 4); int length = reader.ReadInt32(); byte[] data = reader.ReadBytes(length); File.WriteAllBytes(Path.Combine(args[0], "extracted.ted"), data); } File.WriteAllBytes(Path.Combine(args[0], "REPLAY.0"), tmp); } else { byte[] tmp = null; if (IsEncrypted(File.ReadAllBytes(args[0]))) { tmp = Decrypt(Path.GetDirectoryName(args[0])); } else { tmp = File.ReadAllBytes(args[0]); } if (tmp == null) { Console.WriteLine("Decryption Failed!"); return; } int pos = ContainsTED(tmp); if (pos < 4) { Console.WriteLine("Couldn't find GT6TED file!"); return; } using (MemoryStream ms = new MemoryStream(tmp)) { EndianBinReader reader = new EndianBinReader(ms); reader.BaseStream.Position = (pos - 4); int length = reader.ReadInt32(); byte[] data = reader.ReadBytes(length); File.WriteAllBytes(Path.Combine(Path.GetDirectoryName(args[0]), "extracted.ted"), data); } File.WriteAllBytes(args[0], tmp); } } else { WriteInfo(); } }