38 _In_ PMIB_TCPROW pTcpRow
41 static PWSTR DangerousProcesses[] =
43 L
"csrss.exe", L
"dwm.exe", L
"logonui.exe", L
"lsass.exe", L
"lsm.exe",
44 L
"services.exe", L
"smss.exe", L
"wininit.exe", L
"winlogon.exe"
49 static ULONG PhSvcReferenceCount = 0;
55 _In_ UINT uNotification,
58 _In_ LONG_PTR dwRefData
61 switch (uNotification)
64 SendMessage(hwnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, IDYES,
TRUE);
78 TASKDIALOGCONFIG config = {
sizeof(config) };
79 TASKDIALOG_BUTTON buttons[1];
86 config.hwndParent = hWnd;
88 config.pszWindowTitle = L
"Process Hacker";
89 config.pszMainIcon = TD_ERROR_ICON;
98 config.pszContent = L
"You will need to provide administrator permission. "
99 L
"Click Continue to complete this operation.";
100 config.dwCommonButtons = TDCBF_CANCEL_BUTTON;
102 buttons[0].nButtonID = IDYES;
103 buttons[0].pszButtonText = L
"Continue";
106 config.pButtons = buttons;
107 config.nDefaultButton = IDYES;
144 _In_ NTSTATUS Status,
146 _Out_ PBOOLEAN Success
153 Status == STATUS_ACCESS_DENIED ||
154 Status == STATUS_PRIVILEGE_NOT_HELD ||
176 HANDLE processHandle;
177 LARGE_INTEGER timeout;
178 PROCESS_BASIC_INFORMATION basicInfo;
191 status = NtWaitForSingleObject(processHandle,
FALSE, &timeout);
194 status == STATUS_WAIT_0 &&
198 status = basicInfo.ExitStatus;
201 NtClose(processHandle);
236 _In_ NTSTATUS Status,
237 _Out_ PBOOLEAN Connected
246 Status == STATUS_ACCESS_DENIED ||
247 Status == STATUS_PRIVILEGE_NOT_HELD ||
291 _In_ BOOLEAN ConnectOnly
343 static PWSTR relativeFileNames[] =
345 L
"\\x86\\ProcessHacker.exe",
346 L
"\\..\\x86\\ProcessHacker.exe",
348 L
"\\..\\Debug32\\ProcessHacker.exe",
350 L
"\\..\\Release32\\ProcessHacker.exe"
355 for (i = 0; i <
sizeof(relativeFileNames) /
sizeof(PWSTR); i++)
401 _In_ BOOLEAN ConnectOnly
410 if (PhSvcCurrentMode == Mode)
416 _InterlockedDecrement(&PhSvcReferenceCount);
424 if (PhSvcReferenceCount == 0)
435 PhSvcCurrentMode = Mode;
436 _InterlockedIncrement(&PhSvcReferenceCount);
438 else if (!ConnectOnly)
448 LARGE_INTEGER interval;
460 NtDelayExecution(
FALSE, &interval);
461 }
while (--attempts != 0);
466 PhSvcCurrentMode = Mode;
467 _InterlockedIncrement(&PhSvcReferenceCount);
473 if (PhSvcCurrentMode == Mode)
476 _InterlockedIncrement(&PhSvcReferenceCount);
499 if (_InterlockedDecrement(&PhSvcReferenceCount) == 0)
511 if (LockWorkStation())
514 PhShowStatus(hWnd, L
"Unable to lock the computer", 0, GetLastError());
523 if (ExitWindowsEx(EWX_LOGOFF, 0))
526 PhShowStatus(hWnd, L
"Unable to logoff the computer", 0, GetLastError());
539 PowerSystemSleeping1,
545 PhShowStatus(hWnd, L
"Unable to sleep the computer", status, 0);
557 PowerActionHibernate,
558 PowerSystemSleeping1,
564 PhShowStatus(hWnd, L
"Unable to hibernate the computer", status, 0);
582 if (ExitWindowsEx(EWX_REBOOT | Flags, 0))
585 PhShowStatus(hWnd, L
"Unable to restart the computer", 0, GetLastError());
604 if (ExitWindowsEx(EWX_POWEROFF | Flags, 0))
608 else if (ExitWindowsEx(EWX_SHUTDOWN | Flags, 0))
614 PhShowStatus(hWnd, L
"Unable to shut down the computer", 0, GetLastError());
626 BOOLEAN success =
FALSE;
636 L
"Connect to session",
647 if (oldSelectedChoice)
649 RtlSecureZeroMemory(oldSelectedChoice->
Buffer, oldSelectedChoice->
Length);
653 oldSelectedChoice = selectedChoice;
667 if (oldSelectedChoice)
669 RtlSecureZeroMemory(oldSelectedChoice->
Buffer, oldSelectedChoice->
Length);
684 PhShowStatus(hWnd, L
"Unable to disconnect the session", 0, GetLastError());
705 PhShowStatus(hWnd, L
"Unable to logoff the session", 0, GetLastError());
716 static BOOLEAN PhpIsDangerousProcess(
721 HANDLE processHandle;
743 NtClose(processHandle);
754 for (i = 0; i <
sizeof(DangerousProcesses) /
sizeof(PWSTR); i++)
783 static BOOLEAN PhpShowContinueMessageProcesses(
786 _In_opt_ PWSTR Message,
787 _In_ BOOLEAN WarnOnlyIfDangerous,
789 _In_ ULONG NumberOfProcesses
794 BOOLEAN critical =
FALSE;
795 BOOLEAN dangerous =
FALSE;
796 BOOLEAN cont =
FALSE;
798 if (NumberOfProcesses == 0)
801 for (i = 0; i < NumberOfProcesses; i++)
803 HANDLE processHandle;
804 ULONG breakOnTermination;
806 breakOnTermination = 0;
810 NtQueryInformationProcess(processHandle, ProcessBreakOnTermination, &breakOnTermination,
sizeof(ULONG), NULL);
811 NtClose(processHandle);
814 if (breakOnTermination != 0)
821 if (PhpIsDangerousProcess(Processes[i]->ProcessId))
828 if (WarnOnlyIfDangerous && !dangerous)
833 if (NumberOfProcesses == 1)
835 object = Processes[0]->ProcessName->Buffer;
837 else if (NumberOfProcesses == 2)
841 Processes[0]->ProcessName->Buffer,
843 Processes[1]->ProcessName->Buffer
848 object = L
"the selected processes";
869 L
"You are about to ",
871 L
" one or more system processes."
884 L
"You are about to ",
886 L
" one or more critical processes. This will shut down the operating system immediately."
893 L
"You are about to ",
895 L
" one or more critical processes."
934 static BOOLEAN PhpShowErrorProcess(
938 _In_ NTSTATUS Status,
939 _In_opt_ ULONG Win32Result
947 L
"Unable to %s %s (PID %u)",
949 Process->ProcessName->Buffer,
950 (ULONG)Process->ProcessId
963 Process->ProcessName->Buffer
974 _In_ ULONG NumberOfProcesses
977 BOOLEAN success =
TRUE;
978 BOOLEAN cancelled =
FALSE;
981 if (!PhpShowContinueMessageProcesses(
984 L
"Terminating a process will cause unsaved data to be lost.",
991 for (i = 0; i < NumberOfProcesses; i++)
994 HANDLE processHandle;
999 Processes[i]->ProcessId
1007 NtClose(processHandle);
1028 PhpShowErrorProcess(hWnd, L
"terminate", Processes[i], status, 0);
1039 if (!PhpShowErrorProcess(hWnd, L
"terminate", Processes[i], status, 0))
1051 _In_ PVOID Processes,
1052 _Inout_ PBOOLEAN Success
1057 HANDLE processHandle;
1074 NtClose(processHandle);
1081 if (!PhpShowErrorProcess(hWnd, L
"terminate", Process, status, 0))
1099 if (processItem->
CreateTime.QuadPart >= Process->CreateTime.QuadPart)
1122 BOOLEAN success =
TRUE;
1123 BOOLEAN cont =
FALSE;
1132 L
"Terminating a process tree will cause the process and its descendants to be terminated.",
1146 PhShowStatus(hWnd, L
"Unable to enumerate processes", status, 0);
1159 _In_ ULONG NumberOfProcesses
1162 BOOLEAN success =
TRUE;
1163 BOOLEAN cancelled =
FALSE;
1166 if (!PhpShowContinueMessageProcesses(
1176 for (i = 0; i < NumberOfProcesses; i++)
1179 HANDLE processHandle;
1184 Processes[i]->ProcessId
1188 NtClose(processHandle);
1209 PhpShowErrorProcess(hWnd, L
"suspend", Processes[i], status, 0);
1220 if (!PhpShowErrorProcess(hWnd, L
"suspend", Processes[i], status, 0))
1232 _In_ ULONG NumberOfProcesses
1235 BOOLEAN success =
TRUE;
1236 BOOLEAN cancelled =
FALSE;
1239 if (!PhpShowContinueMessageProcesses(
1249 for (i = 0; i < NumberOfProcesses; i++)
1252 HANDLE processHandle;
1257 Processes[i]->ProcessId
1261 NtClose(processHandle);
1282 PhpShowErrorProcess(hWnd, L
"resume", Processes[i], status, 0);
1293 if (!PhpShowErrorProcess(hWnd, L
"resume", Processes[i], status, 0))
1308 BOOLEAN cont =
FALSE;
1309 HANDLE processHandle = NULL;
1319 Process->ProcessName->Buffer,
1320 L
"The process will be restarted with the same command line and "
1321 L
"working directory, but if it is running under a different user it "
1322 L
"will be restarted under the current user.",
1348 PhShowError(hWnd, L
"POSIX processes cannot be restarted.");
1369 NtClose(processHandle);
1370 processHandle = NULL;
1387 NtClose(processHandle);
1388 processHandle = NULL;
1396 currentDirectory->
Buffer,
1405 NtClose(processHandle);
1409 PhpShowErrorProcess(hWnd, L
"restart", Process, status, 0);
1423 BOOLEAN cont =
FALSE;
1431 Process->ProcessName->Buffer,
1432 L
"Debugging a process may result in loss of data.",
1480 if (!DebuggerCommand)
1482 PhShowError(hWnd, L
"Unable to locate the debugger.");
1508 PhpShowErrorProcess(hWnd, L
"debug", Process, status, 0);
1518 _In_ ULONG NumberOfProcesses
1521 BOOLEAN success =
TRUE;
1524 for (i = 0; i < NumberOfProcesses; i++)
1527 HANDLE processHandle;
1532 Processes[i]->ProcessId
1535 QUOTA_LIMITS quotaLimits;
1537 memset("aLimits, 0,
sizeof(QUOTA_LIMITS));
1538 quotaLimits.MinimumWorkingSetSize = -1;
1539 quotaLimits.MaximumWorkingSetSize = -1;
1541 status = NtSetInformationProcess(
1545 sizeof(QUOTA_LIMITS)
1548 NtClose(processHandle);
1555 if (!PhpShowErrorProcess(hWnd, L
"reduce the working set of", Processes[i], status, 0))
1570 BOOLEAN cont =
FALSE;
1571 HANDLE processHandle;
1579 L
"virtualization for the process",
1580 L
"Enabling or disabling virtualization for a process may "
1581 L
"alter its functionality and produce undesirable effects.",
1607 NtClose(tokenHandle);
1610 NtClose(processHandle);
1615 PhpShowErrorProcess(hWnd, L
"set virtualization for", Process, status, 0);
1628 HANDLE processHandle;
1629 HANDLE debugObjectHandle;
1656 NtClose(debugObjectHandle);
1659 NtClose(processHandle);
1662 if (status == STATUS_PORT_NOT_SET)
1670 PhpShowErrorProcess(hWnd, L
"detach debugger from", Process, status, 0);
1684 { L
"DLL files (*.dll)", L
"*.dll" },
1685 { L
"All files (*.*)", L
"*.*" }
1691 HANDLE processHandle;
1712 LARGE_INTEGER timeout;
1721 NtClose(processHandle);
1726 PhpShowErrorProcess(hWnd, L
"inject the DLL into", Process, status, 0);
1736 _In_ ULONG NumberOfProcesses,
1737 _In_ ULONG IoPriority
1740 BOOLEAN success =
TRUE;
1741 BOOLEAN cancelled =
FALSE;
1744 for (i = 0; i < NumberOfProcesses; i++)
1747 HANDLE processHandle;
1752 Processes[i]->ProcessId
1757 NtClose(processHandle);
1779 PhpShowErrorProcess(hWnd, L
"set the I/O priority of", Processes[i], status, 0);
1790 if (!PhpShowErrorProcess(hWnd, L
"set the I/O priority of", Processes[i], status, 0))
1802 _In_ ULONG PagePriority
1806 HANDLE processHandle;
1814 status = NtSetInformationProcess(
1816 ProcessPagePriority,
1821 NtClose(processHandle);
1826 PhpShowErrorProcess(hWnd, L
"set the page priority of", Process, status, 0);
1836 _In_ ULONG NumberOfProcesses,
1837 _In_ ULONG PriorityClass
1840 BOOLEAN success =
TRUE;
1841 BOOLEAN cancelled =
FALSE;
1844 for (i = 0; i < NumberOfProcesses; i++)
1847 HANDLE processHandle;
1853 Processes[i]->ProcessId
1858 status = NtSetInformationProcess(processHandle, ProcessPriorityClass, &priorityClass,
sizeof(
PROCESS_PRIORITY_CLASS));
1860 NtClose(processHandle);
1882 PhpShowErrorProcess(hWnd, L
"set the priority of", Processes[i], status, 0);
1893 if (!PhpShowErrorProcess(hWnd, L
"set the priority of", Processes[i], status, 0))
1907 static WCHAR *choices[] = { L
"Disabled", L
"Enabled", L
"Enabled, DEP-ATL thunk emulation disabled" };
1909 HANDLE processHandle;
1912 BOOLEAN selectedOption;
1939 selectedOption =
FALSE;
1942 NtClose(processHandle);
1947 PhpShowErrorProcess(hWnd, L
"set the DEP status of", Process, status, 0);
1956 sizeof(choices) /
sizeof(PWSTR),
1992 LARGE_INTEGER timeout;
1998 NtClose(processHandle);
2005 else if (status == STATUS_NOT_SUPPORTED)
2009 L
"This feature is not supported by your operating system. "
2010 L
"The minimum supported versions are Windows XP SP3 and Windows Vista SP1."
2016 if (!PhpShowErrorProcess(hWnd, L
"set the DEP status of", Process, status, 0))
2029 static WCHAR *choices[] = { L
"Protected", L
"Not Protected" };
2032 HANDLE processHandle;
2051 PhShowStatus(hWnd, L
"Unable to open the process", status, 0);
2067 while (
PhaChoiceDialog(hWnd, L
"Protection", L
"Protection:", choices,
sizeof(choices) /
sizeof(PWSTR),
2068 NULL, 0, &selectedChoice, NULL, NULL))
2085 if (!PhpShowErrorProcess(hWnd, L
"set the protection of", Process, status, 0))
2092 PhShowStatus(hWnd, L
"Unable to query process protection", status, 0);
2095 NtClose(processHandle);
2100 static VOID PhpShowErrorService(
2104 _In_ NTSTATUS Status,
2105 _In_opt_ ULONG Win32Result
2113 Service->Name->Buffer
2125 SC_HANDLE serviceHandle;
2126 BOOLEAN success =
FALSE;
2128 serviceHandle =
PhOpenService(Service->Name->Buffer, SERVICE_START);
2132 if (StartService(serviceHandle, 0, NULL))
2135 CloseServiceHandle(serviceHandle);
2157 PhpShowErrorService(hWnd, L
"start", Service, status, 0);
2164 PhpShowErrorService(hWnd, L
"start", Service, status, 0);
2176 SC_HANDLE serviceHandle;
2177 BOOLEAN success =
FALSE;
2179 serviceHandle =
PhOpenService(Service->Name->Buffer, SERVICE_PAUSE_CONTINUE);
2183 SERVICE_STATUS serviceStatus;
2185 if (ControlService(serviceHandle, SERVICE_CONTROL_CONTINUE, &serviceStatus))
2188 CloseServiceHandle(serviceHandle);
2210 PhpShowErrorService(hWnd, L
"continue", Service, status, 0);
2217 PhpShowErrorService(hWnd, L
"continue", Service, status, 0);
2229 SC_HANDLE serviceHandle;
2230 BOOLEAN success =
FALSE;
2232 serviceHandle =
PhOpenService(Service->Name->Buffer, SERVICE_PAUSE_CONTINUE);
2236 SERVICE_STATUS serviceStatus;
2238 if (ControlService(serviceHandle, SERVICE_CONTROL_PAUSE, &serviceStatus))
2241 CloseServiceHandle(serviceHandle);
2263 PhpShowErrorService(hWnd, L
"pause", Service, status, 0);
2270 PhpShowErrorService(hWnd, L
"pause", Service, status, 0);
2282 SC_HANDLE serviceHandle;
2283 BOOLEAN success =
FALSE;
2285 serviceHandle =
PhOpenService(Service->Name->Buffer, SERVICE_STOP);
2289 SERVICE_STATUS serviceStatus;
2291 if (ControlService(serviceHandle, SERVICE_CONTROL_STOP, &serviceStatus))
2294 CloseServiceHandle(serviceHandle);
2316 PhpShowErrorService(hWnd, L
"stop", Service, status, 0);
2323 PhpShowErrorService(hWnd, L
"stop", Service, status, 0);
2335 SC_HANDLE serviceHandle;
2336 BOOLEAN success =
FALSE;
2342 Service->Name->Buffer,
2343 L
"Deleting a service can prevent the system from starting "
2344 L
"or functioning properly.",
2349 serviceHandle =
PhOpenService(Service->Name->Buffer, DELETE);
2353 if (DeleteService(serviceHandle))
2356 CloseServiceHandle(serviceHandle);
2378 PhpShowErrorService(hWnd, L
"delete", Service, status, 0);
2385 PhpShowErrorService(hWnd, L
"delete", Service, status, 0);
2395 _In_ ULONG NumberOfConnections
2399 BOOLEAN success =
TRUE;
2400 BOOLEAN cancelled =
FALSE;
2412 L
"This feature is not supported by your operating system."
2417 for (i = 0; i < NumberOfConnections; i++)
2421 Connections[i]->State != MIB_TCP_STATE_ESTAB
2425 tcpRow.dwState = MIB_TCP_STATE_DELETE_TCB;
2426 tcpRow.dwLocalAddr = Connections[i]->LocalEndpoint.Address.Ipv4;
2427 tcpRow.dwLocalPort = _byteswap_ushort((USHORT)Connections[i]->LocalEndpoint.Port);
2428 tcpRow.dwRemoteAddr = Connections[i]->RemoteEndpoint.Address.Ipv4;
2429 tcpRow.dwRemotePort = _byteswap_ushort((USHORT)Connections[i]->RemoteEndpoint.Port);
2431 if ((result = SetTcpEntry_I(&tcpRow)) != 0)
2439 if (result == ERROR_MR_MID_NOT_FOUND)
2440 result = ERROR_ACCESS_DENIED;
2444 L
"Unable to close the TCP connection",
2445 NTSTATUS_FROM_WIN32(result),
2454 PhShowStatus(hWnd, L
"Unable to close the TCP connection", status, 0);
2467 MB_ICONERROR | MB_OKCANCEL,
2468 L
"Unable to close the TCP connection (from %s:%u). "
2469 L
"Make sure Process Hacker is running with administrative privileges.",
2470 Connections[i]->LocalAddressString,
2471 Connections[i]->LocalEndpoint.Port
2481 static BOOLEAN PhpShowContinueMessageThreads(
2485 _In_ BOOLEAN Warning,
2487 _In_ ULONG NumberOfThreads
2491 BOOLEAN cont =
FALSE;
2493 if (NumberOfThreads == 0)
2498 if (NumberOfThreads == 1)
2500 object = L
"the selected thread";
2504 object = L
"the selected threads";
2523 static BOOLEAN PhpShowErrorThread(
2527 _In_ NTSTATUS Status,
2528 _In_opt_ ULONG Win32Result
2534 L
"Unable to %s thread %u",
2536 (ULONG)Thread->ThreadId
2546 _In_ ULONG NumberOfThreads
2549 BOOLEAN success =
TRUE;
2550 BOOLEAN cancelled =
FALSE;
2553 if (!PhpShowContinueMessageThreads(
2556 L
"Terminating a thread may cause the process to stop working.",
2563 for (i = 0; i < NumberOfThreads; i++)
2566 HANDLE threadHandle;
2571 Threads[i]->ThreadId
2575 NtClose(threadHandle);
2586 PhaFormatString(L
"Unable to terminate thread %u", (ULONG)Threads[i]->ThreadId)->Buffer,
2596 PhpShowErrorThread(hWnd, L
"terminate", Threads[i], status, 0);
2607 if (!PhpShowErrorThread(hWnd, L
"terminate", Threads[i], status, 0))
2618 _In_ HANDLE ProcessId,
2620 _In_ ULONG NumberOfThreads
2623 BOOLEAN success =
TRUE;
2634 if (!PhpShowContinueMessageThreads(
2637 L
"Forcibly terminating threads may cause the system to crash or become unstable.",
2646 if (!PhpShowContinueMessageThreads(
2649 L
"Forcibly terminating system threads may cause the system to crash or become unstable.",
2657 for (i = 0; i < NumberOfThreads; i++)
2660 HANDLE threadHandle;
2665 Threads[i]->ThreadId
2669 NtClose(threadHandle);
2676 if (!PhpShowErrorThread(hWnd, L
"terminate", Threads[i], status, 0))
2687 _In_ ULONG NumberOfThreads
2690 BOOLEAN success =
TRUE;
2691 BOOLEAN cancelled =
FALSE;
2694 for (i = 0; i < NumberOfThreads; i++)
2697 HANDLE threadHandle;
2701 THREAD_SUSPEND_RESUME,
2702 Threads[i]->ThreadId
2706 NtClose(threadHandle);
2717 PhaFormatString(L
"Unable to suspend thread %u", (ULONG)Threads[i]->ThreadId)->Buffer,
2727 PhpShowErrorThread(hWnd, L
"suspend", Threads[i], status, 0);
2738 if (!PhpShowErrorThread(hWnd, L
"suspend", Threads[i], status, 0))
2750 _In_ ULONG NumberOfThreads
2753 BOOLEAN success =
TRUE;
2754 BOOLEAN cancelled =
FALSE;
2757 for (i = 0; i < NumberOfThreads; i++)
2760 HANDLE threadHandle;
2764 THREAD_SUSPEND_RESUME,
2765 Threads[i]->ThreadId
2769 NtClose(threadHandle);
2780 PhaFormatString(L
"Unable to resume thread %u", (ULONG)Threads[i]->ThreadId)->Buffer,
2790 PhpShowErrorThread(hWnd, L
"resume", Threads[i], status, 0);
2801 if (!PhpShowErrorThread(hWnd, L
"resume", Threads[i], status, 0))
2813 _In_ ULONG ThreadPriorityWin32
2817 ULONG win32Result = 0;
2818 HANDLE threadHandle;
2826 if (!SetThreadPriority(threadHandle, ThreadPriorityWin32))
2827 win32Result = GetLastError();
2829 NtClose(threadHandle);
2834 PhpShowErrorThread(hWnd, L
"set the priority of", Thread, status, 0);
2844 _In_ ULONG IoPriority
2848 BOOLEAN success =
TRUE;
2849 HANDLE threadHandle;
2853 THREAD_SET_INFORMATION,
2859 NtClose(threadHandle);
2881 PhpShowErrorThread(hWnd, L
"set the I/O priority of", Thread, status, 0);
2888 PhpShowErrorThread(hWnd, L
"set the I/O priority of", Thread, status, 0);
2898 _In_ ULONG PagePriority
2902 HANDLE threadHandle;
2906 THREAD_SET_INFORMATION,
2910 status = NtSetInformationThread(
2917 NtClose(threadHandle);
2922 PhpShowErrorThread(hWnd, L
"set the page priority of", Thread, status, 0);
2931 _In_ HANDLE ProcessId,
2936 BOOLEAN cont =
FALSE;
2937 HANDLE processHandle;
2944 switch (Module->Type)
2949 message = L
"Unloading a module may cause the process to crash.";
2952 message = L
"Unloading a module may cause the process to crash. NOTE: This feature may not work correctly on your version of Windows.";
2957 message = L
"Unloading a driver may cause system instability.";
2962 message = L
"Unmapping a section view may cause the process to crash.";
2971 Module->Name->Buffer,
2984 switch (Module->Type)
2995 LARGE_INTEGER timeout;
3000 Module->BaseAddress,
3004 NtClose(processHandle);
3007 if (status == STATUS_DLL_NOT_FOUND)
3009 PhShowError(hWnd, L
"Unable to find the module to unload.");
3027 status =
PhUnloadDriver(Module->BaseAddress, Module->Name->Buffer);
3031 BOOLEAN success =
FALSE;
3057 L
"Unable to unload ",
3058 Module->Name->Buffer,
3059 L
". Make sure Process Hacker is running with "
3060 L
"administrative privileges. Error"
3082 NtClose(processHandle);
3107 _In_ HANDLE ProcessId,
3113 BOOLEAN cont =
FALSE;
3114 HANDLE processHandle;
3121 if (!(MemoryItem->Type & (MEM_MAPPED | MEM_IMAGE)))
3126 message = L
"Freeing memory regions may cause the process to crash.";
3131 message = L
"Decommitting memory regions may cause the process to crash.";
3137 message = L
"Unmapping a section view may cause the process to crash.";
3143 L
"the memory region",
3165 baseAddress = MemoryItem->BaseAddress;
3167 if (!(MemoryItem->Type & (MEM_MAPPED | MEM_IMAGE)))
3173 regionSize = MemoryItem->RegionSize;
3179 Free ? MEM_RELEASE : MEM_DECOMMIT
3187 NtClose(processHandle);
3194 if (!(MemoryItem->Type & (MEM_MAPPED | MEM_IMAGE)))
3197 message = L
"Unable to free the memory region";
3199 message = L
"Unable to decommit the memory region";
3203 message = L
"Unable to unmap the section view";
3218 static BOOLEAN PhpShowErrorHandle(
3222 _In_ NTSTATUS Status,
3223 _In_opt_ ULONG Win32Result
3231 L
"Unable to %s handle \"%s\" (0x%Ix)",
3233 Handle->BestObjectName->Buffer,
3234 (ULONG)Handle->Handle
3245 L
"Unable to %s handle 0x%Ix",
3247 (ULONG)Handle->Handle
3257 _In_ HANDLE ProcessId,
3259 _In_ ULONG NumberOfHandles,
3264 BOOLEAN cont =
FALSE;
3265 BOOLEAN success =
TRUE;
3266 HANDLE processHandle;
3268 if (NumberOfHandles == 0)
3276 NumberOfHandles == 1 ? L
"the selected handle" : L
"the selected handles",
3277 L
"Closing handles may cause system instability and data corruption.",
3297 for (i = 0; i < NumberOfHandles; i++)
3306 DUPLICATE_CLOSE_SOURCE
3313 if (!PhpShowErrorHandle(
3324 NtClose(processHandle);
3328 PhShowStatus(hWnd, L
"Unable to open the process", status, 0);
3337 _In_ HANDLE ProcessId,
3339 _In_ ULONG Attributes
3343 HANDLE processHandle;
3370 NtClose(processHandle);
3375 PhpShowErrorHandle(hWnd, L
"set attributes of", Handle, status, 0);