70 static HANDLE PhSipThread = NULL;
 
   71 static HWND PhSipWindow = NULL;
 
   72 static PPH_LIST PhSipDialogList = NULL;
 
   75 static RECT MinimumSize;
 
   82 static HWND ContainerControl;
 
   83 static HWND SeparatorControl;
 
   84 static HWND RestoreSummaryControl;
 
   85 static WNDPROC RestoreSummaryControlOldWndProc;
 
   86 static BOOLEAN RestoreSummaryControlHot;
 
   87 static BOOLEAN RestoreSummaryControlHasFocus;
 
   91 static BOOLEAN ThemeHasItemBackground;
 
   94 static HWND CpuDialog;
 
   96 static RECT CpuGraphMargin;
 
   97 static HWND CpuGraphHandle;
 
   99 static HWND *CpusGraphHandle;
 
  101 static BOOLEAN OneGraphPerCpu;
 
  102 static HWND CpuPanel;
 
  103 static ULONG CpuTicked;
 
  104 static ULONG NumberOfProcessors;
 
  115 static HWND MemoryDialog;
 
  117 static RECT MemoryGraphMargin;
 
  118 static HWND CommitGraphHandle;
 
  120 static HWND PhysicalGraphHandle;
 
  122 static HWND MemoryPanel;
 
  123 static ULONG MemoryTicked;
 
  132 static BOOLEAN MmAddressesInitialized;
 
  133 static PSIZE_T MmSizeOfPagedPoolInBytes;
 
  134 static PSIZE_T MmMaximumNonPagedPoolInBytes;
 
  137 static HWND IoDialog;
 
  139 static HWND IoGraphHandle;
 
  142 static ULONG IoTicked;
 
  147 static BOOLEAN AlwaysOnTop;
 
  150     _In_opt_ PWSTR SectionName
 
  174     HACCEL acceleratorTable;
 
  179     PhSipWindow = CreateDialog(
 
  190     while (result = GetMessage(&message, NULL, 0, 0))
 
  198             message.hwnd == PhSipWindow ||
 
  199             IsChild(PhSipWindow, message.hwnd)
 
  202             if (TranslateAccelerator(PhSipWindow, acceleratorTable, &message))
 
  206         if (!processed && PhSipDialogList)
 
  210             for (i = 0; i < PhSipDialogList->
Count; i++)
 
  212                 if (IsDialogMessage((HWND)PhSipDialogList->
Items[i], &message))
 
  222             if (!IsDialogMessage(PhSipWindow, &message))
 
  224                 TranslateMessage(&message);
 
  225                 DispatchMessage(&message);
 
  234     NtClose(PhSipThread);
 
  242         PhSipDialogList = NULL;
 
  245     return STATUS_SUCCESS;
 
  259             PhSipWindow = hwndDlg;
 
  288     case WM_THEMECHANGED:
 
  304                 SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, result);
 
  349         &ProcessesUpdatedRegistration
 
  352     ContainerControl = CreateDialog(
 
  359     if (!EnableThemeDialogTexture_I)
 
  372         &ProcessesUpdatedRegistration
 
  392     for (i = 0; i < SectionList->
Count; i++)
 
  394         section = SectionList->
Items[i];
 
  413     _In_ BOOLEAN Showing,
 
  428     CurrentSection = NULL;
 
  446     SeparatorControl = CreateWindow(
 
  449         WS_CHILD | SS_OWNERDRAW,
 
  460     RestoreSummaryControl = CreateWindow(
 
  463         WS_CHILD | WS_TABSTOP | SS_OWNERDRAW | SS_NOTIFY,
 
  473     RestoreSummaryControlOldWndProc = (WNDPROC)GetWindowLongPtr(RestoreSummaryControl, GWLP_WNDPROC);
 
  475     RestoreSummaryControlHot = 
FALSE;
 
  477     if (EnableThemeDialogTexture_I)
 
  478         EnableThemeDialogTexture_I(ContainerControl, ETDT_ENABLETAB);
 
  480     GetWindowRect(GetDlgItem(PhSipWindow, IDOK), &buttonRect);
 
  481     MapWindowPoints(NULL, PhSipWindow, (POINT *)&buttonRect, 2);
 
  482     GetClientRect(PhSipWindow, &clientRect);
 
  484     MinimumSize.left = 0;
 
  487     MinimumSize.bottom = 290;
 
  488     MapDialogRect(PhSipWindow, &MinimumSize);
 
  490     MinimumSize.right += CurrentParameters.
PanelWidth;
 
  491     MinimumSize.right += GetSystemMetrics(SM_CXFRAME) * 2;
 
  492     MinimumSize.bottom += GetSystemMetrics(SM_CYFRAME) * 2;
 
  494     if (SectionList->
Count != 0)
 
  496         ULONG newMinimumHeight;
 
  499             GetSystemMetrics(SM_CYCAPTION) +
 
  505             clientRect.bottom - buttonRect.top +
 
  506             GetSystemMetrics(SM_CYFRAME) * 2;
 
  508         if (newMinimumHeight > (ULONG)MinimumSize.bottom)
 
  509             MinimumSize.bottom = newMinimumHeight;
 
  524     Button_SetCheck(GetDlgItem(PhSipWindow, 
IDC_ALWAYSONTOP), AlwaysOnTop ? BST_CHECKED : BST_UNCHECKED);
 
  537     if (SectionList && SectionList->
Count != 0)
 
  548     _In_ PRECT DragRectangle
 
  570         DestroyWindow(PhSipWindow);
 
  574             AlwaysOnTop = Button_GetCheck(GetDlgItem(PhSipWindow, 
IDC_ALWAYSONTOP)) == BST_CHECKED;
 
  580             if (Code == STN_CLICKED)
 
  609         if (index < SectionList->Count)
 
  613     if (SectionList && Code == STN_CLICKED)
 
  618         for (i = 0; i < SectionList->
Count; i++)
 
  620             section = SectionList->
Items[i];
 
  633     _Out_ LRESULT *Result
 
  636     switch (Header->code)
 
  645             for (i = 0; i < SectionList->
Count; i++)
 
  647                 section = SectionList->
Items[i];
 
  669                 for (i = 0; i < SectionList->
Count; i++)
 
  671                     section = SectionList->
Items[i];
 
  677                         graphGetTooltipText.
Index = getTooltipText->
Index;
 
  682                         getTooltipText->
Text = graphGetTooltipText.
Text;
 
  698                 for (i = 0; i < SectionList->
Count; i++)
 
  700                     section = SectionList->
Items[i];
 
  717             for (i = 0; i < SectionList->
Count; i++)
 
  719                 section = SectionList->
Items[i];
 
  723                     if (mouseEvent->
Message == WM_LBUTTONDOWN)
 
  740     _In_ DRAWITEMSTRUCT *DrawItemStruct
 
  757     for (i = 0; i < SectionList->
Count; i++)
 
  759         section = SectionList->
Items[i];
 
  763             PhSipDrawPanel(section, DrawItemStruct->hDC, &DrawItemStruct->rcItem);
 
  773     _In_ ULONG_PTR WParam,
 
  774     _In_ ULONG_PTR LParam
 
  781             if (IsIconic(PhSipWindow))
 
  782                 ShowWindow(PhSipWindow, SW_RESTORE);
 
  784                 ShowWindow(PhSipWindow, SW_SHOW);
 
  786             SetForegroundWindow(PhSipWindow);
 
  796                 for (i = 0; i < SectionList->
Count; i++)
 
  798                     section = SectionList->
Items[i];
 
  822                 for (i = 0; i < SectionList->
Count; i++)
 
  824                     section = SectionList->
Items[i];
 
  831             InvalidateRect(PhSipWindow, NULL, 
TRUE);
 
  845     window = PhSipWindow;
 
  853     _In_ COLORREF Color1,
 
  860         DrawInfo->BackColor = RGB(0xef, 0xef, 0xef);
 
  865         DrawInfo->GridColor = RGB(0xc7, 0xc7, 0xc7);
 
  866         DrawInfo->TextColor = RGB(0x00, 0x00, 0x00);
 
  867         DrawInfo->TextBoxColor = RGB(0xe7, 0xe7, 0xe7);
 
  870         DrawInfo->BackColor = RGB(0x00, 0x00, 0x00);
 
  871         DrawInfo->LineColor1 = Color1;
 
  873         DrawInfo->LineColor2 = Color2;
 
  875         DrawInfo->GridColor = RGB(0x00, 0x57, 0x00);
 
  876         DrawInfo->TextColor = RGB(0x00, 0xff, 0x00);
 
  877         DrawInfo->TextBoxColor = RGB(0x00, 0x22, 0x00);
 
  883     _In_ HWND DialogWindowHandle
 
  886     if (!PhSipDialogList)
 
  893     _In_ HWND DialogWindowHandle
 
  898     if ((index = PhFindItemList(PhSipDialogList, DialogWindowHandle)) != -1)
 
  908     TEXTMETRIC textMetrics;
 
  916     if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, 
sizeof(LOGFONT), &logFont, 0))
 
  918         CurrentParameters.
Font = CreateFontIndirect(&logFont);
 
  926     hdc = GetDC(PhSipWindow);
 
  928     logFont.lfHeight -= MulDiv(3, GetDeviceCaps(hdc, LOGPIXELSY), 72);
 
  929     CurrentParameters.
MediumFont = CreateFontIndirect(&logFont);
 
  931     logFont.lfHeight -= MulDiv(3, GetDeviceCaps(hdc, LOGPIXELSY), 72);
 
  932     CurrentParameters.
LargeFont = CreateFontIndirect(&logFont);
 
  938     originalFont = SelectObject(hdc, CurrentParameters.
Font);
 
  939     GetTextMetrics(hdc, &textMetrics);
 
  940     CurrentParameters.
FontHeight = textMetrics.tmHeight;
 
  943     SelectObject(hdc, CurrentParameters.
MediumFont);
 
  944     GetTextMetrics(hdc, &textMetrics);
 
  948     SelectObject(hdc, originalFont);
 
  967     ReleaseDC(PhSipWindow, hdc);
 
  974     if (CurrentParameters.
Font)
 
  975         DeleteObject(CurrentParameters.
Font);
 
  979         DeleteObject(CurrentParameters.
LargeFont);
 
 1009     section->
Name = Template->Name;
 
 1010     section->
Flags = Template->Flags;
 
 1011     section->
Callback = Template->Callback;
 
 1012     section->
Context = Template->Context;
 
 1041         WS_CHILD | SS_OWNERDRAW | SS_NOTIFY,
 
 1084     for (i = 0; i < SectionList->
Count; i++)
 
 1086         section = SectionList->
Items[i];
 
 1105     section.
Flags = Flags;
 
 1116     FillRect(hdc, Rect, GetSysColorBrush(COLOR_3DFACE));
 
 1118     if (RestoreSummaryControlHot || RestoreSummaryControlHasFocus)
 
 1120         if (ThemeHasItemBackground)
 
 1133             FillRect(hdc, Rect, GetSysColorBrush(COLOR_WINDOW));
 
 1137     SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
 
 1138     SetBkMode(hdc, TRANSPARENT);
 
 1140     SelectObject(hdc, CurrentParameters.
MediumFont);
 
 1141     DrawText(hdc, L
"Back", 4, Rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
 
 1152     FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DHIGHLIGHT));
 
 1154     FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DSHADOW));
 
 1166         FillRect(hdc, Rect, GetSysColorBrush(COLOR_3DFACE));
 
 1168     sysInfoDrawPanel.
