2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2006-05-08 18:35:56 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2006-05-08 18:35:56 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2006-05-08 18:35:56 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2006-05-08 18:35:56 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2006-05-08 18:35:56 +00:00
|
|
|
|
|
|
|
#ifndef _BOINC_DIAGNOSTICS_WIN_
|
|
|
|
#define _BOINC_DIAGNOSTICS_WIN_
|
|
|
|
|
2012-08-01 21:02:54 +00:00
|
|
|
#include "boinc_win.h"
|
|
|
|
|
2006-05-08 18:35:56 +00:00
|
|
|
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
|
|
|
|
|
|
|
|
typedef LONG NTSTATUS;
|
|
|
|
|
|
|
|
typedef LONG KPRIORITY;
|
|
|
|
|
2014-04-28 18:57:58 +00:00
|
|
|
//MinGW-W64 defines this struct in its own header
|
2016-12-31 11:01:28 +00:00
|
|
|
#if !defined(HAVE_CLIENT_ID) && !defined(__MINGW32__)
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef struct _CLIENT_ID {
|
|
|
|
DWORD UniqueProcess;
|
|
|
|
DWORD UniqueThread;
|
|
|
|
} CLIENT_ID;
|
2014-04-28 18:57:58 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2014-04-28 18:57:58 +00:00
|
|
|
//MinGW-W64 defines this struct in its own header
|
2016-12-31 11:01:28 +00:00
|
|
|
#if !defined(HAVE_VM_COUNTERS) && !defined(__MINGW32__)
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef struct _VM_COUNTERS {
|
2007-06-01 22:34:47 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
// the following was inferred by painful reverse engineering
|
|
|
|
SIZE_T PeakVirtualSize; // not actually
|
|
|
|
SIZE_T PageFaultCount;
|
|
|
|
SIZE_T PeakWorkingSetSize;
|
|
|
|
SIZE_T WorkingSetSize;
|
|
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
|
|
SIZE_T PagefileUsage;
|
|
|
|
SIZE_T PeakPagefileUsage;
|
|
|
|
SIZE_T VirtualSize; // not actually
|
|
|
|
#else
|
2006-05-08 18:35:56 +00:00
|
|
|
SIZE_T PeakVirtualSize;
|
|
|
|
SIZE_T VirtualSize;
|
|
|
|
ULONG PageFaultCount;
|
|
|
|
SIZE_T PeakWorkingSetSize;
|
|
|
|
SIZE_T WorkingSetSize;
|
|
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
|
|
SIZE_T PagefileUsage;
|
|
|
|
SIZE_T PeakPagefileUsage;
|
2007-06-01 22:34:47 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
} VM_COUNTERS;
|
2014-04-28 18:57:58 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2014-04-28 18:57:58 +00:00
|
|
|
//MinGW-W64 defines this struct in its own header
|
2016-12-31 11:01:28 +00:00
|
|
|
#if !defined(HAVE_SYSTEM_THREADS) && !defined(__MINGW32__)
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef struct _SYSTEM_THREADS {
|
|
|
|
LARGE_INTEGER KernelTime;
|
|
|
|
LARGE_INTEGER UserTime;
|
|
|
|
LARGE_INTEGER CreateTime;
|
|
|
|
ULONG WaitTime;
|
|
|
|
PVOID StartAddress;
|
|
|
|
CLIENT_ID ClientId;
|
|
|
|
KPRIORITY Priority;
|
|
|
|
KPRIORITY BasePriority;
|
|
|
|
ULONG ContextSwitchCount;
|
|
|
|
LONG State;
|
|
|
|
LONG WaitReason;
|
|
|
|
} SYSTEM_THREADS, * PSYSTEM_THREADS;
|
2014-04-28 18:57:58 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2014-05-03 20:09:10 +00:00
|
|
|
#ifndef HAVE_SYSTEM_PROCESSES
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef struct _SYSTEM_PROCESSES {
|
|
|
|
ULONG NextEntryDelta;
|
|
|
|
ULONG ThreadCount;
|
|
|
|
ULONG Reserved1[6];
|
|
|
|
LARGE_INTEGER CreateTime;
|
|
|
|
LARGE_INTEGER UserTime;
|
|
|
|
LARGE_INTEGER KernelTime;
|
|
|
|
UNICODE_STRING ProcessName;
|
|
|
|
KPRIORITY BasePriority;
|
2007-06-01 22:34:47 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
ULONG pad1;
|
|
|
|
ULONG ProcessId;
|
|
|
|
ULONG pad2;
|
|
|
|
ULONG InheritedFromProcessId;
|
|
|
|
ULONG pad3, pad4, pad5;
|
|
|
|
#else
|
2006-05-08 18:35:56 +00:00
|
|
|
ULONG ProcessId;
|
|
|
|
ULONG InheritedFromProcessId;
|
2007-06-01 22:34:47 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
ULONG HandleCount;
|
|
|
|
ULONG Reserved2[2];
|
|
|
|
VM_COUNTERS VmCounters;
|
|
|
|
IO_COUNTERS IoCounters;
|
|
|
|
SYSTEM_THREADS Threads[1];
|
|
|
|
} SYSTEM_PROCESSES, * PSYSTEM_PROCESSES;
|
2014-05-02 22:40:59 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2014-04-28 18:57:58 +00:00
|
|
|
//MinGW-W64 defines this struct in its own header
|
2016-12-31 11:01:28 +00:00
|
|
|
#if !defined(HAVE_THREAD_STATE) && !defined(__MINGW32__)
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef enum _THREAD_STATE {
|
2014-04-28 18:57:58 +00:00
|
|
|
StateInitialized,
|
|
|
|
StateReady,
|
|
|
|
StateRunning,
|
|
|
|
StateStandby,
|
|
|
|
StateTerminated,
|
|
|
|
StateWait,
|
|
|
|
StateTransition
|
2006-05-08 18:35:56 +00:00
|
|
|
} THREAD_STATE, *PTHREAD_STATE;
|
2014-04-28 18:57:58 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2014-05-03 20:09:10 +00:00
|
|
|
#ifndef HAVE_THREAD_WAIT_REASON
|
2006-05-08 18:35:56 +00:00
|
|
|
typedef enum _THREAD_WAIT_REASON {
|
|
|
|
ThreadWaitReasonExecutive,
|
|
|
|
ThreadWaitReasonFreePage,
|
|
|
|
ThreadWaitReasonPageIn,
|
|
|
|
ThreadWaitReasonPoolAllocation,
|
|
|
|
ThreadWaitReasonDelayExecution,
|
|
|
|
ThreadWaitReasonSuspended,
|
|
|
|
ThreadWaitReasonUserRequest,
|
|
|
|
ThreadWaitReasonWrExecutive,
|
|
|
|
ThreadWaitReasonWrFreePage,
|
|
|
|
ThreadWaitReasonWrPageIn,
|
|
|
|
ThreadWaitReasonWrPoolAllocation,
|
|
|
|
ThreadWaitReasonWrDelayExecution,
|
|
|
|
ThreadWaitReasonWrSuspended,
|
|
|
|
ThreadWaitReasonWrUserRequest,
|
|
|
|
ThreadWaitReasonWrEventPairHigh,
|
|
|
|
ThreadWaitReasonWrEventPairLow,
|
|
|
|
ThreadWaitReasonWrLpcReceive,
|
|
|
|
ThreadWaitReasonWrLpcReply,
|
|
|
|
ThreadWaitReasonWrVirtualMemory,
|
|
|
|
ThreadWaitReasonWrPageOut,
|
|
|
|
ThreadWaitReasonMaximumWaitReason
|
|
|
|
} THREAD_WAIT_REASON;
|
2014-05-03 20:09:10 +00:00
|
|
|
#endif
|
2006-05-08 18:35:56 +00:00
|
|
|
|
2017-02-17 13:48:48 +00:00
|
|
|
// older mingw versions (before 2012-07-12) do not define this in winternl.h
|
|
|
|
#if defined(__MINGW32__)
|
|
|
|
#ifndef NT_SUCCESS
|
|
|
|
#define NT_SUCCESS(status) ((NTSTATUS) (status) >= 0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2006-05-08 18:35:56 +00:00
|
|
|
#endif
|