Ejemplo n.º 1
0
        private async void StartTypeDump()
        {
            if (_memoryProxyType == typeof(BasicMemory))
            {
                var shouldContinue = await Utilities.MessageBox(
                    $"You are using native user-mode API.{Environment.NewLine}" +
                    "Are you sure you wish to continue?",
                    messageDialogStyle : MessageDialogStyle.AffirmativeAndNegative,
                    metroDialogSettings : new MetroDialogSettings
                {
                    AnimateHide = false,
                    AnimateShow = false
                });

                if (shouldContinue != MessageDialogResult.Affirmative)
                {
                    Log.Add("Operation cancelled");
                    return;
                }

                if (TxProcessHandle.Text.ToLower().EndsWith(".exe"))
                {
                    TxProcessHandle.Text = TxProcessHandle.Text.Substring(0, TxProcessHandle.Text.Length - 4);
                    Log.Add("Removed '.exe' from the proces handle (BasicMemory requires this to be omitted)");
                }
            }

            ToggleProcessingButtons(false);

            _inspector = new Inspector();
            _inspector.ProgressChanged += Inspector_ProgressChanged;

            var progressWatcher   = new System.Timers.Timer(200);
            var lastProgressValue = 0d;

            progressWatcher.Start();
            progressWatcher.Elapsed += (sender, args) =>
            {
                try
                {
                    Dispatcher.Invoke(() =>
                    {
                        // Precision comparison should be fine here, but we'll do this just in case
                        const double epsilon = double.Epsilon;
                        if (Math.Abs(PbMain.Value - lastProgressValue) < epsilon &&
                            Math.Abs(PbMain.Value - 1) > epsilon &&
                            Math.Abs(PbMain.Value) > epsilon)
                        {
                            PbMain.IsIndeterminate = true;
                            return;
                        }

                        lastProgressValue = PbMain.Value;
                    });
                }
                catch
                {
                    //
                }
            };

            PbMain.FadeIn(200);

            var fileName      = _dumpToFile ? TxOutputFile.Text : "";
            var processHandle = TxProcessHandle.Text;
            var moduleToDump  = TxInspectorTarget.Text;

            TypeDefinitionsDb = null;
            var exceptionOccurred = false;
            await Task.Run(() =>
            {
                try
                {
                    Thread.Sleep(200); // Wait for the progress bar.. because it looks nice.

                    CacheStore.Clear();

                    _inspector.DumpTypes(
                        fileName,
                        _memoryProxyType,
                        processHandle: processHandle,
                        moduleToDump: moduleToDump);
                }
                catch (Exception ex)
                {
                    exceptionOccurred = true;
                    Log.Exception(null, ex);
                }
            });

            ToggleProcessingButtons(true);

            if (exceptionOccurred)
            {
                PbMain.Value = 0;
                PbMain.FadeOut();
                return;
            }

            TvMainView.DataContext = this;
            TvMainView.ItemsSource = TypeDefinitions;

            //PbMain.FadeOut(1000);
            if (!BtnShowInspector.IsVisible)
            {
                BtnShowInspector.FadeIn(200);
                BtnSaveToFile.FadeIn(200);
            }
        }
Ejemplo n.º 2
0
        private async void BtnDumpOffsets_Click(object sender, RoutedEventArgs e)
        {
            if (_memoryProxyType == typeof(BasicMemory))
            {
                var shouldContinue = await Utilities.MessageBox(
                    $"You are using native user-mode API.{Environment.NewLine}" +
                    "Are you sure you wish to continue?",
                    messageDialogStyle : MessageDialogStyle.AffirmativeAndNegative,
                    metroDialogSettings : new MetroDialogSettings
                {
                    AnimateHide = false,
                    AnimateShow = false
                });

                if (shouldContinue != MessageDialogResult.Affirmative)
                {
                    Log.Add("Operation cancelled");
                    return;
                }

                if (TxProcessHandle.Text.ToLower().EndsWith(".exe"))
                {
                    TxProcessHandle.Text = TxProcessHandle.Text.Substring(0, TxProcessHandle.Text.Length - 4);
                    Log.Add("Removed '.exe' from the proces handle (BasicMemory requires this to be omitted)");
                }
            }

            BtnDumpOffsets.IsEnabled = false;
            _inspector = new Inspector();
            _inspector.ProgressChanged += Inspector_ProgressChanged;

            PbMain.FadeIn(200);

            var fileName      = _dumpToFile ? TxOutputFile.Text : "";
            var processHandle = TxProcessHandle.Text;
            var moduleToDump  = TxInspectorTarget.Text;

            bool exceptionOccurred = false;
            await Task.Run(() =>
            {
                try
                {
                    Thread.Sleep(200); // Wait for the progress bar.. because it looks nice.

                    CacheStore.Clear();

                    _inspector.DumpTypes(
                        fileName,
                        _memoryProxyType,
                        processHandle: processHandle,
                        moduleToDump: moduleToDump);
                }
                catch (Exception ex)
                {
                    exceptionOccurred = true;
                    Log.Exception(null, ex);
                }
            });

            BtnDumpOffsets.IsEnabled = true;
            if (exceptionOccurred)
            {
                return;
            }

            TvMainView.DataContext = _inspector;
            TvMainView.ItemsSource = _inspector.TypeDefinitions;

            //PbMain.FadeOut(1000);
            BtnShowInspector.FadeIn(200);
            BtnSaveToFile.FadeIn(200);
        }