Ejemplo n.º 1
0
        private bool WalkStackCallback(ThreadStackFrame stackFrame)
        {
            ulong address = stackFrame.PcAddress.ToUInt64();

            // HACK for XP where the top user-mode frame for system threads is always 0xffffffff
            if (_pid == 4)
            {
                if (OSVersion.WindowsVersion == WindowsVersion.XP && address == 0xffffffff)
                {
                    return(true);
                }
            }

            try
            {
                ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new[]
                {
                    Utils.FormatAddress(address),
                    _symbols.GetSymbolFromAddress(address)
                }));

                newItem.Tag = address;

                try
                {
                    if (stackFrame.Params.Length > 0)
                    {
                        newItem.ToolTipText = "Parameters: ";
                    }

                    foreach (IntPtr arg in stackFrame.Params)
                    {
                        newItem.ToolTipText += Utils.FormatAddress(arg) + ", ";
                    }

                    if (newItem.ToolTipText.EndsWith(", "))
                    {
                        newItem.ToolTipText = newItem.ToolTipText.Remove(newItem.ToolTipText.Length - 2);
                    }

                    try
                    {
                        string fileAndLine = _symbols.GetLineFromAddress(address);

                        if (fileAndLine != null)
                        {
                            newItem.ToolTipText += "\nFile: " + fileAndLine;
                        }
                    }
                    catch
                    {
                    }
                }
                catch (Exception ex2)
                {
                    Logging.Log(ex2);
                }
            }
            catch (Exception ex)
            {
                Logging.Log(ex);

                ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new string[]
                {
                    Utils.FormatAddress(address),
                    "???"
                }));

                newItem.Tag = address;
            }

            return(true);
        }