Skip to content

Commit e86dbba

Browse files
committed
Remove legacy cycle time information
1 parent 8cdd6d8 commit e86dbba

File tree

2 files changed

+9
-154
lines changed

2 files changed

+9
-154
lines changed

ProcessHacker/include/proctree.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ typedef struct _PH_PROCESS_NODE
161161
USHORT ImageDllCharacteristics;
162162
// App ID
163163
PPH_STRING AppIdText;
164-
// Cycles (Vista only)
165-
PH_UINT64_DELTA CyclesDelta;
166164
// DPI awareness
167165
ULONG DpiAwareness;
168166
// File attributes

ProcessHacker/proctree.c

Lines changed: 9 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ VOID PhpRemoveProcessNode(
6161
_In_ PPH_PROCESS_NODE ProcessNode
6262
);
6363

64-
VOID PhpUpdateNeedCyclesInformation(
65-
VOID
66-
);
67-
68-
VOID PhpUpdateProcessNodeCycles(
69-
_Inout_ PPH_PROCESS_NODE ProcessNode
70-
);
71-
7264
LONG PhpProcessTreeNewPostSortFunction(
7365
_In_ LONG Result,
7466
_In_ PVOID Node1,
@@ -92,13 +84,11 @@ static PH_CM_MANAGER ProcessTreeListCm;
9284
static PPH_HASH_ENTRY ProcessNodeHashSet[256] = PH_HASH_SET_INIT; // hashtable of all nodes
9385
static PPH_LIST ProcessNodeList; // list of all nodes, used when sorting is enabled
9486
static PPH_LIST ProcessNodeRootList; // list of root nodes
87+
static PH_TN_FILTER_SUPPORT FilterSupport;
9588

9689
BOOLEAN PhProcessTreeListStateHighlighting = TRUE;
9790
static PPH_POINTER_LIST ProcessNodeStateList = NULL; // list of nodes which need to be processed
9891

99-
static PH_TN_FILTER_SUPPORT FilterSupport;
100-
static BOOLEAN NeedCyclesInformation = FALSE;
101-
10292
static HDC GraphContext = NULL;
10393
static ULONG GraphContextWidth = 0;
10494
static ULONG GraphContextHeight = 0;
@@ -254,8 +244,6 @@ VOID PhLoadSettingsProcessTreeList(
254244
{
255245
SendMessage(TreeNew_GetTooltips(ProcessTreeListHandle), TTM_SETDELAYTIME, TTDT_INITIAL, 0);
256246
}
257-
258-
PhpUpdateNeedCyclesInformation();
259247
}
260248

261249
VOID PhSaveSettingsProcessTreeList(
@@ -624,10 +612,6 @@ VOID PhTickProcessNodes(
624612
node->CpuGraphBuffers.Valid = FALSE;
625613
node->PrivateGraphBuffers.Valid = FALSE;
626614
node->IoGraphBuffers.Valid = FALSE;
627-
628-
// Updates cycles if necessary.
629-
if (NeedCyclesInformation)
630-
PhpUpdateProcessNodeCycles(node);
631615
}
632616

633617
fullyInvalidated = FALSE;
@@ -986,17 +970,17 @@ static VOID PhpUpdateProcessOsContext(
986970
{
987971
if (NT_SUCCESS(PhGetProcessSwitchContext(processHandle, &ProcessNode->OsContextGuid)))
988972
{
989-
if (memcmp(&ProcessNode->OsContextGuid, &WINTHRESHOLD_CONTEXT_GUID, sizeof(GUID)) == 0)
973+
if (IsEqualGUID(&ProcessNode->OsContextGuid, &WINTHRESHOLD_CONTEXT_GUID))
990974
ProcessNode->OsContextVersion = WINDOWS_10;
991-
else if (memcmp(&ProcessNode->OsContextGuid, &WINBLUE_CONTEXT_GUID, sizeof(GUID)) == 0)
975+
else if (IsEqualGUID(&ProcessNode->OsContextGuid, &WINBLUE_CONTEXT_GUID))
992976
ProcessNode->OsContextVersion = WINDOWS_8_1;
993-
else if (memcmp(&ProcessNode->OsContextGuid, &WIN8_CONTEXT_GUID, sizeof(GUID)) == 0)
977+
else if (IsEqualGUID(&ProcessNode->OsContextGuid, &WIN8_CONTEXT_GUID))
994978
ProcessNode->OsContextVersion = WINDOWS_8;
995-
else if (memcmp(&ProcessNode->OsContextGuid, &WIN7_CONTEXT_GUID, sizeof(GUID)) == 0)
979+
else if (IsEqualGUID(&ProcessNode->OsContextGuid, &WIN7_CONTEXT_GUID))
996980
ProcessNode->OsContextVersion = WINDOWS_7;
997-
else if (memcmp(&ProcessNode->OsContextGuid, &VISTA_CONTEXT_GUID, sizeof(GUID)) == 0)
981+
else if (IsEqualGUID(&ProcessNode->OsContextGuid, &VISTA_CONTEXT_GUID))
998982
ProcessNode->OsContextVersion = WINDOWS_VISTA;
999-
else if (memcmp(&ProcessNode->OsContextGuid, &XP_CONTEXT_GUID, sizeof(GUID)) == 0)
983+
else if (IsEqualGUID(&ProcessNode->OsContextGuid, &XP_CONTEXT_GUID))
1000984
ProcessNode->OsContextVersion = WINDOWS_XP;
1001985
}
1002986

@@ -1182,91 +1166,6 @@ static VOID PhpUpdateProcessNodeFileAttributes(
11821166
}
11831167
}
11841168

1185-
static VOID PhpUpdateNeedCyclesInformation(
1186-
VOID
1187-
)
1188-
{
1189-
PH_TREENEW_COLUMN column;
1190-
1191-
NeedCyclesInformation = FALSE;
1192-
1193-
// Before Windows Vista, there is no cycle time measurement.
1194-
// On Windows 7 and above, cycle time information is available directly from the process item.
1195-
// We only need to query cycle time separately for Windows Vista.
1196-
if (WindowsVersion != WINDOWS_VISTA)
1197-
return;
1198-
1199-
TreeNew_GetColumn(ProcessTreeListHandle, PHPRTLC_CYCLES, &column);
1200-
1201-
if (column.Visible)
1202-
{
1203-
NeedCyclesInformation = TRUE;
1204-
return;
1205-
}
1206-
1207-
TreeNew_GetColumn(ProcessTreeListHandle, PHPRTLC_CYCLESDELTA, &column);
1208-
1209-
if (column.Visible)
1210-
{
1211-
NeedCyclesInformation = TRUE;
1212-
return;
1213-
}
1214-
}
1215-
1216-
static VOID PhpUpdateProcessNodeCycles(
1217-
_Inout_ PPH_PROCESS_NODE ProcessNode
1218-
)
1219-
{
1220-
if (ProcessNode->ProcessId == SYSTEM_IDLE_PROCESS_ID)
1221-
{
1222-
PULARGE_INTEGER idleThreadCycleTimes;
1223-
ULONG64 cycleTime;
1224-
ULONG i;
1225-
1226-
// System Idle Process requires special treatment.
1227-
1228-
idleThreadCycleTimes = PhAllocate(
1229-
sizeof(ULARGE_INTEGER) * (ULONG)PhSystemBasicInformation.NumberOfProcessors
1230-
);
1231-
1232-
if (NT_SUCCESS(NtQuerySystemInformation(
1233-
SystemProcessorIdleCycleTimeInformation,
1234-
idleThreadCycleTimes,
1235-
sizeof(ULARGE_INTEGER) * (ULONG)PhSystemBasicInformation.NumberOfProcessors,
1236-
NULL
1237-
)))
1238-
{
1239-
cycleTime = 0;
1240-
1241-
for (i = 0; i < (ULONG)PhSystemBasicInformation.NumberOfProcessors; i++)
1242-
cycleTime += idleThreadCycleTimes[i].QuadPart;
1243-
1244-
PhUpdateDelta(&ProcessNode->CyclesDelta, cycleTime);
1245-
}
1246-
1247-
PhFree(idleThreadCycleTimes);
1248-
}
1249-
else if (ProcessNode->ProcessItem->QueryHandle)
1250-
{
1251-
ULONG64 cycleTime;
1252-
1253-
if (NT_SUCCESS(PhGetProcessCycleTime(ProcessNode->ProcessItem->QueryHandle, &cycleTime)))
1254-
{
1255-
PhUpdateDelta(&ProcessNode->CyclesDelta, cycleTime);
1256-
}
1257-
}
1258-
1259-
if (ProcessNode->CyclesDelta.Value != 0)
1260-
PhMoveReference(&ProcessNode->CyclesText, PhFormatUInt64(ProcessNode->CyclesDelta.Value, TRUE));
1261-
else
1262-
PhClearReference(&ProcessNode->CyclesText);
1263-
1264-
if (ProcessNode->CyclesDelta.Delta != 0)
1265-
PhMoveReference(&ProcessNode->CyclesDeltaText, PhFormatUInt64(ProcessNode->CyclesDelta.Delta, TRUE));
1266-
else
1267-
PhClearReference(&ProcessNode->CyclesDeltaText);
1268-
}
1269-
12701169
#define SORT_FUNCTION(Column) PhpProcessTreeNewCompare##Column
12711170

12721171
#define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpProcessTreeNewCompare##Column( \
@@ -1411,14 +1310,6 @@ BEGIN_SORT_FUNCTION(PeakWorkingSet)
14111310
END_SORT_FUNCTION
14121311

14131312
BEGIN_SORT_FUNCTION(PrivateWs)
1414-
{
1415-
PhpUpdateProcessNodeWsCounters(node1);
1416-
PhpUpdateProcessNodeWsCounters(node2);
1417-
sortResult = uintptrcmp(node1->WsCounters.NumberOfPrivatePages, node2->WsCounters.NumberOfPrivatePages);
1418-
}
1419-
END_SORT_FUNCTION
1420-
1421-
BEGIN_SORT_FUNCTION(PrivateWsWin7)
14221313
{
14231314
sortResult = uintptrcmp(processItem1->WorkingSetPrivateSize, processItem2->WorkingSetPrivateSize);
14241315
}
@@ -1661,24 +1552,12 @@ BEGIN_SORT_FUNCTION(WindowStatus)
16611552
END_SORT_FUNCTION
16621553

16631554
BEGIN_SORT_FUNCTION(Cycles)
1664-
{
1665-
sortResult = uint64cmp(node1->CyclesDelta.Value, node2->CyclesDelta.Value);
1666-
}
1667-
END_SORT_FUNCTION
1668-
1669-
BEGIN_SORT_FUNCTION(CyclesWin7)
16701555
{
16711556
sortResult = uint64cmp(processItem1->CycleTimeDelta.Value, processItem2->CycleTimeDelta.Value);
16721557
}
16731558
END_SORT_FUNCTION
16741559

16751560
BEGIN_SORT_FUNCTION(CyclesDelta)
1676-
{
1677-
sortResult = uint64cmp(node1->CyclesDelta.Delta, node2->CyclesDelta.Delta);
1678-
}
1679-
END_SORT_FUNCTION
1680-
1681-
BEGIN_SORT_FUNCTION(CyclesDeltaWin7)
16821561
{
16831562
sortResult = uint64cmp(processItem1->CycleTimeDelta.Delta, processItem2->CycleTimeDelta.Delta);
16841563
}
@@ -2011,19 +1890,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
20111890
SORT_FUNCTION(FileModifiedTime),
20121891
SORT_FUNCTION(FileSize)
20131892
};
2014-
static PH_INITONCE initOnce = PH_INITONCE_INIT;
20151893
int (__cdecl *sortFunction)(const void *, const void *);
20161894

2017-
if (PhBeginInitOnce(&initOnce))
2018-
{
2019-
// TODO: Remove this.
2020-
sortFunctions[PHPRTLC_PRIVATEWS] = SORT_FUNCTION(PrivateWsWin7);
2021-
sortFunctions[PHPRTLC_CYCLES] = SORT_FUNCTION(CyclesWin7);
2022-
sortFunctions[PHPRTLC_CYCLESDELTA] = SORT_FUNCTION(CyclesDeltaWin7);
2023-
2024-
PhEndInitOnce(&initOnce);
2025-
}
2026-
20271895
if (!PhCmForwardSort(
20281896
(PPH_TREENEW_NODE *)ProcessNodeList->Items,
20291897
ProcessNodeList->Count,
@@ -2183,15 +2051,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
21832051
getCellText->Text = node->PeakWorkingSetText->sr;
21842052
break;
21852053
case PHPRTLC_PRIVATEWS:
2186-
if (WindowsVersion >= WINDOWS_7)
2187-
{
2188-
PhMoveReference(&node->PrivateWsText, PhFormatSize(processItem->WorkingSetPrivateSize, -1));
2189-
}
2190-
else
2191-
{
2192-
PhpUpdateProcessNodeWsCounters(node);
2193-
PhMoveReference(&node->PrivateWsText, PhFormatSize((ULONG64)node->WsCounters.NumberOfPrivatePages * PAGE_SIZE, -1));
2194-
}
2054+
PhMoveReference(&node->PrivateWsText, PhFormatSize(processItem->WorkingSetPrivateSize, -1));
21952055
getCellText->Text = node->PrivateWsText->sr;
21962056
break;
21972057
case PHPRTLC_SHAREDWS:
@@ -3101,11 +2961,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
31012961

31022962
data.Selection = PhShowEMenu(data.Menu, hwnd, PH_EMENU_SHOW_LEFTRIGHT,
31032963
PH_ALIGN_LEFT | PH_ALIGN_TOP, data.MouseEvent->ScreenLocation.x, data.MouseEvent->ScreenLocation.y);
3104-
PhHandleTreeNewColumnMenu(&data);
3105-
3106-
if (data.ProcessedId == PH_TN_COLUMN_MENU_HIDE_COLUMN_ID || data.ProcessedId == PH_TN_COLUMN_MENU_CHOOSE_COLUMNS_ID)
3107-
PhpUpdateNeedCyclesInformation();
31082964

2965+
PhHandleTreeNewColumnMenu(&data);
31092966
PhDeleteTreeNewColumnMenu(&data);
31102967
}
31112968
return TRUE;

0 commit comments

Comments
 (0)