コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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();
            }
        }