public void Read(FileReader reader) { Label1 = new LBL1(); NLI1 = new NLI1(); Text2 = new TXT2(); reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; reader.ReadSignature(8, "MsgStdBn"); ByteOrderMark = reader.ReadUInt16(); reader.CheckByteOrderMark(ByteOrderMark); IsBigEndian = reader.IsBigEndian; Padding = reader.ReadUInt16(); byte encoding = reader.ReadByte(); Version = reader.ReadByte(); ushort SectionCount = reader.ReadUInt16(); Unknown = reader.ReadUInt16(); uint FileSize = reader.ReadUInt32(); Reserved = reader.ReadBytes(10); if (encoding == 0x00) { StringEncoding = Encoding.UTF8; } else if (reader.IsBigEndian) { StringEncoding = Encoding.BigEndianUnicode; } else { StringEncoding = Encoding.Unicode; } for (int i = 0; i < SectionCount; i++) { long pos = reader.Position; string Signature = reader.ReadString(4, Encoding.ASCII); uint SectionSize = reader.ReadUInt32(); Console.WriteLine("Signature " + Signature); switch (Signature) { case "NLI1": NLI1 = new NLI1(); NLI1.Signature = Signature; NLI1.Read(reader, this); entries.Add(NLI1); break; case "TXT2": Text2 = new TXT2(); Text2.Signature = Signature; Text2.Read(reader, this); entries.Add(Text2); break; case "LBL1": Label1 = new LBL1(); Label1.Signature = Signature; Label1.Read(reader, this); entries.Add(Label1); break; case "ATR1": case "ATO1": case "TSY1": default: MSBTEntry entry = new MSBTEntry(); entry.Signature = Signature; entry.Padding = reader.ReadBytes(8); entry.Data = reader.ReadBytes((int)SectionSize); entries.Add(entry); break; } reader.SeekBegin(pos + SectionSize + 0x10); reader.Align(16); } //Setup labels to text properly if (Label1 != null && Text2 != null) { foreach (var label in Label1.Labels) { label.String = Text2.TextData[(int)label.Index]; } } }
public void Read(FileReader reader) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; reader.ReadSignature(8, "MsgStdBn"); ByteOrderMark = reader.ReadUInt16(); reader.CheckByteOrderMark(ByteOrderMark); Padding = reader.ReadUInt16(); byte encoding = reader.ReadByte(); Version = reader.ReadByte(); ushort SectionCount = reader.ReadUInt16(); ushort Unknown = reader.ReadUInt16(); uint FileSize = reader.ReadUInt32(); Reserved = reader.ReadBytes(10); StringEncoding = (encoding == 0x01 ? Encoding.BigEndianUnicode : Encoding.UTF8); for (int i = 0; i < SectionCount; i++) { long pos = reader.Position; string Signature = reader.ReadString(4, Encoding.ASCII); uint SectionSize = reader.ReadUInt32(); Console.WriteLine("Signature " + Signature); switch (Signature) { case "NLI1": NLI1 = new NLI1(); NLI1.Read(reader, this); entries.Add(NLI1); break; case "TXT2": Text2 = new TXT2(); Text2.Read(reader, this); entries.Add(Text2); break; case "LBL1": Label1 = new LBL1(); Label1.Read(reader, this); entries.Add(Label1); break; case "ATR1": case "ATO1": case "TSY1": default: MSBTEntry entry = new MSBTEntry(); entry.Signature = Signature; entry.Padding = reader.ReadBytes(8); entry.EntryCount = reader.ReadUInt32(); entry.Data = reader.ReadBytes((int)SectionSize); entries.Add(entry); break; } while (reader.BaseStream.Position % 16 != 0 && reader.BaseStream.Position != reader.BaseStream.Length) { reader.ReadByte(); } } }