Skip to content

Commit 870e609

Browse files
committed
Add CPU/Core/Socket indexes to CPU tooltips winsiderss#1083
1 parent a46dbce commit 870e609

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

ProcessHacker/include/sysinfop.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ VOID PhSipOnUserMessage(
9898
_In_ ULONG_PTR LParam
9999
);
100100

101+
ULONG PhSipGetProcessorRelationshipIndex(
102+
_In_ LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
103+
_In_ ULONG Index
104+
);
105+
101106
// Framework
102107

103108
VOID PhSipRegisterDialog(

ProcessHacker/syssccpu.c

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* System Information CPU section
44
*
55
* Copyright (C) 2011-2016 wj32
6-
* Copyright (C) 2017-2021 dmex
6+
* Copyright (C) 2017-2022 dmex
77
*
88
* This file is part of Process Hacker.
99
*
@@ -829,7 +829,7 @@ VOID PhSipNotifyCpuGraph(
829829
{
830830
FLOAT cpuKernel;
831831
FLOAT cpuUser;
832-
PH_FORMAT format[9];
832+
PH_FORMAT format[15];
833833

834834
cpuKernel = PhGetItemCircularBuffer_FLOAT(&PhCpusKernelHistory[Index], getTooltipText->Index);
835835
cpuUser = PhGetItemCircularBuffer_FLOAT(&PhCpusUserHistory[Index], getTooltipText->Index);
@@ -842,8 +842,14 @@ VOID PhSipNotifyCpuGraph(
842842
PhInitFormatF(&format[4], (DOUBLE)cpuUser * 100, 2);
843843
PhInitFormatS(&format[5], L"%)");
844844
PhInitFormatSR(&format[6], PH_AUTO_T(PH_STRING, PhSipGetMaxCpuString(getTooltipText->Index))->sr);
845-
PhInitFormatC(&format[7], L'\n');
846-
PhInitFormatSR(&format[8], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
845+
PhInitFormatS(&format[7], L"\nCPU ");
846+
PhInitFormatU(&format[8], Index);
847+
PhInitFormatS(&format[9], L", Core ");
848+
PhInitFormatU(&format[10], PhSipGetProcessorRelationshipIndex(RelationProcessorCore, Index));
849+
PhInitFormatS(&format[11], L", Socket ");
850+
PhInitFormatU(&format[12], PhSipGetProcessorRelationshipIndex(RelationProcessorPackage, Index));
851+
PhInitFormatS(&format[13], L"\n");
852+
PhInitFormatSR(&format[14], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
847853

848854
PhMoveReference(&CpusGraphState[Index].TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 160));
849855
}
@@ -1533,3 +1539,40 @@ NTSTATUS PhSipQueryProcessorLogicalInformationEx(
15331539

15341540
return status;
15351541
}
1542+
1543+
ULONG PhSipGetProcessorRelationshipIndex(
1544+
_In_ LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
1545+
_In_ ULONG Index
1546+
)
1547+
{
1548+
ULONG index;
1549+
ULONG bufferLength;
1550+
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer;
1551+
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX logicalInfo;
1552+
1553+
if (!NT_SUCCESS(PhSipQueryProcessorLogicalInformationEx(RelationshipType, &buffer, &bufferLength)))
1554+
return ULONG_MAX;
1555+
1556+
index = 0;
1557+
1558+
for (
1559+
logicalInfo = buffer;
1560+
(ULONG_PTR)logicalInfo < (ULONG_PTR)PTR_ADD_OFFSET(buffer, bufferLength);
1561+
logicalInfo = PTR_ADD_OFFSET(logicalInfo, logicalInfo->Size)
1562+
)
1563+
{
1564+
PROCESSOR_RELATIONSHIP processor = logicalInfo->Processor;
1565+
//BOOLEAN hyperThreaded = processor.Flags & LTP_PC_SMT;
1566+
1567+
if (processor.GroupMask[0].Mask & ((KAFFINITY)1 << Index))
1568+
{
1569+
PhFree(buffer);
1570+
return index;
1571+
}
1572+
1573+
index++;
1574+
}
1575+
1576+
PhFree(buffer);
1577+
return ULONG_MAX;
1578+
}

0 commit comments

Comments
 (0)