internal static void DetectFileTypes(ArcView file, List <Entry> dir) { byte[] signature_buffer = new byte[4]; foreach (PackedEntry entry in dir) { uint signature; if (entry.IsPacked) { using (var input = file.CreateStream(entry.Offset, Math.Min(entry.Size, 0x20u))) using (var reader = new ShsCompression(input)) { reader.Unpack(signature_buffer); signature = LittleEndian.ToUInt32(signature_buffer, 0); } } else { signature = file.View.ReadUInt32(entry.Offset); } if (0x78534444 == signature) // 'DDSx' { entry.Type = "script"; entry.Name = Path.ChangeExtension(entry.Name, "hxb"); } else if (0 != signature) { IResource res; if (0x020000 == signature || 0x0A0000 == signature) { res = ImageFormat.Tga; } else { res = AutoEntry.DetectFileType(signature); } if (res != null) { entry.ChangeType(res); } } } }
public override Stream OpenEntry(ArcFile arc, Entry entry) { var input = arc.File.CreateStream(entry.Offset, entry.Size); var pent = entry as PackedEntry; if (null == pent || !pent.IsPacked) { return(input); } var data = new byte[pent.UnpackedSize]; using (var reader = new ShsCompression(input)) { reader.Unpack(data); if (data.Length > 16 && Binary.AsciiEqual(data, 0, "DDSxHXB")) { DecryptHxb(data); } return(new BinMemoryStream(data, entry.Name)); } }