public static string ExtractStringAtOffset(EndianBinReader reader, uint offset) { reader.BaseStream.Seek(offset, SeekOrigin.Begin); byte Length = reader.ReadByte(); return(Encoding.ASCII.GetString(reader.ReadBytes(Length), 0, Length)); }
public static string Parse(EndianBinReader node, uint ptr) { uint length = Util.ExtractValueAndAdvance(node, ref ptr); string data = Encoding.ASCII.GetString(node.ReadBytes((int)length)); return(data); }
public static string ExtractStringAtOffset(ref EndianBinReader reader, uint offset) { reader.BaseStream.Position += offset; byte Length = reader.ReadByte(); return(Encoding.ASCII.GetString(reader.ReadBytes((int)Length)).TrimEnd('\0')); }
private string ReadString(EndianBinReader reader, ushort length) { var buffer = reader.ReadBytes(length - 1); /* Haven't seen any evidence in the gt6 eboot upon getting a string that this corresponds to a rtext being encrypted * if (_header.Obfuscated == 1 && buffer.Length > 0) * buffer = Decrypt(buffer, Constants.KEY.AlignString(0x20)); */ buffer = Decrypt(buffer, Constants.KEY.AlignString(0x20)); return(Encoding.UTF8.GetString(buffer)); }
public EntryMetaData(EndianBinReader reader) { CarID = reader.ReadUInt32(); OrderID = reader.ReadUInt32(); DataOffset = reader.ReadUInt32(); LookupTableOffsets = reader.ReadBytes(4); Lookup1 = LookupTableOffsets[0]; Lookup2 = LookupTableOffsets[1]; Lookup3 = LookupTableOffsets[2]; Lookup4 = LookupTableOffsets[3]; var saveOffset = reader.BaseStream.Position; reader.BaseStream.Position = DataOffset; Data = reader.ReadNullTerminatedString(); reader.BaseStream.Position = saveOffset; }
public bool Read(EndianBinReader reader, uint size, uint realSize) { Size = size; RealSize = realSize; if ((Magic = reader.ReadUInt32()) != 0xC5EEF7FFu) { return(false); } DataSize = reader.ReadUInt32(); DataSize = (uint)-DataSize; Size -= Consts.kVOLUME_SEGMENT_HEADER_SIZE; Data = reader.ReadBytes((int)Size); Data = DeflateStream.UncompressBuffer(Data); System.Diagnostics.Debug.Assert(Data.Length == RealSize); return(true); }
public bool Read(EndianBinReader reader) { if ((Magic = reader.ReadUInt32()) != Consts.kVOLUME_HEADER_MAGIC) { return(false); } Seed = reader.ReadUInt32(); if (Seed <= 0) { return(false); } Size = reader.ReadUInt32(); RealSize = reader.ReadUInt32(); PatchSequence = reader.ReadUInt64(); FileSize = reader.ReadUInt64(); var buffer = reader.ReadBytes(128); TitleID = Encoding.UTF8.GetString(buffer); return(true); }
public StringBTree(EndianBinReader reader, uint offset) { reader.BaseStream.Seek(offset, SeekOrigin.Begin); Length = reader.ReadByte(); Text = Encoding.ASCII.GetString(reader.ReadBytes((int)Length)); }
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(); } }