Esempio n. 1
0
        public bool Install()
        {
            if (!Exists())
            {
                return(false);
            }

            try
            {
                pd = new ProcessDebugger(process.Id);
                pd.Run();

                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                {
                }

                foreach (ProcessThread pT in process.Threads)
                {
                    if (pd.GetThreadStartAddress(pT.Id) == pd.GetAddress(D2Pointers.Game.mainThread))
                    {
                        mainThreadId = pT.Id;
                        break;
                    }
                }

                ApplySettings();
            }
            catch
            {
                return(false);
            }

            CheckInGame(true);

            overlay      = new OverlayWindow();
            overlay.game = this;
            overlay.PostCreate();
            overlay.InGameStateChanged(InGame);

            AutoTeleport = new AutoTeleHandler(this);
            Pickit       = new Pickit(this);
            PlayerInfo   = new PlayerInfo(this);
            MapHandler   = new MapHandler(this);

            syncTimer.Start();
            gameCheckTimer.Start();
            selectedUnitTimer.Start();

            return(true);
        }
Esempio n. 2
0
        public void Start()
        {
            try
            {
                pd = new ProcessDebugger(process.Id);
                var breakpoints = new List <HardwareBreakPoint>();
                var data        = BuildDatas.ContainsKey(build) ? BuildDatas[build] : null;

                if (data != null)
                {
                    breakpoints.Add(new CascBreakpoint1(data.CascOffs1));
                    breakpoints.Add(new CascBreakpoint2(data.CascOffs2));
                }
                else
                {
                    throw new Exception("No offset data for build " + build);
                }

                pd.Run();

                var time = DateTime.Now;

                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Attaching to {0}...", process.GetVersionInfo());
                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Waiting 5 sec to come up...");
                while (!pd.WaitForComeUp(50) && time.MSecToNow() < 5000)
                {
                }

                if (!pd.IsDebugging)
                {
                    throw new Exception("Failed to start logger");
                }

                PrettyLogger.WriteLine(ConsoleColor.Yellow, "Installing breakpoints...");
                foreach (var bp in breakpoints)
                {
                    pd.AddBreakPoint(bp);
                }

                PrettyLogger.WriteLine(ConsoleColor.Magenta, "Successfully attached to {0} PID: {1}.",
                                       process.GetVersionInfo(), process.Id);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (pd != null)
            {
                try
                {
                    DetachHacks();
                    ResetButtonText(false);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
                return;
            }

            var procInfo = processesComboBox.SelectedItem as ProcessInfo;
            if (procInfo == null)
            {
                ShowError("Select a process!");
                return;
            }

            try
            {
                if (Process.GetProcessById(procInfo.Id) == null)
                {
                    ShowError(string.Format("Can't find process '{0}'!", procInfo.DisplayName));
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowError(string.Format("Error: {0}", ex.Message));
                return;
            }

            try
            {
                pd = new ProcessDebugger(procInfo.Id);
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(File.ReadAllBytes(pd.Process.MainModule.FileName));
                    Debug.WriteLine(pd.Process.MainModule.FileVersionInfo);
                    Debug.WriteLine(string.Format("MD5: {0}", string.Join(", ", hash.Select(it => string.Format("0x{0:X2}", it)).ToArray())));
                    if (!hash.SequenceEqual(MainForm.hash))
                        throw new Exception("Hash does not match. Probably newer version of WoT executable.");
                }
                pd.Run();
                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                { }
                ToggleHacks();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
                return;
            }

            ResetButtonText(true);
        }
Esempio n. 4
0
        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (pd != null)
            {
                try
                {
                    DetachHacks();
                    ResetButtonText(false);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
                return;
            }

            var procInfo = processesComboBox.SelectedItem as ProcessInfo;

            if (procInfo == null)
            {
                ShowError("Select a process!");
                return;
            }

            try
            {
                if (Process.GetProcessById(procInfo.Id) == null)
                {
                    ShowError(string.Format("Can't find process '{0}'!", procInfo.DisplayName));
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowError(string.Format("Error: {0}", ex.Message));
                return;
            }

            try
            {
                pd = new ProcessDebugger(procInfo.Id);
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(File.ReadAllBytes(pd.Process.MainModule.FileName));
                    Debug.WriteLine(pd.Process.MainModule.FileVersionInfo);
                    Debug.WriteLine(string.Format("MD5: {0}", string.Join(", ", hash.Select(it => string.Format("0x{0:X2}", it)).ToArray())));
                    if (!hash.SequenceEqual(MainForm.hash))
                    {
                        throw new Exception("Hash does not match. Probably newer version of WoT executable.");
                    }
                }
                pd.Run();
                var now = DateTime.Now;
                while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000)
                {
                }
                ToggleHacks();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
                return;
            }

            ResetButtonText(true);
        }