예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = Plugin.Models.AppView;
            _gameMemory = Plugin.Models.AppView.GameMemory;
            _options    = Plugin.Models.AppView.Options;

            ToggleAttachWindow(true);

            _options.PropertyChanged             += Options_PropertyChanged;
            _gameMemory.Emulator.PropertyChanged += Emulator_PropertyChanged;
        }
        public object PullData()
        {
            try
            {
                if (!GameRunning) // Not running? Bail out!
                {
                    return(null);
                }

                if (_stopwatch[0].ElapsedMilliseconds >= 2000L)
                {
                    _memoryScanner.Update();
                    _stopwatch[0].Restart();
                }

                IGameMemoryRECVX memory = _memoryScanner.Refresh();

                if (_stopwatch[1].ElapsedMilliseconds >= 3000L)
                {
                    _memoryScanner.RefreshRank();
                    _stopwatch[1].Restart();
                }

                return(memory);
            }
            catch (Win32Exception ex)
            {
                // Only show the error if its not ERROR_PARTIAL_COPY.
                // ERROR_PARTIAL_COPY is typically an issue with reading as the
                // program exits or reading right as the pointers are changing
                // (i.e. switching back to main menu).
                if (ex.NativeErrorCode != 0x0000012B)
                {
                    _hostDelegates.ExceptionMessage(ex);
                }
                return(null);
            }
            catch (Exception ex)
            {
                _hostDelegates.ExceptionMessage(ex);
                return(null);
            }
        }