Skip to content

Commit f96b85f

Browse files
committed
Partial revert b133e0e (Update process node cache)
1 parent 6a224fe commit f96b85f

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

ProcessHacker/include/proctree.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ typedef struct _PH_PROCESS_NODE
209209
PPH_STRING VirtualSizeText;
210210
PPH_STRING PeakVirtualSizeText;
211211
PPH_STRING PageFaultsText;
212-
WCHAR BasePriorityText[PH_INT32_STR_LEN_1];
213-
WCHAR ThreadsText[PH_INT32_STR_LEN_1 + 3];
214-
WCHAR HandlesText[PH_INT32_STR_LEN_1 + 3];
215-
WCHAR GdiHandlesText[PH_INT32_STR_LEN_1 + 3];
216-
WCHAR UserHandlesText[PH_INT32_STR_LEN_1 + 3];
212+
PPH_STRING SessionIdText;
213+
PPH_STRING BasePriorityText;
214+
PPH_STRING ThreadsText;
215+
PPH_STRING HandlesText;
216+
PPH_STRING GdiHandlesText;
217+
PPH_STRING UserHandlesText;
217218
PPH_STRING IoRoRateText;
218219
PPH_STRING IoWRateText;
219-
WCHAR PagePriorityText[PH_INT32_STR_LEN_1];
220220
PPH_STRING StartTimeText;
221221
WCHAR TotalCpuTimeText[PH_TIMESPAN_STR_LEN_1];
222222
WCHAR KernelCpuTimeText[PH_TIMESPAN_STR_LEN_1];
@@ -240,12 +240,12 @@ typedef struct _PH_PROCESS_NODE
240240
PPH_STRING FileModifiedTimeText;
241241
PPH_STRING FileSizeText;
242242
PPH_STRING SubprocessCountText;
243-
WCHAR JobObjectIdText[PH_INT32_STR_LEN_1];
243+
PPH_STRING JobObjectIdText;
244244
PPH_STRING ProtectionText;
245245
PPH_STRING DesktopInfoText;
246-
WCHAR PidHexText[PH_PTR_STR_LEN_1];
247-
WCHAR CpuCoreUsageText[PH_PTR_STR_LEN_1 + 3];
248-
WCHAR ImageCoherencyText[PH_PTR_STR_LEN_1 + 3];
246+
PPH_STRING PidHexText;
247+
PPH_STRING CpuCoreUsageText;
248+
PPH_STRING ImageCoherencyText;
249249
PPH_STRING ImageCoherencyStatusText;
250250
PPH_STRING ErrorModeText;
251251
PPH_STRING CodePageText;

ProcessHacker/proctree.c

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ VOID PhpRemoveProcessNode(
562562
PhClearReference(&ProcessNode->VirtualSizeText);
563563
PhClearReference(&ProcessNode->PeakVirtualSizeText);
564564
PhClearReference(&ProcessNode->PageFaultsText);
565+
PhClearReference(&ProcessNode->SessionIdText);
566+
PhClearReference(&ProcessNode->BasePriorityText);
567+
PhClearReference(&ProcessNode->ThreadsText);
568+
PhClearReference(&ProcessNode->HandlesText);
569+
PhClearReference(&ProcessNode->GdiHandlesText);
570+
PhClearReference(&ProcessNode->UserHandlesText);
565571
PhClearReference(&ProcessNode->IoRoRateText);
566572
PhClearReference(&ProcessNode->IoWRateText);
567573
PhClearReference(&ProcessNode->StartTimeText);
@@ -587,8 +593,12 @@ VOID PhpRemoveProcessNode(
587593
PhClearReference(&ProcessNode->FileModifiedTimeText);
588594
PhClearReference(&ProcessNode->FileSizeText);
589595
PhClearReference(&ProcessNode->SubprocessCountText);
596+
PhClearReference(&ProcessNode->JobObjectIdText);
590597
PhClearReference(&ProcessNode->ProtectionText);
591598
PhClearReference(&ProcessNode->DesktopInfoText);
599+
PhClearReference(&ProcessNode->PidHexText);
600+
PhClearReference(&ProcessNode->CpuCoreUsageText);
601+
PhClearReference(&ProcessNode->ImageCoherencyText);
592602
PhClearReference(&ProcessNode->ImageCoherencyStatusText);
593603
PhClearReference(&ProcessNode->CodePageText);
594604

@@ -2517,27 +2527,36 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
25172527
}
25182528
break;
25192529
case PHPRTLC_SESSIONID:
2520-
PhInitializeStringRefLongHint(&getCellText->Text, processItem->SessionIdString);
2530+
{
2531+
PhMoveReference(&node->SessionIdText, PhFormatUInt64(processItem->SessionId, TRUE));
2532+
getCellText->Text = node->SessionIdText->sr;
2533+
}
25212534
break;
25222535
case PHPRTLC_PRIORITYCLASS:
25232536
PhInitializeStringRefLongHint(&getCellText->Text, PhGetProcessPriorityClassString(processItem->PriorityClass));
25242537
break;
25252538
case PHPRTLC_BASEPRIORITY:
2526-
PhPrintInt32(node->BasePriorityText, processItem->BasePriority);
2527-
PhInitializeStringRefLongHint(&getCellText->Text, node->BasePriorityText);
2539+
{
2540+
PhMoveReference(&node->BasePriorityText, PhFormatUInt64(processItem->BasePriority, TRUE));
2541+
getCellText->Text = node->BasePriorityText->sr;
2542+
}
25282543
break;
25292544
case PHPRTLC_THREADS:
25302545
{
25312546
ULONG value = 0;
25322547
PhpAggregateFieldIfNeeded(node, AggregateTypeInt32, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, NumberOfThreads), &value);
2533-
PhpFormatInt32GroupDigits(value, node->ThreadsText, sizeof(node->ThreadsText), &getCellText->Text);
2548+
//PhpFormatInt32GroupDigits(value, node->ThreadsText, sizeof(node->ThreadsText), &getCellText->Text);
2549+
PhMoveReference(&node->ThreadsText, PhFormatUInt64(value, TRUE));
2550+
getCellText->Text = node->ThreadsText->sr;
25342551
}
25352552
break;
25362553
case PHPRTLC_HANDLES:
25372554
{
25382555
ULONG value = 0;
25392556
PhpAggregateFieldIfNeeded(node, AggregateTypeInt32, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, NumberOfHandles), &value);
2540-
PhpFormatInt32GroupDigits(value, node->HandlesText, sizeof(node->HandlesText), &getCellText->Text);
2557+
//PhpFormatInt32GroupDigits(value, node->HandlesText, sizeof(node->HandlesText), &getCellText->Text);
2558+
PhMoveReference(&node->HandlesText, PhFormatUInt64(value, TRUE));
2559+
getCellText->Text = node->HandlesText->sr;
25412560
}
25422561
break;
25432562
case PHPRTLC_GDIHANDLES:
@@ -2546,7 +2565,9 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
25462565

25472566
ULONG value = 0;
25482567
PhpAggregateFieldIfNeeded(node, AggregateTypeInt32, AggregateLocationProcessNode, FIELD_OFFSET(PH_PROCESS_NODE, GdiHandles), &value);
2549-
PhpFormatInt32GroupDigits(value, node->GdiHandlesText, sizeof(node->GdiHandlesText), &getCellText->Text);
2568+
//PhpFormatInt32GroupDigits(value, node->GdiHandlesText, sizeof(node->GdiHandlesText), &getCellText->Text);
2569+
PhMoveReference(&node->GdiHandlesText, PhFormatUInt64(value, TRUE));
2570+
getCellText->Text = node->GdiHandlesText->sr;
25502571
}
25512572
break;
25522573
case PHPRTLC_USERHANDLES:
@@ -2555,7 +2576,9 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
25552576

