Process Hacker
thrdact.c
Go to the documentation of this file.
1 /*
2  * Process Hacker Extended Tools -
3  * thread actions extensions
4  *
5  * Copyright (C) 2010 wj32
6  *
7  * This file is part of Process Hacker.
8  *
9  * Process Hacker is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * Process Hacker is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "exttools.h"
24 #include "resource.h"
25 
27  _In_ HWND hWnd,
28  _In_ PPH_THREAD_ITEM Thread
29  )
30 {
31  NTSTATUS status;
32  BOOLEAN cont = FALSE;
33  HANDLE threadHandle;
34  IO_STATUS_BLOCK isb;
35 
36  if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
37  hWnd,
38  L"end",
39  L"I/O for the selected thread",
40  NULL,
41  FALSE
42  ))
43  cont = TRUE;
44 
45  if (!cont)
46  return FALSE;
47 
48  if (NT_SUCCESS(status = PhOpenThread(&threadHandle, THREAD_TERMINATE, Thread->ThreadId)))
49  {
50  status = NtCancelSynchronousIoFile(threadHandle, NULL, &isb);
51  }
52 
53  if (status == STATUS_NOT_FOUND)
54  {
55  PhShowInformation(hWnd, L"There is no synchronous I/O to cancel.");
56  return FALSE;
57  }
58  else if (!NT_SUCCESS(status))
59  {
60  PhShowStatus(hWnd, L"Unable to cancel synchronous I/O", status, 0);
61  return FALSE;
62  }
63 
64  return TRUE;
65 }