31 typedef struct _PH_NF_BITMAP
35 BITMAPINFOHEADER Header;
60 _In_opt_ PVOID Parameter,
61 _In_opt_ PVOID Context
71 _Out_ HBITMAP *Bitmap,
72 _Out_opt_ PVOID *Bits,
74 _Out_ HBITMAP *OldBitmap
81 _Out_ HBITMAP *Bitmap,
82 _Out_opt_ PVOID *Bits,
84 _Out_ HBITMAP *OldBitmap
139 remainingPart = iconList->
sr;
141 while (remainingPart.
Length != 0)
178 &PhNfpProcessesUpdatedRegistration
186 ULONG registeredIconMask;
190 registeredIconMask =
PhNfIconMask & ~PH_ICON_DEFAULT_ALL;
192 if (registeredIconMask != 0)
201 if (PhNfRegisteredIcons[i])
203 if (registeredIconMask & PhNfRegisteredIcons[i]->IconId)
208 PhNfRegisteredIcons[i]->Plugin->Name.Buffer,
209 PhNfRegisteredIcons[i]->
SubId
245 _In_ ULONG_PTR WParam,
246 _In_ ULONG_PTR LParam
249 ULONG iconIndex = HIWORD(LParam);
252 if (iconIndex <
sizeof(PhNfRegisteredIcons) /
sizeof(
PPH_NF_ICON) && PhNfRegisteredIcons[iconIndex])
254 registeredIcon = PhNfRegisteredIcons[iconIndex];
270 switch (LOWORD(LParam))
278 case WM_LBUTTONDBLCLK:
290 GetCursorPos(&location);
299 case NIN_BALLOONUSERCLICK:
305 BOOLEAN showMiniInfo =
FALSE;
318 (ULONG_PTR)&showMiniInfoSectionData,
329 switch (1 << iconIndex)
339 showMiniInfoSectionData.
SectionName = L
"Commit Charge";
342 showMiniInfoSectionData.
SectionName = L
"Physical Memory";
351 GetCursorPos(&location);
402 NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE };
410 if (!_BitScanForward(&Id, Id))
415 notifyIcon.uFlags = NIF_INFO;
416 wcsncpy_s(notifyIcon.szInfoTitle,
sizeof(notifyIcon.szInfoTitle) /
sizeof(WCHAR), Title, _TRUNCATE);
417 wcsncpy_s(notifyIcon.szInfo,
sizeof(notifyIcon.szInfo) /
sizeof(WCHAR), Text, _TRUNCATE);
418 notifyIcon.uTimeout = Timeout;
419 notifyIcon.dwInfoFlags = Flags;
421 Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon);
434 iconInfo.fIcon =
TRUE;
435 iconInfo.xHotspot = 0;
436 iconInfo.yHotspot = 0;
438 iconInfo.hbmColor = Bitmap;
440 return CreateIconIndirect(&iconInfo);
446 _In_opt_ PVOID Context,
465 if (!_BitScanReverse(&iconIndex, iconId) ||
466 iconIndex >=
sizeof(PhNfRegisteredIcons) /
sizeof(
PPH_NF_ICON))
485 PhNfRegisteredIcons[iconIndex] = icon;
496 if (!_BitScanReverse(&iconIndex, Id))
499 return PhNfRegisteredIcons[iconIndex];
511 if (PhNfRegisteredIcons[i])
513 if (PhNfRegisteredIcons[i]->SubId == SubId &&
516 return PhNfRegisteredIcons[i];
564 memset(bits, 0, width * height *
sizeof(ULONG));
566 iconInfo.fIcon =
TRUE;
567 iconInfo.xHotspot = 0;
568 iconInfo.yHotspot = 0;
573 SelectObject(hdc, oldBitmap);
583 NOTIFYICONDATA notifyIcon = {
sizeof(NOTIFYICONDATA) };
593 if (!_BitScanForward(&Id, Id))
598 notifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
601 notifyIcon.szTip,
sizeof(notifyIcon.szTip) /
sizeof(WCHAR),
608 notifyIcon.uFlags |= NIF_SHOWTIP;
610 Shell_NotifyIcon(NIM_ADD, ¬ifyIcon);
614 notifyIcon.uVersion = NOTIFYICON_VERSION_4;
615 Shell_NotifyIcon(NIM_SETVERSION, ¬ifyIcon);
625 NOTIFYICONDATA notifyIcon = {
sizeof(NOTIFYICONDATA) };
631 if (!_BitScanForward(&Id, Id))
637 Shell_NotifyIcon(NIM_DELETE, ¬ifyIcon);
649 NOTIFYICONDATA notifyIcon = {
sizeof(NOTIFYICONDATA) };
658 if (!_BitScanForward(¬ifyId, Id))
662 notifyIcon.uID = notifyId;
663 notifyIcon.uFlags = Flags;
670 sizeof(notifyIcon.szTip) /
sizeof(WCHAR),
676 notifyIcon.hIcon = Icon;
679 notifyIcon.uFlags |= NIF_SHOWTIP;
681 if (!Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon))
685 Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon);
692 _In_opt_ PVOID Parameter,
693 _In_opt_ PVOID Context
696 ULONG registeredIconMask;
714 if (registeredIconMask != 0)
720 if (PhNfRegisteredIcons[i] && (registeredIconMask & PhNfRegisteredIcons[i]->IconId))
732 PVOID newIconOrBitmap;
738 if (!Icon->UpdateCallback)
741 newIconOrBitmap = NULL;
746 Icon->UpdateCallback(
759 newIcon = newIconOrBitmap;
771 DestroyIcon(newIcon);
775 if (updateFlags & PH_NF_UPDATE_IS_BITMAP)
776 DeleteObject(newIconOrBitmap);
778 DestroyIcon(newIconOrBitmap);
788 _Out_ HBITMAP *Bitmap,
789 _Out_opt_ PVOID *Bits,
791 _Out_ HBITMAP *OldBitmap
801 _Out_ HBITMAP *Bitmap,
802 _Out_opt_ PVOID *Bits,
804 _Out_ HBITMAP *OldBitmap
807 if (!Context->Initialized)
811 screenHdc = GetDC(NULL);
812 Context->Hdc = CreateCompatibleDC(screenHdc);
814 memset(&Context->Header, 0,
sizeof(BITMAPINFOHEADER));
815 Context->Header.biSize =
sizeof(BITMAPINFOHEADER);
818 Context->Header.biPlanes = 1;
819 Context->Header.biBitCount = 32;
820 Context->Bitmap = CreateDIBSection(screenHdc, (BITMAPINFO *)&Context->Header, DIB_RGB_COLORS, &Context->Bits, NULL, 0);
822 ReleaseDC(NULL, screenHdc);
824 Context->Initialized =
TRUE;
829 *Bitmap = Context->Bitmap;
830 if (Bits) *Bits = Context->Bits;
832 *OldBitmap = SelectObject(Context->Hdc, Context->Bitmap);
845 RGB(0x00, 0x00, 0x00),
864 HANDLE maxCpuProcessId;
872 maxDataCount = drawInfo.
Width / 2 + 1;
873 lineData1 = _alloca(maxDataCount *
sizeof(FLOAT));
874 lineData2 = _alloca(maxDataCount *
sizeof(FLOAT));
891 SelectObject(hdc, oldBitmap);
897 maxCpuProcessId = (HANDLE)PhGetItemCircularBuffer_ULONG(&
PhMaxCpuHistory, 0);
899 maxCpuProcessId = NULL;
904 maxCpuProcessItem = NULL;
910 if (maxCpuProcessItem)
919 text =
PhFormat(format, maxCpuProcessItem ? 8 : 3, 128);
938 RGB(0x00, 0x00, 0x00),
959 HANDLE maxIoProcessId;
967 maxDataCount = drawInfo.
Width / 2 + 1;
968 lineData1 = _alloca(maxDataCount *
sizeof(FLOAT));
969 lineData2 = _alloca(maxDataCount *
sizeof(FLOAT));
974 for (i = 0; i < lineDataCount; i++)
982 if (max < lineData1[i] + lineData2[i])
983 max = lineData1[i] + lineData2[i];
1000 SelectObject(hdc, oldBitmap);
1006 maxIoProcessId = (HANDLE)PhGetItemCircularBuffer_ULONG(&
PhMaxIoHistory, 0);
1008 maxIoProcessId = NULL;
1013 maxIoProcessItem = NULL;
1022 if (maxIoProcessItem)
1028 text =
PhFormat(format, maxIoProcessItem ? 8 : 6, 128);
1047 RGB(0x00, 0x00, 0x00),
1058 ULONG lineDataCount;
1066 DOUBLE commitFraction;
1073 maxDataCount = drawInfo.
Width / 2 + 1;
1074 lineData1 = _alloca(maxDataCount *
sizeof(FLOAT));
1078 for (i = 0; i < lineDataCount; i++)
1079 lineData1[i] = (FLOAT)PhGetItemCircularBuffer_ULONG(&
PhCommitHistory, i);
1091 SelectObject(hdc, oldBitmap);
1122 RGB(0x00, 0x00, 0x00),
1133 ULONG lineDataCount;
1141 ULONG physicalUsage;
1142 FLOAT physicalFraction;
1149 maxDataCount = drawInfo.
Width / 2 + 1;
1150 lineData1 = _alloca(maxDataCount *
sizeof(FLOAT));
1154 for (i = 0; i < lineDataCount; i++)
1167 SelectObject(hdc, oldBitmap);
1199 HANDLE maxCpuProcessId;
1223 dcBrush = GetStockObject(DC_BRUSH);
1224 dcPen = GetStockObject(DC_PEN);
1228 rect.bottom = height;
1229 SetDCBrushColor(hdc, RGB(0x00, 0x00, 0x00));
1230 FillRect(hdc, &rect, dcBrush);
1235 SelectObject(hdc, dcPen);
1236 SetDCPenColor(hdc, uColor);
1238 points[0].y = height - 1;
1239 points[1].x = width;
1240 points[1].y = height - 1;
1241 Polyline(hdc, points, 2);
1246 rect.top = height - ul - kl;
1248 rect.bottom = height - kl;
1249 SetDCBrushColor(hdc, ubColor);
1250 FillRect(hdc, &rect, dcBrush);
1253 points[0].y = height - 1 - ul - kl;
1254 if (points[0].y < 0) points[0].y = 0;
1255 points[1].x = width;
1256 points[1].y = points[0].y;
1257 SelectObject(hdc, dcPen);
1258 SetDCPenColor(hdc, uColor);
1259 Polyline(hdc, points, 2);
1264 rect.top = height - kl;
1266 rect.bottom = height;
1267 SetDCBrushColor(hdc, kbColor);
1268 FillRect(hdc, &rect, dcBrush);
1271 points[0].y = height - 1 - kl;
1272 if (points[0].y < 0) points[0].y = 0;
1273 points[1].x = width;
1274 points[1].y = points[0].y;
1275 SelectObject(hdc, dcPen);
1276 SetDCPenColor(hdc, kColor);
1277 Polyline(hdc, points, 2);
1282 SelectObject(hdc, oldBitmap);
1288 maxCpuProcessId = (HANDLE)PhGetItemCircularBuffer_ULONG(&
PhMaxCpuHistory, 0);
1290 maxCpuProcessId = NULL;
1292 if (maxCpuProcessId)