Beispiel #1
0
        /// <summary>
        /// Tries to extracts the original filename for the OLE object out of the ObjectReplacement file
        /// </summary>
        /// <param name="zipEntry"></param>
        /// <returns></returns>
        internal static string GetFileNameFromObjectReplacementFile(SharpCompress.Archives.IArchiveEntry zipEntry)
        {
            try
            {
                using (var zipEntryStream = zipEntry.OpenEntryStream())
                    using (var zipEntryMemoryStream = new MemoryStream())
                    {
                        zipEntryStream.CopyTo(zipEntryMemoryStream);
                        zipEntryMemoryStream.Position = 0x4470;
                        using (var binaryReader = new BinaryReader(zipEntryMemoryStream))
                        {
                            while (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
                            {
                                var value = binaryReader.ReadUInt16();

                                // We have found the start position from where we are going to read
                                // the original filename
                                if (value != 0x8000 || binaryReader.PeekChar() != 0x46)
                                {
                                    continue;
                                }
                                // Skip the peeked char
                                zipEntryMemoryStream.Position += 2;

                                // Read until we find the next 0x46 value
                                while (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
                                {
                                    value = binaryReader.ReadUInt16();
                                    if (value != 0x46)
                                    {
                                        continue;
                                    }
                                    // Skip the next 6 bytes
                                    binaryReader.ReadBytes(6);

                                    // Get the length of name string
                                    var length = binaryReader.ReadUInt16();

                                    // Skip the next 2 bytes
                                    zipEntryMemoryStream.Position += 2;

                                    // Read the filename bytes
                                    var fileNameBytes = binaryReader.ReadBytes(length);
                                    var fileName      = Encoding.Unicode.GetString(fileNameBytes);
                                    fileName = fileName.Replace("\0", string.Empty);
                                    return(fileName);
                                }
                            }
                        }
                    }
            }
            catch
            {
                return(null);
            }

            return(null);
        }
Beispiel #2
0
 public CompressedPage(SharpCompress.Archives.IArchiveEntry Entry)
 {
     //this.Entry = Entry;
     Cache = new MemoryStreamCache()
     {
         MemoryStreamProvider = async(th) =>
         {
             using var s = Entry.OpenEntryStream();
             return(await th.GetMemoryStreamAsync(s));
         }
     };
 }
Beispiel #3
0
 public PageCompress(SharpCompress.Archives.IArchiveEntry entry)
 {
     Entry = entry;
 }
Beispiel #4
0
 public PageCompressed(SharpCompress.Archives.IArchiveEntry Entry)
 {
     this.Entry = Entry;
 }
Beispiel #5
0
 public Entry(SharpCompress.Archives.IArchiveEntry archiveEntry)
 {
     this.archiveEntry = archiveEntry;
 }