Ejemplo n.º 1
0
        public LoadingTabPage(string tabTitle, DrawingBrush iconDrawingBrush, LoadingOperation operation)
        {
            _operation       = operation;
            HeaderText       = tabTitle;
            IconDrawingBrush = iconDrawingBrush;

            CancelCommand = new DelegateCommand(Close);

            operation.Completed += page =>
            {
                if (page == null)
                {
                    Close();
                    return;
                }

                Page = page;
                OnPropertyChanged(nameof(Page));
                HeaderText = page.HeaderText;
                OnPropertyChanged(nameof(HeaderText));
                IconDrawingBrush = page.IconDrawingBrush;
                OnPropertyChanged(nameof(IconDrawingBrush));
            };

            void Close()
            {
                operation.Cancel();
                CloseRequested?.Invoke();
            }
        }
        public AttachToProcessWindow(MainWindow mainWindow)
        {
            RefreshProcessesCommand = new DelegateCommand(RefreshProcesses);
            AttachToProcessCommand  = new DelegateCommand <Process>(
                process =>
            {
                if (process == null)
                {
                    return;
                }

                var operation = new LoadingOperation(
                    (progressCallback, token) =>
                {
                    var analyzer = new HeapAnalyzer(process.Id);

                    var summary = analyzer.GetStringSummary(progressCallback, token);

                    var description = $"All strings in process {process.Id} ({process.ProcessName})";

                    return(new StringListPage(mainWindow, summary, analyzer, process.ProcessName, description));
                });

                mainWindow.AddTab(new LoadingTabPage(process.ProcessName, StringListPage.IconDrawingBrush, operation));

                Close();
            });

            RefreshProcesses();

            InitializeComponent();
        }
Ejemplo n.º 3
0
        public ReferrersPage(MainWindow mainWindow, ReferrerTreeViewModel referrerTree, HeapAnalyzer analyzer, string headerText)
        {
            ReferrerTree = referrerTree ?? throw new ArgumentNullException(nameof(referrerTree));
            HeaderText   = headerText;

            _analyzerLease = analyzer.GetLease();

            ShowStringReferencedByFieldCommand = new DelegateCommand <ReferrerTreeNode>(ShowStringReferencedByField);

            void ShowStringReferencedByField(ReferrerTreeNode node)
            {
                var title = $"Refs of {FieldReference.DescribeFieldReferences(node.ReferrerChain)}";

                var operation = new LoadingOperation(
                    (progressCallback, token) =>
                {
                    var summary = analyzer.GetTypeReferenceStringSummary(node.ReferrerType, node.FieldOffset);

                    var description = $"Strings referenced by field {FieldReference.DescribeFieldReferences(node.ReferrerChain)} of type {node.ReferrerType.Name}";

                    return(new StringListPage(mainWindow, summary, analyzer, title, description));
                });

                mainWindow.AddTab(new LoadingTabPage(title, StringListPage.IconDrawingBrush, operation));
            }
        }
Ejemplo n.º 4
0
        public HomePage(MainWindow mainWindow)
        {
            OpenDumpCommand        = new DelegateCommand(OpenDump);
            AttachToProcessCommand = new DelegateCommand(() => new AttachToProcessWindow(mainWindow)
            {
                Owner = mainWindow
            }.ShowDialog());
            ShowAboutCommand = new DelegateCommand(() => new AboutWindow {
                Owner = mainWindow
            }.Show());

            IconDrawingBrush = (DrawingBrush)Application.Current.FindResource("HomeIconBrush");

            void OpenDump()
            {
                var openFileDialog = new OpenFileDialog
                {
                    Filter = "Dump files (*.dmp)|*.dmp|All files (*.*)|*.*"
                };

                if (openFileDialog.ShowDialog() == true)
                {
                    var dumpFilePath = openFileDialog.FileName;

                    OpenDumpFile(dumpFilePath);
                }
            }

            void OpenDumpFile(string dumpFilePath)
            {
                var operation = new LoadingOperation(
                    token =>
                {
                    var analyzer = new HeapAnalyzer(dumpFilePath);

                    var summary = analyzer.GetStringSummary(token);

                    var description = $"All strings in {dumpFilePath}";

                    return(new StringListPage(mainWindow, summary, analyzer, Path.GetFileNameWithoutExtension(dumpFilePath), description));
                });

                mainWindow.AddTab(new LoadingTabPage(Path.GetFileNameWithoutExtension(dumpFilePath), StringListPage.IconDrawingBrush, operation));
            }
        }