ReactOS 0.4.15-dev-8241-g63935f8
endproc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ProcessPage_OnEndProcess (void)
 
BOOL IsCriticalProcess (HANDLE hProcess)
 
void ProcessPage_OnEndProcessTree (void)
 

Function Documentation

◆ IsCriticalProcess()

BOOL IsCriticalProcess ( HANDLE  hProcess)

Definition at line 68 of file endproc.c.

69{
71 ULONG BreakOnTermination;
72
73 /* return early if the process handle does not exist */
74 if (!hProcess)
75 return FALSE;
76
77 /* the important system processes that we don't want to let the user
78 kill come marked as critical, this simplifies the check greatly.
79
80 a critical process brings the system down when is terminated:
81 <http://www.geoffchappell.com/studies/windows/win32/ntdll/api/rtl/peb/setprocessiscritical.htm> */
82
85 &BreakOnTermination,
86 sizeof(ULONG),
87 NULL);
88
89 if (NT_SUCCESS(status) && BreakOnTermination)
90 return TRUE;
91
92 return FALSE;
93}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
@ ProcessBreakOnTermination
Definition: winternl.h:398
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59

Referenced by ProcessPage_OnEndProcess(), ProcessPage_OnEndProcessTree(), and ShutdownProcessTreeHelper().

◆ ProcessPage_OnEndProcess()

void ProcessPage_OnEndProcess ( void  )

Definition at line 15 of file endproc.c.

16{
17 DWORD dwProcessId;
19 WCHAR szTitle[256];
20 WCHAR strErrorText[260];
21
22 dwProcessId = GetSelectedProcessId();
23
24 if (dwProcessId == 0)
25 return;
26
28
29 /* forbid killing system processes even if we have privileges -- sigh, windows kludge! */
31 {
33 LoadStringW(hInst, IDS_MSG_CLOSESYSTEMPROCESS, strErrorText, 256);
36 return;
37 }
38
39 /* if this is a standard process just ask for confirmation before doing it */
40 LoadStringW(hInst, IDS_MSG_WARNINGTERMINATING, strErrorText, 256);
43 {
45 return;
46 }
47
48 /* no such process or not enough privileges to open its token */
49 if (!hProcess)
50 {
51 GetLastErrorText(strErrorText, 260);
54 return;
55 }
56
57 /* try to kill it, and notify the user if didn't work */
59 {
60 GetLastErrorText(strErrorText, 260);
63 }
64
66}
#define IDS_MSG_CLOSESYSTEMPROCESS
Definition: resource.h:258
#define IDS_MSG_WARNINGTERMINATING
Definition: resource.h:253
#define IDS_MSG_TASKMGRWARNING
Definition: resource.h:252
#define IDS_MSG_UNABLETERMINATEPRO
Definition: resource.h:254
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL IsCriticalProcess(HANDLE hProcess)
Definition: endproc.c:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PROCESS_TERMINATE
Definition: pstypes.h:157
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
HWND hMainWnd
Definition: magnifier.c:32
DWORD GetSelectedProcessId(void)
Definition: procpage.c:88
BOOL ConfirmMessageBox(HWND hWnd, LPCWSTR Text, LPCWSTR Title, UINT Type)
Definition: taskmgr.c:1059
LPWSTR GetLastErrorText(LPWSTR lpszBuf, DWORD dwSize)
Definition: taskmgr.c:1083
#define MB_TOPMOST
Definition: winuser.h:825
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MB_YESNO
Definition: winuser.h:817
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790
#define MB_ICONWARNING
Definition: winuser.h:786
#define MB_ICONSTOP
Definition: winuser.h:803
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ApplicationPageWndProc(), ProcessPageOnNotify(), ProcessPageWndProc(), and TaskManagerWndProc().

◆ ProcessPage_OnEndProcessTree()

void ProcessPage_OnEndProcessTree ( void  )

Definition at line 146 of file endproc.c.

147{
148 DWORD dwProcessId;
150 WCHAR szTitle[256];
151 WCHAR strErrorText[260];
152
153 dwProcessId = GetSelectedProcessId();
154
155 if (dwProcessId == 0)
156 return;
157
159
160 /* forbid killing system processes even if we have privileges -- sigh, windows kludge! */
162 {
164 LoadStringW(hInst, IDS_MSG_CLOSESYSTEMPROCESS, strErrorText, 256);
167 return;
168 }
169
170 LoadStringW(hInst, IDS_MSG_WARNINGTERMINATING, strErrorText, 256);
173 {
175 return;
176 }
177
178 if (!hProcess)
179 {
180 GetLastErrorText(strErrorText, 260);
183 return;
184 }
185
186 if (!ShutdownProcessTree(hProcess, dwProcessId))
187 {
188 GetLastErrorText(strErrorText, 260);
191 }
192
194}
BOOL ShutdownProcessTree(HANDLE hParentProcess, DWORD dwParentPID)
Definition: endproc.c:131

Referenced by TaskManagerWndProc().