1 // Berkeley Open Infrastructure for Network Computing 2 // http://boinc.berkeley.edu 3 // Copyright (C) 2005 University of California 4 // 5 // This is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU Lesser General Public 7 // License as published by the Free Software Foundation; 8 // either version 2.1 of the License, or (at your option) any later version. 9 // 10 // This software is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 // See the GNU Lesser General Public License for more details. 14 // 15 // To view the GNU Lesser General Public License visit 16 // http://www.gnu.org/copyleft/lesser.html 17 // or write to the Free Software Foundation, Inc., 18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 // 20 21 #ifndef _BOINC_TERMINATE_ 22 #define _BOINC_TERMINATE_ 23 24 #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0) 25 #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L) 26 #define SystemProcessAndThreadInformation 5 27 28 typedef LONG NTSTATUS; 29 30 typedef LONG KPRIORITY; 31 32 typedef struct _CLIENT_ID { 33 DWORD UniqueProcess; 34 DWORD UniqueThread; 35 } CLIENT_ID; 36 37 typedef struct _VM_COUNTERS { 38 SIZE_T PeakVirtualSize; 39 SIZE_T VirtualSize; 40 ULONG PageFaultCount; 41 SIZE_T PeakWorkingSetSize; 42 SIZE_T WorkingSetSize; 43 SIZE_T QuotaPeakPagedPoolUsage; 44 SIZE_T QuotaPagedPoolUsage; 45 SIZE_T QuotaPeakNonPagedPoolUsage; 46 SIZE_T QuotaNonPagedPoolUsage; 47 SIZE_T PagefileUsage; 48 SIZE_T PeakPagefileUsage; 49 } VM_COUNTERS; 50 51 typedef struct _SYSTEM_THREADS { 52 LARGE_INTEGER KernelTime; 53 LARGE_INTEGER UserTime; 54 LARGE_INTEGER CreateTime; 55 ULONG WaitTime; 56 PVOID StartAddress; 57 CLIENT_ID ClientId; 58 KPRIORITY Priority; 59 KPRIORITY BasePriority; 60 ULONG ContextSwitchCount; 61 LONG State; 62 LONG WaitReason; 63 } SYSTEM_THREADS, * PSYSTEM_THREADS; 64 65 typedef struct _SYSTEM_PROCESSES_NT4 { 66 ULONG NextEntryDelta; 67 ULONG ThreadCount; 68 ULONG Reserved1[6]; 69 LARGE_INTEGER CreateTime; 70 LARGE_INTEGER UserTime; 71 LARGE_INTEGER KernelTime; 72 UNICODE_STRING ProcessName; 73 KPRIORITY BasePriority; 74 ULONG ProcessId; 75 ULONG InheritedFromProcessId; 76 ULONG HandleCount; 77 ULONG Reserved2[2]; 78 VM_COUNTERS VmCounters; 79 SYSTEM_THREADS Threads[1]; 80 } SYSTEM_PROCESSES_NT4, *PSYSTEM_PROCESSES_NT4; 81 82 typedef struct _SYSTEM_PROCESSES { 83 ULONG NextEntryDelta; 84 ULONG ThreadCount; 85 ULONG Reserved1[6]; 86 LARGE_INTEGER CreateTime; 87 LARGE_INTEGER UserTime; 88 LARGE_INTEGER KernelTime; 89 UNICODE_STRING ProcessName; 90 KPRIORITY BasePriority; 91 #ifdef _WIN64 92 ULONG pad1; 93 ULONG ProcessId; 94 ULONG pad2; 95 ULONG InheritedFromProcessId; 96 ULONG pad3, pad4, pad5; 97 #else 98 ULONG ProcessId; 99 ULONG InheritedFromProcessId; 100 #endif 101 ULONG HandleCount; 102 ULONG Reserved2[2]; 103 VM_COUNTERS VmCounters; 104 IO_COUNTERS IoCounters; 105 SYSTEM_THREADS Threads[1]; 106 } SYSTEM_PROCESSES, * PSYSTEM_PROCESSES; 107 108 typedef enum _THREAD_STATE { 109 ThreadStateInitialized, 110 ThreadStateReady, 111 ThreadStateRunning, 112 ThreadStateStandby, 113 ThreadStateTerminated, 114 ThreadStateWaiting, 115 ThreadStateTransition 116 } THREAD_STATE, *PTHREAD_STATE; 117 118 typedef enum _THREAD_WAIT_REASON { 119 ThreadWaitReasonExecutive, 120 ThreadWaitReasonFreePage, 121 ThreadWaitReasonPageIn, 122 ThreadWaitReasonPoolAllocation, 123 ThreadWaitReasonDelayExecution, 124 ThreadWaitReasonSuspended, 125 ThreadWaitReasonUserRequest, 126 ThreadWaitReasonWrExecutive, 127 ThreadWaitReasonWrFreePage, 128 ThreadWaitReasonWrPageIn, 129 ThreadWaitReasonWrPoolAllocation, 130 ThreadWaitReasonWrDelayExecution, 131 ThreadWaitReasonWrSuspended, 132 ThreadWaitReasonWrUserRequest, 133 ThreadWaitReasonWrEventPairHigh, 134 ThreadWaitReasonWrEventPairLow, 135 ThreadWaitReasonWrLpcReceive, 136 ThreadWaitReasonWrLpcReply, 137 ThreadWaitReasonWrVirtualMemory, 138 ThreadWaitReasonWrPageOut, 139 ThreadWaitReasonMaximumWaitReason 140 } THREAD_WAIT_REASON; 141 142 143 // Prototypes 144 BOOL TerminateProcessEx( tstring& strProcessName, bool bRecursive = true ); 145 146 147 #endif 148 149