hdc = hdc;
 
 1169     sysInfoDrawPanel.
Rect = *Rect;
 
 1173     sysInfoDrawPanel.
Title = NULL;
 
 1181         sysInfoDrawPanel.
Rect.right = Rect->right;
 
 1199     hdc = DrawPanel->hdc;
 
 1201     if (ThemeHasItemBackground)
 
 1209             if (Section->GraphHot || Section->PanelHot || Section->HasFocus)
 
 1211                 if (Section == CurrentSection)
 
 1212                     stateId = TREIS_HOTSELECTED;
 
 1214                     stateId = TREIS_HOT;
 
 1216             else if (Section == CurrentSection)
 
 1218                 stateId = TREIS_SELECTED;
 
 1225                 themeRect = DrawPanel->Rect;
 
 1226                 themeRect.left -= 2; 
 
 1238         else if (Section->HasFocus)
 
 1258             if (Section->GraphHot || Section->PanelHot || Section->HasFocus)
 
 1260                 brush = GetSysColorBrush(COLOR_WINDOW); 
 
 1262             else if (Section == CurrentSection)
 
 1264                 brush = GetSysColorBrush(COLOR_WINDOW);
 
 1269                 FillRect(hdc, &DrawPanel->Rect, brush);
 
 1277         SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
 
 1279     SetBkMode(hdc, TRANSPARENT);
 
 1284     rect.bottom = DrawPanel->Rect.bottom;
 
 1286     flags = DT_NOPREFIX;
 
 1289         rect.right = DrawPanel->Rect.right; 
 
 1291         flags |= DT_END_ELLIPSIS;
 
 1293     if (DrawPanel->Title)
 
 1295         SelectObject(hdc, CurrentParameters.
MediumFont);
 
 1296         DrawText(hdc, DrawPanel->Title->Buffer, (ULONG)DrawPanel->Title->Length / 2, &rect, flags | DT_SINGLELINE);
 
 1299     if (DrawPanel->SubTitle)
 
 1304         SelectObject(hdc, CurrentParameters.
Font);
 
 1307         DrawText(hdc, DrawPanel->SubTitle->Buffer, (ULONG)DrawPanel->SubTitle->Length / 2, &measureRect, (flags & ~DT_END_ELLIPSIS) | DT_CALCRECT);
 
 1309         if (measureRect.right <= rect.right || !DrawPanel->SubTitleOverflow)
 
 1312             DrawText(hdc, DrawPanel->SubTitle->Buffer, (ULONG)DrawPanel->SubTitle->Length / 2, &rect, flags);
 
 1317             DrawText(hdc, DrawPanel->SubTitleOverflow->Buffer, (ULONG)DrawPanel->SubTitleOverflow->Length / 2, &rect, flags);
 
 1328     ULONG availableHeight;
 
 1329     ULONG availableWidth;
 
 1336     GetWindowRect(GetDlgItem(PhSipWindow, IDOK), &buttonRect);
 
 1337     MapWindowPoints(NULL, PhSipWindow, (POINT *)&buttonRect, 2);
 
 1338     GetClientRect(PhSipWindow, &clientRect);
 
 1344     deferHandle = BeginDeferWindowPos(SectionList->
Count);
 
 1347     for (i = 0; i < SectionList->
Count; i++)
 
 1349         section = SectionList->
