internal static bool ReadAsDirectory(BitsStream stream) { bool dir = stream.ReadInt() == 2147483392; stream.Seek(stream.Position - 4); return(dir); }
public override void Read(BitsStream stream) { bool IsResourceFile = stream.ReadBool(); long Offset = (long)stream.ReadBits(23); int Size = (int)stream.ReadBits(24); NameOffset = (int)stream.ReadBits(16); ContentEntryIndex = stream.ReadInt(); ContentEntryCount = stream.ReadInt(); }
public void Read(BigEndianBinaryReader br) { Identifier = (HeaderIDs)br.ReadInt32(); EntryCount = br.ReadInt32(); TOCSize = EntryCount * 16; BitsStream stream = new BitsStream(br.BaseStream); stream.Position = 8; stream.ReadBits(1); nameShift = (int)stream.ReadBits(3); namesLength = (int)stream.ReadBits(28); br.BaseStream.Position = 12; EncryptedFlag = br.ReadInt32(); }
public void Read(BigEndianBinaryReader br, int extra = 0) { if (File.Header.Encrypted) { int tocSize = File.Header.TOCSize + File.Header.namesLength; byte[] tocData = br.ReadBytes(tocSize); tocData = DataUtil.DecryptNew(tocData); // Create a memory stream and override our active binary reader var ms = new MemoryStream(tocData); br = new BigEndianBinaryReader(ms); byte[] tData = br.ReadBytes(File.Header.TOCSize); System.IO.File.WriteAllBytes(@"Z:\D\Downloads\gms\GTAV\toc_test.bin", tData); br.BaseStream.Position = 0; } int entryCount = File.Header.EntryCount; BitsStream stream = new BitsStream(br.BaseStream); for (int i = 0; i < entryCount; i++) { TOCEntry entry; if (TOCEntry.ReadAsDirectory(stream)) { entry = new DirectoryEntry(this); } else { entry = new FileEntry(this); } entry.Read(stream); _entries.Add(entry); } br.BaseStream.Position = File.Header.EntryCount * 16; byte[] stringData = br.ReadBytes(File.Header.namesLength); _nameStringTable = Encoding.ASCII.GetString(stringData); }
public override void Read(BitsStream stream) { try { IsResourceFile = stream.ReadBool(); Offset = (long)stream.ReadBits(23); SizeInArchive = (int)stream.ReadBits(24); NameOffset = (int)stream.ReadBits(16); Offset <<= 9; if (IsResourceFile) { if (Size == 0xFFFFFF) { throw new Exception("Resource with size -1, not supported"); } uint systemFlag = (uint)stream.ReadInt(); uint graphicsFlag = (uint)stream.ReadInt(); IsCompressed = false; IsEncrypted = false; Size = SizeInArchive; } else { Size = stream.ReadInt(); IsEncrypted = stream.ReadInt() == 1; IsCompressed = Size != 0 ? true : false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public abstract void Read(BitsStream br);