Example #1
0
        private static IReadOnlyList <TValue> ReadStreamList <THeader, TValue>(View view, IReadOnlyList <Native.MinidumpDirectory> directory, Native.MinidumpStreamType streamType, Func <THeader, uint> countAccessor)
            where THeader : unmanaged
            where TValue : unmanaged
        {
            if (!FindStream(directory, streamType, out var location) || location.DataSize < sizeof(THeader))
            {
                return(ImmutableList <TValue> .Empty);
            }

            var start = view.GetPointer(location);
            var count = countAccessor(*(THeader *)start);

            if (location.DataSize != (sizeof(THeader) + (count * sizeof(TValue))))
            {
                return(ImmutableList <TValue> .Empty);
            }

            var list = ImmutableList <TValue> .Empty;

            for (var i = 0; i < count; i++)
            {
                list = list.Add(*(TValue *)(start + sizeof(THeader) + (i * sizeof(TValue))));
            }

            return(list);
        }
Example #2
0
 private static T ReadStreamStruct <T>(View view, IReadOnlyList <Native.MinidumpDirectory> directory, Native.MinidumpStreamType streamType) where T : unmanaged =>
 !FindStream(directory, streamType, out var location) || location.DataSize != sizeof(T) ? default : *(T *)view.GetPointer(location);
Example #3
0
        private static IReadOnlyList <T> ReadStreamList <T>(View view, IReadOnlyList <Native.MinidumpDirectory> directory, Native.MinidumpStreamType streamType) where T : unmanaged
        {
            if (!FindStream(directory, streamType, out var location) || location.DataSize < sizeof(uint))
            {
                return(ImmutableList <T> .Empty);
            }

            var start = view.GetPointer(location);
            var count = *(uint *)start;

            if (location.DataSize != (sizeof(uint) + (count * sizeof(T))))
            {
                return(ImmutableList <T> .Empty);
            }

            var list = ImmutableList <T> .Empty;

            for (var i = 0; i < count; i++)
            {
                list = list.Add(*(T *)(start + sizeof(uint) + (i * sizeof(T))));
            }

            return(list);
        }
Example #4
0
        private static bool FindStream(IReadOnlyList <Native.MinidumpDirectory> directory, Native.MinidumpStreamType streamType, out Native.MinidumpLocationDescriptor location)
        {
            var directoryEntry = directory.Where(d => d.StreamType == streamType).SingleOrDefault();

            location = directoryEntry.Location;
            return(directoryEntry.StreamType == streamType);
        }