Example #1
0
        /// <summary>
        /// This thread waits for the game window, then stops music/animation and enables the trainer hotkeys
        /// </summary>
        private void TrainerLoop()
        {
            try
            {
                // wait for the game window
                while (!GameProcessFound && !TrainerExiting)
                {
                    GameProcess = LocateGameWindow();
                    if (GameProcess == null)
                    {
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        GameProcessFound = true;
                    }
                }

                if (GameProcessFound)
                {
                    // found the process, proceed
                    GameBaseAddress = (uint)GameProcess.MainModule.BaseAddress;

                    // WPF quirks ftw, we have to run this on the thread which owns the window
                    this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                    {
                        this.Title = this.Title + " - game found!";
                    });

                    // stop music and wpf animations

                    // sometimes this doesnt stop correctly, needs investigation
                    BassMOD.BASSMOD_MusicStop();
                    ((Storyboard)this.Resources["LogoZoom"]).Stop();
                    ((Storyboard)this.Resources["LogoRotate"]).Stop();
                    ((Storyboard)this.Resources["BackgroundRotate"]).Stop();

                    GameMemory.Open(GameProcess);

                    GameMemoryScanner = new SigScan(GameProcess, (IntPtr)GameBaseAddress, MemorySearchRegionSize);

                    // enable all option hotkeys
                    SetupOptions();
                }
            }
            catch (ThreadInterruptedException)
            {
            }
        }
Example #2
0
        /// <summary>
        /// This thread waits for the game window, then stops music/animation and enables the trainer hotkeys
        /// </summary>
        private void TrainerLoop()
        {
            try
            {
                // wait for the game window
                while (!GameProcessFound && !TrainerExiting)
                {
                    GameProcess = LocateGameWindow();
                    if (GameProcess == null)
                        Thread.Sleep(1000);
                    else
                        GameProcessFound = true;
                }

                if (GameProcessFound)
                {
                    // found the process, proceed
                    GameBaseAddress = (uint)GameProcess.MainModule.BaseAddress;

                    // WPF quirks ftw, we have to run this on the thread which owns the window
                    this.Dispatcher.BeginInvoke((ThreadStart)delegate()
                    {
                        this.Title = this.Title + " - game found!";
                    });

                    // stop music and wpf animations

                    // sometimes this doesnt stop correctly, needs investigation
                    BassMOD.BASSMOD_MusicStop();
                    ((Storyboard)this.Resources["LogoZoom"]).Stop();
                    ((Storyboard)this.Resources["LogoRotate"]).Stop();
                    ((Storyboard)this.Resources["BackgroundRotate"]).Stop();

                    GameMemory.Open(GameProcess);

                    GameMemoryScanner = new SigScan(GameProcess, (IntPtr)GameBaseAddress, MemorySearchRegionSize);

                    // enable all option hotkeys
                    SetupOptions();
                }
            }
            catch (ThreadInterruptedException)
            {
            }
        }