Exemplo n.º 1
0
 internal DebuggeeThread(DebuggeeProcess process, IntPtr threadHandle, int id, IntPtr startAddress)
 {
     Process       = process ?? throw new ArgumentNullException(nameof(process));
     _threadHandle = threadHandle;
     Id            = id;
     StartAddress  = startAddress;
 }
Exemplo n.º 2
0
 private DebuggeeProcess GetOrCreateProcess(IntPtr processHandle, int processId)
 {
     lock (_processes)
     {
         var process = GetProcessById(processId);
         if (process == null)
         {
             process = new DebuggeeProcess(this, processHandle, processId);
             _processes.Add(processId, process);
         }
         return(process);
     }
 }
Exemplo n.º 3
0
        public DebuggeeProcess StartProcess(DebuggerProcessStartInfo info)
        {
            IsActive = true;
            var             started = new ManualResetEvent(false);
            DebuggeeProcess process = null;

            // Spawn debugger loop on new thread.
            new Thread(() =>
            {
                // Initialize startup info.
                var startupInfo = new STARTUPINFO();
                startupInfo.cb  = (uint)Marshal.SizeOf <STARTUPINFO>();

                // Create process with debug flag set.
                var processInfo = NativeMethods.CreateProcess(
                    null, info.CommandLine, IntPtr.Zero, IntPtr.Zero, false,
                    ProcessCreationFlags.DEBUG_ONLY_THIS_PROCESS | ProcessCreationFlags.CREATE_NEW_CONSOLE,
                    IntPtr.Zero, null, ref startupInfo);

                process = GetOrCreateProcess(processInfo.hProcess, processInfo.dwProcessId);

                // Signal process has started.
                started.Set();

                // Enter debugger loop.
                DebuggerLoop();
            })
            {
                IsBackground = true
            }.Start();

            // Wait for process.
            started.WaitOne();

            return(process);
        }
Exemplo n.º 4
0
 internal Int3Breakpoint(DebuggeeProcess process, IntPtr address, bool enabled)
 {
     _process = process;
     Address  = address;
     Enabled  = enabled;
 }