Example #1
0
        private async void LoadTypeDbClick(object sender, RoutedEventArgs e)
        {
            ToggleProcessingButtons(false);

            var ofd = new OpenFileDialog
            {
                Filter = "Unispect TypeDef DB|*.utd;*.gz|All files|*.*"
            };
            var dialogResult = ofd.ShowDialog(this);

            if (dialogResult == true)
            {
                try
                {
                    Log.Add("Loading type definition database");

                    PbMain.IsIndeterminate = true;
                    if (!PbMain.IsVisible)
                    {
                        PbMain.FadeIn();
                    }

                    await Task.Run(() =>
                    {
                        Thread.Sleep(100);
                        TypeDefinitionsDb = ofd.FileName.ToLower().EndsWith(".gz")
                            ? Serializer.LoadCompressed <List <TypeDefWrapper> >(ofd.FileName)
                            : Serializer.Load <List <TypeDefWrapper> >(ofd.FileName);
                    });

                    PbMain.IsIndeterminate = false;
                    PbMain.Value           = 1;
                    TvMainView.DataContext = this;
                    TvMainView.ItemsSource = TypeDefinitionsDb;

                    if (!BtnShowInspector.IsVisible)
                    {
                        BtnShowInspector.FadeIn(200);
                        BtnSaveToFile.FadeIn(200);
                    }

                    Log.Add("Done");
                }
                catch (Exception ex)
                {
                    Log.Exception(
                        "Could not load the type definition database, " +
                        "perhaps it's from a different version of Unispect.",
                        ex);
                }
            }

            ToggleProcessingButtons(true);
        }
Example #2
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);
            }
        }
Example #3
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);
        }