Beispiel #1
0
        /// <summary>
        /// Continue a debug event previously gotten by WaitForDebugEvent
        /// </summary>
        /// <param name="nativeEvent"></param>
        /// <remarks>Can't continue a debug event if we just detached from the process</remarks>
        public void ContinueEvent(NativeEvent nativeEvent)
        {
            if (nativeEvent == null)
            {
                throw new ArgumentNullException("nativeEvent");
            }
            if (nativeEvent.ContinueStatus == NativeMethods.ContinueStatus.CONTINUED)
            {
                throw new ArgumentException("event was already continued", "nativeEvent");
            }
            if (nativeEvent.Pipeline != this)
            {
                throw new ArgumentException("event does not belong to this pipeline");
            }
            EnsureIsOnWin32EventThread();

            // Verify that the process for this event is still connected to our pipeline.
            // The lookup will throw if the process detached or was terminated.
            NativeDbgProcess proc = nativeEvent.Process;

            Debug.Assert(proc.Id == nativeEvent.ProcessId);


            nativeEvent.DoCleanupForContinue();

            bool fContinueOk = NativeMethods.ContinueDebugEvent((uint)nativeEvent.ProcessId, (uint)nativeEvent.ThreadId, nativeEvent.ContinueStatus);

            if (!fContinueOk)
            {
                int err = Marshal.GetLastWin32Error();
                throw new InvalidOperationException("Continue failed on process " + nativeEvent.ProcessId + " error=" + err);
            }

            // Mark as continued so that we don't accidentally continue again.
            nativeEvent.ContinueStatus = NativeMethods.ContinueStatus.CONTINUED;
        }