Beispiel #1
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;
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            CascBP  cascBP = null;
            Process process;

            try
            {
                process = MagicHelpers.SelectProcess("world of warcraft");
                var debugging = false;
                Kernel32.CheckRemoteDebuggerPresent(process.Handle, ref debugging);
                if (debugging)
                {
                    throw new Exception("Already being debugged.");
                }

                cascBP = new CascBP(process);
            }
            catch (Exception e)
            {
                PrettyLogger.WriteLine(ConsoleColor.Red, "Failed to select process: \"{0}\"", e.Message);
                return;
            }

            if (!MagicHelpers.SetDebugPrivileges())
            {
                PrettyLogger.WriteLine(ConsoleColor.Red, "Failed to set debug privileges");
                return;
            }

            try
            {
                var build = ExtractBuildFromArgs(args);
                if (build != null)
                {
                    cascBP.ForceBuild((int)build);
                }

                cascBP.Start();
                cascBP.Join();
            }
            catch (Exception e)
            {
                PrettyLogger.WriteLine(ConsoleColor.Red, "Exception: {0}", e.Message);
                return;
            }
        }