Esempio n. 1
0
        public void Decompile(uint address, bool setRoot, bool updateHistory = true)
        {
            address |= 0x80000000;

            if (_ramState == null)
            {
                UpdateSnapshot();
            }

            if (setRoot)
            {
                SetRoot(address);
            }

            if (updateHistory)
            {
                HistoricPoint currentPoint = new HistoricPoint(address, null);
                if (_currentHistoricPoint != null && currentPoint == _currentHistoricPoint.Value)
                {
                    // Same history, don't update
                }
                // End of history is free; add to end
                else if (_currentHistoricPoint == null || _currentHistoricPoint == _history.Last)
                {
                    _currentHistoricPoint = _history.AddLast(currentPoint);
                }
                else // End of history contians history
                {
                    // Same history; don't change
                    if (currentPoint == _currentHistoricPoint.Next.Value)
                    {
                        _currentHistoricPoint = _currentHistoricPoint.Next;
                    }
                    else // Writing over existing history
                    {
                        // Remove existing history
                        while (_history.Last != null && _history.Last != _currentHistoricPoint)
                        {
                            _history.RemoveLast();
                        }

                        // Add new item
                        _currentHistoricPoint = _history.AddLast(currentPoint);
                    }
                }

                // Clean history
                while (_history.Count > MaxHistoryCount)
                {
                    // We need to make sure that we are not removing the first element, which
                    // will never happen, since we are always at least moving away from the first item
                    // Therefore, the only case would be when MaxHistory is set to 0, which it never is.
                    _history.RemoveFirst();
                }
                UpdateHistoryButtons();
            }

            _decompilerView.Text = DecompileFunction(address);
            _textBoxAddress.Text = DecompilerFunctionUtilities.AddressToString(address);
            _currentAddress      = address;
        }