コード例 #1
0
        /// <inheritdoc />
        public void Dispose()
        {
            if (this.isDisposed)
            {
                return;
            }

            bool isAlreadyInit;

            DkmComponentManager.InitializeThread(DkmComponentManager.IdeComponentId, out isAlreadyInit);

            try
            {
                this.FinalizeQuery();

                DkmProcess process = this.inspectionContext.Thread.Process;
                process.FreeVirtualMemory(this.procMemForQuery, 0, MEM_RELEASE);
            }
            finally
            {
                if (!isAlreadyInit)
                {
                    DkmComponentManager.UninitializeThread(DkmComponentManager.IdeComponentId);
                }
            }

            this.isDisposed = true;
        }
コード例 #2
0
        /// <summary>
        /// Create a new <see cref="SqliteFuncEvalQuery"/> instance.
        /// </summary>
        /// <param name="inspectionContext">Context for all function evaluations</param>
        /// <param name="sqliteInstanceName">Property name of a 'sqlite3 *' instance</param>
        /// <param name="query">Query to execute</param>
        /// <returns><see cref="SqliteFuncEvalQuery"/> instance</returns>
        public static async Task <SqliteFuncEvalQuery> CreateAsync(
            DkmInspectionContext inspectionContext,
            string sqliteInstanceName,
            string query)
        {
            // Initialize the query
            return(await Task.Run(() =>
            {
                bool isAlreadyInit;
                DkmComponentManager.InitializeThread(DkmComponentManager.IdeComponentId, out isAlreadyInit);

                try
                {
                    var funcEval = new SqliteFuncEvalQuery(inspectionContext, sqliteInstanceName, query);

                    funcEval.PrepareQuery();
                    int columnCount = funcEval.QueryColumnCount();
                    funcEval.QueryColumnDetails(columnCount);

                    return funcEval;
                }
                finally
                {
                    if (!isAlreadyInit)
                    {
                        DkmComponentManager.UninitializeThread(DkmComponentManager.IdeComponentId);
                    }
                }
            }));
        }
コード例 #3
0
        /// <summary>
        /// Execute the query and return rows up to the maximum
        /// </summary>
        /// <param name="maxRows">Maximum number of rows to returns</param>
        /// <param name="token"><see cref="CancellationToken"/> instance</param>
        /// <returns><see cref="IEnumerable{T}"/> of row data</returns>
        public async Task <IEnumerable <string[]> > ExecuteAsync(int maxRows, CancellationToken token)
        {
            if (this.queryComplete)
            {
                return(Enumerable.Empty <string[]>());
            }

            return(await Task.Run(() =>
            {
                bool isAlreadyInit;
                DkmComponentManager.InitializeThread(DkmComponentManager.IdeComponentId, out isAlreadyInit);

                try
                {
                    return this.GetRows(maxRows, token);
                }
                finally
                {
                    if (!isAlreadyInit)
                    {
                        DkmComponentManager.UninitializeThread(DkmComponentManager.IdeComponentId);
                    }
                }
            }));
        }
コード例 #4
0
 public void Dispose()
 {
     if (!_alreadyInitialized)
     {
         // Since we don't own this thread we need to uninitialize the dispatcher. Otherwise if the thread is reused by another bit of code
         // trying to call into the Concord API than its InitializeThread will fail.
         // The work items we queued to the work list above will be run on a dedicated thread maintained by the Concord dispatcher.
         DkmComponentManager.UninitializeThread(_id);
     }
 }
コード例 #5
0
        /// <summary>
        /// Finds a module of given MVID in one of the processes being debugged and returns its baseline metadata.
        /// Shall only be called while in debug mode.
        /// </summary>
        public ModuleMetadata TryGetBaselineMetadata(Guid mvid)
        {
            return(_baselineMetadata.GetOrAdd(mvid, m =>
            {
                DkmComponentManager.InitializeThread(DebuggerService.ComponentId);

                try
                {
                    var clrModuleInstance = FindClrModuleInstance(m);
                    if (clrModuleInstance == null)
                    {
                        return default;
                    }

                    var metadata = GetBaselineModuleMetadata(clrModuleInstance);
                    if (metadata == null)
                    {
                        return default;
                    }

                    // hook up a callback on module unload (the call blocks until the message is processed):
                    DkmCustomMessage.Create(
                        Connection: clrModuleInstance.Process.Connection,
                        Process: clrModuleInstance.Process,
                        SourceId: DebuggerService.MessageSourceId,
                        MessageCode: 0,
                        Parameter1: this,
                        Parameter2: clrModuleInstance).SendLower();

                    return metadata;
                }
                finally
                {
                    DkmComponentManager.UninitializeThread(DebuggerService.ComponentId);
                }
            }));
        }