/// <summary> /// Sets the active output filter. There can only be one. If a filter is already installed Flush() will be called /// first. /// </summary> /// <param name="filter">The output filter to make active.</param> public void SetOutputFilter(OUTPUT_FILTER filter) { var flushed = _outputFilter?.Flush(); flushed?.OutputLineMaskDisabled(_passthroughUtilities); _outputFilter = filter; }
private SimpleOutputHandler(DebugUtilities executionUtilities, DebugUtilities passthroughUtilities, OUTPUT_FILTER outputFilter, bool passThrough, bool passThroughOnly) { ExecutionUtilities = executionUtilities; PassthroughUtilities = passthroughUtilities; passthroughUtilities.OutputMaskSave(); Installed = false; PreviousCallbacks = IntPtr.Zero; if (passThroughOnly == false) { DataBuffer = new DbgStringBuilder(executionUtilities, 1024); } LineBuffer = new DbgStringBuilder(executionUtilities, 1024); OutputFilter = outputFilter; PassThrough = passThrough; PassThroughOnly = passThroughOnly; executionUtilities.DebugClient.GetOutputCallbacksWide(out PreviousCallbacks); /* We will need to release this */ ThisIDebugOutputCallbacksPtr = Marshal.GetComInterfaceForObject(this, typeof(IDebugOutputCallbacksWide)); InstallationHRESULT = executionUtilities.DebugClient.SetOutputCallbacksWide(ThisIDebugOutputCallbacksPtr); if (SUCCEEDED(InstallationHRESULT)) { Installed = true; InstalledThreadId = Thread.CurrentThread.ManagedThreadId; BufferedOutput = new List <BufferLine>(1024); } else { Dispose(); } }
private AdvancedOutputHandler(DebugUtilities executionUtilities, DebugUtilities passthroughUtilities, OUTPUT_FILTER outputFilter, bool wantsDml) { if (_installed == true) { Revert(); throw new Exception("Can not install an Output Handler more than once."); } _executionUtilities = executionUtilities; _passthroughUtilities = passthroughUtilities; _previousCallbacks = IntPtr.Zero; passthroughUtilities.OutputMaskSave(); passthroughUtilities.OutputMaskDisableAll(); passthroughUtilities.DebugClient.FlushCallbacks(); executionUtilities.DebugClient.FlushCallbacks(); _outputFilter = outputFilter; _interestMask = wantsDml ? DEBUG_OUTCBI.DML : DEBUG_OUTCBI.TEXT; executionUtilities.DebugClient.GetOutputCallbacks(out _previousCallbacks); /* We will need to release this */ _thisIDebugOutputCallbacksPtr = Marshal.GetComInterfaceForObject(this, typeof(IDebugOutputCallbacks2)); _installationHresult = executionUtilities.DebugClient.SetOutputCallbacks(_thisIDebugOutputCallbacksPtr); if (SUCCEEDED(_installationHresult)) { _installed = true; _installedThreadId = Thread.CurrentThread.ManagedThreadId; _bufferedOutput = new List <CallbackData>(128); } else { Dispose(); } }
/// <summary> /// Remove any output filter that is installed. Flushes a /// </summary> public void RemoveOutputFilter() { if (OutputFilter != null) { ProcessLineNoFilter(PreviousMask, OutputFilter.Flush()); OutputFilter = null; } }
/// <summary> /// Sets the active output filter. There can only be one. If a filter is already installed Flush() will be called /// first. /// </summary> /// <param name="filter">The output filter to make active.</param> public void SetOutputFilter(OUTPUT_FILTER filter) { if (OutputFilter != null) { ProcessLineNoFilter(PreviousMask, OutputFilter.Flush()); } OutputFilter = filter; }
/// <summary> /// Remove any output filter that is installed. Flushes a /// </summary> public void RemoveOutputFilter() { if (OutputFilter != null) { ProcessLineNoFilter(PreviousMask, OutputFilter.Flush(), PreviousTextWasDml, PreviousDmlFlags); OutputFilter = null; } }
/// <summary> /// Remove any output filter that is installed. Flushes a /// </summary> public void RemoveOutputFilter() { if (_outputFilter != null) { var flushed = _outputFilter.Flush(); flushed?.OutputLineMaskDisabled(_passthroughUtilities); _outputFilter = null; } }
/// <summary> /// Creates a new SimpleOutputHandler instances and sets it as the active handler for the debugger. /// </summary> /// <param name="debugUtilities">A DebugUtilities associated with the debugger.</param> /// <param name="executionUtilities"> /// An utilities associated with the output handler. This interface should be used for all /// actions where output should be redirected to the output handler. /// </param> /// <param name="outputCallbacks"> /// An out parameter to receive the new SimpleOutputHandler. CALL Revert AND/OR Dipose TO /// REMOVE! /// </param> /// <param name="filter">An optional filter object to process the output data.</param> /// <param name="passThrough"> /// Whether the output data should be passed to the previously installed output handler. Default /// is to cache locally only. /// </param> /// <param name="passThroughOnly"> /// Disables local caching of output data. Save memory and is more effient when the primary /// goes it to pass the output data to the previously installed output handled (normally WinDbg). /// </param> /// <returns>Last HRESULT of the install process.</returns> public static int Install(DebugUtilities debugUtilities, out DebugUtilities executionUtilities, out SimpleOutputHandler outputCallbacks, OUTPUT_FILTER filter = null, bool passThrough = false, bool passThroughOnly = false) { IDebugClient executionClient; int hr = debugUtilities.DebugClient.CreateClient(out executionClient); if (FAILED(hr)) { debugUtilities.OutputVerboseLine("SimpleOutputHandler.Install Failed creating a new debug client for execution: {0:x8}", hr); outputCallbacks = null; executionUtilities = null; return(hr); } executionUtilities = new DebugUtilities(executionClient); var oc = new SimpleOutputHandler(executionUtilities, debugUtilities, filter, passThrough, passThroughOnly); outputCallbacks = SUCCEEDED(oc.InstallationHRESULT) ? oc : null; return(oc.InstallationHRESULT); }
/// <summary> /// Creates a new SimpleOutputHandler instances and sets it as the active handler for the debugger. /// </summary> /// <param name="debugUtilities">A DebugUtilities associated with the debugger.</param> /// <param name="outputCallbacks"> /// An out parameter to receive the new SimpleOutputHandler. CALL Revert AND/OR Dipose TO /// REMOVE! /// </param> /// <param name="filter">An optional filter object to process the output data.</param> /// <param name="passThrough"> /// Whether the output data should be passed to the previously installed output handler. Default /// is to cache locally only. /// </param> /// <param name="passThroughOnly"> /// Disables local caching of output data. Save memory and is more effient when the primary /// goes it to pass the output data to the previously installed output handled (normally WinDbg). /// </param> /// <returns>Last HRESULT of the install process.</returns> public static int Install(DebugUtilities debugUtilities, out SimpleOutputHandler outputCallbacks, OUTPUT_FILTER filter = null, bool passThrough = false, bool passThroughOnly = false) { var oc = new SimpleOutputHandler(debugUtilities, debugUtilities, filter, passThrough, passThroughOnly); outputCallbacks = SUCCEEDED(oc.InstallationHRESULT) ? oc : null; return(oc.InstallationHRESULT); }
/// <summary> /// Creates a new SimpleOutputHandler instances and sets it as the active handler for the debugger. /// </summary> /// <param name="debugUtilities">A DebugUtilities associated with the debugger.</param> /// <param name="executionUtilities"> /// An utilities associated with the output handler. This interface should be used for all /// actions where output should be redirected to the output handler. /// </param> /// <param name="outputCallbacks"> /// An out parameter to receive the new SimpleOutputHandler. CALL Revert AND/OR Dipose TO /// REMOVE! /// </param> /// <param name="filter">An optional filter object to process the output data.</param> /// <param name="wantsDml">Whether DML should be accepted.</param> /// <param name="passThrough"> /// Whether the output data should be passed to the previously installed output handler. Default /// is to cache locally only. /// </param> /// <param name="passThroughOnly"> /// Disables local caching of output data. Save memory and is more effient when the primary /// goes it to pass the output data to the previously installed output handled (normally WinDbg). /// </param> /// <returns>Last HRESULT of the install process.</returns> public static int Install(DebugUtilities debugUtilities, out DebugUtilities executionUtilities, out SimpleOutputHandler2 outputCallbacks, OUTPUT_FILTER filter = null, bool wantsDml = true, bool passThrough = false, bool passThroughOnly = false) { IDebugClient executionClient; executionUtilities = new DebugUtilities(out executionClient); if (executionClient == null) { debugUtilities.OutputVerboseLine("SimpleOutputHandler.Install Failed creating a new debug client for execution"); outputCallbacks = null; executionUtilities = null; return(E_FAIL); } executionUtilities.IsFiltered = true; debugUtilities.IsFiltered = true; var oc = new SimpleOutputHandler2(executionUtilities, debugUtilities, filter, wantsDml, passThrough, passThroughOnly); outputCallbacks = SUCCEEDED(oc.InstallationHRESULT) ? oc : null; return(oc.InstallationHRESULT); }
/// <summary> /// Creates a new SimpleOutputHandler instances and sets it as the active handler for the debugger. /// </summary> /// <param name="debugUtilities">A DebugUtilities associated with the debugger.</param> /// <param name="outputCallbacks"> /// An out parameter to receive the new SimpleOutputHandler. CALL Revert AND/OR Dipose TO /// REMOVE! /// </param> /// <param name="filter">An optional filter object to process the output data.</param> /// <param name="wantsDml">Whether DML should be accepted.</param> /// <param name="InterestMask"></param> /// <returns>DebugUtilities that will get filtered</returns> public static DebugUtilities Install(DebugUtilities debugUtilities, out AdvancedOutputHandler outputCallbacks, OUTPUT_FILTER filter = null, bool wantsDml = true, DEBUG_OUTPUT InterestMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.ERROR) { IDebugClient executionClient; DebugUtilities executionUtilities; var hr = debugUtilities.DebugClient.CreateClient(out executionClient); if (FAILED(hr)) { debugUtilities.OutputVerboseLine("SimpleOutputHandler.Install Failed creating a new debug client for execution: {0:x8}", hr); outputCallbacks = null; executionUtilities = null; return(null); } executionUtilities = new DebugUtilities(executionClient) { IsFiltered = true }; executionUtilities.DebugClient.SetOutputMask(InterestMask); executionUtilities.OutputMaskSave(); var oc = new AdvancedOutputHandler(executionUtilities, debugUtilities, filter, wantsDml); outputCallbacks = SUCCEEDED(oc._installationHresult) ? oc : null; filter.OnInstall(debugUtilities, executionUtilities); if (outputCallbacks != null) { return(executionUtilities); } return(null); }