Skip to content

Commit

Permalink
Merge pull request #451 from processhacker/master
Browse files Browse the repository at this point in the history
[pull] master from processhacker:master
  • Loading branch information
pull[bot] authored Apr 15, 2022
2 parents c6df01c + e99de7d commit 60d3e4f
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 102 deletions.
2 changes: 1 addition & 1 deletion ProcessHacker/ProcessHacker.rc
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ BEGIN
LTEXT "Graph history length:",IDC_STATIC,106,56,69,8
EDITTEXT IDC_SAMPLECOUNT,180,55,48,12,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Automatic",IDC_SAMPLECOUNTAUTOMATIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,233,56,48,10
CONTROL "",IDC_SETTINGS,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,103,301,110
CONTROL "",IDC_SETTINGS,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_TABSTOP,7,103,301,110
LTEXT "Application font:",IDC_STATIC,121,72,54,8
RTEXT "Process Hacker is the default Task Manager:",IDC_DEFSTATE,7,88,166,8
LTEXT "Symbol path:",IDC_STATIC,7,39,43,8
Expand Down
2 changes: 1 addition & 1 deletion ProcessHacker/hndlprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc(
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ParentWindow = GetParent(hwndDlg);

PhSetApplicationWindowIcon(hwndDlg);
PhSetApplicationWindowIcon(context->ParentWindow);

PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
Expand Down
1 change: 0 additions & 1 deletion ProcessHacker/hndlstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <hndlinfo.h>
#include <hndlprv.h>
#include <settings.h>
#include <phsettings.h>

typedef struct _HANDLE_STATISTICS_ENTRY
{
Expand Down
4 changes: 2 additions & 2 deletions ProcessHacker/miniinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ BOOLEAN PhMipCpuListSectionCallback(

// CPU %.2f%%
PhInitFormatS(&format[0], L"CPU ");
PhInitFormatF(&format[1], ((DOUBLE)PhCpuUserUsage + PhCpuKernelUsage) * 100, 2);
PhInitFormatF(&format[1], ((DOUBLE)PhCpuUserUsage + PhCpuKernelUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[2], L'%');

ListSection->Section->Parameters->SetSectionText(ListSection->Section,
Expand Down Expand Up @@ -2015,7 +2015,7 @@ BOOLEAN PhMipCpuListSectionCallback(
PH_FORMAT format[2];

// %.2f%%
PhInitFormatF(&format[0], cpuUsage, 2);
PhInitFormatF(&format[0], cpuUsage, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

cpuUsageText = PhFormat(format, RTL_NUMBER_OF(format), 16);
Expand Down
10 changes: 5 additions & 5 deletions ProcessHacker/notifico.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,15 +1283,15 @@ VOID PhNfpCpuHistoryIconUpdateCallback(
maxCpuProcessItem = NULL;

PhInitFormatS(&format[0], L"CPU Usage: ");
PhInitFormatF(&format[1], ((DOUBLE)PhCpuKernelUsage + PhCpuUserUsage) * 100, 2);
PhInitFormatF(&format[1], ((DOUBLE)PhCpuKernelUsage + PhCpuUserUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[2], '%');

if (maxCpuProcessItem)
{
PhInitFormatC(&format[3], '\n');
PhInitFormatSR(&format[4], maxCpuProcessItem->ProcessName->sr);
PhInitFormatS(&format[5], L": ");
PhInitFormatF(&format[6], (DOUBLE)maxCpuProcessItem->CpuUsage * 100, 2);
PhInitFormatF(&format[6], (DOUBLE)maxCpuProcessItem->CpuUsage * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[7], '%');
}

Expand Down Expand Up @@ -1676,7 +1676,7 @@ VOID PhNfpCpuUsageIconUpdateCallback(
PhInitFormatC(&format[0], L'\n');
PhInitFormatSR(&format[1], maxCpuProcessItem->ProcessName->sr);
PhInitFormatS(&format[2], L": ");
PhInitFormatF(&format[3], (DOUBLE)maxCpuProcessItem->CpuUsage * 100, 2);
PhInitFormatF(&format[3], (DOUBLE)maxCpuProcessItem->CpuUsage * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[4], L'%');

maxCpuText = PhFormat(format, 5, 128);
Expand All @@ -1690,7 +1690,7 @@ VOID PhNfpCpuUsageIconUpdateCallback(
}

PhInitFormatS(&format[0], L"CPU usage: ");
PhInitFormatF(&format[1], (DOUBLE)(PhCpuKernelUsage + PhCpuUserUsage) * 100, 2);
PhInitFormatF(&format[1], (DOUBLE)(PhCpuKernelUsage + PhCpuUserUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[2], L'%');
if (maxCpuText) PhInitFormatSR(&format[3], maxCpuText->sr);
else PhInitFormatC(&format[3], L' ');
Expand Down Expand Up @@ -1779,7 +1779,7 @@ VOID PhNfpCpuUsageTextIconUpdateCallback(
}

PhInitFormatS(&format[0], L"CPU usage: ");
PhInitFormatF(&format[1], (DOUBLE)(PhCpuKernelUsage + PhCpuUserUsage) * 100, 2);
PhInitFormatF(&format[1], (DOUBLE)(PhCpuKernelUsage + PhCpuUserUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[2], L'%');
if (maxCpuText) PhInitFormatSR(&format[3], maxCpuText->sr);
else PhInitFormatC(&format[3], L' ');
Expand Down
14 changes: 7 additions & 7 deletions ProcessHacker/proctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
PH_FORMAT format;
SIZE_T returnLength;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

if (PhFormatToBuffer(&format, 1, node->CpuUsageText, sizeof(node->CpuUsageText), &returnLength))
{
Expand All @@ -2446,7 +2446,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
SIZE_T returnLength;

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

if (PhFormatToBuffer(format, 2, node->CpuUsageText, sizeof(node->CpuUsageText), &returnLength))
{
Expand Down Expand Up @@ -3276,7 +3276,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
{
PH_FORMAT format;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

PhMoveReference(&node->CpuCoreUsageText, PhFormat(&format, 1, 0));
getCellText->Text = node->CpuCoreUsageText->sr;
Expand All @@ -3286,7 +3286,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
PH_FORMAT format[2];

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

PhMoveReference(&node->CpuCoreUsageText, PhFormat(format, RTL_NUMBER_OF(format), 0));
getCellText->Text = node->CpuCoreUsageText->sr;
Expand Down Expand Up @@ -3329,7 +3329,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
break;
}

PhInitFormatF(&format[0], (DOUBLE)(processItem->ImageCoherency * 100.f), 2);
PhInitFormatF(&format[0], (DOUBLE)(processItem->ImageCoherency * 100.f), PhMaxPrecisionUnit);
PhInitFormatS(&format[1], L"%");

PhMoveReference(&node->ImageCoherencyText, PhFormat(format, RTL_NUMBER_OF(format), 0));
Expand Down Expand Up @@ -4100,7 +4100,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
break;

decimal *= 100;
PhInitFormatF(&format[0], decimal, 2);
PhInitFormatF(&format[0], decimal, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), getHeaderText->TextCache, getHeaderText->TextCacheSize, &returnLength))
Expand Down Expand Up @@ -4230,7 +4230,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
decimal *= 100;
decimal *= (ULONG)PhSystemBasicInformation.NumberOfProcessors;

PhInitFormatF(&format[0], decimal, 2);
PhInitFormatF(&format[0], decimal, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), getHeaderText->TextCache, getHeaderText->TextCacheSize, &returnLength))
Expand Down
4 changes: 2 additions & 2 deletions ProcessHacker/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ PPH_STRING PhSiSizeLabelYFunction(

format.Type = SizeFormatType | FormatUsePrecision | FormatUseRadix;
format.Precision = 0;
format.Radix = UCHAR_MAX;
format.Radix = (UCHAR)PhMaxSizeUnit;
format.u.Size = size;

return PhFormat(&format, 1, 0);
Expand All @@ -1025,7 +1025,7 @@ PPH_STRING PhSiDoubleLabelYFunction(
{
PH_FORMAT format[2];

PhInitFormatF(&format[0], value * 100, 2);
PhInitFormatF(&format[0], value * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

return PhFormat(format, RTL_NUMBER_OF(format), 0);
Expand Down
24 changes: 12 additions & 12 deletions ProcessHacker/syssccpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ BOOLEAN PhSipCpuSectionCallback(
cpuUser = PhGetItemCircularBuffer_FLOAT(&PhCpuUserHistory, getTooltipText->Index);

// %.2f%%%s\n%s
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhSipGetMaxCpuString(getTooltipText->Index))->sr);
PhInitFormatC(&format[3], L'\n');
Expand All @@ -216,7 +216,7 @@ BOOLEAN PhSipCpuSectionCallback(
break;

// %.2f%%
PhInitFormatF(&format[0], ((DOUBLE)PhCpuKernelUsage + PhCpuUserUsage) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)PhCpuKernelUsage + PhCpuUserUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

drawPanel->Title = PhCreateString(L"CPU");
Expand Down Expand Up @@ -768,11 +768,11 @@ VOID PhSipNotifyCpuGraph(
cpuUser = PhGetItemCircularBuffer_FLOAT(&PhCpusUserHistory[Index], 0);

// %.2f%% (K: %.2f%%, U: %.2f%%)
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[1], L"% (K: ");
PhInitFormatF(&format[2], (DOUBLE)cpuKernel * 100, 2);
PhInitFormatF(&format[2], (DOUBLE)cpuKernel * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[3], L"%, U: ");
PhInitFormatF(&format[4], (DOUBLE)cpuUser * 100, 2);
PhInitFormatF(&format[4], (DOUBLE)cpuUser * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[5], L"%)");

PhMoveReference(&CpusGraphState[Index].Text, PhFormat(format, RTL_NUMBER_OF(format), 64));
Expand Down Expand Up @@ -812,7 +812,7 @@ VOID PhSipNotifyCpuGraph(
cpuUser = PhGetItemCircularBuffer_FLOAT(&PhCpuUserHistory, getTooltipText->Index);

// %.2f%%%s\n%s
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhSipGetMaxCpuString(getTooltipText->Index))->sr);
PhInitFormatC(&format[3], L'\n');
Expand All @@ -835,11 +835,11 @@ VOID PhSipNotifyCpuGraph(
cpuUser = PhGetItemCircularBuffer_FLOAT(&PhCpusUserHistory[Index], getTooltipText->Index);

// %.2f%% (K: %.2f%%, U: %.2f%%)%s\n%s
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)cpuKernel + cpuUser) * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[1], L"% (K: ");
PhInitFormatF(&format[2], (DOUBLE)cpuKernel * 100, 2);
PhInitFormatF(&format[2], (DOUBLE)cpuKernel * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[3], L"%, U: ");
PhInitFormatF(&format[4], (DOUBLE)cpuUser * 100, 2);
PhInitFormatF(&format[4], (DOUBLE)cpuUser * 100, PhMaxPrecisionUnit);
PhInitFormatS(&format[5], L"%)");
PhInitFormatSR(&format[6], PH_AUTO_T(PH_STRING, PhSipGetMaxCpuString(getTooltipText->Index))->sr);
PhInitFormatS(&format[7], L"\nCPU ");
Expand Down Expand Up @@ -938,7 +938,7 @@ VOID PhSipUpdateCpuPanel(
cpuGhz = (DOUBLE)PowerInformation[0].CurrentMhz / 1000;

// %.2f%%
PhInitFormatF(&format[0], ((DOUBLE)PhCpuUserUsage + PhCpuKernelUsage) * 100, 2);
PhInitFormatF(&format[0], ((DOUBLE)PhCpuUserUsage + PhCpuKernelUsage) * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[1], L'%');

if (PhFormatToBuffer(format, 2, formatBuffer, sizeof(formatBuffer), NULL))
Expand Down Expand Up @@ -1205,7 +1205,7 @@ PPH_STRING PhSipGetMaxCpuString(
PhInitFormatS(&format[2], L" (");
PhInitFormatU(&format[3], HandleToUlong(maxProcessRecord->ProcessId));
PhInitFormatS(&format[4], L"): ");
PhInitFormatF(&format[5], (DOUBLE)maxCpuUsage * 100, 2);
PhInitFormatF(&format[5], (DOUBLE)maxCpuUsage * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[6], L'%');

maxUsageString = PhFormat(format, RTL_NUMBER_OF(format), 128);
Expand All @@ -1218,7 +1218,7 @@ PPH_STRING PhSipGetMaxCpuString(
PhInitFormatC(&format[0], L'\n');
PhInitFormatSR(&format[1], maxProcessRecord->ProcessName->sr);
PhInitFormatS(&format[2], L": ");
PhInitFormatF(&format[3], (DOUBLE)maxCpuUsage * 100, 2);
PhInitFormatF(&format[3], (DOUBLE)maxCpuUsage * 100, PhMaxPrecisionUnit);
PhInitFormatC(&format[4], L'%');

maxUsageString = PhFormat(format, RTL_NUMBER_OF(format), 128);
Expand Down
18 changes: 9 additions & 9 deletions ProcessHacker/thrdlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
PH_FORMAT format;
SIZE_T returnLength;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

if (PhFormatToBuffer(&format, 1, node->CpuUsageText, sizeof(node->CpuUsageText), &returnLength))
{
Expand All @@ -865,7 +865,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
SIZE_T returnLength;

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

if (PhFormatToBuffer(format, 2, node->CpuUsageText, sizeof(node->CpuUsageText), &returnLength))
{
Expand Down Expand Up @@ -1160,7 +1160,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
PH_FORMAT format;
SIZE_T returnLength;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

if (PhFormatToBuffer(&format, 1, node->CpuCoreUsageText, sizeof(node->CpuCoreUsageText), &returnLength))
{
Expand All @@ -1174,7 +1174,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
SIZE_T returnLength;

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

if (PhFormatToBuffer(format, 2, node->CpuCoreUsageText, sizeof(node->CpuCoreUsageText), &returnLength))
{
Expand Down Expand Up @@ -1567,7 +1567,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
PH_FORMAT format;
SIZE_T returnLength;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

if (PhFormatToBuffer(&format, 1, node->CpuUserUsageText, sizeof(node->CpuUserUsageText), &returnLength))
{
Expand All @@ -1581,7 +1581,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
SIZE_T returnLength;

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

if (PhFormatToBuffer(format, 2, node->CpuUserUsageText, sizeof(node->CpuUserUsageText), &returnLength))
{
Expand All @@ -1602,7 +1602,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
PH_FORMAT format;
SIZE_T returnLength;

PhInitFormatF(&format, cpuUsage, 2);
PhInitFormatF(&format, cpuUsage, PhMaxPrecisionUnit);

if (PhFormatToBuffer(&format, 1, node->CpuKernelUsageText, sizeof(node->CpuKernelUsageText), &returnLength))
{
Expand All @@ -1616,7 +1616,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
SIZE_T returnLength;

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

if (PhFormatToBuffer(format, 2, node->CpuKernelUsageText, sizeof(node->CpuKernelUsageText), &returnLength))
{
Expand Down Expand Up @@ -1680,7 +1680,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback(
PhInitFormatS(&format[1], L" | ");
PhInitFormatSize(&format[2], stackLimit);
PhInitFormatS(&format[3], L" (");
PhInitFormatF(&format[4], percent, 1);
PhInitFormatF(&format[4], percent, PhMaxPrecisionUnit);
PhInitFormatS(&format[5], L"%)");

PhMoveReference(&node->StackUsageText, PhFormat(format, RTL_NUMBER_OF(format), 0));
Expand Down
19 changes: 17 additions & 2 deletions phnt/include/ntpsapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ typedef enum _PROCESSINFOCLASS
ProcessFaultInformation, // PROCESS_FAULT_INFORMATION
ProcessTelemetryIdInformation, // q: PROCESS_TELEMETRY_ID_INFORMATION
ProcessCommitReleaseInformation, // PROCESS_COMMIT_RELEASE_INFORMATION
ProcessDefaultCpuSetsInformation,
ProcessAllowedCpuSetsInformation,
ProcessDefaultCpuSetsInformation, // SYSTEM_CPU_SET_INFORMATION[5]
ProcessAllowedCpuSetsInformation, // SYSTEM_CPU_SET_INFORMATION[5]
ProcessSubsystemProcess,
ProcessJobMemoryInformation, // q: PROCESS_JOB_MEMORY_INFO
ProcessInPrivate, // s: void // ETW // since THRESHOLD2 // 70
Expand Down Expand Up @@ -2342,6 +2342,21 @@ NtAllocateReserveObject(
);
#endif

// Process snapshotting

#if (PHNT_VERSION >= PHNT_WINBLUE)
// rev
NTSYSCALLAPI
NTSTATUS
NTAPI
PssNtCaptureSnapshot(
_Out_ PHANDLE SnapshotHandle,
_In_ HANDLE ProcessHandle,
_In_ ULONG CaptureFlags,
_In_ ULONG ThreadContextFlags
);
#endif

#endif

#endif
Loading

0 comments on commit 60d3e4f

Please sign in to comment.