Ejemplo n.º 1
0
        void captureWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            CaptureArguments captureArguments = (CaptureArguments)e.Argument;

            using (FileStream crashDumpFileStream = File.Create(captureArguments.FilePath))
            {
                bool success = MiniDumpFile.Create(
                    captureArguments.ProcessHandle,
                    (uint)captureArguments.ProcessId,
                    crashDumpFileStream.SafeFileHandle,
                    captureArguments.MiniDumpType,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero);

                if (!success)
                {
                    int lastError = Marshal.GetLastWin32Error();

                    // Neat way to avoid the pain of calling FormatMessage.
                    // You can create a new instance of Win32Exception without calling GetLast*Error first,
                    // but I prefer this way as it's more obvious what's happening
                    Win32Exception lastErrorException = new Win32Exception(lastError);

                    MessageBox.Show(lastErrorException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        public SummaryView(MiniDumpFile miniDumpFile)
            : this()
        {
            _miniDumpFile = miniDumpFile;

            #region Header data

            MiniDumpHeader header = _miniDumpFile.ReadHeader();

            if (header == null)
            {
                return;
            }

            txtDateTime.Text = header.TimeDateStamp.ToString();
            txtFlags.Text    = header.Flags.ToString();
            lblAvailableStreamsHeading.Text = $"Available Streams ({header.DirectoryEntries.Count} items)";

            foreach (MiniDumpDirectory directoryEntry in header.DirectoryEntries.OrderBy(entry => entry.StreamType.ToString()))
            {
                ListViewItem newItem = new ListViewItem(directoryEntry.StreamType.ToString());
                newItem.Tag = directoryEntry;
                newItem.SubItems.Add(Formatters.FormatAsMemoryAddress(directoryEntry.Location.Rva));
                newItem.SubItems.Add(directoryEntry.Location.DataSizePretty);

                listView1.Items.Add(newItem);
            }
            #endregion

            #region Module stream
            MiniDumpModule[] modules = _miniDumpFile.ReadModuleList();

            if (modules.Length > 1)
            {
                this.txtMainModule.Text = modules[0].PathAndFileName;
            }
            #endregion

            #region SystemInfo stream
            MiniDumpSystemInfoStream systemInfoStream = _miniDumpFile.ReadSystemInfo();

            if (systemInfoStream != null)
            {
                this.txtOperatingSystem.Text = systemInfoStream.OperatingSystemDescription;

                if (!string.IsNullOrEmpty(systemInfoStream.CSDVersion))
                {
                    this.txtOperatingSystem.Text += $" ({systemInfoStream.CSDVersion})";
                }
            }
            #endregion
        }
Ejemplo n.º 3
0
        public MemoryInfoView(MiniDumpMemoryInfoStream memoryInfoStream, MiniDumpFile minidumpFile)
            : this()
        {
            _memoryInfoStream = memoryInfoStream;
            _minidumpFile     = minidumpFile;

            if (_memoryInfoStream.NumberOfEntries == 0)
            {
                this.listView1.Items.Add("No data found for stream");
            }
            else
            {
                List <ListViewItem> listItems = new List <ListViewItem>();

                foreach (MiniDumpMemoryInfo memoryInfo in _memoryInfoStream.Entries)
                {
                    ListViewItem newItem = new ListViewItem(Formatters.FormatAsMemoryAddress(memoryInfo.BaseAddress));
                    newItem.Tag = memoryInfo;

                    // If the state is MEM_FREE then AllocationProtect, RegionSize, Protect and Type are undefined.
                    if (memoryInfo.State == MemoryState.MEM_FREE)
                    {
                        newItem.SubItems.Add(string.Empty);
                        newItem.SubItems.Add(string.Empty);
                        newItem.SubItems.Add(memoryInfo.RegionSizePretty);
                        newItem.SubItems.Add(memoryInfo.State.ToString());
                        newItem.SubItems.Add(string.Empty);
                        newItem.SubItems.Add(string.Empty);
                    }
                    else
                    {
                        newItem.SubItems.Add(Formatters.FormatAsMemoryAddress(memoryInfo.AllocationBase));
                        newItem.SubItems.Add(memoryInfo.AllocationProtect.ToString());
                        newItem.SubItems.Add(memoryInfo.RegionSizePretty);
                        newItem.SubItems.Add(memoryInfo.State.ToString());
                        // Some regions don't have any Protection information
                        newItem.SubItems.Add(((int)memoryInfo.Protect == 0) ? string.Empty : memoryInfo.Protect.ToString());
                        newItem.SubItems.Add(memoryInfo.Type.ToString());
                    }

                    listItems.Add(newItem);
                }

                listView1.AddItemsForFiltering(listItems);
            }
        }
Ejemplo n.º 4
0
        private void OpenNewSession(string filePath)
        {
            ResetTree();
            CloseExistingSession();

            try
            {
                _miniDumpFile = MiniDumpFile.OpenExisting(filePath);

                this.treeView1.Nodes[0].Text        = Path.GetFileName(filePath);
                this.treeView1.Nodes[0].ToolTipText = filePath;
                this.treeView1.SelectedNode         = treeView1.Nodes[0];

                CmdDisplayStream("Summary");
            }
            catch (Exception e)
            {
                MessageBox.Show($"An error occured while attempting to load your minidump:\r\n\r\n\"{e.Message.TrimEnd(null)}\"", "Error Loading Minidump", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }