コード例 #1
0
 /// <inheritdoc/>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         var hhs = hotHeapStream;
         if (hhs != null)
         {
             hhs.Dispose();
         }
         hotHeapStream = null;
     }
     base.Dispose(disposing);
 }
コード例 #2
0
        private ThreadSafe.IList <HotHeapStream> CreateHotHeapStreams2()
        {
            var list = ThreadSafeListCreator.Create <HotHeapStream>();

            try
            {
                long dirBaseOffs = GetHotHeapDirectoryBaseOffset();
                for (long offs = dirBaseOffs; offs + 8 <= endOffset - 8; offs += 8)
                {
                    fullStream.Position = offs;
                    HeapType heapType;
                    long     hotHeapOffset;
                    ReadHotHeapDirectory(fullStream, dirBaseOffs, out heapType, out hotHeapOffset);

                    IImageStream  dataStream    = null;
                    HotHeapStream hotHeapStream = null;
                    try
                    {
                        dataStream             = fullStream.Clone();
                        list.Add(hotHeapStream = CreateHotHeapStream(heapType, dataStream, hotHeapOffset));
                        dataStream             = null;
                        hotHeapStream          = null;
                    }
                    catch
                    {
                        if (hotHeapStream != null)
                        {
                            hotHeapStream.Dispose();
                        }
                        if (dataStream != null)
                        {
                            dataStream.Dispose();
                        }
                        throw;
                    }
                }
            }
            catch
            {
                foreach (var h in list)
                {
                    h.Dispose();
                }
                throw;
            }
            return(list);
        }
コード例 #3
0
        private void InitializeHotStreams(IList <HotStream> hotStreams)
        {
            if (hotStreams == null || hotStreams.Count == 0)
            {
                return;
            }

            // If this is a 32-bit image, make sure that we emulate this by masking
            // all base offsets to 32 bits.
            long offsetMask = GetPointerSize() == 8 ? -1L : uint.MaxValue;

            // It's always the last one found that is used
            var hotTable = hotStreams[hotStreams.Count - 1].HotTableStream;

            if (hotTable != null)
            {
                hotTable.Initialize(offsetMask);
                tablesStream.HotTableStream = hotTable;
            }

            HotHeapStream hotStrings = null, hotBlob = null, hotGuid = null, hotUs = null;

            for (int i = hotStreams.Count - 1; i >= 0; i--)
            {
                var hotStream      = hotStreams[i];
                var hotHeapStreams = hotStream.HotHeapStreams;
                if (hotHeapStreams == null)
                {
                    continue;
                }

                // It's always the last one found that is used
                for (int j = hotHeapStreams.Count - 1; j >= 0; j--)
                {
                    var hotHeap = hotHeapStreams[j];
                    switch (hotHeap.HeapType)
                    {
                    case HeapType.Strings:
                        if (hotStrings == null)
                        {
                            hotHeap.Initialize(offsetMask);
                            hotStrings = hotHeap;
                        }
                        break;

                    case HeapType.Guid:
                        if (hotGuid == null)
                        {
                            hotHeap.Initialize(offsetMask);
                            hotGuid = hotHeap;
                        }
                        break;

                    case HeapType.Blob:
                        if (hotBlob == null)
                        {
                            hotHeap.Initialize(offsetMask);
                            hotBlob = hotHeap;
                        }
                        break;

                    case HeapType.US:
                        if (hotUs == null)
                        {
                            hotHeap.Initialize(offsetMask);
                            hotUs = hotHeap;
                        }
                        break;
                    }
                }
            }
            InitializeNonExistentHeaps();
            stringsStream.HotHeapStream = hotStrings;
            guidStream.HotHeapStream    = hotGuid;
            blobStream.HotHeapStream    = hotBlob;
            usStream.HotHeapStream      = hotUs;
        }