30 #define PH_THRDPRV_PRIVATE
36 typedef struct _PH_THREAD_QUERY_DATA
38 SLIST_ENTRY ListEntry;
49 typedef struct _PH_THREAD_SYMBOL_LOAD_CONTEXT
76 _In_opt_ PVOID Parameter,
77 _In_opt_ PVOID Context
82 _In_ PVOID ProcessInformation
102 _In_ PTHREAD_START_ROUTINE Function,
103 _In_opt_ PVOID Context
153 threadProvider->
RunId = 1;
158 return threadProvider;
187 entry = RtlInterlockedFlushSList(&threadProvider->
QueryListHead);
228 ThreadProvider->Terminating =
TRUE;
231 static BOOLEAN LoadSymbolsEnumGenericModulesCallback(
233 _In_opt_ PVOID Context
239 if (context->ThreadProvider->Terminating)
254 Module->FileName->Buffer,
255 (ULONG64)Module->BaseAddress,
262 static BOOLEAN LoadBasicSymbolsEnumGenericModulesCallback(
264 _In_opt_ PVOID Context
270 if (context->ThreadProvider->Terminating)
278 Module->FileName->Buffer,
279 (ULONG64)Module->BaseAddress,
294 loadContext.ThreadProvider = ThreadProvider;
295 loadContext.SymbolProvider = ThreadProvider->SymbolProvider;
298 runId = ThreadProvider->RunId;
303 if (ThreadProvider->SymbolProvider->IsRealHandle ||
306 loadContext.ProcessId = ThreadProvider->ProcessId;
308 ThreadProvider->ProcessId,
309 ThreadProvider->SymbolProvider->ProcessHandle,
311 LoadSymbolsEnumGenericModulesCallback,
319 loadContext.ProcessId = NtCurrentProcessId();
321 NtCurrentProcessId(),
324 LoadBasicSymbolsEnumGenericModulesCallback,
337 LoadSymbolsEnumGenericModulesCallback,
362 ThreadProvider->SymbolProvider,
374 ThreadProvider->SymbolsLoadedRunId = runId;
439 lookupThreadItem.
ThreadId = ThreadId;
444 ThreadProvider->ThreadHashtable,
450 threadItem = *threadItemPtr;
467 ULONG enumerationKey = 0;
472 while (
PhEnumHashtable(ThreadProvider->ThreadHashtable, (PVOID *)&threadItem, &enumerationKey))
494 LONG newSymbolsLoading;
496 if (data->ThreadProvider->Terminating)
499 newSymbolsLoading = _InterlockedIncrement(&data->ThreadProvider->SymbolsLoading);
501 if (newSymbolsLoading == 1)
504 if (data->ThreadProvider->SymbolsLoadedRunId == 0)
508 data->ThreadProvider->SymbolProvider,
509 data->ThreadItem->StartAddress,
510 &data->StartAddressResolveLevel,
511 &data->ThreadItem->StartAddressFileName,
516 if (data->StartAddressResolveLevel ==
PhsrlAddress && data->ThreadProvider->SymbolsLoadedRunId < data->RunId)
525 data->ThreadProvider->SymbolProvider,
526 data->ThreadItem->StartAddress,
527 &data->StartAddressResolveLevel,
528 &data->ThreadItem->StartAddressFileName,
534 newSymbolsLoading = _InterlockedDecrement(&data->ThreadProvider->SymbolsLoading);
536 if (newSymbolsLoading == 0)
551 data->ThreadProvider->HasServicesKnown =
TRUE;
556 data->ThreadProvider->SymbolProvider->IsRealHandle &&
557 data->ThreadItem->ThreadHandle)
562 data->ThreadItem->ThreadHandle,
563 data->ThreadProvider->ProcessHandle,
568 data->ThreadProvider->ProcessId,
575 RtlInterlockedPushEntrySList(&data->ThreadProvider->QueryListHead, &data->ListEntry);
578 return STATUS_SUCCESS;
592 data->RunId = ThreadProvider->RunId;
599 _In_ ULONG64 Address,
609 ThreadProvider->SymbolProvider,
614 if (fileName == NULL)
644 static NTSTATUS PhpGetThreadCycleTime(
647 _Out_ PULONG64 CycleTime
659 return STATUS_SUCCESS;
663 return STATUS_INVALID_PARAMETER;
667 _In_
LONG PriorityWin32
670 switch (PriorityWin32)
672 case THREAD_PRIORITY_TIME_CRITICAL:
674 case THREAD_PRIORITY_HIGHEST:
676 case THREAD_PRIORITY_ABOVE_NORMAL:
678 case THREAD_PRIORITY_NORMAL:
680 case THREAD_PRIORITY_BELOW_NORMAL:
682 case THREAD_PRIORITY_LOWEST:
684 case THREAD_PRIORITY_IDLE:
686 case THREAD_PRIORITY_ERROR_RETURN:
707 _In_opt_ PVOID Parameter,
708 _In_opt_ PVOID Context
719 _In_ PVOID ProcessInformation
726 ULONG numberOfThreads;
735 process = &localProcess;
747 for (i = 0; i < numberOfThreads; i++)
756 ULONG enumerationKey = 0;
761 BOOLEAN found =
FALSE;
764 for (i = 0; i < numberOfThreads; i++)
780 if (!threadsToRemove)
791 for (i = 0; i < threadsToRemove->
Count; i++)
809 entry = RtlInterlockedFlushSList(&threadProvider->
QueryListHead);
816 if (data->StartAddressResolveLevel ==
PhsrlFunction && data->StartAddressString)
818 PhSwapReference(&data->ThreadItem->StartAddressString, data->StartAddressString);
819 data->ThreadItem->StartAddressResolveLevel = data->StartAddressResolveLevel;
824 data->ThreadItem->JustResolved =
TRUE;
833 for (i = 0; i < numberOfThreads; i++)
842 PVOID startAddress = NULL;
893 NtQueryInformationThread(
895 ThreadQuerySetWin32StartAddress,
951 GUITHREADINFO info = {
sizeof(GUITHREADINFO) };
966 BOOLEAN modified =
FALSE;
1002 newStartAddressString
1113 GUITHREADINFO info = {
sizeof(GUITHREADINFO) };
1135 threadProvider->
RunId++;