Exemplo n.º 1
0
        private static Minidump GetMinidumpFromStream(Stream stream)
        {
            IAddressSpace sas      = new StreamAddressSpace(stream);
            Minidump      minidump = new Minidump(sas);

            return(minidump);
        }
Exemplo n.º 2
0
 internal MinidumpLoadedImage(Minidump minidump, MinidumpModule module)
 {
     Minidump    = minidump;
     _module     = module;
     _peFile     = new Lazy <PEFile>(CreatePEFile);
     _moduleName = new Lazy <string>(GetModuleName);
 }
Exemplo n.º 3
0
 private void CheckNestedPEImages(Minidump minidump)
 {
     foreach (var loadedImage in minidump.LoadedImages)
     {
         Assert.True(loadedImage.Image.HasValidDosSignature.Check());
         Assert.True(loadedImage.Image.HasValidPESignature.Check());
     }
 }
Exemplo n.º 4
0
        private static void CheckLoadedModules(Stream stream)
        {
            Minidump minidump = GetMinidumpFromStream(stream);

            var modules = minidump.LoadedImages;

            Assert.True(modules.Count > 0);
        }
Exemplo n.º 5
0
        private void CheckModuleNames(Minidump minidump)
        {
            Assert.Equal(1, minidump.LoadedImages.Where(i => i.ModuleName.EndsWith(@"\clr.dll")).Count());

            foreach (var module in minidump.LoadedImages)
            {
                Assert.NotNull(module.ModuleName);
            }
        }
Exemplo n.º 6
0
        private void CheckPdbInfo(Minidump minidump, Guid guid)
        {
            PEFile      image = minidump.LoadedImages.Where(i => i.ModuleName.EndsWith(@"\clr.dll")).Single().Image;
            PEPdbRecord pdb   = image.Pdb;

            Assert.NotNull(pdb);
            Assert.Equal(ClrPdb, pdb.Path);
            Assert.Equal(ClrAge, pdb.Age);
            Assert.Equal(guid, pdb.Signature);
        }
Exemplo n.º 7
0
        private static void CheckStartupMemoryRead(Stream stream)
        {
            IAddressSpace       sas        = new StreamAddressSpace(stream);
            MaxStreamReadHelper readHelper = new MaxStreamReadHelper(sas);

            Minidump minidump = new Minidump(readHelper);

            // We should have read the header of a minidump, so we cannot have read nothing.
            Assert.True(readHelper.Max > 0);

            // We should only read the header and not too far into the dump file, 1k should be plenty.
            Assert.True(readHelper.Max <= 1024);
        }
Exemplo n.º 8
0
        private void CheckMemoryRanges(Minidump minidump)
        {
            ReadOnlyCollection <MinidumpLoadedImage> images = minidump.LoadedImages;
            ReadOnlyCollection <MinidumpSegment>     memory = minidump.Segments;

            // Ensure that all of our images actually correspond to memory in the crash dump.  Note that our minidumps used
            // for this test are all full dumps with all memory (including images) in them.
            foreach (var image in images)
            {
                int count = memory.Where(m => m.VirtualAddress <= image.BaseAddress && image.BaseAddress < m.VirtualAddress + m.Size).Count();
                Assert.Equal(1, count);

                // Check the start of each image for the PE header 'MZ'
                byte[] header = minidump.VirtualAddressReader.Read(image.BaseAddress, 2);
                Assert.Equal((byte)'M', header[0]);
                Assert.Equal((byte)'Z', header[1]);
            }
        }
Exemplo n.º 9
0
        public void CheckIsMinidump()
        {
            using (Stream stream = GetCrashDump(x86Dump))
            {
                Assert.True(Minidump.IsValidMinidump(new StreamAddressSpace(stream)));
                Assert.False(Minidump.IsValidMinidump(new StreamAddressSpace(stream), 1));
            }

            using (Stream stream = GetCrashDump(x64Dump))
            {
                Assert.True(Minidump.IsValidMinidump(new StreamAddressSpace(stream)));
                Assert.False(Minidump.IsValidMinidump(new StreamAddressSpace(stream), 1));
            }

            // These are GZiped files, they should not be minidumps.
            using (FileStream stream = File.OpenRead(x86Dump))
                Assert.False(Minidump.IsValidMinidump(new StreamAddressSpace(stream)));

            using (FileStream stream = File.OpenRead(x64Dump))
                Assert.False(Minidump.IsValidMinidump(new StreamAddressSpace(stream)));
        }