adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.27k stars 480 forks source link

weird file extension, but a 7Z archive #312

Open blandfbt opened 6 years ago

blandfbt commented 6 years ago

I'm working with your package, and I am trying to open an archive file with an XBK extension. If I use 7Zip, I can view the contents, extract it, etc. However, when I try to open it as an archive using (var archive = SevenZipArchive.Open(filepath)) I get the following stack trace errors. (removed a few of the ' so the code would stay in a block) Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object. at SharpCompress.Common.SevenZip.ArchiveReader.ReadDatabase(IPasswordProvider pass) at SharpCompress.Archives.SevenZip.SevenZipArchive.LoadFactory(Stream stream) at SharpCompress.Archives.SevenZip.SevenZipArchive.<LoadEntries>d__11.MoveNext() at SharpCompress.LazyReadOnlyCollection1.LazyLoader.MoveNext() at SharpCompress.Utility.ForEach[T](IEnumerable1 items, Action1 action) at SharpCompress.LazyReadOnlyCollection1.EnsureFullyLoaded() at SharpCompress.LazyReadOnlyCollection1.get_Count() at SharpCompress.Test.Streams.StreamTests.zipp(String zippath) at SharpCompress.Test.Streams.StreamTests.Main(String[] args)

I tried to track down where this comes from, and I think it might be the header for the archive file. The first two lines of hex are are always of the form: 504b 0304 1403 0600 0800 0098 fd4a 0000 0000 0000 0000 0000 0000 1a00 0000 3230 or 504b 0304 1403 0600 0800 0098 fb4a 0000 0000 0000 0000 0000 0000 1a00 0000 3230

I tried to insert a new header (maybe naive of me), per the 7Zip recovery guide, but it doesn't help. I can still open it with 7Zip or PeaZip with the new header though. 377a bcaf 271c 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Any ideas where I could dig into this?

adamhathcock commented 6 years ago

Sorry, it's been a while since I dove into the 7Zip archive format (which I hate.) I'm not sure how to help here with an obscure file format.