727 lines
21 KiB
C
727 lines
21 KiB
C
/*
|
|
* Process Hacker -
|
|
* Process properties
|
|
*
|
|
* Copyright (C) 2009-2016 wj32
|
|
*
|
|
* This file is part of Process Hacker.
|
|
*
|
|
* Process Hacker is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Process Hacker is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <phapp.h>
|
|
#include <procprp.h>
|
|
#include <procprpp.h>
|
|
|
|
#include <uxtheme.h>
|
|
|
|
#include <kphuser.h>
|
|
|
|
#include <phplug.h>
|
|
#include <procprv.h>
|
|
#include <settings.h>
|
|
|
|
PPH_OBJECT_TYPE PhpProcessPropContextType;
|
|
PPH_OBJECT_TYPE PhpProcessPropPageContextType;
|
|
PH_STRINGREF PhpLoadingText = PH_STRINGREF_INIT(L"Loading...");
|
|
|
|
static RECT MinimumSize = { -1, -1, -1, -1 };
|
|
|
|
BOOLEAN PhProcessPropInitialization(
|
|
VOID
|
|
)
|
|
{
|
|
PhpProcessPropContextType = PhCreateObjectType(L"ProcessPropContext", 0, PhpProcessPropContextDeleteProcedure);
|
|
PhpProcessPropPageContextType = PhCreateObjectType(L"ProcessPropPageContext", 0, PhpProcessPropPageContextDeleteProcedure);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
PPH_PROCESS_PROPCONTEXT PhCreateProcessPropContext(
|
|
_In_ HWND ParentWindowHandle,
|
|
_In_ PPH_PROCESS_ITEM ProcessItem
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPCONTEXT propContext;
|
|
PROPSHEETHEADER propSheetHeader;
|
|
|
|
propContext = PhCreateObject(sizeof(PH_PROCESS_PROPCONTEXT), PhpProcessPropContextType);
|
|
memset(propContext, 0, sizeof(PH_PROCESS_PROPCONTEXT));
|
|
|
|
propContext->PropSheetPages = PhAllocate(sizeof(HPROPSHEETPAGE) * PH_PROCESS_PROPCONTEXT_MAXPAGES);
|
|
|
|
if (!PH_IS_FAKE_PROCESS_ID(ProcessItem->ProcessId))
|
|
{
|
|
propContext->Title = PhFormatString(
|
|
L"%s (%u)",
|
|
ProcessItem->ProcessName->Buffer,
|
|
HandleToUlong(ProcessItem->ProcessId)
|
|
);
|
|
}
|
|
else
|
|
{
|
|
PhSetReference(&propContext->Title, ProcessItem->ProcessName);
|
|
}
|
|
|
|
memset(&propSheetHeader, 0, sizeof(PROPSHEETHEADER));
|
|
propSheetHeader.dwSize = sizeof(PROPSHEETHEADER);
|
|
propSheetHeader.dwFlags =
|
|
PSH_MODELESS |
|
|
PSH_NOAPPLYNOW |
|
|
PSH_NOCONTEXTHELP |
|
|
PSH_PROPTITLE |
|
|
PSH_USECALLBACK |
|
|
PSH_USEHICON;
|
|
propSheetHeader.hwndParent = ParentWindowHandle;
|
|
propSheetHeader.hIcon = ProcessItem->SmallIcon;
|
|
propSheetHeader.pszCaption = propContext->Title->Buffer;
|
|
propSheetHeader.pfnCallback = PhpPropSheetProc;
|
|
|
|
propSheetHeader.nPages = 0;
|
|
propSheetHeader.nStartPage = 0;
|
|
propSheetHeader.phpage = propContext->PropSheetPages;
|
|
|
|
if (PhCsForceNoParent)
|
|
propSheetHeader.hwndParent = NULL;
|
|
|
|
memcpy(&propContext->PropSheetHeader, &propSheetHeader, sizeof(PROPSHEETHEADER));
|
|
|
|
PhSetReference(&propContext->ProcessItem, ProcessItem);
|
|
PhInitializeEvent(&propContext->CreatedEvent);
|
|
|
|
return propContext;
|
|
}
|
|
|
|
VOID NTAPI PhpProcessPropContextDeleteProcedure(
|
|
_In_ PVOID Object,
|
|
_In_ ULONG Flags
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPCONTEXT propContext = (PPH_PROCESS_PROPCONTEXT)Object;
|
|
|
|
PhFree(propContext->PropSheetPages);
|
|
PhDereferenceObject(propContext->Title);
|
|
PhDereferenceObject(propContext->ProcessItem);
|
|
}
|
|
|
|
VOID PhRefreshProcessPropContext(
|
|
_Inout_ PPH_PROCESS_PROPCONTEXT PropContext
|
|
)
|
|
{
|
|
PropContext->PropSheetHeader.hIcon = PropContext->ProcessItem->SmallIcon;
|
|
}
|
|
|
|
VOID PhSetSelectThreadIdProcessPropContext(
|
|
_Inout_ PPH_PROCESS_PROPCONTEXT PropContext,
|
|
_In_ HANDLE ThreadId
|
|
)
|
|
{
|
|
PropContext->SelectThreadId = ThreadId;
|
|
}
|
|
|
|
INT CALLBACK PhpPropSheetProc(
|
|
_In_ HWND hwndDlg,
|
|
_In_ UINT uMsg,
|
|
_In_ LPARAM lParam
|
|
)
|
|
{
|
|
#define PROPSHEET_ADD_STYLE (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
|
|
|
switch (uMsg)
|
|
{
|
|
case PSCB_PRECREATE:
|
|
{
|
|
if (lParam)
|
|
{
|
|
if (((DLGTEMPLATEEX *)lParam)->signature == 0xffff)
|
|
{
|
|
((DLGTEMPLATEEX *)lParam)->style |= PROPSHEET_ADD_STYLE;
|
|
}
|
|
else
|
|
{
|
|
((DLGTEMPLATE *)lParam)->style |= PROPSHEET_ADD_STYLE;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case PSCB_INITIALIZED:
|
|
{
|
|
PPH_PROCESS_PROPSHEETCONTEXT propSheetContext;
|
|
|
|
propSheetContext = PhAllocate(sizeof(PH_PROCESS_PROPSHEETCONTEXT));
|
|
memset(propSheetContext, 0, sizeof(PH_PROCESS_PROPSHEETCONTEXT));
|
|
|
|
PhInitializeLayoutManager(&propSheetContext->LayoutManager, hwndDlg);
|
|
|
|
propSheetContext->OldWndProc = (WNDPROC)GetWindowLongPtr(hwndDlg, GWLP_WNDPROC);
|
|
SetWindowLongPtr(hwndDlg, GWLP_WNDPROC, (LONG_PTR)PhpPropSheetWndProc);
|
|
|
|
SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)propSheetContext);
|
|
|
|
if (MinimumSize.left == -1)
|
|
{
|
|
RECT rect;
|
|
|
|
rect.left = 0;
|
|
rect.top = 0;
|
|
rect.right = 290;
|
|
rect.bottom = 320;
|
|
MapDialogRect(hwndDlg, &rect);
|
|
MinimumSize = rect;
|
|
MinimumSize.left = 0;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
PPH_PROCESS_PROPSHEETCONTEXT PhpGetPropSheetContext(
|
|
_In_ HWND hwnd
|
|
)
|
|
{
|
|
return (PPH_PROCESS_PROPSHEETCONTEXT)GetProp(hwnd, PhMakeContextAtom());
|
|
}
|
|
|
|
LRESULT CALLBACK PhpPropSheetWndProc(
|
|
_In_ HWND hwnd,
|
|
_In_ UINT uMsg,
|
|
_In_ WPARAM wParam,
|
|
_In_ LPARAM lParam
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPSHEETCONTEXT propSheetContext = PhpGetPropSheetContext(hwnd);
|
|
WNDPROC oldWndProc = propSheetContext->OldWndProc;
|
|
|
|
switch (uMsg)
|
|
{
|
|
case WM_DESTROY:
|
|
{
|
|
HWND tabControl;
|
|
TCITEM tabItem;
|
|
WCHAR text[128];
|
|
|
|
// Save the window position and size.
|
|
|
|
PhSaveWindowPlacementToSetting(L"ProcPropPosition", L"ProcPropSize", hwnd);
|
|
|
|
// Save the selected tab.
|
|
|
|
tabControl = PropSheet_GetTabControl(hwnd);
|
|
|
|
tabItem.mask = TCIF_TEXT;
|
|
tabItem.pszText = text;
|
|
tabItem.cchTextMax = sizeof(text) / 2 - 1;
|
|
|
|
if (TabCtrl_GetItem(tabControl, TabCtrl_GetCurSel(tabControl), &tabItem))
|
|
{
|
|
PhSetStringSetting(L"ProcPropPage", text);
|
|
}
|
|
}
|
|
break;
|
|
case WM_NCDESTROY:
|
|
{
|
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
|
|
PhDeleteLayoutManager(&propSheetContext->LayoutManager);
|
|
|
|
RemoveProp(hwnd, PhMakeContextAtom());
|
|
PhFree(propSheetContext);
|
|
}
|
|
break;
|
|
case WM_COMMAND:
|
|
{
|
|
switch (LOWORD(wParam))
|
|
{
|
|
case IDOK:
|
|
// Prevent the OK button from working (even though
|
|
// it's already hidden). This prevents the Enter
|
|
// key from closing the dialog box.
|
|
return 0;
|
|
}
|
|
}
|
|
break;
|
|
case WM_SIZE:
|
|
{
|
|
if (!IsIconic(hwnd))
|
|
{
|
|
PhLayoutManagerLayout(&propSheetContext->LayoutManager);
|
|
}
|
|
}
|
|
break;
|
|
case WM_SIZING:
|
|
{
|
|
PhResizingMinimumSize((PRECT)lParam, wParam, MinimumSize.right, MinimumSize.bottom);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
BOOLEAN PhpInitializePropSheetLayoutStage1(
|
|
_In_ HWND hwnd
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPSHEETCONTEXT propSheetContext = PhpGetPropSheetContext(hwnd);
|
|
|
|
if (!propSheetContext->LayoutInitialized)
|
|
{
|
|
HWND tabControlHandle;
|
|
PPH_LAYOUT_ITEM tabControlItem;
|
|
PPH_LAYOUT_ITEM tabPageItem;
|
|
|
|
tabControlHandle = PropSheet_GetTabControl(hwnd);
|
|
tabControlItem = PhAddLayoutItem(&propSheetContext->LayoutManager, tabControlHandle,
|
|
NULL, PH_ANCHOR_ALL | PH_LAYOUT_IMMEDIATE_RESIZE);
|
|
tabPageItem = PhAddLayoutItem(&propSheetContext->LayoutManager, tabControlHandle,
|
|
NULL, PH_LAYOUT_TAB_CONTROL); // dummy item to fix multiline tab control
|
|
|
|
propSheetContext->TabPageItem = tabPageItem;
|
|
|
|
PhAddLayoutItem(&propSheetContext->LayoutManager, GetDlgItem(hwnd, IDCANCEL),
|
|
NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
|
|
|
|
// Hide the OK button.
|
|
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
|
|
// Set the Cancel button's text to "Close".
|
|
SetDlgItemText(hwnd, IDCANCEL, L"Close");
|
|
|
|
propSheetContext->LayoutInitialized = TRUE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
VOID PhpInitializePropSheetLayoutStage2(
|
|
_In_ HWND hwnd
|
|
)
|
|
{
|
|
PH_RECTANGLE windowRectangle;
|
|
|
|
windowRectangle.Position = PhGetIntegerPairSetting(L"ProcPropPosition");
|
|
windowRectangle.Size = PhGetScalableIntegerPairSetting(L"ProcPropSize", TRUE).Pair;
|
|
|
|
if (windowRectangle.Size.X < MinimumSize.right)
|
|
windowRectangle.Size.X = MinimumSize.right;
|
|
if (windowRectangle.Size.Y < MinimumSize.bottom)
|
|
windowRectangle.Size.Y = MinimumSize.bottom;
|
|
|
|
PhAdjustRectangleToWorkingArea(NULL, &windowRectangle);
|
|
|
|
MoveWindow(hwnd, windowRectangle.Left, windowRectangle.Top,
|
|
windowRectangle.Width, windowRectangle.Height, FALSE);
|
|
|
|
// Implement cascading by saving an offsetted rectangle.
|
|
windowRectangle.Left += 20;
|
|
windowRectangle.Top += 20;
|
|
|
|
PhSetIntegerPairSetting(L"ProcPropPosition", windowRectangle.Position);
|
|
}
|
|
|
|
BOOLEAN PhAddProcessPropPage(
|
|
_Inout_ PPH_PROCESS_PROPCONTEXT PropContext,
|
|
_In_ _Assume_refs_(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext
|
|
)
|
|
{
|
|
HPROPSHEETPAGE propSheetPageHandle;
|
|
|
|
if (PropContext->PropSheetHeader.nPages == PH_PROCESS_PROPCONTEXT_MAXPAGES)
|
|
return FALSE;
|
|
|
|
propSheetPageHandle = CreatePropertySheetPage(
|
|
&PropPageContext->PropSheetPage
|
|
);
|
|
// CreatePropertySheetPage would have sent PSPCB_ADDREF,
|
|
// which would have added a reference.
|
|
PhDereferenceObject(PropPageContext);
|
|
|
|
PropPageContext->PropContext = PropContext;
|
|
PhReferenceObject(PropContext);
|
|
|
|
PropContext->PropSheetPages[PropContext->PropSheetHeader.nPages] =
|
|
propSheetPageHandle;
|
|
PropContext->PropSheetHeader.nPages++;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOLEAN PhAddProcessPropPage2(
|
|
_Inout_ PPH_PROCESS_PROPCONTEXT PropContext,
|
|
_In_ HPROPSHEETPAGE PropSheetPageHandle
|
|
)
|
|
{
|
|
if (PropContext->PropSheetHeader.nPages == PH_PROCESS_PROPCONTEXT_MAXPAGES)
|
|
return FALSE;
|
|
|
|
PropContext->PropSheetPages[PropContext->PropSheetHeader.nPages] =
|
|
PropSheetPageHandle;
|
|
PropContext->PropSheetHeader.nPages++;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContext(
|
|
_In_ LPCWSTR Template,
|
|
_In_ DLGPROC DlgProc,
|
|
_In_opt_ PVOID Context
|
|
)
|
|
{
|
|
return PhCreateProcessPropPageContextEx(NULL, Template, DlgProc, Context);
|
|
}
|
|
|
|
PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContextEx(
|
|
_In_opt_ PVOID InstanceHandle,
|
|
_In_ LPCWSTR Template,
|
|
_In_ DLGPROC DlgProc,
|
|
_In_opt_ PVOID Context
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPPAGECONTEXT propPageContext;
|
|
|
|
propPageContext = PhCreateObject(sizeof(PH_PROCESS_PROPPAGECONTEXT), PhpProcessPropPageContextType);
|
|
memset(propPageContext, 0, sizeof(PH_PROCESS_PROPPAGECONTEXT));
|
|
|
|
propPageContext->PropSheetPage.dwSize = sizeof(PROPSHEETPAGE);
|
|
propPageContext->PropSheetPage.dwFlags =
|
|
PSP_USECALLBACK;
|
|
propPageContext->PropSheetPage.hInstance = InstanceHandle;
|
|
propPageContext->PropSheetPage.pszTemplate = Template;
|
|
propPageContext->PropSheetPage.pfnDlgProc = DlgProc;
|
|
propPageContext->PropSheetPage.lParam = (LPARAM)propPageContext;
|
|
propPageContext->PropSheetPage.pfnCallback = PhpStandardPropPageProc;
|
|
|
|
propPageContext->Context = Context;
|
|
|
|
return propPageContext;
|
|
}
|
|
|
|
VOID NTAPI PhpProcessPropPageContextDeleteProcedure(
|
|
_In_ PVOID Object,
|
|
_In_ ULONG Flags
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPPAGECONTEXT propPageContext = (PPH_PROCESS_PROPPAGECONTEXT)Object;
|
|
|
|
if (propPageContext->PropContext)
|
|
PhDereferenceObject(propPageContext->PropContext);
|
|
}
|
|
|
|
INT CALLBACK PhpStandardPropPageProc(
|
|
_In_ HWND hwnd,
|
|
_In_ UINT uMsg,
|
|
_In_ LPPROPSHEETPAGE ppsp
|
|
)
|
|
{
|
|
PPH_PROCESS_PROPPAGECONTEXT propPageContext;
|
|
|
|
propPageContext = (PPH_PROCESS_PROPPAGECONTEXT)ppsp->lParam;
|
|
|
|
if (uMsg == PSPCB_ADDREF)
|
|
PhReferenceObject(propPageContext);
|
|
else if (uMsg == PSPCB_RELEASE)
|
|
PhDereferenceObject(propPageContext);
|
|
|
|
return 1;
|
|
}
|
|
|
|
BOOLEAN PhPropPageDlgProcHeader(
|
|
_In_ HWND hwndDlg,
|
|
_In_ UINT uMsg,
|
|
_In_ LPARAM lParam,
|
|
_Out_ LPPROPSHEETPAGE *PropSheetPage,
|
|
_Out_ PPH_PROCESS_PROPPAGECONTEXT *PropPageContext,
|
|
_Out_ PPH_PROCESS_ITEM *ProcessItem
|
|
)
|
|
{
|
|
return PhpPropPageDlgProcHeader(hwndDlg, uMsg, lParam, PropSheetPage, PropPageContext, ProcessItem);
|
|
}
|
|
|
|
VOID PhPropPageDlgProcDestroy(
|
|
_In_ HWND hwndDlg
|
|
)
|
|
{
|
|
PhpPropPageDlgProcDestroy(hwndDlg);
|
|
}
|
|
|
|
PPH_LAYOUT_ITEM PhAddPropPageLayoutItem(
|
|
_In_ HWND hwnd,
|
|
_In_ HWND Handle,
|
|
_In_ PPH_LAYOUT_ITEM ParentItem,
|
|
_In_ ULONG Anchor
|
|
)
|
|
{
|
|
HWND parent;
|
|
PPH_PROCESS_PROPSHEETCONTEXT propSheetContext;
|
|
PPH_LAYOUT_MANAGER layoutManager;
|
|
PPH_LAYOUT_ITEM realParentItem;
|
|
BOOLEAN doLayoutStage2;
|
|
PPH_LAYOUT_ITEM item;
|
|
|
|
parent = GetParent(hwnd);
|
|
propSheetContext = PhpGetPropSheetContext(parent);
|
|
layoutManager = &propSheetContext->LayoutManager;
|
|
|
|
doLayoutStage2 = PhpInitializePropSheetLayoutStage1(parent);
|
|
|
|
if (ParentItem != PH_PROP_PAGE_TAB_CONTROL_PARENT)
|
|
realParentItem = ParentItem;
|
|
else
|
|
realParentItem = propSheetContext->TabPageItem;
|
|
|
|
// Use the HACK if the control is a direct child of the dialog.
|
|
if (ParentItem && ParentItem != PH_PROP_PAGE_TAB_CONTROL_PARENT &&
|
|
// We detect if ParentItem is the layout item for the dialog
|
|
// by looking at its parent.
|
|
(ParentItem->ParentItem == &layoutManager->RootItem ||
|
|
(ParentItem->ParentItem->Anchor & PH_LAYOUT_TAB_CONTROL)))
|
|
{
|
|
RECT dialogRect;
|
|
RECT dialogSize;
|
|
RECT margin;
|
|
|
|
// MAKE SURE THESE NUMBERS ARE CORRECT.
|
|
dialogSize.right = 260;
|
|
dialogSize.bottom = 260;
|
|
MapDialogRect(hwnd, &dialogSize);
|
|
|
|
// Get the original dialog rectangle.
|
|
GetWindowRect(hwnd, &dialogRect);
|
|
dialogRect.right = dialogRect.left + dialogSize.right;
|
|
dialogRect.bottom = dialogRect.top + dialogSize.bottom;
|
|
|
|
// Calculate the margin from the original rectangle.
|
|
GetWindowRect(Handle, &margin);
|
|
margin = PhMapRect(margin, dialogRect);
|
|
PhConvertRect(&margin, &dialogRect);
|
|
|
|
item = PhAddLayoutItemEx(layoutManager, Handle, realParentItem, Anchor, margin);
|
|
}
|
|
else
|
|
{
|
|
item = PhAddLayoutItem(layoutManager, Handle, realParentItem, Anchor);
|
|
}
|
|
|
|
if (doLayoutStage2)
|
|
PhpInitializePropSheetLayoutStage2(parent);
|
|
|
|
return item;
|
|
}
|
|
|
|
VOID PhDoPropPageLayout(
|
|
_In_ HWND hwnd
|
|
)
|
|
{
|
|
HWND parent;
|
|
PPH_PROCESS_PROPSHEETCONTEXT propSheetContext;
|
|
|
|
parent = GetParent(hwnd);
|
|
propSheetContext = PhpGetPropSheetContext(parent);
|
|
PhLayoutManagerLayout(&propSheetContext->LayoutManager);
|
|
}
|
|
|
|
NTSTATUS PhpProcessPropertiesThreadStart(
|
|
_In_ PVOID Parameter
|
|
)
|
|
{
|
|
PH_AUTO_POOL autoPool;
|
|
PPH_PROCESS_PROPCONTEXT PropContext = (PPH_PROCESS_PROPCONTEXT)Parameter;
|
|
PPH_PROCESS_PROPPAGECONTEXT newPage;
|
|
PPH_STRING startPage;
|
|
HWND hwnd;
|
|
BOOL result;
|
|
MSG message;
|
|
|
|
PhInitializeAutoPool(&autoPool);
|
|
|
|
// Wait for stage 1 to be processed.
|
|
PhWaitForEvent(&PropContext->ProcessItem->Stage1Event, NULL);
|
|
// Refresh the icon which may have been updated due to
|
|
// stage 1.
|
|
PhRefreshProcessPropContext(PropContext);
|
|
|
|
// Add the pages...
|
|
|
|
// General
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCGENERAL),
|
|
PhpProcessGeneralDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Statistics
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCSTATISTICS),
|
|
PhpProcessStatisticsDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Performance
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCPERFORMANCE),
|
|
PhpProcessPerformanceDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Threads
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCTHREADS),
|
|
PhpProcessThreadsDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Token
|
|
PhAddProcessPropPage2(
|
|
PropContext,
|
|
PhCreateTokenPage(PhpOpenProcessTokenForPage, (PVOID)PropContext->ProcessItem->ProcessId, PhpProcessTokenHookProc)
|
|
);
|
|
|
|
// Modules
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCMODULES),
|
|
PhpProcessModulesDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Memory
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCMEMORY),
|
|
PhpProcessMemoryDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Environment
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCENVIRONMENT),
|
|
PhpProcessEnvironmentDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Handles
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCHANDLES),
|
|
PhpProcessHandlesDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
|
|
// Job
|
|
if (
|
|
PropContext->ProcessItem->IsInJob &&
|
|
// There's no way the job page can function without KPH since it needs
|
|
// to open a handle to the job.
|
|
KphIsConnected()
|
|
)
|
|
{
|
|
PhAddProcessPropPage2(
|
|
PropContext,
|
|
PhCreateJobPage(PhpOpenProcessJobForPage, (PVOID)PropContext->ProcessItem->ProcessId, PhpProcessJobHookProc)
|
|
);
|
|
}
|
|
|
|
// Services
|
|
if (PropContext->ProcessItem->ServiceList && PropContext->ProcessItem->ServiceList->Count != 0)
|
|
{
|
|
newPage = PhCreateProcessPropPageContext(
|
|
MAKEINTRESOURCE(IDD_PROCSERVICES),
|
|
PhpProcessServicesDlgProc,
|
|
NULL
|
|
);
|
|
PhAddProcessPropPage(PropContext, newPage);
|
|
}
|
|
|
|
// Plugin-supplied pages
|
|
if (PhPluginsEnabled)
|
|
{
|
|
PH_PLUGIN_PROCESS_PROPCONTEXT pluginProcessPropContext;
|
|
|
|
pluginProcessPropContext.PropContext = PropContext;
|
|
pluginProcessPropContext.ProcessItem = PropContext->ProcessItem;
|
|
|
|
PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackProcessPropertiesInitializing), &pluginProcessPropContext);
|
|
}
|
|
|
|
// Create the property sheet
|
|
|
|
if (PropContext->SelectThreadId)
|
|
PhSetStringSetting(L"ProcPropPage", L"Threads");
|
|
|
|
startPage = PhGetStringSetting(L"ProcPropPage");
|
|
PropContext->PropSheetHeader.dwFlags |= PSH_USEPSTARTPAGE;
|
|
PropContext->PropSheetHeader.pStartPage = startPage->Buffer;
|
|
|
|
hwnd = (HWND)PropertySheet(&PropContext->PropSheetHeader);
|
|
|
|
PhDereferenceObject(startPage);
|
|
|
|
PropContext->WindowHandle = hwnd;
|
|
PhSetEvent(&PropContext->CreatedEvent);
|
|
|
|
// Main event loop
|
|
|
|
while (result = GetMessage(&message, NULL, 0, 0))
|
|
{
|
|
if (result == -1)
|
|
break;
|
|
|
|
if (!PropSheet_IsDialogMessage(hwnd, &message))
|
|
{
|
|
TranslateMessage(&message);
|
|
DispatchMessage(&message);
|
|
}
|
|
|
|
PhDrainAutoPool(&autoPool);
|
|
|
|
if (!PropSheet_GetCurrentPageHwnd(hwnd))
|
|
break;
|
|
}
|
|
|
|
DestroyWindow(hwnd);
|
|
PhDereferenceObject(PropContext);
|
|
|
|
PhDeleteAutoPool(&autoPool);
|
|
|
|
return STATUS_SUCCESS;
|
|
}
|
|
|
|
BOOLEAN PhShowProcessProperties(
|
|
_In_ PPH_PROCESS_PROPCONTEXT Context
|
|
)
|
|
{
|
|
HANDLE threadHandle;
|
|
|
|
PhReferenceObject(Context);
|
|
threadHandle = PhCreateThread(0, PhpProcessPropertiesThreadStart, Context);
|
|
|
|
if (threadHandle)
|
|
{
|
|
NtClose(threadHandle);
|
|
return TRUE;
|
|
}
|
|
else
|
|
{
|
|
PhDereferenceObject(Context);
|
|
return FALSE;
|
|
}
|
|
}
|