25562577
ULONG value = 0;
25572578
PhpAggregateFieldIfNeeded(node, AggregateTypeInt32, AggregateLocationProcessNode, FIELD_OFFSET(PH_PROCESS_NODE, UserHandles), &value);
2558-
PhpFormatInt32GroupDigits(value, node->UserHandlesText, sizeof(node->UserHandlesText), &getCellText->Text);
2579+
//PhpFormatInt32GroupDigits(value, node->UserHandlesText, sizeof(node->UserHandlesText), &getCellText->Text);
2580+
PhMoveReference(&node->UserHandlesText, PhFormatUInt64(value, TRUE));
2581+
getCellText->Text = node->UserHandlesText->sr;
25592582
}
25602583
break;
25612584
case PHPRTLC_IORORATE:
@@ -3149,8 +3172,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
31493172
{
31503173
if (processItem->JobObjectId != 0)
31513174
{
3152-
PhPrintInt32(node->JobObjectIdText, processItem->JobObjectId);
3153-
PhInitializeStringRefLongHint(&getCellText->Text, node->JobObjectIdText);
3175+
PhMoveReference(&node->JobObjectIdText, PhFormatUInt64(processItem->JobObjectId, TRUE));
3176+
getCellText->Text = node->JobObjectIdText->sr;
31543177
}
31553178
}
31563179
break;
@@ -3182,15 +3205,11 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
31823205
if (PH_IS_REAL_PROCESS_ID(processItem->ProcessId))
31833206
{
31843207
PH_FORMAT format;
3185-
SIZE_T returnLength;
31863208

31873209
PhInitFormatIX(&format, HandleToUlong(processItem->ProcessId));
31883210

3189-
if (PhFormatToBuffer(&format, 1, node->PidHexText, sizeof(node->PidHexText), &returnLength))
3190-
{
3191-
getCellText->Text.Buffer = node->PidHexText;
3192-
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
3193-
}
3211+
PhMoveReference(&node->PidHexText, PhFormat(&format, 1, 0));
3212+
getCellText->Text = node->PidHexText->sr;
31943213
}
31953214
}
31963215
break;
@@ -3206,29 +3225,21 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
32063225
if (cpuUsage >= 0.01)
32073226
{
32083227
PH_FORMAT format;
3209-
SIZE_T returnLength;
32103228

32113229
PhInitFormatF(&format, cpuUsage, 2);
32123230

3213-
if (PhFormatToBuffer(&format, 1, node->CpuCoreUsageText, sizeof(node->CpuCoreUsageText), &returnLength))
3214-
{
3215-
getCellText->Text.Buffer = node->CpuCoreUsageText;
3216-
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL); // minus null terminator
3217-
}
3231+
PhMoveReference(&node->CpuCoreUsageText, PhFormat(&format, 1, 0));
3232+
getCellText->Text = node->CpuCoreUsageText->sr;
32183233
}
32193234
else if (cpuUsage != 0 && PhCsShowCpuBelow001)
32203235
{
32213236
PH_FORMAT format[2];
3222-
SIZE_T returnLength;
32233237

32243238
PhInitFormatS(&format[0], L"< ");
32253239
PhInitFormatF(&format[1], 0.01, 2);
32263240

3227-
if (PhFormatToBuffer(format, 2, node->CpuCoreUsageText, sizeof(node->CpuCoreUsageText), &returnLength))
3228-
{
3229-
getCellText->Text.Buffer = node->CpuCoreUsageText;
3230-
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
3231-
}
3241+
PhMoveReference(&node->CpuCoreUsageText, PhFormat(format, RTL_NUMBER_OF(format), 0));
3242+
getCellText->Text = node->CpuCoreUsageText->sr;
32323243
}
32333244
}
32343245
break;
@@ -3239,7 +3250,6 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
32393250
case PHPRTLC_IMAGE_COHERENCY:
32403251
{
32413252
PH_FORMAT format[2];
3242-
SIZE_T returnLength;
32433253

32443254
if (!PhEnableImageCoherencySupport)
32453255
break;
@@ -3272,13 +3282,10 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
32723282
PhInitFormatF(&format[0], (DOUBLE)(processItem->ImageCoherency * 100.f), 2);
32733283
PhInitFormatS(&format[1], L"%");
32743284

3275-
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), node->ImageCoherencyText, sizeof(node->ImageCoherencyText), &returnLength))
3276-
{
3277-
getCellText->Text.Buffer = node->ImageCoherencyText;
3278-
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
3279-
}
3280-
break;
3285+
PhMoveReference(&node->ImageCoherencyText, PhFormat(format, RTL_NUMBER_OF(format), 0));
3286+
getCellText->Text = node->ImageCoherencyText->sr;
32813287
}
3288+
break;
32823289
case PHPRTLC_ERRORMODE:
32833290
{
32843291
PhpUpdateProcessNodeErrorMode(node);

0 commit comments

Comments
 (0)