using (var zipFile = new ZipArchive(fsMibcFile, ZipArchiveMode.Read, leaveOpen: false, entryNameEncoding: null))
{
disposeOnException = false;
- var mibcDataEntry = zipFile.GetEntry(Path.GetFileName(filename) + ".dll");
+ ZipArchiveEntry mibcDataEntry = zipFile.GetEntry(Path.GetFileName(filename) + ".dll");
+
+ if (mibcDataEntry == null)
+ {
+ // Input may have been renamed at some point; look for a single .dll inside the ZIP.
+ mibcDataEntry = zipFile.Entries.Count == 1 ? zipFile.Entries[0] : null;
+
+ if (mibcDataEntry == null || !mibcDataEntry.Name.EndsWith(".dll"))
+ {
+ throw new InvalidDataException("Could not find input assembly in compressed MIBC file (expected archive to contain a single .dll file)");
+ }
+ }
+
using (var mibcDataStream = mibcDataEntry.Open())
{
peData = new byte[mibcDataEntry.Length];