Items[i];
 
 1351         deferHandle = DeferWindowPos(
 
 1359             SWP_NOACTIVATE | SWP_NOZORDER
 
 1366     EndDeferWindowPos(deferHandle);
 
 1375     ULONG availableHeight;
 
 1376     ULONG availableWidth;
 
 1382     ULONG containerLeft;
 
 1384     GetWindowRect(GetDlgItem(PhSipWindow, IDOK), &buttonRect);
 
 1385     MapWindowPoints(NULL, PhSipWindow, (POINT *)&buttonRect, 2);
 
 1386     GetClientRect(PhSipWindow, &clientRect);
 
 1395     deferHandle = BeginDeferWindowPos(SectionList->
Count * 2 + 3);
 
 1398     for (i = 0; i < SectionList->
Count; i++)
 
 1400         section = SectionList->
Items[i];
 
 1402         deferHandle = DeferWindowPos(
 
 1410             SWP_NOACTIVATE | SWP_NOZORDER
 
 1413         deferHandle = DeferWindowPos(
 
 1421             SWP_NOACTIVATE | SWP_NOZORDER
 
 1430     deferHandle = DeferWindowPos(
 
 1432         RestoreSummaryControl,
 
 1438         SWP_NOACTIVATE | SWP_NOZORDER
 
 1440     InvalidateRect(RestoreSummaryControl, NULL, 
TRUE);
 
 1442     deferHandle = DeferWindowPos(
 
 1450         SWP_NOACTIVATE | SWP_NOZORDER
 
 1454     deferHandle = DeferWindowPos(
 
 1460         clientRect.right - containerLeft,
 
 1462         SWP_NOACTIVATE | SWP_NOZORDER
 
 1465     EndDeferWindowPos(deferHandle);
 
 1476             SWP_NOACTIVATE | SWP_NOZORDER
 
 1487     BOOLEAN fromSummaryView;
 
 1492     oldSection = CurrentSection;
 
 1493     CurrentSection = NewSection;
 
 1495     for (i = 0; i < SectionList->
Count; i++)
 
 1497         section = SectionList->
Items[i];
 
 1502         if (fromSummaryView)
 
 1508         if (section == CurrentSection && !section->
DialogHandle)
 
 1513             if (section == CurrentSection)
 
 1520     ShowWindow(ContainerControl, SW_SHOW);
 
 1521     ShowWindow(RestoreSummaryControl, SW_SHOW);
 
 1522     ShowWindow(SeparatorControl, SW_SHOW);
 
 1528     InvalidateRect(NewSection->PanelHandle, NULL, 
TRUE);
 
 1544     CurrentSection = NULL;
 
 1546     for (i = 0; i < SectionList->
Count; i++)
 
 1548         section = SectionList->
Items[i];
 
 1559     ShowWindow(ContainerControl, SW_HIDE);
 
 1560     ShowWindow(RestoreSummaryControl, SW_HIDE);
 
 1561     ShowWindow(SeparatorControl, SW_HIDE);
 
 1581                 DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD,
 
 1613             SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
 
 1645         if (wParam == VK_SPACE || wParam == VK_RETURN ||
 
 1646             wParam == VK_UP || wParam == VK_DOWN ||
 
 1647             wParam == VK_LEFT || wParam == VK_RIGHT)
 
 1648             return DLGC_WANTALLKEYS;
 
 1652             if (wParam == VK_SPACE || wParam == VK_RETURN)
 
 1656             else if (wParam == VK_UP || wParam == VK_LEFT ||
 
 1657                 wParam == VK_DOWN || wParam == VK_RIGHT)
 
 1661                 for (i = 0; i < SectionList->
Count; i++)
 
 1663                     if (SectionList->
Items[i] == section)
 
 1665                         if ((wParam == VK_UP || wParam == VK_LEFT) && i > 0)
 
 1669                         else if (wParam == VK_DOWN || wParam == VK_RIGHT)
 
 1671                             if (i < SectionList->Count - 1)
 
 1674                                 SetFocus(RestoreSummaryControl);
 
 1685             TRACKMOUSEEVENT trackMouseEvent;
 
 1687             trackMouseEvent.cbSize = 
sizeof(TRACKMOUSEEVENT);
 
 1688             trackMouseEvent.dwFlags = TME_LEAVE;
 
 1689             trackMouseEvent.hwndTrack = hwnd;
 
 1690             trackMouseEvent.dwHoverTime = 0;
 
 1691             TrackMouseEvent(&trackMouseEvent);
 
 1725     case WM_NCLBUTTONDOWN:
 
 1730     case WM_UPDATEUISTATE:
 
 1732             switch (LOWORD(wParam))
 
 1735                 if (HIWORD(wParam) & UISF_HIDEFOCUS)
 
 1739                 if (HIWORD(wParam) & UISF_HIDEFOCUS)
 
 1742             case UIS_INITIALIZE:
 
 1743                 section->
HideFocus = !!(HIWORD(wParam) & UISF_HIDEFOCUS);
 
 1750     return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
 
 1768         oldWndProc = RestoreSummaryControlOldWndProc;
 
 1775             SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
 
 1782                 RestoreSummaryControlHasFocus = 
TRUE;
 
 1783                 InvalidateRect(hwnd, NULL, 
TRUE);
 
 1791                 RestoreSummaryControlHasFocus = 
FALSE;
 
 1792                 InvalidateRect(hwnd, NULL, 
TRUE);
 
 1798             SetCursor(LoadCursor(NULL, IDC_HAND));
 
 1802         if (wParam == VK_SPACE || wParam == VK_RETURN ||
 
 1803             wParam == VK_UP || wParam == VK_DOWN ||
 
 1804             wParam == VK_LEFT || wParam == VK_RIGHT)
 
 1805             return DLGC_WANTALLKEYS;
 
 1809             if (wParam == VK_SPACE || wParam == VK_RETURN)
 
 1816             else if (wParam == VK_UP || wParam == VK_LEFT)
 
 1818                 if (!section && SectionList->
Count != 0)
 
 1827             TRACKMOUSEEVENT trackMouseEvent;
 
 1829             trackMouseEvent.cbSize = 
sizeof(TRACKMOUSEEVENT);
 
 1830             trackMouseEvent.dwFlags = TME_LEAVE;
 
 1831             trackMouseEvent.hwndTrack = hwnd;
 
 1832             trackMouseEvent.dwHoverTime = 0;
 
 1833             TrackMouseEvent(&trackMouseEvent);
 
 1849                 RestoreSummaryControlHot = 
TRUE;
 
 1850                 InvalidateRect(RestoreSummaryControl, NULL, 
TRUE);
 
 1872                 RestoreSummaryControlHasFocus = 
FALSE;
 
 1873                 RestoreSummaryControlHot = 
FALSE;
 
 1874                 InvalidateRect(RestoreSummaryControl, NULL, 
TRUE);
 
 1880     return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
 
 1909             ThemeHasItemBackground = 
FALSE;
 
 1915         ThemeHasItemBackground = 
FALSE;
 
 1923     SetFocus(PhSipWindow); 
 
 1924     SetWindowPos(PhSipWindow, AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0,
 
 1925         SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 
 1929     _In_opt_ PVOID Parameter,
 
 1930     _In_opt_ PVOID Context
 
 1938     _In_ USHORT Precision
 
 1953     _In_opt_ PVOID Parameter1,
 
 1954     _In_opt_ PVOID Parameter2
 
 1993             if (!Section->GraphState.Valid)
 
 1997                 Section->GraphState.Valid = 
TRUE;
 
 2012                 (cpuKernel + cpuUser) * 100,
 
 2016             getTooltipText->
Text = Section->GraphState.TooltipText->sr;
 
 2044     CpusGraphHandle = PhAllocate(
sizeof(HWND) * NumberOfProcessors);
 
 2045     CpusGraphState = PhAllocate(
sizeof(
PH_GRAPH_STATE) * NumberOfProcessors);
 
 2051     for (i = 0; i < NumberOfProcessors; i++)
 
 2057         ProcessorInformation,
 
 2067     CurrentPerformanceDistribution = NULL;
 
 2068     PreviousPerformanceDistribution = NULL;
 
 2082     for (i = 0; i < NumberOfProcessors; i++)
 
 2087     PhFree(InterruptInformation);
 
 2088     PhFree(PowerInformation);
 
 2090     if (CurrentPerformanceDistribution)
 
 2091         PhFree(CurrentPerformanceDistribution);
 
 2092     if (PreviousPerformanceDistribution)
 
 2093         PhFree(PreviousPerformanceDistribution);
 
 2109         InterruptInformation,
 
 2114         for (i = 0; i < NumberOfProcessors; i++)
 
 2115             dpcCount += InterruptInformation[i].DpcCount;
 
 2124         ProcessorInformation,
 
 2136         if (PreviousPerformanceDistribution)
 
 2137             PhFree(PreviousPerformanceDistribution);
 
 2139         PreviousPerformanceDistribution = CurrentPerformanceDistribution;
 
 2140         CurrentPerformanceDistribution = NULL;
 
 2166             WCHAR brandString[49];
 
 2170             CpuDialog = hwndDlg;
 
 2174             CpuGraphMargin = graphItem->
Margin;
 
 2181             SetDlgItemText(hwndDlg, 
IDC_CPUNAME, brandString);
 
 2184             ShowWindow(CpuPanel, SW_SHOW);
 
 2189             if (NumberOfProcessors != 1)
 
 2192                 Button_SetCheck(GetDlgItem(CpuPanel, 
IDC_ONEGRAPHPERCPU), OneGraphPerCpu ? BST_CHECKED : BST_UNCHECKED);
 
 2197                 OneGraphPerCpu = 
FALSE;
 
 2219             NMHDR *header = (NMHDR *)lParam;
 
 2222             if (header->hwndFrom == CpuGraphHandle)
 
 2228                 for (i = 0; i < NumberOfProcessors; i++)
 
 2230                     if (header->hwndFrom == CpusGraphHandle[i])
 
 2261             switch (LOWORD(wParam))
 
 2265                     OneGraphPerCpu = Button_GetCheck(GetDlgItem(hwndDlg, 
IDC_ONEGRAPHPERCPU)) == BST_CHECKED;
 
 2284     CpuGraphHandle = CreateWindow(
 
 2287         WS_CHILD | WS_BORDER,
 
 2299     for (i = 0; i < NumberOfProcessors; i++)
 
 2301         CpusGraphHandle[i] = CreateWindow(
 
 2304             WS_CHILD | WS_BORDER,
 
 2325     GetClientRect(CpuDialog, &clientRect);
 
 2326     deferHandle = BeginDeferWindowPos(OneGraphPerCpu ? NumberOfProcessors : 1);
 
 2328     if (!OneGraphPerCpu)
 
 2330         deferHandle = DeferWindowPos(
 
 2334             CpuGraphMargin.left,
 
 2336             clientRect.right - CpuGraphMargin.left - CpuGraphMargin.right,
 
 2337             clientRect.bottom - CpuGraphMargin.top - CpuGraphMargin.bottom,
 
 2338             SWP_NOACTIVATE | SWP_NOZORDER
 
 2343         ULONG numberOfRows = 1;
 
 2344         ULONG numberOfColumns = NumberOfProcessors;
 
 2346         for (ULONG rows = 2; rows <= NumberOfProcessors / rows; rows++)
 
 2348             if (NumberOfProcessors % rows != 0)
 
 2351             numberOfRows = rows;
 
 2352             numberOfColumns = NumberOfProcessors / rows;
 
 2355         if (numberOfRows == 1)
 
 2357             numberOfRows = (ULONG)sqrt(NumberOfProcessors);
 
 2358             numberOfColumns = (NumberOfProcessors + numberOfRows - 1) / numberOfRows;
 
 2361         ULONG numberOfYPaddings = numberOfRows - 1;
 
 2362         ULONG numberOfXPaddings = numberOfColumns - 1;
 
 2364         ULONG cellHeight = (clientRect.bottom - CpuGraphMargin.top - CpuGraphMargin.bottom - 
PH_SYSINFO_CPU_PADDING * numberOfYPaddings) / numberOfRows;
 
 2365         ULONG y = CpuGraphMargin.top;
 
 2370         for (ULONG row = 0; row < numberOfRows; row++)
 
 2374             if (row == numberOfRows - 1)
 
 2375                 cellHeight = clientRect.bottom - CpuGraphMargin.bottom - y;
 
 2377             cellWidth = (clientRect.right - CpuGraphMargin.left - CpuGraphMargin.right - 
PH_SYSINFO_CPU_PADDING * numberOfXPaddings) / numberOfColumns;
 
 2378             x = CpuGraphMargin.left;
 
 2380             for (ULONG column = 0; column < numberOfColumns; column++)
 
 2384                 if (column == numberOfColumns - 1)
 
 2385                     cellWidth = clientRect.right - CpuGraphMargin.right - x;
 
 2387                 if (i < NumberOfProcessors)
 
 2389                     deferHandle = DeferWindowPos(
 
 2397                         SWP_NOACTIVATE | SWP_NOZORDER
 
 2409     EndDeferWindowPos(deferHandle);
 
 2418     ShowWindow(CpuGraphHandle, !OneGraphPerCpu ? SW_SHOW : SW_HIDE);
 
 2420     for (i = 0; i < NumberOfProcessors; i++)
 
 2422         ShowWindow(CpusGraphHandle[i], OneGraphPerCpu ? SW_SHOW : SW_HIDE);
 
 2431     switch (Header->code)
 
 2449                 if (!CpuGraphState.
Valid)
 
 2459                     &CpusGraphState[Index],
 
 2464                 if (!CpusGraphState[Index].Valid)
 
 2491                             (cpuKernel + cpuUser) * 100,
 
 2501                     if (CpusGraphState[Index].TooltipIndex != getTooltipText->
Index)
 
 2510                             L
"%.2f%% (K: %.2f%%, U: %.2f%%)%s\n%s",
 
 2511                             (cpuKernel + cpuUser) * 100,
 
 2557     InvalidateRect(CpuGraphHandle, NULL, 
FALSE);
 
 2559     for (i = 0; i < NumberOfProcessors; i++)
 
 2566         InvalidateRect(CpusGraphHandle[i], NULL, 
FALSE);
 
 2574     HWND hwnd = CpuPanel;
 
 2577     BOOLEAN distributionSucceeded;
 
 2584     distributionSucceeded = 
FALSE;
 
 2590             cpuGhz = (DOUBLE)PowerInformation[0].MaxMhz * cpuFraction / 1000;
 
 2591             distributionSucceeded = 
TRUE;
 
 2595     if (!distributionSucceeded)
 
 2596         cpuGhz = (DOUBLE)PowerInformation[0].CurrentMhz / 1000;
 
 2598     SetDlgItemText(hwnd, 
IDC_SPEED, 
PhaFormatString(L
"%.2f / %.2f GHz", cpuGhz, (DOUBLE)PowerInformation[0].MaxMhz / 1000)->Buffer);
 
 2646     maxProcessId = PhGetItemCircularBuffer_ULONG(&
PhMaxCpuHistory, Index);
 
 2674 #ifdef PH_RECORD_MAX_USAGE 
 2682 #ifdef PH_RECORD_MAX_USAGE 
 2689                 L
"\n%s (%u): %.2f%%",
 
 2710     return maxUsageString;
 
 2714     _Out_writes_(49) PWSTR BrandString
 
 2717     ULONG brandString[4 * 3];
 
 2719     __cpuid(&brandString[0], 0x80000002);
 
 2720     __cpuid(&brandString[4], 0x80000003);
 
 2721     __cpuid(&brandString[8], 0x80000004);
 
 2724     BrandString[48] = 0;
 
 2728     _Out_ DOUBLE *Fraction
 
 2743     if (CurrentPerformanceDistribution->
ProcessorCount != NumberOfProcessors || PreviousPerformanceDistribution->
ProcessorCount != NumberOfProcessors)
 
 2747     differences = PhAllocate(stateSize * NumberOfProcessors);
 
 2749     for (i = 0; i < NumberOfProcessors; i++)
 
 2760         for (j = 0; j < stateDistribution->
StateCount; j++)
 
 2764                 stateDifference->
States[j] = stateDistribution->
States[j];
 
 2775     for (i = 0; i < NumberOfProcessors; i++)
 
 2786         for (j = 0; j < stateDistribution->
StateCount; j++)
 
 2805     for (i = 0; i < NumberOfProcessors; i++)
 
 2809         for (j = 0; j < 2; j++)
 
 2811             count += (ULONGLONG)stateDifference->
States[j].
Hits.QuadPart;
 
 2838     buffer = PhAllocate(bufferSize);
 
 2840     status = NtQuerySystemInformation(
 
 2848     while (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 8)
 
 2851         buffer = PhAllocate(bufferSize);
 
 2853         status = NtQuerySystemInformation(
 
 2873     _In_opt_ PVOID Parameter1,
 
 2874     _In_opt_ PVOID Parameter2
 
 2884                 MemoryDialog = NULL;
 
 2916                 if (!Section->GraphState.Valid)
 
 2920                         Section->GraphState.Data1[i] = (FLOAT)PhGetItemCircularBuffer_ULONG(&
PhCommitHistory, i);
 
 2927                             Section->GraphState.Data1,
 
 2933                     Section->GraphState.Valid = 
TRUE;
 
 2942                 if (!Section->GraphState.Valid)
 
 2946                         Section->GraphState.Data1[i] = (FLOAT)PhGetItemCircularBuffer_ULONG(&
PhPhysicalHistory, i);
 
 2953                             Section->GraphState.Data1,
 
 2959                     Section->GraphState.Valid = 
TRUE;
 
 2974                     L
"Commit Charge: %s\n%s",
 
 2978                 getTooltipText->
Text = Section->GraphState.TooltipText->sr;
 
 2985                     L
"Physical Memory: %s\n%s",
 
 2989                 getTooltipText->
Text = Section->GraphState.TooltipText->sr;
 
 3013                 (FLOAT)usedPages * 100 / totalPages,
 
 3019                 (FLOAT)usedPages * 100 / totalPages,
 
 3050         MmAddressesInitialized = 
TRUE;
 
 3077     if (MemoryTicked > 2)
 
 3095             static BOOL (WINAPI *getPhysicallyInstalledSystemMemory)(PULONGLONG) = NULL;
 
 3099             ULONGLONG installedMemory;
 
 3103             MemoryDialog = hwndDlg;
 
 3107             MemoryGraphMargin = graphItem->
Margin;
 
 3113             if (!getPhysicallyInstalledSystemMemory)
 
 3114                 getPhysicallyInstalledSystemMemory = 
PhGetModuleProcAddress(L
"kernel32.dll", 
"GetPhysicallyInstalledSystemMemory");
 
 3116             if (getPhysicallyInstalledSystemMemory && getPhysicallyInstalledSystemMemory(&installedMemory))
 
 3127             MemoryPanel = CreateDialog(
 
 3133             ShowWindow(MemoryPanel, SW_SHOW);
 
 3136             CommitGraphHandle = CreateWindow(
 
 3139                 WS_VISIBLE | WS_CHILD | WS_BORDER,
 
 3151             PhysicalGraphHandle = CreateWindow(
 
 3154                 WS_VISIBLE | WS_CHILD | WS_BORDER,
 
 3183             NMHDR *header = (NMHDR *)lParam;
 
 3185             if (header->hwndFrom == CommitGraphHandle)
 
 3189             else if (header->hwndFrom == PhysicalGraphHandle)
 
 3216             switch (LOWORD(wParam))
 
 3242     GetClientRect(MemoryDialog, &clientRect);
 
 3243     GetClientRect(GetDlgItem(MemoryDialog, 
IDC_COMMIT_L), &labelRect);
 
 3244     graphWidth = clientRect.right - MemoryGraphMargin.left - MemoryGraphMargin.right;
 
 3245     graphHeight = (clientRect.bottom - MemoryGraphMargin.top - MemoryGraphMargin.bottom - labelRect.bottom * 2 - 
PH_SYSINFO_MEMORY_PADDING * 3) / 2;
 
 3247     deferHandle = BeginDeferWindowPos(4);
 
 3248     y = MemoryGraphMargin.top;
 
 3250     deferHandle = DeferWindowPos(
 
 3254         MemoryGraphMargin.left,
 
 3258         SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER
 
 3262     deferHandle = DeferWindowPos(
 
 3266         MemoryGraphMargin.left,
 
 3270         SWP_NOACTIVATE | SWP_NOZORDER
 
 3274     deferHandle = DeferWindowPos(
 
 3278         MemoryGraphMargin.left,
 
 3282         SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER
 
 3286     deferHandle = DeferWindowPos(
 
 3288         PhysicalGraphHandle,
 
 3290         MemoryGraphMargin.left,
 
 3293         clientRect.bottom - MemoryGraphMargin.bottom - y,
 
 3294         SWP_NOACTIVATE | SWP_NOZORDER
 
 3297     EndDeferWindowPos(deferHandle);
 
 3304     switch (Header->code)
 
 3321             if (!CommitGraphState.
Valid)
 
 3332                         CommitGraphState.
Data1,
 
 3355                         L
"Commit Charge: %s\n%s",
 
 3372     switch (Header->code)
 
 3384                 &PhysicalGraphState,
 
 3389             if (!PhysicalGraphState.
Valid)
 
 3400                         PhysicalGraphState.
Data1,
 
 3423                         L
"Physical Memory: %s\n%s",
 
 3445     InvalidateRect(CommitGraphHandle, NULL, 
FALSE);
 
 3452     InvalidateRect(PhysicalGraphHandle, NULL, 
FALSE);
 
 3460     PWSTR nonPagedLimit;
 
 3492     if (MemoryTicked > 1)
 
 3497     if (MemoryTicked > 1)
 
 3507     if (MemoryTicked > 1)
 
 3512     if (MemoryTicked > 1)
 
 3519     if (MmAddressesInitialized && (MmSizeOfPagedPoolInBytes || MmMaximumNonPagedPoolInBytes))
 
 3532             pagedLimit = nonPagedLimit = L
"no driver";
 
 3536             pagedLimit = nonPagedLimit = L
"no symbols";
 
 3545     if (MemoryTicked > 1)
 
 3550     if (MemoryTicked > 1)
 
 3555     if (MemoryTicked > 1)
 
 3560     if (MemoryTicked > 1)
 
 3576             ULONG_PTR standbyPageCount;
 
 3577             ULONG_PTR repurposedPageCount;
 
 3580             standbyPageCount = 0;
 
 3581             repurposedPageCount = 0;
 
 3583             for (i = 0; i < 8; i++)
 
 3629     _In_ PVOID Parameter
 
 3659                 L
"MmSizeOfPagedPoolInBytes",
 
 3663                 MmSizeOfPagedPoolInBytes = (PSIZE_T)symbolInfo.
Address;
 
 3668                 L
"MmMaximumNonPagedPoolInBytes",
 
 3672                 MmMaximumNonPagedPoolInBytes = (PSIZE_T)symbolInfo.
Address;
 
 3681     return STATUS_SUCCESS;
 
 3685     _Out_ PSIZE_T Paged,
 
 3686     _Out_ PSIZE_T NonPaged
 
 3690     SIZE_T nonPaged = 0;
 
 3692     if (MmSizeOfPagedPoolInBytes)
 
 3696             MmSizeOfPagedPoolInBytes,
 
 3703     if (MmMaximumNonPagedPoolInBytes)
 
 3707             MmMaximumNonPagedPoolInBytes,
 
 3715     *NonPaged = nonPaged;
 
 3721     _In_opt_ PVOID Parameter1,
 
 3722     _In_opt_ PVOID Parameter2
 
 3763             if (!Section->GraphState.Valid)
 
 3772                     Section->GraphState.Data1[i] = data1 =
 
 3775                     Section->GraphState.Data2[i] = data2 =
 
 3778                     if (max < data1 + data2)
 
 3779                         max = data1 + data2;
 
 3783                 if (max < 1024 * 1024)
 
 3789                     Section->GraphState.Data1,
 
 3794                     Section->GraphState.Data2,
 
 3799                 Section->GraphState.Valid = 
TRUE;
 
 3815                 L
"R: %s\nW: %s\nO: %s%s\n%s",
 
 3822             getTooltipText->
Text = Section->GraphState.TooltipText->sr;
 
 3903             ShowWindow(IoPanel, SW_SHOW);
 
 3906             IoGraphHandle = CreateWindow(
 
 3909                 WS_VISIBLE | WS_CHILD | WS_BORDER,
 
 3939             NMHDR *header = (NMHDR *)lParam;
 
 3941             if (header->hwndFrom == IoGraphHandle)
 
 3975     switch (Header->code)
 
 3992             if (!IoGraphState.
Valid)
 
 4001                     IoGraphState.
Data1[i] = data1 =
 
 4004                     IoGraphState.
Data2[i] = data2 =
 
 4007                     if (max < data1 + data2)
 
 4008                         max = data1 + data2;
 
 4012                 if (max < 1024 * 1024)
 
 4049                         L
"R: %s\nW: %s\nO: %s%s\n%s",
 
 4093     InvalidateRect(IoGraphHandle, NULL, 
FALSE);
 
 4147     maxProcessId = PhGetItemCircularBuffer_ULONG(&
PhMaxIoHistory, Index);
 
 4164 #ifdef PH_RECORD_MAX_USAGE 
 4165     ULONG64 maxIoReadOther;
 
 4173 #ifdef PH_RECORD_MAX_USAGE 
 4180                 L
"\n%s (%u): R+O: %s, W: %s",
 
 4190                 L
"\n%s: R+O: %s, W: %s",
 
 4203     return maxUsageString;