Files
dmex 6d330ca52f Improve UI rendering and plugin reliability
Create controls at their initial layout sizes and reduce system information panel flicker. Recover GPU/NPU monitoring after adapter restarts, correct sensor aggregation, and optimize graph updates. Restrict upload destinations, bound updater downloads, use monotonic transfer timing, and fix resource leaks and firewall cache races.
2026-10-24 02:35:15 +11:00

1365 lines
54 KiB
C

/*
* Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved.
*
* This file is part of System Informer.
*
* Authors:
*
* dmex 2021-2026
*
*/
#include "exttools.h"
typedef struct _ET_FRAMES_CONTEXT
{
HWND WindowHandle;
PET_PROCESS_BLOCK Block;
PH_CALLBACK_REGISTRATION ProcessesUpdatedRegistration;
BOOLEAN Enabled;
LONG WindowDpi;
HWND FramesPerSecondGroupBox;
HWND FramesLatencyGroupBox;
HWND PresentIntervalGroupBox;
HWND PresentDurationGroupBox;
HWND FramesRenderTimeGroupBox;
HWND FramesDisplayTimeGroupBox;
HWND FramesDisplayLatencyGroupBox;
HWND FramesPerSecondGraphHandle;
HWND FramesLatencyGraphHandle;
HWND PresentIntervalGraphHandle;
HWND PresentDurationGraphHandle;
HWND FramesRenderTimeGraphHandle;
HWND FramesDisplayTimeGraphHandle;
HWND FramesDisplayLatencyGraphHandle;
PH_GRAPH_STATE FramesPerSecondGraphState;
PH_GRAPH_STATE FramesLatencyGraphState;
PH_GRAPH_STATE PresentIntervalGraphState;
PH_GRAPH_STATE PresentDurationGraphState;
PH_GRAPH_STATE FramesRenderTimeGraphState;
PH_GRAPH_STATE FramesDisplayTimeGraphState;
PH_GRAPH_STATE FramesDisplayLatencyGraphState;
} ET_FRAMES_CONTEXT, *PET_FRAMES_CONTEXT;
static RECT NormalGraphTextMargin = { 5, 5, 5, 5 };
static RECT NormalGraphTextPadding = { 3, 3, 3, 3 };
static VOID FramesPropEnsureHistory(
_In_ PET_FRAMES_CONTEXT Context
)
{
PET_PROCESS_BLOCK block;
if (!EtFramesEnabled)
return;
block = Context->Block;
if (!block)
return;
if (!block->FramesPerSecondHistory.Data || block->FramesPerSecondHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesPerSecondHistory, block->FramesPerSecond);
if (!block->FramesLatencyHistory.Data || block->FramesLatencyHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesLatencyHistory, block->FramesLatency);
if (!block->FramesMsBetweenPresentsHistory.Data || block->FramesMsBetweenPresentsHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesMsBetweenPresentsHistory, block->FramesMsBetweenPresents);
if (!block->FramesMsInPresentApiHistory.Data || block->FramesMsInPresentApiHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesMsInPresentApiHistory, block->FramesMsInPresentApi);
if (!block->FramesMsUntilRenderCompleteHistory.Data || block->FramesMsUntilRenderCompleteHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesMsUntilRenderCompleteHistory, block->FramesMsUntilRenderComplete);
if (!block->FramesMsUntilDisplayedHistory.Data || block->FramesMsUntilDisplayedHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesMsUntilDisplayedHistory, block->FramesMsUntilDisplayed);
if (!block->FramesDisplayLatencyHistory.Data || block->FramesDisplayLatencyHistory.Count == 0)
ET_CIRCULAR_BUFFER_ADD_FLOAT(&block->FramesDisplayLatencyHistory, block->FramesDisplayLatency);
}
PPH_STRING FramesLabelYFunction(
_In_ PPH_GRAPH_DRAW_INFO DrawInfo,
_In_ ULONG DataIndex,
_In_ FLOAT Value,
_In_ FLOAT Parameter
)
{
FLOAT value;
value = (FLOAT)(Value * Parameter);
if (value != 0)
{
PH_FORMAT format[1];
PhInitFormatF(&format[0], value, 2);
return PhFormat(format, RTL_NUMBER_OF(format), 0);
}
else
{
return PhReferenceEmptyString();
}
}
VOID FramesPropUpdateWindowDpi(
_In_ PET_FRAMES_CONTEXT Context
)
{
Context->WindowDpi = PhGetWindowDpi(Context->WindowHandle);
}
_Function_class_(PH_GRAPH_MESSAGE_CALLBACK)
BOOLEAN FramesPropGraphMessageCallback(
_In_ HWND WindowHandle,
_In_ ULONG Message,
_In_ PVOID Parameter1,
_In_ PVOID Parameter2,
_In_ PVOID Context
)
{
PET_FRAMES_CONTEXT context = (PET_FRAMES_CONTEXT)Context;
NMHDR *header = (NMHDR *)Parameter1;
switch (header->code)
{
case GCN_GETDRAWINFO:
{
PPH_GRAPH_GETDRAWINFO getDrawInfo = (PPH_GRAPH_GETDRAWINFO)header;
PPH_GRAPH_DRAW_INFO drawInfo = getDrawInfo->DrawInfo;
FramesPropEnsureHistory(context);
if (header->hwndFrom == context->FramesPerSecondGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_CPU_KERNEL), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->FramesPerSecondGraphState, getDrawInfo, context->Block->FramesPerSecondHistory.Count);
if (!context->FramesPerSecondGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesPerSecondHistory, context->FramesPerSecondGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->FramesPerSecondGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->FramesPerSecondGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->FramesPerSecondGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->FramesPerSecondGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesPerSecond, 2);
PhInitFormatS(&format[1], L" FPS");
PhMoveReference(&context->FramesPerSecondGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->FramesPerSecondGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->FramesPerSecondGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->FramesLatencyGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_PHYSICAL), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->FramesLatencyGraphState, getDrawInfo, context->Block->FramesLatencyHistory.Count);
if (!context->FramesLatencyGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesLatencyHistory, context->FramesLatencyGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->FramesLatencyGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->FramesLatencyGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->FramesLatencyGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->FramesLatencyGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesLatency, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->FramesLatencyGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->FramesLatencyGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->FramesLatencyGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->PresentIntervalGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_IO_WRITE), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->PresentIntervalGraphState, getDrawInfo, context->Block->FramesMsBetweenPresentsHistory.Count);
if (!context->PresentIntervalGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesMsBetweenPresentsHistory, context->PresentIntervalGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->PresentIntervalGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->PresentIntervalGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->PresentIntervalGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->PresentIntervalGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesMsBetweenPresents, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->PresentIntervalGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->PresentIntervalGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->PresentIntervalGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->PresentDurationGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_PRIVATE), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->PresentDurationGraphState, getDrawInfo, context->Block->FramesMsInPresentApiHistory.Count);
if (!context->PresentDurationGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesMsInPresentApiHistory, context->PresentDurationGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->PresentDurationGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->PresentDurationGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->PresentDurationGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->PresentDurationGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesMsInPresentApi, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->PresentDurationGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->PresentDurationGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->PresentDurationGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->FramesRenderTimeGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_PRIVATE), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->FramesRenderTimeGraphState, getDrawInfo, context->Block->FramesMsUntilRenderCompleteHistory.Count);
if (!context->FramesRenderTimeGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesMsUntilRenderCompleteHistory, context->FramesRenderTimeGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->FramesRenderTimeGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->FramesRenderTimeGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->FramesRenderTimeGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->FramesRenderTimeGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesMsUntilRenderComplete, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->FramesRenderTimeGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->FramesRenderTimeGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->FramesRenderTimeGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->FramesDisplayTimeGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_CPU_KERNEL), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->FramesDisplayTimeGraphState, getDrawInfo, context->Block->FramesMsUntilDisplayedHistory.Count);
if (!context->FramesDisplayTimeGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesMsUntilDisplayedHistory, context->FramesDisplayTimeGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->FramesDisplayTimeGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->FramesDisplayTimeGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->FramesDisplayTimeGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->FramesDisplayTimeGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesMsUntilDisplayed, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->FramesDisplayTimeGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->FramesDisplayTimeGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->FramesDisplayTimeGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
else if (header->hwndFrom == context->FramesDisplayLatencyGraphHandle)
{
drawInfo->Flags = PH_GRAPH_USE_GRID_X | PH_GRAPH_USE_GRID_Y | (EtEnableScaleText ? PH_GRAPH_LABEL_MAX_Y : 0);
PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(SETTING_COLOR_PHYSICAL), 0, context->WindowDpi);
PhGraphStateGetDrawInfo(&context->FramesDisplayLatencyGraphState, getDrawInfo, context->Block->FramesDisplayLatencyHistory.Count);
if (!context->FramesDisplayLatencyGraphState.Valid)
{
FLOAT max = 0;
PhCopyCircularBuffer_FLOAT(&context->Block->FramesDisplayLatencyHistory, context->FramesDisplayLatencyGraphState.Data1, drawInfo->LineDataCount);
if (EtEnableAvxSupport && drawInfo->LineDataCount > 128)
{
max = PhMaxMemorySingles(context->FramesDisplayLatencyGraphState.Data1, drawInfo->LineDataCount);
}
else
{
for (ULONG i = 0; i < drawInfo->LineDataCount; i++)
{
FLOAT data = context->FramesDisplayLatencyGraphState.Data1[i];
if (max < data)
max = data;
}
}
if (max != 0)
{
PhDivideSinglesBySingle(context->FramesDisplayLatencyGraphState.Data1, max, drawInfo->LineDataCount);
}
drawInfo->LabelYFunction = FramesLabelYFunction;
drawInfo->LabelYFunctionParameter = max;
context->FramesDisplayLatencyGraphState.Valid = TRUE;
}
if (EtGraphShowText)
{
HDC hdc;
PH_FORMAT format[2];
PhInitFormatF(&format[0], context->Block->FramesDisplayLatency, 2);
PhInitFormatS(&format[1], L" ms");
PhMoveReference(&context->FramesDisplayLatencyGraphState.Text, PhFormat(format, RTL_NUMBER_OF(format), 0));
hdc = Graph_GetBufferedContext(context->FramesDisplayLatencyGraphHandle);
PhSetGraphText(
hdc,
drawInfo,
&context->FramesDisplayLatencyGraphState.Text->sr,
&NormalGraphTextMargin,
&NormalGraphTextPadding,
PH_ALIGN_TOP | PH_ALIGN_LEFT
);
}
else
{
drawInfo->Text.Buffer = NULL;
}
}
}
break;
case GCN_GETTOOLTIPTEXT:
{
PPH_GRAPH_GETTOOLTIPTEXT getTooltipText = (PPH_GRAPH_GETTOOLTIPTEXT)header;
if (getTooltipText->Index < getTooltipText->TotalCount)
{
if (header->hwndFrom == context->FramesPerSecondGraphHandle)
{
if (context->FramesPerSecondGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesPerSecondHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" FPS\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->FramesPerSecondGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->FramesPerSecondGraphState.TooltipText);
}
else if (header->hwndFrom == context->FramesLatencyGraphHandle)
{
if (context->FramesLatencyGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesLatencyHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->FramesLatencyGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->FramesLatencyGraphState.TooltipText);
}
else if (header->hwndFrom == context->PresentIntervalGraphHandle)
{
if (context->PresentIntervalGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesMsBetweenPresentsHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->PresentIntervalGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->PresentIntervalGraphState.TooltipText);
}
else if (header->hwndFrom == context->PresentDurationGraphHandle)
{
if (context->PresentDurationGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesMsInPresentApiHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->PresentDurationGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->PresentDurationGraphState.TooltipText);
}
else if (header->hwndFrom == context->FramesRenderTimeGraphHandle)
{
if (context->FramesRenderTimeGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesMsUntilRenderCompleteHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->FramesRenderTimeGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->FramesRenderTimeGraphState.TooltipText);
}
else if (header->hwndFrom == context->FramesDisplayTimeGraphHandle)
{
if (context->FramesDisplayTimeGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesMsUntilDisplayedHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->FramesDisplayTimeGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->FramesDisplayTimeGraphState.TooltipText);
}
else if (header->hwndFrom == context->FramesDisplayLatencyGraphHandle)
{
if (context->FramesDisplayLatencyGraphState.TooltipIndex != getTooltipText->Index)
{
FLOAT value;
PH_FORMAT format[3];
value = PhGetItemCircularBuffer_FLOAT(&context->Block->FramesDisplayLatencyHistory, getTooltipText->Index);
PhInitFormatF(&format[0], value, 2);
PhInitFormatS(&format[1], L" ms\n");
PhInitFormatSR(&format[2], PH_AUTO_T(PH_STRING, PhGetStatisticsTimeString(NULL, getTooltipText->Index))->sr);
PhMoveReference(&context->FramesDisplayLatencyGraphState.TooltipText, PhFormat(format, RTL_NUMBER_OF(format), 0));
}
getTooltipText->Text = PhGetStringRef(context->FramesDisplayLatencyGraphState.TooltipText);
}
}
}
break;
}
return TRUE;
}
VOID FramesPropGetGraphRects(
_In_ PET_FRAMES_CONTEXT Context,
_Out_writes_(7) RECT GroupRects[7],
_Out_writes_(7) RECT GraphRects[7]
)
{
RECT clientRect;
RECT margin;
RECT innerMargin;
LONG between;
LONG graphWidth;
LONG graphHeight;
margin.left = margin.top = margin.right = margin.bottom = PhScaleToDisplay(13, Context->WindowDpi);
innerMargin.left = innerMargin.right = innerMargin.bottom = PhScaleToDisplay(10, Context->WindowDpi);
innerMargin.top = PhScaleToDisplay(20, Context->WindowDpi);
between = PhScaleToDisplay(3, Context->WindowDpi);
PhGetClientRect(Context->WindowHandle, &clientRect);
graphWidth = clientRect.right - margin.left - margin.right;
graphHeight = (clientRect.bottom - margin.top - margin.bottom - between * 6) / 7;
for (ULONG i = 0; i < 7; i++)
{
GroupRects[i].left = margin.left;
GroupRects[i].top = margin.top + (graphHeight + between) * i;
GroupRects[i].right = GroupRects[i].left + graphWidth;
GroupRects[i].bottom = GroupRects[i].top + graphHeight;
GraphRects[i].left = GroupRects[i].left + innerMargin.left;
GraphRects[i].top = GroupRects[i].top + innerMargin.top;
GraphRects[i].right = GroupRects[i].right - innerMargin.right;
GraphRects[i].bottom = GroupRects[i].bottom - innerMargin.bottom;
}
}
VOID FramesPropCreateGraphs(
_In_ PET_FRAMES_CONTEXT Context
)
{
PH_GRAPH_CREATEPARAMS graphCreateParams;
RECT groupRects[7];
RECT graphRects[7];
FramesPropGetGraphRects(Context, groupRects, graphRects);
memset(&graphCreateParams, 0, sizeof(PH_GRAPH_CREATEPARAMS));
graphCreateParams.Size = sizeof(PH_GRAPH_CREATEPARAMS);
graphCreateParams.Callback = FramesPropGraphMessageCallback;
graphCreateParams.Context = Context;
Context->FramesPerSecondGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[0].left,
graphRects[0].top,
graphRects[0].right - graphRects[0].left,
graphRects[0].bottom - graphRects[0].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->FramesPerSecondGraphHandle, TRUE);
Context->FramesLatencyGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[1].left,
graphRects[1].top,
graphRects[1].right - graphRects[1].left,
graphRects[1].bottom - graphRects[1].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->FramesLatencyGraphHandle, TRUE);
Context->PresentIntervalGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[2].left,
graphRects[2].top,
graphRects[2].right - graphRects[2].left,
graphRects[2].bottom - graphRects[2].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->PresentIntervalGraphHandle, TRUE);
Context->PresentDurationGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[3].left,
graphRects[3].top,
graphRects[3].right - graphRects[3].left,
graphRects[3].bottom - graphRects[3].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->PresentDurationGraphHandle, TRUE);
Context->FramesRenderTimeGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[4].left,
graphRects[4].top,
graphRects[4].right - graphRects[4].left,
graphRects[4].bottom - graphRects[4].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->FramesRenderTimeGraphHandle, TRUE);
Context->FramesDisplayTimeGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[5].left,
graphRects[5].top,
graphRects[5].right - graphRects[5].left,
graphRects[5].bottom - graphRects[5].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->FramesDisplayTimeGraphHandle, TRUE);
Context->FramesDisplayLatencyGraphHandle = PhCreateWindow(
PH_GRAPH_CLASSNAME,
NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
graphRects[6].left,
graphRects[6].top,
graphRects[6].right - graphRects[6].left,
graphRects[6].bottom - graphRects[6].top,
Context->WindowHandle,
NULL,
NULL,
&graphCreateParams
);
Graph_SetTooltip(Context->FramesDisplayLatencyGraphHandle, TRUE);
}
VOID FramesPropCreatePanel(
_In_ PET_FRAMES_CONTEXT Context
)
{
RECT margin;
margin.left = 0;
margin.top = 0;
margin.right = 0;
margin.bottom = 10;
MapDialogRect(Context->WindowHandle, &margin);
SendMessage(Context->WindowHandle, WM_SIZE, 0, 0);
}
VOID FramesPropLayoutGraphs(
_In_ PET_FRAMES_CONTEXT Context
)
{
HDWP deferHandle;
RECT groupRects[7];
RECT graphRects[7];
Context->FramesPerSecondGraphState.Valid = FALSE;
Context->FramesPerSecondGraphState.TooltipIndex = ULONG_MAX;
Context->FramesLatencyGraphState.Valid = FALSE;
Context->FramesLatencyGraphState.TooltipIndex = ULONG_MAX;
Context->PresentIntervalGraphState.Valid = FALSE;
Context->PresentIntervalGraphState.TooltipIndex = ULONG_MAX;
Context->PresentDurationGraphState.Valid = FALSE;
Context->PresentDurationGraphState.TooltipIndex = ULONG_MAX;
Context->FramesRenderTimeGraphState.Valid = FALSE;
Context->FramesRenderTimeGraphState.TooltipIndex = ULONG_MAX;
Context->FramesDisplayTimeGraphState.Valid = FALSE;
Context->FramesDisplayTimeGraphState.TooltipIndex = ULONG_MAX;
Context->FramesDisplayLatencyGraphState.Valid = FALSE;
Context->FramesDisplayLatencyGraphState.TooltipIndex = ULONG_MAX;
FramesPropGetGraphRects(Context, groupRects, graphRects);
deferHandle = BeginDeferWindowPos(14);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesPerSecondGroupBox,
NULL,
groupRects[0].left,
groupRects[0].top,
groupRects[0].right - groupRects[0].left,
groupRects[0].bottom - groupRects[0].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesPerSecondGraphHandle,
NULL,
graphRects[0].left,
graphRects[0].top,
graphRects[0].right - graphRects[0].left,
graphRects[0].bottom - graphRects[0].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesLatencyGroupBox,
NULL,
groupRects[1].left,
groupRects[1].top,
groupRects[1].right - groupRects[1].left,
groupRects[1].bottom - groupRects[1].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesLatencyGraphHandle,
NULL,
graphRects[1].left,
graphRects[1].top,
graphRects[1].right - graphRects[1].left,
graphRects[1].bottom - graphRects[1].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->PresentIntervalGroupBox,
NULL,
groupRects[2].left,
groupRects[2].top,
groupRects[2].right - groupRects[2].left,
groupRects[2].bottom - groupRects[2].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->PresentIntervalGraphHandle,
NULL,
graphRects[2].left,
graphRects[2].top,
graphRects[2].right - graphRects[2].left,
graphRects[2].bottom - graphRects[2].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->PresentDurationGroupBox,
NULL,
groupRects[3].left,
groupRects[3].top,
groupRects[3].right - groupRects[3].left,
groupRects[3].bottom - groupRects[3].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->PresentDurationGraphHandle,
NULL,
graphRects[3].left,
graphRects[3].top,
graphRects[3].right - graphRects[3].left,
graphRects[3].bottom - graphRects[3].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesRenderTimeGroupBox,
NULL,
groupRects[4].left,
groupRects[4].top,
groupRects[4].right - groupRects[4].left,
groupRects[4].bottom - groupRects[4].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesRenderTimeGraphHandle,
NULL,
graphRects[4].left,
graphRects[4].top,
graphRects[4].right - graphRects[4].left,
graphRects[4].bottom - graphRects[4].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesDisplayTimeGroupBox,
NULL,
groupRects[5].left,
groupRects[5].top,
groupRects[5].right - groupRects[5].left,
groupRects[5].bottom - groupRects[5].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesDisplayTimeGraphHandle,
NULL,
graphRects[5].left,
graphRects[5].top,
graphRects[5].right - graphRects[5].left,
graphRects[5].bottom - graphRects[5].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesDisplayLatencyGroupBox,
NULL,
groupRects[6].left,
groupRects[6].top,
groupRects[6].right - groupRects[6].left,
groupRects[6].bottom - groupRects[6].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
deferHandle = DeferWindowPos(
deferHandle,
Context->FramesDisplayLatencyGraphHandle,
NULL,
graphRects[6].left,
graphRects[6].top,
graphRects[6].right - graphRects[6].left,
graphRects[6].bottom - graphRects[6].top,
SWP_NOACTIVATE | SWP_NOZORDER
);
EndDeferWindowPos(deferHandle);
}
VOID FramesPropUpdateGraphs(
_In_ PET_FRAMES_CONTEXT Context
)
{
FramesPropEnsureHistory(Context);
Context->FramesPerSecondGraphState.Valid = FALSE;
Context->FramesPerSecondGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->FramesPerSecondGraphHandle);
Context->FramesLatencyGraphState.Valid = FALSE;
Context->FramesLatencyGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->FramesLatencyGraphHandle);
Context->PresentIntervalGraphState.Valid = FALSE;
Context->PresentIntervalGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->PresentIntervalGraphHandle);
Context->PresentDurationGraphState.Valid = FALSE;
Context->PresentDurationGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->PresentDurationGraphHandle);
Context->FramesRenderTimeGraphState.Valid = FALSE;
Context->FramesRenderTimeGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->FramesRenderTimeGraphHandle);
Context->FramesDisplayTimeGraphState.Valid = FALSE;
Context->FramesDisplayTimeGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->FramesDisplayTimeGraphHandle);
Context->FramesDisplayLatencyGraphState.Valid = FALSE;
Context->FramesDisplayLatencyGraphState.TooltipIndex = ULONG_MAX;
Graph_Update(Context->FramesDisplayLatencyGraphHandle);
}
VOID FramesPropUpdatePanel(
_In_ PET_FRAMES_CONTEXT Context
)
{
PCWSTR runtime;
PCWSTR presentMode;
PPH_STRING string;
PH_FORMAT format[5];
runtime = EtRuntimeToString(Context->Block->FramesRuntime);
presentMode = EtPresentModeToString(Context->Block->FramesPresentMode);
PhInitFormatS(&format[0], L"FPS: ");
PhInitFormatS(&format[1], presentMode);
PhInitFormatS(&format[2], L" (");
PhInitFormatS(&format[3], runtime);
PhInitFormatC(&format[4], L')');
string = PhFormat(format, RTL_NUMBER_OF(format), 0);
PhSetGroupBoxText(Context->FramesPerSecondGroupBox, PhGetString(string));
PhDereferenceObject(string);
}
VOID NTAPI FramesProcessesUpdatedHandler(
_In_opt_ PVOID Parameter,
_In_opt_ PVOID Context
)
{
PET_FRAMES_CONTEXT context = Context;
if (context && context->WindowHandle && context->Enabled)
{
PostMessage(context->WindowHandle, WM_PH_UPDATE_DIALOG, 0, 0);
}
}
INT_PTR CALLBACK EtpFramesPageDlgProc(
_In_ HWND WindowHandle,
_In_ UINT WindowMessage,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
LPPROPSHEETPAGE propSheetPage;
PPH_PROCESS_PROPPAGECONTEXT propPageContext;
PPH_PROCESS_ITEM processItem;
PET_FRAMES_CONTEXT context;
if (PhPropPageDlgProcHeader(WindowHandle, WindowMessage, lParam, &propSheetPage, &propPageContext, &processItem))
{
context = propPageContext->Context;
}
else
{
return FALSE;
}
switch (WindowMessage)
{
case WM_INITDIALOG:
{
PhSetWindowStyle(WindowHandle, WS_CLIPCHILDREN, WS_CLIPCHILDREN);
context = PhAllocateZero(sizeof(ET_FRAMES_CONTEXT));
context->WindowHandle = WindowHandle;
context->Block = EtGetProcessBlock(processItem);
context->Enabled = TRUE;
context->FramesPerSecondGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPS);
context->FramesLatencyGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSLATENCY);
context->PresentIntervalGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSPRESENT);
context->PresentDurationGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSPRESENTINTERVAL);
context->FramesRenderTimeGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSFRAMERENDER);
context->FramesDisplayTimeGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSFRAMEDISPLAY);
context->FramesDisplayLatencyGroupBox = GetDlgItem(WindowHandle, IDC_GROUPFPSDISPLAYLATENCY);
propPageContext->Context = context;
PhInitializeGraphState(&context->FramesPerSecondGraphState);
PhInitializeGraphState(&context->FramesLatencyGraphState);
PhInitializeGraphState(&context->PresentIntervalGraphState);
PhInitializeGraphState(&context->PresentDurationGraphState);
PhInitializeGraphState(&context->FramesRenderTimeGraphState);
PhInitializeGraphState(&context->FramesDisplayTimeGraphState);
PhInitializeGraphState(&context->FramesDisplayLatencyGraphState);
FramesPropUpdateWindowDpi(context);
FramesPropCreateGraphs(context);
FramesPropCreatePanel(context);
SetWindowPos(context->FramesPerSecondGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->FramesLatencyGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->PresentIntervalGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->PresentDurationGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->FramesRenderTimeGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->FramesDisplayTimeGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
SetWindowPos(context->FramesDisplayLatencyGroupBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
PhSetWindowStyle(context->FramesPerSecondGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->FramesLatencyGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->PresentIntervalGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->PresentDurationGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->FramesRenderTimeGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->FramesDisplayTimeGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhSetWindowStyle(context->FramesDisplayLatencyGroupBox, WS_CLIPSIBLINGS, WS_CLIPSIBLINGS);
PhInitializeThemeWindowGroupBoxEx(context->FramesPerSecondGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->FramesLatencyGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->PresentIntervalGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->PresentDurationGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->FramesRenderTimeGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->FramesDisplayTimeGroupBox);
PhInitializeThemeWindowGroupBoxEx(context->FramesDisplayLatencyGroupBox);
PhRegisterCallback(
PhGetGeneralCallback(GeneralCallbackProcessProviderUpdatedEvent),
FramesProcessesUpdatedHandler,
context,
&context->ProcessesUpdatedRegistration
);
PhInitializeWindowTheme(WindowHandle, !!PhGetIntegerSetting(SETTING_ENABLE_THEME_SUPPORT));
}
break;
case WM_DESTROY:
{
PhUnregisterCallback(PhGetGeneralCallback(GeneralCallbackProcessProviderUpdatedEvent), &context->ProcessesUpdatedRegistration);
PhDeleteGraphState(&context->FramesPerSecondGraphState);
PhDeleteGraphState(&context->FramesLatencyGraphState);
PhDeleteGraphState(&context->PresentIntervalGraphState);
PhDeleteGraphState(&context->PresentDurationGraphState);
PhDeleteGraphState(&context->FramesRenderTimeGraphState);
PhDeleteGraphState(&context->FramesDisplayTimeGraphState);
PhDeleteGraphState(&context->FramesDisplayLatencyGraphState);
if (context->FramesPerSecondGraphHandle)
DestroyWindow(context->FramesPerSecondGraphHandle);
if (context->FramesLatencyGraphHandle)
DestroyWindow(context->FramesLatencyGraphHandle);
if (context->PresentIntervalGraphHandle)
DestroyWindow(context->PresentIntervalGraphHandle);
if (context->PresentDurationGraphHandle)
DestroyWindow(context->PresentDurationGraphHandle);
if (context->FramesRenderTimeGraphHandle)
DestroyWindow(context->FramesRenderTimeGraphHandle);
if (context->FramesDisplayTimeGraphHandle)
DestroyWindow(context->FramesDisplayTimeGraphHandle);
if (context->FramesDisplayLatencyGraphHandle)
DestroyWindow(context->FramesDisplayLatencyGraphHandle);
PhFree(context);
}
break;
case WM_SHOWWINDOW:
{
if (PhBeginPropPageLayout(WindowHandle, propPageContext))
PhEndPropPageLayout(WindowHandle, propPageContext);
}
break;
case WM_DPICHANGED_AFTERPARENT:
{
FramesPropUpdateWindowDpi(context);
FramesPropLayoutGraphs(context);
}
break;
case WM_NOTIFY:
{
LPNMHDR header = (LPNMHDR)lParam;
switch (header->code)
{
case PSN_SETACTIVE:
{
context->Enabled = TRUE;
if (context->FramesPerSecondGraphHandle)
{
context->FramesPerSecondGraphState.Valid = FALSE;
context->FramesPerSecondGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->FramesPerSecondGraphHandle);
}
if (context->FramesLatencyGraphHandle)
{
context->FramesLatencyGraphState.Valid = FALSE;
context->FramesLatencyGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->FramesLatencyGraphHandle);
}
if (context->PresentIntervalGraphHandle)
{
context->PresentIntervalGraphState.Valid = FALSE;
context->PresentIntervalGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->PresentIntervalGraphHandle);
}
if (context->PresentDurationGraphHandle)
{
context->PresentDurationGraphState.Valid = FALSE;
context->PresentDurationGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->PresentDurationGraphHandle);
}
if (context->FramesRenderTimeGraphHandle)
{
context->FramesRenderTimeGraphState.Valid = FALSE;
context->FramesRenderTimeGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->FramesRenderTimeGraphHandle);
}
if (context->FramesDisplayTimeGraphHandle)
{
context->FramesDisplayTimeGraphState.Valid = FALSE;
context->FramesDisplayTimeGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->FramesDisplayTimeGraphHandle);
}
if (context->FramesDisplayLatencyGraphHandle)
{
context->FramesDisplayLatencyGraphState.Valid = FALSE;
context->FramesDisplayLatencyGraphState.TooltipIndex = ULONG_MAX;
Graph_Draw(context->FramesDisplayLatencyGraphHandle);
}
}
break;
case PSN_KILLACTIVE:
context->Enabled = FALSE;
break;
}
}
break;
case WM_PH_UPDATE_DIALOG:
{
if (!FlagOn(processItem->State, PH_PROCESS_ITEM_REMOVED) && context->Enabled)
{
FramesPropUpdateGraphs(context);
FramesPropUpdatePanel(context);
}
}
break;
case WM_SIZE:
{
FramesPropLayoutGraphs(context);
}
break;
case WM_CTLCOLORBTN:
return HANDLE_WM_CTLCOLORBTN(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
case WM_CTLCOLORDLG:
return HANDLE_WM_CTLCOLORDLG(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
case WM_CTLCOLORSTATIC:
return HANDLE_WM_CTLCOLORSTATIC(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
}
return FALSE;
}
VOID EtProcessFramesPropertiesInitializing(
_In_ PVOID Parameter
)
{
PPH_PLUGIN_PROCESS_PROPCONTEXT propContext = Parameter;
if (EtFramesEnabled)
{
PhAddProcessPropPage(
propContext->PropContext,
PhCreateProcessPropPageContextEx(PluginInstance->DllBase, MAKEINTRESOURCE(IDD_PROCFRAMES), EtpFramesPageDlgProc, NULL)
);
}
}