private bool BreakHandler(ConsoleBreakSignal signal) { if (signal == ConsoleBreakSignal.Close || signal == ConsoleBreakSignal.Shutdown) { // Set the event so ReadKey throws an exception to unwind. _closingWaitHandle.Set(); } return(false); }
private bool _HandlerWrapper(ConsoleBreakSignal ctrlType) { if (!m_allowExtendedEvents) { // There are actually other signals which are not represented by the // ConsoleSpecialKey type (like CTRL_CLOSE_EVENT). We won't handle // those. if ((ctrlType != ConsoleBreakSignal.CtrlBreak) && (ctrlType != ConsoleBreakSignal.CtrlC)) { return(false); } } return(m_handler(ctrlType)); } // end _HandlerWrapper
} // end ProcessRecord() private bool _CtrlCHandler(ConsoleBreakSignal ctrlType) { LogManager.Trace("WriteDbgDumpFileCommand._CtrlCHandler ({0})", ctrlType); LogManager.Flush(); if (ctrlType == ConsoleBreakSignal.CtrlBreak) { QueueSafeAction(() => { this.Host.EnterNestedPrompt(); }); } else { SafeWriteWarning("Canceling... Canceling dump creation might take a long time. Sorry."); CancelTS.Cancel(); } return(true); } // end _CtrlCHandler()
} // end constructor private bool _CtrlCHandler(ConsoleBreakSignal ctrlType) { LogManager.Trace("_CtrlCHandler ({0}), thread apartment type: {1}", ctrlType, Thread.CurrentThread.GetApartmentState()); LogManager.Flush(); if (ctrlType == ConsoleBreakSignal.CtrlBreak) { QueueSafeAction(() => { this.Host.EnterNestedPrompt(); }); } else { Debugger.Break(); CancelTS.Cancel(); } return(true); } // end _CtrlCHandler()
private bool BreakHandler(ConsoleBreakSignal signal) { if (signal == ConsoleBreakSignal.Close || signal == ConsoleBreakSignal.Shutdown) { // Set the event so ReadKey throws an exception to unwind. _closingWaitHandle.Set(); } return false; }
private bool _Handler(ConsoleBreakSignal ctrlType) { m_cts.Cancel(); return(true); }
} // end _RegisterWaitForGuestModeEvent() private bool _CtrlCHandler(ConsoleBreakSignal ctrlType) { LogManager.Trace("_CtrlCHandler ({0}), thread apartment type: {1}", ctrlType, Thread.CurrentThread.GetApartmentState()); LogManager.Flush(); if (DbgProvider.GuestModeShareConsole) { // Ideally we could just let the CTRL-C go to ntsd or cdb or kd or whoever // the real console owner is. The problem is that if we return false here // (and let the signal go to the next in the chain), the PowerShell // runtime will handle it (by canceling the pipeline, resulting in calling // our StopProcessing). So in addition to keeping the debugger's handler // from getting it, it really discombobulates our dormant state. // // So what we're going to do instead is do the same work that the debugger // would have done. This is scary and fragile (what if they change it?), // but a) I don't have a better idea at the moment, and b) hopefully it's // not too risky--the only thing that the console debugger's handler does // is try to break in. // Note that only CTRL-C and CTRL-BREAK get handled by CtrlCInterceptor, // so we don't have to check for that. // This could block, so just to be safe I'm going to do it on a // threadpool thread. (Break() is safe to call from any thread.) ThreadPool.QueueUserWorkItem((x) => { try { Debugger.Break(); } catch (DbgProviderException dpe) { SafeWriteWarning("Could not break in: {0}", Util.GetExceptionMessages(dpe)); } }); return(true); } // end if( sharing console ) if (ctrlType == ConsoleBreakSignal.CtrlBreak) { SafeWriteWarning("Attempting to enter nested prompt... you will not be able to interact with the debugger."); // If they /do/ try to run a debugger command, they should get a // reasonable error explaining that they can't do while DbgShell is // dormant. QueueSafeAction(() => { this.Host.EnterNestedPrompt(); }); } else { SafeWriteWarning("You cannot break into the target from DbgShell while DbgShell is inactive."); SafeWriteWarning("Instead, break in from the main debugger (windbg/ntsd/cdb/kd)."); SafeWriteWarning("You can run !dbgshell from the debugger to re-activate DbgShell."); } return(true); } // end _CtrlCHandler()