public DbgEngDataReader(int pid, AttachFlag flags, uint msecTimeout) { IDebugClient client = CreateIDebugClient(); CreateClient(client); DEBUG_ATTACH attach = flags == AttachFlag.Invasive ? DEBUG_ATTACH.DEFAULT : DEBUG_ATTACH.NONINVASIVE; int hr = _control.AddEngineOptions(DEBUG_ENGOPT.INITIAL_BREAK); if (hr == 0) { hr = client.AttachProcess(0, (uint)pid, attach); } if (hr == 0) { hr = _control.WaitForEvent(0, msecTimeout); } if (hr == 1) { throw new TimeoutException("Break in did not occur within the allotted timeout."); } if (hr != 0) { if ((uint)hr == 0xd00000bb) { throw new InvalidOperationException("Mismatched architecture between this process and the target process."); } throw new ClrDiagnosticsException($"Could not attach to pid {pid:X}, HRESULT: 0x{hr:x8}", ClrDiagnosticsExceptionKind.DebuggerError, hr); } }
public DbgEngDataReader(int pid, AttachFlag flags, uint msecTimeout) { IDebugClient client = CreateIDebugClient(); CreateClient(client); DEBUG_ATTACH attach = (flags == AttachFlag.Invasive) ? DEBUG_ATTACH.DEFAULT : DEBUG_ATTACH.NONINVASIVE; int hr = m_control.AddEngineOptions(DEBUG_ENGOPT.INITIAL_BREAK); if (hr == 0) { hr = client.AttachProcess(0, (uint)pid, attach); } if (hr == 0) { hr = m_control.WaitForEvent(0, msecTimeout); } if (hr == 1) { throw new TimeoutException("Break in did not occur within the allotted timeout."); } else if (hr != 0) { throw new ClrDiagnosticsException(String.Format("Could not attach to pid {0:X}, HRESULT: 0x{1:x8}", pid, hr), ClrDiagnosticsException.HR.DebuggerError); } }