Skip to content

Commit

Permalink
WindowExplorer auto refresh on find
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Dec 4, 2024
1 parent b9ac48c commit dff2b2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
17 changes: 7 additions & 10 deletions plugins/ExtendedTools/objprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,7 @@ VOID EtHandlePropertiesWindowInitialized(

if (GetUserObjectInformation(hDesktop, UOI_HEAPSIZE, &vInfo, sizeof(vInfo), NULL))
{
PPH_STRING size = PH_AUTO(PhFormatSize(vInfo * 1024, ULONG_MAX));
PhSetIListViewSubItem(context->ListViewClass, EtListViewRowCache[OBJECT_GENERAL_INDEX_DESKTOPHEAP], 1, PhGetString(size));
PhSetIListViewSubItem(context->ListViewClass, EtListViewRowCache[OBJECT_GENERAL_INDEX_DESKTOPHEAP], 1, PhaFormatSize(vInfo * 1024, ULONG_MAX)->Buffer);
}

CloseDesktop(hDesktop);
Expand Down Expand Up @@ -2187,10 +2186,8 @@ static BOOL CALLBACK EtpEnumDesktopsCallback(
PSID UserSid = NULL;

GetUserObjectInformation(hDesktop, UOI_USER_SID, NULL, 0, &nLengthNeeded);

if (nLengthNeeded)
UserSid = PhAllocate(nLengthNeeded);

if (UserSid && GetUserObjectInformation(hDesktop, UOI_USER_SID, UserSid, nLengthNeeded, &nLengthNeeded))
{
PPH_STRING sid = PH_AUTO(PhSidToStringSid(UserSid));
Expand All @@ -2200,8 +2197,7 @@ static BOOL CALLBACK EtpEnumDesktopsCallback(

if (GetUserObjectInformation(hDesktop, UOI_HEAPSIZE, &vInfo, sizeof(vInfo), NULL))
{
PPH_STRING size = PH_AUTO(PhFormatString(L"%d MB", vInfo / 1024));
PhSetIListViewSubItem(context->ListViewClass, lvItemIndex, ETDTLVC_HEAP, PhGetString(size));
PhSetIListViewSubItem(context->ListViewClass, lvItemIndex, ETDTLVC_HEAP, PhaFormatSize(vInfo * 1024, ULONG_MAX)->Buffer);
}

if (GetUserObjectInformation(hDesktop, UOI_IO, &vInfo, sizeof(vInfo), NULL))
Expand Down Expand Up @@ -2254,7 +2250,7 @@ static NTSTATUS EtpOpenSecurityDesktopHandle(
return status;
}

static NTSTATUS EtpCloseSecurityDesktop(
static NTSTATUS EtpCloseSecurityDesktopHandle(
_In_ HANDLE Handle,
_In_ BOOLEAN Release,
_In_opt_ PVOID Context
Expand Down Expand Up @@ -2295,7 +2291,7 @@ VOID EtpOpenDesktopSecurity(
context->HandleItem->Handle
)))
{
if (NtCompareObjects((HANDLE)OpenContext->CurrentWinStation, (HANDLE)hWinStation) == STATUS_NOT_SAME_OBJECT)
if (PhCompareObjects((HANDLE)OpenContext->CurrentWinStation, (HANDLE)hWinStation) == STATUS_NOT_SAME_OBJECT)
OpenContext->DesktopWinStation = hWinStation;
else
CloseWindowStation(hWinStation);
Expand All @@ -2306,7 +2302,7 @@ VOID EtpOpenDesktopSecurity(
PhGetString(deskName),
L"Desktop",
EtpOpenSecurityDesktopHandle,
EtpCloseSecurityDesktop,
EtpCloseSecurityDesktopHandle,
OpenContext
);
}
Expand Down Expand Up @@ -2340,6 +2336,7 @@ INT_PTR CALLBACK EtpWinStaPageDlgProc(
case WM_INITDIALOG:
{
HWINSTA hWinStation;

context->WindowHandle = hwndDlg;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ListViewClass = PhGetListViewInterface(context->ListViewHandle);
Expand All @@ -2366,7 +2363,7 @@ INT_PTR CALLBACK EtpWinStaPageDlgProc(
)))
{
HWINSTA currentStation = GetProcessWindowStation();
NTSTATUS status = NtCompareObjects((HANDLE)currentStation, (HANDLE)hWinStation);
NTSTATUS status = PhCompareObjects((HANDLE)currentStation, (HANDLE)hWinStation);
if (status == STATUS_NOT_SAME_OBJECT)
SetProcessWindowStation(hWinStation);
EnumDesktops(hWinStation, EtpEnumDesktopsCallback, (LPARAM)context);
Expand Down
4 changes: 4 additions & 0 deletions plugins/WindowExplorer/wnddlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,8 @@ INT_PTR CALLBACK WepWindowsDlgProc(
// break;
case WE_WM_FINDWINDOW:
{
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_REFRESH, BN_CLICKED), 0);

// Direct all mouse events to this window.
SetCapture(hwndDlg);

Expand Down Expand Up @@ -2137,6 +2139,8 @@ INT_PTR CALLBACK WepWindowsPageProc(
break;
case WE_WM_FINDWINDOW:
{
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_REFRESH, BN_CLICKED), 0);

// Direct all mouse events to this window.
SetCapture(hwndDlg);

Expand Down
2 changes: 1 addition & 1 deletion plugins/WindowExplorer/wndtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BOOLEAN WeWindowTreeFilterCallback(

if (windowNode->WindowHandleString[0])
{
if (PhSearchControlMatchLongHintZ(context->SearchMatchHandle, windowNode->WindowHandleString))
if (PhSearchControlMatchPointer(context->SearchMatchHandle, windowNode->WindowHandle))
return TRUE;
}

Expand Down

0 comments on commit dff2b2f

Please sign in to comment.