35 #define SET_BUTTON_BITMAP(Id, Bitmap) \
36 SendMessage(GetDlgItem(hwndDlg, (Id)), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)(Bitmap))
41 static RECT MinimumSize = { -1, -1, -1, -1 };
42 static PWSTR ProtectedSignerStrings[] = { L
"", L
" (Authenticode)", L
" (CodeGen)", L
" (Antimalware)", L
" (Lsa)", L
" (Windows)", L
" (WinTcb)" };
61 _In_ HWND ParentWindowHandle,
66 PROPSHEETHEADER propSheetHeader;
77 ProcessItem->ProcessName->Buffer,
78 (ULONG)ProcessItem->ProcessId
86 memset(&propSheetHeader, 0,
sizeof(PROPSHEETHEADER));
87 propSheetHeader.dwSize =
sizeof(PROPSHEETHEADER);
88 propSheetHeader.dwFlags =
95 propSheetHeader.hwndParent = ParentWindowHandle;
96 propSheetHeader.hIcon = ProcessItem->SmallIcon;
97 propSheetHeader.pszCaption = propContext->
Title->
Buffer;
100 propSheetHeader.nPages = 0;
101 propSheetHeader.nStartPage = 0;
105 propSheetHeader.hwndParent = NULL;
107 memcpy(&propContext->
PropSheetHeader, &propSheetHeader,
sizeof(PROPSHEETHEADER));
131 PropContext->PropSheetHeader.hIcon = PropContext->ProcessItem->SmallIcon;
139 PropContext->SelectThreadId = ThreadId;
148 #define PROPSHEET_ADD_STYLE (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME);
167 case PSCB_INITIALIZED:
176 propSheetContext->
OldWndProc = (WNDPROC)GetWindowLongPtr(hwndDlg, GWLP_WNDPROC);
181 if (MinimumSize.left == -1)
189 MapDialogRect(hwndDlg, &rect);
191 MinimumSize.left = 0;
215 WNDPROC oldWndProc = propSheetContext->
OldWndProc;
231 tabControl = PropSheet_GetTabControl(hwnd);
233 tabItem.mask = TCIF_TEXT;
234 tabItem.pszText = text;
235 tabItem.cchTextMax =
sizeof(text) / 2 - 1;
237 if (TabCtrl_GetItem(tabControl, TabCtrl_GetCurSel(tabControl), &tabItem))
245 SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
254 switch (LOWORD(wParam))
279 return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
290 HWND tabControlHandle;
294 tabControlHandle = PropSheet_GetTabControl(hwnd);
306 ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
308 SetDlgItemText(hwnd, IDCANCEL, L
"Close");
327 if (windowRectangle.
Size.
X < MinimumSize.right)
328 windowRectangle.
Size.
X = MinimumSize.right;
329 if (windowRectangle.
Size.
Y < MinimumSize.bottom)
330 windowRectangle.
Size.
Y = MinimumSize.bottom;
334 MoveWindow(hwnd, windowRectangle.
Left, windowRectangle.
Top,
338 windowRectangle.
Left += 20;
339 windowRectangle.
Top += 20;
349 HPROPSHEETPAGE propSheetPageHandle;
354 propSheetPageHandle = CreatePropertySheetPage(
364 PropContext->PropSheetPages[PropContext->PropSheetHeader.nPages] =
366 PropContext->PropSheetHeader.nPages++;
373 _In_ HPROPSHEETPAGE PropSheetPageHandle
379 PropContext->PropSheetPages[PropContext->PropSheetHeader.nPages] =
381 PropContext->PropSheetHeader.nPages++;
387 _In_ LPCWSTR Template,
388 _In_ DLGPROC DlgProc,
389 _In_opt_ PVOID Context
396 _In_opt_ PVOID InstanceHandle,
397 _In_ LPCWSTR Template,
398 _In_ DLGPROC DlgProc,
399 _In_opt_ PVOID Context
407 propPageContext->
PropSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
413 propPageContext->
PropSheetPage.lParam = (LPARAM)propPageContext;
416 propPageContext->
Context = Context;
418 return propPageContext;
435 _In_ LPPROPSHEETPAGE ppsp
442 if (uMsg == PSPCB_ADDREF)
444 else if (uMsg == PSPCB_RELEASE)
454 _Out_ LPPROPSHEETPAGE *PropSheetPage,
459 LPPROPSHEETPAGE propSheetPage;
462 if (uMsg == WM_INITDIALOG)
473 *PropSheetPage = propSheetPage;
484 _Out_ LPPROPSHEETPAGE *PropSheetPage,
517 BOOLEAN doLayoutStage2;
520 parent = GetParent(hwnd);
527 realParentItem = ParentItem;
535 (ParentItem->ParentItem == &layoutManager->
RootItem ||
543 dialogSize.right = 260;
544 dialogSize.bottom = 260;
545 MapDialogRect(hwnd, &dialogSize);
548 GetWindowRect(hwnd, &dialogRect);
549 dialogRect.right = dialogRect.left + dialogSize.right;
550 dialogRect.bottom = dialogRect.top + dialogSize.bottom;
553 GetWindowRect(Handle, &margin);
577 parent = GetParent(hwnd);
583 _Out_ PHANDLE Handle,
584 _In_ ACCESS_MASK DesiredAccess,
585 _In_opt_ PVOID Context
588 return PhOpenProcess(Handle, DesiredAccess, (HANDLE)Context);
596 return String->Buffer;
606 HANDLE processHandle;
610 if (ProcessItem->IsWow64)
615 SetDlgItemText(hwndDlg,
IDC_DEP, L
"N/A");
620 ProcessItem->ProcessId
632 if ((depStatus & PH_PROCESS_DEP_ENABLED) &&
644 EnableWindow(GetDlgItem(hwndDlg,
IDC_EDITDEP), !(depStatus & PH_PROCESS_DEP_PERMANENT));
647 NtClose(processHandle);
652 if (ProcessItem->QueryHandle)
653 SetDlgItemText(hwndDlg,
IDC_DEP, L
"Enabled, Permanent");
655 SetDlgItemText(hwndDlg,
IDC_DEP, L
"N/A");
666 LPPROPSHEETPAGE propSheetPage;
671 &propSheetPage, &propPageContext, &processItem))
678 HANDLE processHandle = NULL;
680 PROCESS_BASIC_INFORMATION basicInfo;
704 SendMessage(GetDlgItem(hwndDlg,
IDC_FILEICON), STM_SETICON,
796 NtClose(processHandle);
797 processHandle = NULL;
810 LARGE_INTEGER startTime;
811 LARGE_INTEGER currentTime;
812 SYSTEMTIME startTimeFields;
897 PS_PROTECTION protection;
901 ProcessProtectionInformation,
903 sizeof(PS_PROTECTION),
910 switch (protection.Type)
912 case PsProtectedTypeNone:
915 case PsProtectedTypeProtectedLight:
918 case PsProtectedTypeProtected:
926 if (protection.Signer <
sizeof(ProtectedSignerStrings) /
sizeof(PWSTR))
927 signer = ProtectedSignerStrings[protection.Signer];
952 PROCESS_EXTENDED_BASIC_INFORMATION extendedBasicInfo;
959 SetDlgItemText(hwndDlg,
IDC_PROTECTION, extendedBasicInfo.IsProtectedProcess ? L
"Yes" : L
"None");
965 NtClose(processHandle);
969 PROCESS_MITIGATION_POLICY_INFORMATION policyInfo;
971 SetDlgItemText(hwndDlg,
IDC_ASLR, L
"N/A");
973 policyInfo.Policy = ProcessASLRPolicy;
983 ProcessMitigationPolicy,
985 sizeof(PROCESS_MITIGATION_POLICY_INFORMATION),
993 if (policyInfo.ASLRPolicy.EnableBottomUpRandomization)
995 if (policyInfo.ASLRPolicy.EnableForceRelocateImages)
997 if (policyInfo.ASLRPolicy.EnableHighEntropy)
999 if (policyInfo.ASLRPolicy.DisallowStrippedImages)
1005 SetDlgItemText(hwndDlg,
IDC_ASLR, L
"Disabled");
1012 NtClose(processHandle);
1018 ShowWindow(GetDlgItem(hwndDlg,
IDC_ASLR), SW_HIDE);
1101 INT
id = LOWORD(wParam);
1111 L
"ProgramInspectExecutables",
1114 L
"Make sure the PE Viewer executable file is present."
1136 PhShowError(hwndDlg, L
"The process does not exist.");
1159 ULONG numberOfAccessEntries;
1174 numberOfAccessEntries
1185 LPNMHDR header = (LPNMHDR)lParam;
1187 switch (header->code)
1191 switch (header->idFrom)
1202 info.
hWnd = hwndDlg;
1222 static VOID NTAPI StatisticsUpdateHandler(
1223 _In_opt_ PVOID Parameter,
1224 _In_opt_ PVOID Context
1229 if (statisticsContext->
Enabled)
1247 ProcessItem->KernelTime.QuadPart + ProcessItem->UserTime.QuadPart,
PH_TIMESPAN_HMSM);
1251 PhaFormatSize(ProcessItem->VmCounters.PagefileUsage, -1)->Buffer);
1253 PhaFormatSize(ProcessItem->VmCounters.PeakPagefileUsage, -1)->Buffer);
1255 PhaFormatSize(ProcessItem->VmCounters.VirtualSize, -1)->Buffer);
1257 PhaFormatSize(ProcessItem->VmCounters.PeakVirtualSize, -1)->Buffer);
1261 PhaFormatSize(ProcessItem->VmCounters.WorkingSetSize, -1)->Buffer);
1263 PhaFormatSize(ProcessItem->VmCounters.PeakWorkingSetSize, -1)->Buffer);
1268 PhaFormatSize(ProcessItem->IoCounters.ReadTransferCount, -1)->Buffer);
1272 PhaFormatSize(ProcessItem->IoCounters.WriteTransferCount, -1)->Buffer);
1276 PhaFormatSize(ProcessItem->IoCounters.OtherTransferCount, -1)->Buffer);
1288 ULONG pagePriority = -1;
1289 ULONG ioPriority = -1;
1293 BOOLEAN gotCycles =
FALSE;
1294 BOOLEAN gotWsCounters =
FALSE;
1296 if (ProcessItem->QueryHandle)
1305 ProcessItem->QueryHandle,
1316 gdiHandles =
PhaFormatUInt64(GetGuiResources(ProcessItem->QueryHandle, GR_GDIOBJECTS),
TRUE);
1317 userHandles =
PhaFormatUInt64(GetGuiResources(ProcessItem->QueryHandle, GR_USEROBJECTS),
TRUE);
1333 if (Context->ProcessHandle)
1342 gotWsCounters =
TRUE;
1351 privateWs =
PhaFormatSize(ProcessItem->WorkingSetPrivateSize, -1);
1366 if (pagePriority != -1)
1407 LPPROPSHEETPAGE propSheetPage;
1413 &propSheetPage, &propPageContext, &processItem))
1426 statisticsContext = propPageContext->
Context =
1443 StatisticsUpdateHandler,
1461 PhFree(statisticsContext);
1483 switch (LOWORD(wParam))
1495 LPNMHDR header = (LPNMHDR)lParam;
1497 switch (header->code)
1502 case PSN_KILLACTIVE:
1518 static VOID NTAPI PerformanceUpdateHandler(
1519 _In_opt_ PVOID Parameter,
1520 _In_opt_ PVOID Context
1535 LPPROPSHEETPAGE propSheetPage;
1541 &propSheetPage, &propPageContext, &processItem))
1554 performanceContext = propPageContext->
Context =
1561 PerformanceUpdateHandler,
1602 PhFree(performanceContext);
1624 LPNMHDR header = (LPNMHDR)lParam;
1626 switch (header->code)
1713 if (processItem->
VmCounters.PeakPagefileUsage != 0)
1718 (FLOAT)processItem->
VmCounters.PeakPagefileUsage,
1726 else if (header->hwndFrom == performanceContext->
IoGraphHandle)
1769 (FLOAT)PhGetItemCircularBuffer_ULONG64(&processItem->
IoReadHistory, i) +
1770 (FLOAT)PhGetItemCircularBuffer_ULONG64(&processItem->
IoOtherHistory, i);
1772 (FLOAT)PhGetItemCircularBuffer_ULONG64(&processItem->
IoWriteHistory, i);
1774 if (max < data1 + data2)
1775 max = data1 + data2;
1814 cpuUser = PhGetItemCircularBuffer_FLOAT(&processItem->
CpuUserHistory, getTooltipText->
Index);
1818 (cpuKernel + cpuUser) * 100,
1832 SIZE_T privateBytes;
1837 L
"Private Bytes: %s\n%s",
1856 ioRead = PhGetItemCircularBuffer_ULONG64(&processItem->
IoReadHistory, getTooltipText->
Index);
1857 ioWrite = PhGetItemCircularBuffer_ULONG64(&processItem->
IoWriteHistory, getTooltipText->
Index);
1858 ioOther = PhGetItemCircularBuffer_ULONG64(&processItem->
IoOtherHistory, getTooltipText->
Index);
1861 L
"R: %s\nW: %s\nO: %s\n%s",
1881 HWND ioGroupBox = GetDlgItem(hwndDlg,
IDC_GROUPIO);
1883 RECT margin = { 13, 13, 13, 13 };
1884 RECT innerMargin = { 10, 20, 10, 10 };
1896 GetClientRect(hwndDlg, &clientRect);
1897 width = clientRect.right - margin.left - margin.right;
1898 height = (clientRect.bottom - margin.top - margin.bottom - between * 2) / 3;
1900 deferHandle = BeginDeferWindowPos(6);
1902 deferHandle = DeferWindowPos(deferHandle, cpuGroupBox, NULL, margin.left, margin.top,
1903 width, height, SWP_NOACTIVATE | SWP_NOZORDER);
1904 deferHandle = DeferWindowPos(
1908 margin.left + innerMargin.left,
1909 margin.top + innerMargin.top,
1910 width - innerMargin.left - innerMargin.right,
1911 height - innerMargin.top - innerMargin.bottom,
1912 SWP_NOACTIVATE | SWP_NOZORDER
1915 deferHandle = DeferWindowPos(deferHandle, privateBytesGroupBox, NULL, margin.left, margin.top + height + between,
1916 width, height, SWP_NOACTIVATE | SWP_NOZORDER);
1917 deferHandle = DeferWindowPos(
1921 margin.left + innerMargin.left,
1922 margin.top + height + between + innerMargin.top,
1923 width - innerMargin.left - innerMargin.right,
1924 height - innerMargin.top - innerMargin.bottom,
1925 SWP_NOACTIVATE | SWP_NOZORDER
1928 deferHandle = DeferWindowPos(deferHandle, ioGroupBox, NULL, margin.left, margin.top + (height + between) * 2,
1929 width, height, SWP_NOACTIVATE | SWP_NOZORDER);
1930 deferHandle = DeferWindowPos(
1934 margin.left + innerMargin.left,
1935 margin.top + (height + between) * 2 + innerMargin.top,
1936 width - innerMargin.left - innerMargin.right,
1937 height - innerMargin.top - innerMargin.bottom,
1938 SWP_NOACTIVATE | SWP_NOZORDER
1941 EndDeferWindowPos(deferHandle);
1973 static VOID NTAPI ThreadAddedHandler(
1974 _In_opt_ PVOID Parameter,
1975 _In_opt_ PVOID Context
1990 static VOID NTAPI ThreadModifiedHandler(
1991 _In_opt_ PVOID Parameter,
1992 _In_opt_ PVOID Context
2000 static VOID NTAPI ThreadRemovedHandler(
2001 _In_opt_ PVOID Parameter,
2002 _In_opt_ PVOID Context
2010 static VOID NTAPI ThreadsUpdatedHandler(
2011 _In_opt_ PVOID Parameter,
2012 _In_opt_ PVOID Context
2020 static VOID NTAPI ThreadsLoadingStateChangedHandler(
2021 _In_opt_ PVOID Parameter,
2022 _In_opt_ PVOID Context
2032 (LPARAM)(Parameter ? LoadCursor(NULL, IDC_APPSTARTING) : NULL)
2040 _In_ ULONG NumberOfThreads
2045 if (NumberOfThreads == 0)
2049 else if (NumberOfThreads == 1)
2055 ULONG menuItemsMultiEnabled[] =
2069 for (i = 0; i <
sizeof(menuItemsMultiEnabled) /
sizeof(ULONG); i++)
2111 if (NumberOfThreads == 1)
2113 HANDLE threadHandle;
2114 ULONG ioPriority = -1;
2115 ULONG pagePriority = -1;
2116 ULONG threadPriority = THREAD_PRIORITY_ERROR_RETURN;
2122 Threads[0]->ThreadId
2125 threadPriority = GetThreadPriority(threadHandle);
2158 NtClose(tokenHandle);
2162 NtClose(threadHandle);
2165 switch (threadPriority)
2167 case THREAD_PRIORITY_TIME_CRITICAL:
2170 case THREAD_PRIORITY_HIGHEST:
2173 case THREAD_PRIORITY_ABOVE_NORMAL:
2176 case THREAD_PRIORITY_NORMAL:
2179 case THREAD_PRIORITY_BELOW_NORMAL:
2182 case THREAD_PRIORITY_LOWEST:
2185 case THREAD_PRIORITY_IDLE:
2197 if (ioPriority != -1)
2225 if (pagePriority != -1)
2229 switch (pagePriority)
2258 static NTSTATUS NTAPI PhpThreadPermissionsOpenThread(
2259 _Out_ PHANDLE Handle,
2260 _In_ ACCESS_MASK DesiredAccess,
2261 _In_opt_ PVOID Context
2264 return PhOpenThread(Handle, DesiredAccess, (HANDLE)Context);
2267 static NTSTATUS NTAPI PhpOpenThreadTokenObject(
2268 _Out_ PHANDLE Handle,
2269 _In_ ACCESS_MASK DesiredAccess,
2270 _In_opt_ PVOID Context
2288 ULONG numberOfThreads;
2299 PWSTR ioPriority = L
"N/A";
2302 HANDLE threadHandle;
2304 ULONG ioPriorityInteger;
2305 ULONG pagePriorityInteger;
2306 PROCESSOR_NUMBER idealProcessorNumber;
2311 if (numberOfThreads == 1)
2312 threadItem = threads[0];
2318 if (numberOfThreads != 1 && !Force)
2321 if (numberOfThreads == 1)
2345 if ((ULONG)threadItem->
WaitReason < MaximumWaitReason)
2367 if (
NT_SUCCESS(NtQueryInformationThread(threadHandle, ThreadIdealProcessorEx, &idealProcessorNumber,
sizeof(PROCESSOR_NUMBER), NULL)))
2377 if (threadItem->
WaitReason == Suspended &&
NT_SUCCESS(NtQueryInformationThread(threadHandle, ThreadSuspendCount, &suspendCount,
sizeof(ULONG), NULL)))
2388 NtClose(threadHandle);
2422 ULONG numberOfThreads;
2426 if (numberOfThreads != 0)
2442 menuInfo.
u.
Thread.ProcessId = ProcessItem->ProcessId;
2443 menuInfo.
u.
Thread.Threads = threads;
2444 menuInfo.
u.
Thread.NumberOfThreads = numberOfThreads;
2454 ContextMenu->Location.x,
2455 ContextMenu->Location.y
2460 BOOLEAN handled =
FALSE;
2468 SendMessage(hwndDlg, WM_COMMAND, item->
Id, 0);
2484 LPPROPSHEETPAGE propSheetPage;
2491 &propSheetPage, &propPageContext, &processItem))
2507 threadsContext = propPageContext->
Context =
2522 ThreadModifiedHandler,
2528 ThreadRemovedHandler,
2534 ThreadsUpdatedHandler,
2540 ThreadsLoadingStateChangedHandler,
2547 tnHandle = GetDlgItem(hwndDlg,
IDC_LIST);
2548 BringWindowToTop(tnHandle);
2558 HANDLE processHandle;
2559 PROCESS_EXTENDED_BASIC_INFORMATION extendedBasicInfo;
2572 NtClose(processHandle);
2584 NtClose(processHandle);
2668 #define ADD_BL_ITEM(Id) \
2669 PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, Id), dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_BOTTOM)
2706 INT
id = LOWORD(wParam);
2735 ULONG numberOfThreads;
2761 ULONG numberOfThreads;
2776 ULONG numberOfThreads;
2788 ULONG numberOfThreads;
2814 ULONG numberOfAccessEntries;
2818 stdObjectSecurity.
OpenObject = PhpThreadPermissionsOpenThread;
2831 numberOfAccessEntries
2842 HANDLE threadHandle;
2854 PhpOpenThreadTokenObject,
2855 (PVOID)threadHandle,
2859 NtClose(threadHandle);
2863 PhShowStatus(hwndDlg, L
"Unable to open the thread", status, 0);
2897 ULONG threadPriorityWin32;
2902 threadPriorityWin32 = THREAD_PRIORITY_TIME_CRITICAL;
2905 threadPriorityWin32 = THREAD_PRIORITY_HIGHEST;
2908 threadPriorityWin32 = THREAD_PRIORITY_ABOVE_NORMAL;
2911 threadPriorityWin32 = THREAD_PRIORITY_NORMAL;
2914 threadPriorityWin32 = THREAD_PRIORITY_BELOW_NORMAL;
2917 threadPriorityWin32 = THREAD_PRIORITY_LOWEST;
2920 threadPriorityWin32 = THREAD_PRIORITY_IDLE;
3024 LPNMHDR header = (LPNMHDR)lParam;
3026 switch (header->code)
3030 case PSN_KILLACTIVE:
3038 BOOLEAN firstRun = (BOOLEAN)wParam;
3119 static NTSTATUS NTAPI PhpOpenProcessToken(
3120 _Out_ PHANDLE Handle,
3121 _In_ ACCESS_MASK DesiredAccess,
3122 _In_opt_ PVOID Context
3126 HANDLE processHandle;
3136 NtClose(processHandle);
3191 if (ListView_GetItemCount(groupsLv) != 0)
3193 ListView_SetColumnWidth(groupsLv, 0, LVSCW_AUTOSIZE);
3197 if (ListView_GetItemCount(privilegesLv) != 0)
3199 ListView_SetColumnWidth(privilegesLv, 0, LVSCW_AUTOSIZE);
3200 ListView_SetColumnWidth(privilegesLv, 1, LVSCW_AUTOSIZE);
3213 static VOID NTAPI ModuleAddedHandler(
3214 _In_opt_ PVOID Parameter,
3215 _In_opt_ PVOID Context
3230 static VOID NTAPI ModuleModifiedHandler(
3231 _In_opt_ PVOID Parameter,
3232 _In_opt_ PVOID Context
3240 static VOID NTAPI ModuleRemovedHandler(
3241 _In_opt_ PVOID Parameter,
3242 _In_opt_ PVOID Context
3250 static VOID NTAPI ModulesUpdatedHandler(
3251 _In_opt_ PVOID Parameter,
3252 _In_opt_ PVOID Context
3264 _In_ ULONG NumberOfModules
3272 if (inspectExecutables->
Length == 0)
3280 if (NumberOfModules == 0)
3284 else if (NumberOfModules == 1)
3303 ULONG numberOfModules;
3307 if (numberOfModules != 0)
3323 menuInfo.
u.
Module.ProcessId = ProcessItem->ProcessId;
3324 menuInfo.
u.
Module.Modules = modules;
3325 menuInfo.
u.
Module.NumberOfModules = numberOfModules;
3335 ContextMenu->Location.x,
3336 ContextMenu->Location.y
3341 BOOLEAN handled =
FALSE;
3349 SendMessage(hwndDlg, WM_COMMAND, item->
Id, 0);
3365 LPPROPSHEETPAGE propSheetPage;
3372 &propSheetPage, &propPageContext, &processItem))
3390 modulesContext = propPageContext->
Context =
3410 ModuleModifiedHandler,
3416 ModuleRemovedHandler,
3422 ModulesUpdatedHandler,
3429 tnHandle = GetDlgItem(hwndDlg,
IDC_LIST);
3430 BringWindowToTop(tnHandle);
3515 switch (LOWORD(wParam))
3545 L
"ProgramInspectExecutables",
3548 L
"Make sure the PE Viewer executable file is present."
3597 LPNMHDR header = (LPNMHDR)lParam;
3599 switch (header->code)
3604 case PSN_KILLACTIVE:
3612 ULONG runId = (ULONG)wParam;
3664 status = STATUS_SUCCESS;
3678 InvalidateRect(tnHandle, NULL,
FALSE);
3745 _In_ ULONG NumberOfMemoryNodes
3748 if (NumberOfMemoryNodes == 0)
3752 else if (NumberOfMemoryNodes == 1 && !MemoryNodes[0]->IsAllocationBase)
3754 if (MemoryNodes[0]->MemoryItem->State & MEM_FREE)
3760 else if (MemoryNodes[0]->MemoryItem->Type & (MEM_MAPPED | MEM_IMAGE))
3768 ULONG numberOfAllocationBase = 0;
3773 for (i = 0; i < NumberOfMemoryNodes; i++)
3775 if (MemoryNodes[i]->IsAllocationBase)
3776 numberOfAllocationBase++;
3779 if (numberOfAllocationBase == 0 || numberOfAllocationBase == NumberOfMemoryNodes)
3794 ULONG numberOfMemoryNodes;
3814 menuInfo.
u.
Memory.ProcessId = ProcessItem->ProcessId;
3815 menuInfo.
u.
Memory.MemoryNodes = memoryNodes;
3816 menuInfo.
u.
Memory.NumberOfMemoryNodes = numberOfMemoryNodes;
3826 ContextMenu->Location.x,
3827 ContextMenu->Location.y
3832 BOOLEAN handled =
FALSE;
3840 SendMessage(hwndDlg, WM_COMMAND, item->
Id, 0);
3856 LPPROPSHEETPAGE propSheetPage;
3863 &propSheetPage, &propPageContext, &processItem))
3879 memoryContext = propPageContext->
Context =
3885 tnHandle = GetDlgItem(hwndDlg,
IDC_LIST);
3886 BringWindowToTop(tnHandle);
3960 switch (LOWORD(wParam))
3987 PhShowError(hwndDlg, L
"Unable to edit the memory region because it is not committed.");
3995 HANDLE processHandle;
3997 ULONG numberOfMemoryNodes;
4005 PhShowStatus(hwndDlg, L
"Unable to open the process", status, 0);
4011 if (numberOfMemoryNodes != 0)
4015 { L
"Binary files (*.bin)", L
"*.bin" },
4016 { L
"All files (*.*)", L
"*.*" }
4049 for (i = 0; i < numberOfMemoryNodes; i++)
4078 PhShowStatus(hwndDlg, L
"Unable to create the file", status, 0);
4085 NtClose(processHandle);
4137 L
"Read/Write Address",
4138 L
"Enter an address:",
4145 L
"MemoryReadWriteAddressChoices"
4151 if (selectedChoice->
Length == 0)
4158 address = (PVOID)address64;
4176 PhShowError(hwndDlg, L
"Unable to find the memory region for the selected address.");
4220 LPPROPSHEETPAGE propSheetPage;
4225 &propSheetPage, &propPageContext, &processItem))
4232 HANDLE processHandle;
4234 ULONG environmentLength;
4235 ULONG enumerationKey;
4237 HWND lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
4295 NtClose(processHandle);
4332 static VOID NTAPI HandleAddedHandler(
4333 _In_opt_ PVOID Parameter,
4334 _In_opt_ PVOID Context
4349 static VOID NTAPI HandleModifiedHandler(
4350 _In_opt_ PVOID Parameter,
4351 _In_opt_ PVOID Context
4359 static VOID NTAPI HandleRemovedHandler(
4360 _In_opt_ PVOID Parameter,
4361 _In_opt_ PVOID Context
4369 static VOID NTAPI HandlesUpdatedHandler(
4370 _In_opt_ PVOID Parameter,
4371 _In_opt_ PVOID Context
4379 static NTSTATUS PhpDuplicateHandleFromProcessItem(
4380 _Out_ PHANDLE NewHandle,
4381 _In_ ACCESS_MASK DesiredAccess,
4387 HANDLE processHandle;
4405 NtClose(processHandle);
4410 static VOID PhpShowProcessPropContext(
4411 _In_ PVOID Parameter
4420 _In_ ULONG InsertBeforeId,
4421 _In_ BOOLEAN EnableShortcut,
4426 ULONG indexInParent;
4428 if (!
PhFindEMenuItemEx(Menu, 0, NULL, InsertBeforeId, &parentItem, &indexInParent))
4465 if (Info->BestObjectName)
4468 PhShowError(hWnd, L
"Unable to open file location because the object is unnamed.");
4472 if (Info->BestObjectName)
4475 PhShowError(hWnd, L
"Unable to open key because the object is unnamed.");
4479 HANDLE processHandle;
4493 PROCESS_BASIC_INFORMATION basicInfo;
4500 sizeof(PROCESS_BASIC_INFORMATION),
4504 processId = basicInfo.UniqueProcessId;
4507 NtClose(processHandle);
4513 PROCESS_BASIC_INFORMATION basicInfo;
4515 if (
NT_SUCCESS(PhpDuplicateHandleFromProcessItem(
4523 processId = basicInfo.UniqueProcessId;
4533 if (targetProcessItem)
4540 PhShowError(hWnd, L
"The process does not exist.");
4546 HANDLE handle = NULL;
4547 BOOLEAN readOnly =
FALSE;
4549 if (!
NT_SUCCESS(PhpDuplicateHandleFromProcessItem(
4551 SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE,
4556 PhpDuplicateHandleFromProcessItem(
4558 SECTION_QUERY | SECTION_MAP_READ,
4571 PVOID viewBase = NULL;
4572 BOOLEAN tooBig =
FALSE;
4579 viewSize = (SIZE_T)basicInfo.
MaximumSize.QuadPart;
4593 readOnly ? PAGE_READONLY : PAGE_READWRITE
4596 if (status == STATUS_SECTION_PROTECTION && !readOnly)
4617 PhShowWarning(hWnd, L
"The section size is greater than 32 MB. Only the first 32 MB will be available for editing.");
4620 showMemoryEditor->
ProcessId = NtCurrentProcessId();
4631 PhShowStatus(hWnd, L
"Unable to map a view of the section", status, 0);
4642 HANDLE processHandle;
4672 NtClose(processHandle);
4680 if (
NT_SUCCESS(PhpDuplicateHandleFromProcessItem(
4698 if (targetProcessItem)
4707 PhShowError(hWnd, L
"The process does not exist.");
4721 if (Info->BestObjectName)
4724 PhShowError(hWnd, L
"Unable to open file properties because the object is unnamed.");
4730 _In_ HANDLE ProcessId,
4732 _In_ ULONG NumberOfHandles,
4738 if (NumberOfHandles == 0)
4742 else if (NumberOfHandles == 1)
4747 info.
Handle = Handles[0]->Handle;
4748 info.
TypeName = Handles[0]->TypeName;
4773 HandlesContext->SelectedHandleProtected =
FALSE;
4774 HandlesContext->SelectedHandleInherit =
FALSE;
4778 HandlesContext->SelectedHandleProtected =
TRUE;
4784 HandlesContext->SelectedHandleInherit =
TRUE;
4798 ULONG numberOfHandles;
4802 if (numberOfHandles != 0)
4818 menuInfo.
u.
Handle.ProcessId = ProcessItem->ProcessId;
4819 menuInfo.
u.
Handle.Handles = handles;
4820 menuInfo.
u.
Handle.NumberOfHandles = numberOfHandles;
4830 ContextMenu->Location.x,
4831 ContextMenu->Location.y
4836 BOOLEAN handled =
FALSE;
4844 SendMessage(hwndDlg, WM_COMMAND, item->
Id, 0);
4860 LPPROPSHEETPAGE propSheetPage;
4867 &propSheetPage, &propPageContext, &processItem))
4883 handlesContext = propPageContext->
Context =
4903 HandleModifiedHandler,
4909 HandleRemovedHandler,
4915 HandlesUpdatedHandler,
4922 tnHandle = GetDlgItem(hwndDlg,
IDC_LIST);
4923 BringWindowToTop(tnHandle);
5011 INT
id = LOWORD(wParam);
5023 ULONG numberOfHandles;
5042 ULONG attributes = 0;
5119 LPNMHDR header = (LPNMHDR)lParam;
5121 switch (header->code)
5126 case PSN_KILLACTIVE:
5134 ULONG runId = (ULONG)wParam;
5186 status = STATUS_SUCCESS;
5200 InvalidateRect(tnHandle, NULL,
FALSE);
5215 static NTSTATUS NTAPI PhpOpenProcessJob(
5216 _Out_ PHANDLE Handle,
5217 _In_ ACCESS_MASK DesiredAccess,
5218 _In_opt_ PVOID Context
5222 HANDLE processHandle;
5223 HANDLE jobHandle = NULL;
5233 NtClose(processHandle);
5235 if (
NT_SUCCESS(status) && status != STATUS_PROCESS_NOT_IN_JOB && jobHandle)
5237 *Handle = jobHandle;
5241 status = STATUS_UNSUCCESSFUL;
5295 static VOID PhpLayoutServiceListControl(
5297 _In_ HWND ServiceListHandle
5303 MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
5309 rect.right - rect.left,
5310 rect.bottom - rect.top,
5322 LPPROPSHEETPAGE propSheetPage;
5327 &propSheetPage, &propPageContext, &processItem))
5337 ULONG numberOfServices;
5339 HWND serviceListHandle;
5349 ULONG enumerationKey = 0;
5357 services[i++] = serviceItem;
5369 ShowWindow(serviceListHandle, SW_SHOW);
5371 propPageContext->
Context = serviceListHandle;
5391 PhpLayoutServiceListControl(hwndDlg, (HWND)propPageContext->
Context);
5399 PhpLayoutServiceListControl(hwndDlg, (HWND)propPageContext->
Context);
5408 _In_ PVOID Parameter
5529 pluginProcessPropContext.
PropContext = PropContext;
5553 while (result = GetMessage(&message, NULL, 0, 0))
5558 if (!PropSheet_IsDialogMessage(hwnd, &message))
5560 TranslateMessage(&message);
5561 DispatchMessage(&message);
5567 if (!PropSheet_GetCurrentPageHwnd(hwnd))
5569 DestroyWindow(hwnd);
5578 return STATUS_SUCCESS;
5585 HANDLE threadHandle;
5592 NtClose(threadHandle);