コード例 #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;
 }
コード例 #2
0
ファイル: DebuggerSession.cs プロジェクト: schifflee/Ladybug
 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);
     }
 }
コード例 #3
0
ファイル: DebuggerSession.cs プロジェクト: schifflee/Ladybug
        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);
        }
コード例 #4
0
ファイル: Int3Breakpoint.cs プロジェクト: schifflee/Ladybug
 internal Int3Breakpoint(DebuggeeProcess process, IntPtr address, bool enabled)
 {
     _process = process;
     Address  = address;
     Enabled  = enabled;
 }