Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
31f88936
Commit
31f88936
authored
Sep 11, 2013
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taskmgr: Use definitions from winternl.h instead of duplicating them.
parent
69abf20f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
357 deletions
+72
-357
winternl.h
include/winternl.h
+1
-1
perfdata.c
programs/taskmgr/perfdata.c
+66
-75
perfdata.h
programs/taskmgr/perfdata.h
+5
-280
taskmgr.c
programs/taskmgr/taskmgr.c
+0
-1
No files found.
include/winternl.h
View file @
31f88936
...
...
@@ -1363,7 +1363,7 @@ typedef struct _SYSTEM_PROCESS_INFORMATION {
HANDLE
UniqueProcessId
;
/* 44/50 */
HANDLE
ParentProcessId
;
/* 48/58 */
ULONG
HandleCount
;
/* 4c/60 */
DWORD
dwUnknown3
;
/* 50/64 */
ULONG
SessionId
;
/* 50/64 */
DWORD
dwUnknown4
;
/* 54/68 */
VM_COUNTERS
vmCounters
;
/* 58/70 */
IO_COUNTERS
ioCounters
;
/* 88/d0 */
...
...
programs/taskmgr/perfdata.c
View file @
31f88936
...
...
@@ -30,7 +30,7 @@
#include "taskmgr.h"
#include "perfdata.h"
static
PROCNTQSI
NtQuerySystemInformation
=
NULL
;
static
PROCNTQSI
p
NtQuerySystemInformation
=
NULL
;
static
PROCGGR
pGetGuiResources
=
NULL
;
static
PROCGPIC
pGetProcessIoCounters
=
NULL
;
static
CRITICAL_SECTION
PerfDataCriticalSection
;
...
...
@@ -48,7 +48,7 @@ static SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo;
static
SYSTEM_BASIC_INFORMATION
SystemBasicInfo
;
static
SYSTEM_CACHE_INFORMATION
SystemCacheInfo
;
static
SYSTEM_HANDLE_INFORMATION
SystemHandleInfo
;
static
PSYSTEM_PROCESSOR
TIME_INFO
SystemProcessorTimeInfo
=
NULL
;
static
PSYSTEM_PROCESSOR
_PERFORMANCE_INFORMATION
SystemProcessorTimeInfo
=
NULL
;
BOOL
PerfDataInitialize
(
void
)
{
...
...
@@ -57,32 +57,25 @@ BOOL PerfDataInitialize(void)
static
const
WCHAR
wszUser32
[]
=
{
'u'
,
's'
,
'e'
,
'r'
,
'3'
,
'2'
,
'.'
,
'd'
,
'l'
,
'l'
,
0
};
static
const
WCHAR
wszKernel32
[]
=
{
'k'
,
'e'
,
'r'
,
'n'
,
'e'
,
'l'
,
'3'
,
'2'
,
'.'
,
'd'
,
'l'
,
'l'
,
0
};
NtQuerySystemInformation
=
(
PROCNTQSI
)
GetProcAddress
(
GetModuleHandleW
(
wszNtdll
),
"NtQuerySystemInformation"
);
p
NtQuerySystemInformation
=
(
PROCNTQSI
)
GetProcAddress
(
GetModuleHandleW
(
wszNtdll
),
"NtQuerySystemInformation"
);
pGetGuiResources
=
(
PROCGGR
)
GetProcAddress
(
GetModuleHandleW
(
wszUser32
),
"GetGuiResources"
);
pGetProcessIoCounters
=
(
PROCGPIC
)
GetProcAddress
(
GetModuleHandleW
(
wszKernel32
),
"GetProcessIoCounters"
);
InitializeCriticalSection
(
&
PerfDataCriticalSection
);
if
(
!
NtQuerySystemInformation
)
if
(
!
p
NtQuerySystemInformation
)
return
FALSE
;
/*
* Get number of processors in the system
*/
status
=
NtQuerySystemInformation
(
SystemBasicInformation
,
&
SystemBasicInfo
,
sizeof
(
SystemBasicInfo
),
NULL
);
status
=
p
NtQuerySystemInformation
(
SystemBasicInformation
,
&
SystemBasicInfo
,
sizeof
(
SystemBasicInfo
),
NULL
);
if
(
status
!=
NO_ERROR
)
return
FALSE
;
return
TRUE
;
}
void
PerfDataUninitialize
(
void
)
{
NtQuerySystemInformation
=
NULL
;
DeleteCriticalSection
(
&
PerfDataCriticalSection
);
}
void
PerfDataRefresh
(
void
)
{
ULONG
ulSize
;
...
...
@@ -97,35 +90,32 @@ void PerfDataRefresh(void)
WCHAR
wszTemp
[
MAX_PATH
];
DWORD
dwSize
;
SYSTEM_PERFORMANCE_INFORMATION
SysPerfInfo
;
SYSTEM_TIME
_INFORMATION
SysTimeInfo
;
SYSTEM_TIME
OFDAY_INFORMATION
SysTimeInfo
;
SYSTEM_CACHE_INFORMATION
SysCacheInfo
;
LPBYTE
SysHandleInfoData
;
PSYSTEM_PROCESSORTIME_INFO
SysProcessorTimeInfo
;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
*
SysProcessorTimeInfo
;
double
CurrentKernelTime
;
if
(
!
NtQuerySystemInformation
)
return
;
/* Get new system time */
status
=
NtQuerySystemInformation
(
SystemTime
Information
,
&
SysTimeInfo
,
sizeof
(
SysTimeInfo
),
0
);
status
=
pNtQuerySystemInformation
(
SystemTimeOfDay
Information
,
&
SysTimeInfo
,
sizeof
(
SysTimeInfo
),
0
);
if
(
status
!=
NO_ERROR
)
return
;
/* Get new CPU's idle time */
status
=
NtQuerySystemInformation
(
SystemPerformanceInformation
,
&
SysPerfInfo
,
sizeof
(
SysPerfInfo
),
NULL
);
status
=
p
NtQuerySystemInformation
(
SystemPerformanceInformation
,
&
SysPerfInfo
,
sizeof
(
SysPerfInfo
),
NULL
);
if
(
status
!=
NO_ERROR
)
return
;
/* Get system cache information */
status
=
NtQuerySystemInformation
(
SystemCacheInformation
,
&
SysCacheInfo
,
sizeof
(
SysCacheInfo
),
NULL
);
status
=
p
NtQuerySystemInformation
(
SystemCacheInformation
,
&
SysCacheInfo
,
sizeof
(
SysCacheInfo
),
NULL
);
if
(
status
!=
NO_ERROR
)
return
;
/* Get processor time information */
SysProcessorTimeInfo
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SYSTEM_PROCESSORTIME_INFO
)
*
SystemBasicInfo
.
bKeNumber
Processors
);
status
=
NtQuerySystemInformation
(
SystemProcessorTimeInformation
,
SysProcessorTimeInfo
,
sizeof
(
SYSTEM_PROCESSORTIME_INFO
)
*
SystemBasicInfo
.
bKeNumber
Processors
,
&
ulSize
);
sizeof
(
*
SysProcessorTimeInfo
)
*
SystemBasicInfo
.
NumberOf
Processors
);
status
=
pNtQuerySystemInformation
(
SystemProcessorPerformanceInformation
,
SysProcessorTimeInfo
,
sizeof
(
*
SysProcessorTimeInfo
)
*
SystemBasicInfo
.
NumberOf
Processors
,
&
ulSize
);
if
(
status
!=
NO_ERROR
)
{
HeapFree
(
GetProcessHeap
(),
0
,
SysProcessorTimeInfo
);
return
;
...
...
@@ -141,7 +131,7 @@ void PerfDataRefresh(void)
BufferSize
+=
0x10000
;
SysHandleInfoData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BufferSize
);
status
=
NtQuerySystemInformation
(
SystemHandleInformation
,
SysHandleInfoData
,
BufferSize
,
&
ulSize
);
status
=
p
NtQuerySystemInformation
(
SystemHandleInformation
,
SysHandleInfoData
,
BufferSize
,
&
ulSize
);
if
(
status
==
0xC0000004
/*STATUS_INFO_LENGTH_MISMATCH*/
)
{
HeapFree
(
GetProcessHeap
(),
0
,
SysHandleInfoData
);
...
...
@@ -159,7 +149,7 @@ void PerfDataRefresh(void)
BufferSize
+=
0x10000
;
pBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BufferSize
);
status
=
NtQuerySystemInformation
(
SystemProcessInformation
,
pBuffer
,
BufferSize
,
&
ulSize
);
status
=
p
NtQuerySystemInformation
(
SystemProcessInformation
,
pBuffer
,
BufferSize
,
&
ulSize
);
if
(
status
==
0xC0000004
/*STATUS_INFO_LENGTH_MISMATCH*/
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pBuffer
);
...
...
@@ -191,16 +181,16 @@ void PerfDataRefresh(void)
memcpy
(
&
SystemHandleInfo
,
SysHandleInfoData
,
sizeof
(
SYSTEM_HANDLE_INFORMATION
));
HeapFree
(
GetProcessHeap
(),
0
,
SysHandleInfoData
);
for
(
CurrentKernelTime
=
0
,
Idx
=
0
;
Idx
<
SystemBasicInfo
.
bKeNumber
Processors
;
Idx
++
)
{
for
(
CurrentKernelTime
=
0
,
Idx
=
0
;
Idx
<
SystemBasicInfo
.
NumberOf
Processors
;
Idx
++
)
{
CurrentKernelTime
+=
Li2Double
(
SystemProcessorTimeInfo
[
Idx
].
KernelTime
);
CurrentKernelTime
+=
Li2Double
(
SystemProcessorTimeInfo
[
Idx
].
DpcTime
);
CurrentKernelTime
+=
Li2Double
(
SystemProcessorTimeInfo
[
Idx
].
InterruptTime
);
CurrentKernelTime
+=
Li2Double
(
SystemProcessorTimeInfo
[
Idx
].
Reserved1
[
0
]
);
CurrentKernelTime
+=
Li2Double
(
SystemProcessorTimeInfo
[
Idx
].
Reserved1
[
1
]
);
}
/* If it's a first call - skip idle time calcs */
if
(
liOldIdleTime
.
QuadPart
!=
0
)
{
/* CurrentValue = NewValue - OldValue */
dbIdleTime
=
Li2Double
(
SysPerfInfo
.
li
IdleTime
)
-
Li2Double
(
liOldIdleTime
);
dbIdleTime
=
Li2Double
(
SysPerfInfo
.
IdleTime
)
-
Li2Double
(
liOldIdleTime
);
dbKernelTime
=
CurrentKernelTime
-
OldKernelTime
;
dbSystemTime
=
Li2Double
(
SysTimeInfo
.
liKeSystemTime
)
-
Li2Double
(
liOldSystemTime
);
...
...
@@ -209,12 +199,12 @@ void PerfDataRefresh(void)
dbKernelTime
=
dbKernelTime
/
dbSystemTime
;
/* CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors */
dbIdleTime
=
100
.
0
-
dbIdleTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
bKeNumber
Processors
;
/* + 0.5; */
dbKernelTime
=
100
.
0
-
dbKernelTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
bKeNumber
Processors
;
/* + 0.5; */
dbIdleTime
=
100
.
0
-
dbIdleTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
NumberOf
Processors
;
/* + 0.5; */
dbKernelTime
=
100
.
0
-
dbKernelTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
NumberOf
Processors
;
/* + 0.5; */
}
/* Store new CPU's idle and system time */
liOldIdleTime
=
SysPerfInfo
.
li
IdleTime
;
liOldIdleTime
=
SysPerfInfo
.
IdleTime
;
liOldSystemTime
=
SysTimeInfo
.
liKeSystemTime
;
OldKernelTime
=
CurrentKernelTime
;
...
...
@@ -227,9 +217,9 @@ void PerfDataRefresh(void)
pSPI
=
(
PSYSTEM_PROCESS_INFORMATION
)
pBuffer
;
while
(
pSPI
)
{
ProcessCount
++
;
if
(
pSPI
->
Relative
Offset
==
0
)
if
(
pSPI
->
NextEntry
Offset
==
0
)
break
;
pSPI
=
(
PSYSTEM_PROCESS_INFORMATION
)((
LPBYTE
)
pSPI
+
pSPI
->
Relative
Offset
);
pSPI
=
(
PSYSTEM_PROCESS_INFORMATION
)((
LPBYTE
)
pSPI
+
pSPI
->
NextEntry
Offset
);
}
/* Now alloc a new PERFDATA array and fill in the data */
...
...
@@ -242,7 +232,7 @@ void PerfDataRefresh(void)
/* so that we can establish delta values */
pPDOld
=
NULL
;
for
(
Idx2
=
0
;
Idx2
<
ProcessCountOld
;
Idx2
++
)
{
if
(
pPerfDataOld
[
Idx2
].
ProcessId
==
pSPI
->
ProcessId
)
{
if
(
pPerfDataOld
[
Idx2
].
ProcessId
==
(
DWORD_PTR
)
pSPI
->
Unique
ProcessId
)
{
pPDOld
=
&
pPerfDataOld
[
Idx2
];
break
;
}
...
...
@@ -251,8 +241,8 @@ void PerfDataRefresh(void)
/* Clear out process perf data structure */
memset
(
&
pPerfData
[
Idx
],
0
,
sizeof
(
PERFDATA
));
if
(
pSPI
->
Name
.
Buffer
)
lstrcpyW
(
pPerfData
[
Idx
].
ImageName
,
pSPI
->
Name
.
Buffer
);
if
(
pSPI
->
Process
Name
.
Buffer
)
lstrcpyW
(
pPerfData
[
Idx
].
ImageName
,
pSPI
->
Process
Name
.
Buffer
);
else
{
WCHAR
idleW
[
255
];
...
...
@@ -260,36 +250,37 @@ void PerfDataRefresh(void)
lstrcpyW
(
pPerfData
[
Idx
].
ImageName
,
idleW
);
}
pPerfData
[
Idx
].
ProcessId
=
pSPI
->
ProcessId
;
pPerfData
[
Idx
].
ProcessId
=
(
DWORD_PTR
)
pSPI
->
Unique
ProcessId
;
if
(
pPDOld
)
{
double
CurTime
=
Li2Double
(
pSPI
->
KernelTime
)
+
Li2Double
(
pSPI
->
UserTime
);
double
OldTime
=
Li2Double
(
pPDOld
->
KernelTime
)
+
Li2Double
(
pPDOld
->
UserTime
);
double
CpuTime
=
(
CurTime
-
OldTime
)
/
dbSystemTime
;
CpuTime
=
CpuTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
bKeNumber
Processors
;
/* + 0.5; */
CpuTime
=
CpuTime
*
100
.
0
/
(
double
)
SystemBasicInfo
.
NumberOf
Processors
;
/* + 0.5; */
pPerfData
[
Idx
].
CPUUsage
=
(
ULONG
)
CpuTime
;
}
pPerfData
[
Idx
].
CPUTime
.
QuadPart
=
pSPI
->
UserTime
.
QuadPart
+
pSPI
->
KernelTime
.
QuadPart
;
pPerfData
[
Idx
].
WorkingSetSizeBytes
=
pSPI
->
TotalWorkingSetSizeBytes
;
pPerfData
[
Idx
].
PeakWorkingSetSizeBytes
=
pSPI
->
PeakWorkingSetSizeBytes
;
pPerfData
[
Idx
].
vmCounters
.
WorkingSetSize
=
pSPI
->
vmCounters
.
WorkingSetSize
;
pPerfData
[
Idx
].
vmCounters
.
PeakWorkingSetSize
=
pSPI
->
vmCounters
.
PeakWorkingSetSize
;
if
(
pPDOld
)
pPerfData
[
Idx
].
WorkingSetSizeDelta
=
labs
(
(
LONG
)
pSPI
->
TotalWorkingSetSizeBytes
-
(
LONG
)
pPDOld
->
WorkingSetSizeBytes
);
pPerfData
[
Idx
].
WorkingSetSizeDelta
=
labs
(
pSPI
->
vmCounters
.
WorkingSetSize
-
pPDOld
->
vmCounters
.
WorkingSetSize
);
else
pPerfData
[
Idx
].
WorkingSetSizeDelta
=
0
;
pPerfData
[
Idx
].
PageFaultCount
=
pSPI
->
PageFaultCount
;
pPerfData
[
Idx
].
vmCounters
.
PageFaultCount
=
pSPI
->
vmCounters
.
PageFaultCount
;
if
(
pPDOld
)
pPerfData
[
Idx
].
PageFaultCountDelta
=
labs
(
(
LONG
)
pSPI
->
PageFaultCount
-
(
LONG
)
pPDOld
->
PageFaultCount
);
pPerfData
[
Idx
].
PageFaultCountDelta
=
labs
(
pSPI
->
vmCounters
.
PageFaultCount
-
pPDOld
->
vmCounters
.
PageFaultCount
);
else
pPerfData
[
Idx
].
PageFaultCountDelta
=
0
;
pPerfData
[
Idx
].
VirtualMemorySizeBytes
=
pSPI
->
TotalVirtualSizeBytes
;
pPerfData
[
Idx
].
PagedPoolUsagePages
=
pSPI
->
TotalPagedPoolUsagePages
;
pPerfData
[
Idx
].
NonPagedPoolUsagePages
=
pSPI
->
TotalNonPagedPoolUsagePages
;
pPerfData
[
Idx
].
BasePriority
=
pSPI
->
BasePriority
;
pPerfData
[
Idx
].
vmCounters
.
VirtualSize
=
pSPI
->
vmCounters
.
VirtualSize
;
pPerfData
[
Idx
].
vmCounters
.
QuotaPagedPoolUsage
=
pSPI
->
vmCounters
.
QuotaPagedPoolUsage
;
pPerfData
[
Idx
].
vmCounters
.
QuotaNonPagedPoolUsage
=
pSPI
->
vmCounters
.
QuotaNonPagedPoolUsage
;
pPerfData
[
Idx
].
BasePriority
=
pSPI
->
dw
BasePriority
;
pPerfData
[
Idx
].
HandleCount
=
pSPI
->
HandleCount
;
pPerfData
[
Idx
].
ThreadCount
=
pSPI
->
ThreadCount
;
pPerfData
[
Idx
].
ThreadCount
=
pSPI
->
dw
ThreadCount
;
pPerfData
[
Idx
].
SessionId
=
pSPI
->
SessionId
;
hProcess
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
,
FALSE
,
pSPI
->
ProcessId
);
hProcess
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
,
FALSE
,
(
DWORD_PTR
)
pSPI
->
Unique
ProcessId
);
if
(
hProcess
)
{
if
(
OpenProcessToken
(
hProcess
,
TOKEN_QUERY
|
TOKEN_DUPLICATE
|
TOKEN_IMPERSONATE
,
&
hProcessToken
))
{
ImpersonateLoggedOnUser
(
hProcessToken
);
...
...
@@ -309,7 +300,7 @@ void PerfDataRefresh(void)
}
pPerfData
[
Idx
].
UserTime
.
QuadPart
=
pSPI
->
UserTime
.
QuadPart
;
pPerfData
[
Idx
].
KernelTime
.
QuadPart
=
pSPI
->
KernelTime
.
QuadPart
;
pSPI
=
(
PSYSTEM_PROCESS_INFORMATION
)((
LPBYTE
)
pSPI
+
pSPI
->
Relative
Offset
);
pSPI
=
(
PSYSTEM_PROCESS_INFORMATION
)((
LPBYTE
)
pSPI
+
pSPI
->
NextEntry
Offset
);
}
HeapFree
(
GetProcessHeap
(),
0
,
pBuffer
);
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -441,7 +432,7 @@ ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
WorkingSetSizeBytes
=
pPerfData
[
Index
].
WorkingSetSizeBytes
;
WorkingSetSizeBytes
=
pPerfData
[
Index
].
vmCounters
.
WorkingSetSize
;
else
WorkingSetSizeBytes
=
0
;
...
...
@@ -457,7 +448,7 @@ ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
PeakWorkingSetSizeBytes
=
pPerfData
[
Index
].
PeakWorkingSetSizeBytes
;
PeakWorkingSetSizeBytes
=
pPerfData
[
Index
].
vmCounters
.
PeakWorkingSetSize
;
else
PeakWorkingSetSizeBytes
=
0
;
...
...
@@ -489,7 +480,7 @@ ULONG PerfDataGetPageFaultCount(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
PageFaultCount
=
pPerfData
[
Index
].
PageFaultCount
;
PageFaultCount
=
pPerfData
[
Index
].
vmCounters
.
PageFaultCount
;
else
PageFaultCount
=
0
;
...
...
@@ -521,7 +512,7 @@ ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
VirtualMemorySizeBytes
=
pPerfData
[
Index
].
VirtualMemorySizeBytes
;
VirtualMemorySizeBytes
=
pPerfData
[
Index
].
vmCounters
.
VirtualSize
;
else
VirtualMemorySizeBytes
=
0
;
...
...
@@ -537,7 +528,7 @@ ULONG PerfDataGetPagedPoolUsagePages(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
PagedPoolUsagePages
=
pPerfData
[
Index
].
PagedPoolUsagePages
;
PagedPoolUsagePages
=
pPerfData
[
Index
].
vmCounters
.
QuotaPagedPoolUsage
;
else
PagedPoolUsagePages
=
0
;
...
...
@@ -553,7 +544,7 @@ ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
if
(
Index
<
ProcessCount
)
NonPagedPoolUsagePages
=
pPerfData
[
Index
].
NonPagedPoolUsagePages
;
NonPagedPoolUsagePages
=
pPerfData
[
Index
].
vmCounters
.
QuotaNonPagedPoolUsage
;
else
NonPagedPoolUsagePages
=
0
;
...
...
@@ -668,8 +659,8 @@ ULONG PerfDataGetCommitChargeTotalK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Total
=
SystemPerfInfo
.
Mm
TotalCommittedPages
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Total
=
SystemPerfInfo
.
TotalCommittedPages
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -685,8 +676,8 @@ ULONG PerfDataGetCommitChargeLimitK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Limit
=
SystemPerfInfo
.
Mm
TotalCommitLimit
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Limit
=
SystemPerfInfo
.
TotalCommitLimit
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -702,8 +693,8 @@ ULONG PerfDataGetCommitChargePeakK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Peak
=
SystemPerfInfo
.
MmPeakLimi
t
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Peak
=
SystemPerfInfo
.
PeakCommitmen
t
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -721,9 +712,9 @@ ULONG PerfDataGetKernelMemoryTotalK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Paged
=
SystemPerfInfo
.
P
oolPagedBytes
;
NonPaged
=
SystemPerfInfo
.
PoolNonPagedBytes
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Paged
=
SystemPerfInfo
.
P
agedPoolUsage
;
NonPaged
=
SystemPerfInfo
.
NonPagedPoolUsage
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -742,8 +733,8 @@ ULONG PerfDataGetKernelMemoryPagedK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Paged
=
SystemPerfInfo
.
P
oolPagedBytes
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Paged
=
SystemPerfInfo
.
P
agedPoolUsage
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -759,8 +750,8 @@ ULONG PerfDataGetKernelMemoryNonPagedK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
NonPaged
=
SystemPerfInfo
.
PoolNonPagedBytes
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
NonPaged
=
SystemPerfInfo
.
NonPagedPoolUsage
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -776,8 +767,8 @@ ULONG PerfDataGetPhysicalMemoryTotalK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Total
=
SystemBasicInfo
.
u
MmNumberOfPhysicalPages
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Total
=
SystemBasicInfo
.
MmNumberOfPhysicalPages
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
@@ -793,8 +784,8 @@ ULONG PerfDataGetPhysicalMemoryAvailableK(void)
EnterCriticalSection
(
&
PerfDataCriticalSection
);
Available
=
SystemPerfInfo
.
Mm
AvailablePages
;
PageSize
=
SystemBasicInfo
.
u
PageSize
;
Available
=
SystemPerfInfo
.
AvailablePages
;
PageSize
=
SystemBasicInfo
.
PageSize
;
LeaveCriticalSection
(
&
PerfDataCriticalSection
);
...
...
programs/taskmgr/perfdata.h
View file @
31f88936
...
...
@@ -23,25 +23,9 @@
#ifndef __PERFDATA_H
#define __PERFDATA_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "winternl.h"
#if 0
typedef struct _TIME {
DWORD LowPart;
LONG HighPart;
} TIME, *PTIME;
#endif
typedef
ULARGE_INTEGER
TIME
,
*
PTIME
;
typedef
struct
_UNICODE_STRING
{
USHORT
Length
;
USHORT
MaximumLength
;
PWSTR
Buffer
;
}
UNICODE_STRING
,
*
PUNICODE_STRING
;
typedef
ULARGE_INTEGER
TIME
;
typedef
struct
_PERFDATA
{
...
...
@@ -51,227 +35,20 @@ typedef struct _PERFDATA
ULONG
SessionId
;
ULONG
CPUUsage
;
TIME
CPUTime
;
ULONG
WorkingSetSizeBytes
;
ULONG
PeakWorkingSetSizeBytes
;
ULONG
WorkingSetSizeDelta
;
ULONG
PageFaultCount
;
ULONG
PageFaultCountDelta
;
ULONG
VirtualMemorySizeBytes
;
ULONG
PagedPoolUsagePages
;
ULONG
NonPagedPoolUsagePages
;
ULONG
BasePriority
;
ULONG
HandleCount
;
ULONG
ThreadCount
;
ULONG
USERObjectCount
;
ULONG
GDIObjectCount
;
SIZE_T
WorkingSetSizeDelta
;
ULONG
PageFaultCountDelta
;
VM_COUNTERS
vmCounters
;
IO_COUNTERS
IOCounters
;
TIME
UserTime
;
TIME
KernelTime
;
}
PERFDATA
,
*
PPERFDATA
;
typedef
struct
_CLIENT_ID
{
HANDLE
UniqueProcess
;
HANDLE
UniqueThread
;
}
CLIENT_ID
,
*
PCLIENT_ID
;
typedef
enum
_KWAIT_REASON
{
Executive
,
FreePage
,
PageIn
,
PoolAllocation
,
DelayExecution
,
Suspended
,
UserRequest
,
WrExecutive
,
WrFreePage
,
WrPageIn
,
WrDelayExecution
,
WrSuspended
,
WrUserRequest
,
WrQueue
,
WrLpcReceive
,
WrLpcReply
,
WrVirtualMemory
,
WrPageOut
,
WrRendezvous
,
Spare2
,
Spare3
,
Spare4
,
Spare5
,
Spare6
,
WrKernel
,
MaximumWaitReason
,
}
KWAIT_REASON
;
/* SystemProcessThreadInfo (5) */
typedef
struct
_SYSTEM_THREAD_INFORMATION
{
TIME
KernelTime
;
TIME
UserTime
;
TIME
CreateTime
;
ULONG
TickCount
;
ULONG
StartEIP
;
CLIENT_ID
ClientId
;
ULONG
DynamicPriority
;
ULONG
BasePriority
;
ULONG
nSwitches
;
DWORD
State
;
KWAIT_REASON
WaitReason
;
}
SYSTEM_THREAD_INFORMATION
,
*
PSYSTEM_THREAD_INFORMATION
;
typedef
struct
SYSTEM_PROCESS_INFORMATION
{
ULONG
RelativeOffset
;
ULONG
ThreadCount
;
ULONG
Unused1
[
6
];
TIME
CreateTime
;
TIME
UserTime
;
TIME
KernelTime
;
UNICODE_STRING
Name
;
ULONG
BasePriority
;
ULONG
ProcessId
;
ULONG
ParentProcessId
;
ULONG
HandleCount
;
ULONG
SessionId
;
ULONG
Unused2
;
ULONG
PeakVirtualSizeBytes
;
ULONG
TotalVirtualSizeBytes
;
ULONG
PageFaultCount
;
ULONG
PeakWorkingSetSizeBytes
;
ULONG
TotalWorkingSetSizeBytes
;
ULONG
PeakPagedPoolUsagePages
;
ULONG
TotalPagedPoolUsagePages
;
ULONG
PeakNonPagedPoolUsagePages
;
ULONG
TotalNonPagedPoolUsagePages
;
ULONG
TotalPageFileUsageBytes
;
ULONG
PeakPageFileUsageBytes
;
ULONG
TotalPrivateBytes
;
SYSTEM_THREAD_INFORMATION
ThreadSysInfo
[
1
];
}
SYSTEM_PROCESS_INFORMATION
,
*
PSYSTEM_PROCESS_INFORMATION
;
typedef
struct
{
DWORD
dwUnknown1
;
ULONG
uKeMaximumIncrement
;
ULONG
uPageSize
;
ULONG
uMmNumberOfPhysicalPages
;
ULONG
uMmLowestPhysicalPage
;
ULONG
uMmHighestPhysicalPage
;
ULONG
uAllocationGranularity
;
PVOID
pLowestUserAddress
;
PVOID
pMmHighestUserAddress
;
ULONG
uKeActiveProcessors
;
BYTE
bKeNumberProcessors
;
BYTE
bUnknown2
;
WORD
wUnknown3
;
}
SYSTEM_BASIC_INFORMATION
;
/* SystemPerformanceInfo (2) */
typedef
struct
_SYSTEM_PERFORMANCE_INFORMATION
{
LARGE_INTEGER
/*TotalProcessorTime*/
liIdleTime
;
LARGE_INTEGER
IoReadTransferCount
;
LARGE_INTEGER
IoWriteTransferCount
;
LARGE_INTEGER
IoOtherTransferCount
;
ULONG
IoReadOperationCount
;
ULONG
IoWriteOperationCount
;
ULONG
IoOtherOperationCount
;
ULONG
MmAvailablePages
;
ULONG
MmTotalCommittedPages
;
ULONG
MmTotalCommitLimit
;
ULONG
MmPeakLimit
;
ULONG
PageFaults
;
ULONG
WriteCopies
;
ULONG
TransitionFaults
;
ULONG
Unknown1
;
ULONG
DemandZeroFaults
;
ULONG
PagesInput
;
ULONG
PagesRead
;
ULONG
Unknown2
;
ULONG
Unknown3
;
ULONG
PagesOutput
;
ULONG
PageWrites
;
ULONG
Unknown4
;
ULONG
Unknown5
;
ULONG
PoolPagedBytes
;
ULONG
PoolNonPagedBytes
;
ULONG
Unknown6
;
ULONG
Unknown7
;
ULONG
Unknown8
;
ULONG
Unknown9
;
ULONG
MmTotalSystemFreePtes
;
ULONG
MmSystemCodepage
;
ULONG
MmTotalSystemDriverPages
;
ULONG
MmTotalSystemCodePages
;
ULONG
Unknown10
;
ULONG
Unknown11
;
ULONG
Unknown12
;
ULONG
MmSystemCachePage
;
ULONG
MmPagedPoolPage
;
ULONG
MmSystemDriverPage
;
ULONG
CcFastReadNoWait
;
ULONG
CcFastReadWait
;
ULONG
CcFastReadResourceMiss
;
ULONG
CcFastReadNotPossible
;
ULONG
CcFastMdlReadNoWait
;
ULONG
CcFastMdlReadWait
;
ULONG
CcFastMdlReadResourceMiss
;
ULONG
CcFastMdlReadNotPossible
;
ULONG
CcMapDataNoWait
;
ULONG
CcMapDataWait
;
ULONG
CcMapDataNoWaitMiss
;
ULONG
CcMapDataWaitMiss
;
ULONG
CcPinMappedDataCount
;
ULONG
CcPinReadNoWait
;
ULONG
CcPinReadWait
;
ULONG
CcPinReadNoWaitMiss
;
ULONG
CcPinReadWaitMiss
;
ULONG
CcCopyReadNoWait
;
ULONG
CcCopyReadWait
;
ULONG
CcCopyReadNoWaitMiss
;
ULONG
CcCopyReadWaitMiss
;
ULONG
CcMdlReadNoWait
;
ULONG
CcMdlReadWait
;
ULONG
CcMdlReadNoWaitMiss
;
ULONG
CcMdlReadWaitMiss
;
ULONG
CcReadaheadIos
;
ULONG
CcLazyWriteIos
;
ULONG
CcLazyWritePages
;
ULONG
CcDataFlushes
;
ULONG
CcDataPages
;
ULONG
ContextSwitches
;
ULONG
Unknown13
;
ULONG
Unknown14
;
ULONG
SystemCalls
;
}
SYSTEM_PERFORMANCE_INFORMATION
,
*
PSYSTEM_PERFORMANCE_INFORMATION
;
typedef
struct
{
LARGE_INTEGER
liKeBootTime
;
LARGE_INTEGER
liKeSystemTime
;
LARGE_INTEGER
liExpTimeZoneBias
;
ULONG
uCurrentTimeZoneId
;
DWORD
dwReserved
;
}
SYSTEM_TIME_INFORMATION
;
/* SystemCacheInformation (21) */
typedef
struct
_SYSTEM_CACHE_INFORMATION
{
ULONG
CurrentSize
;
ULONG
PeakSize
;
ULONG
PageFaultCount
;
ULONG
MinimumWorkingSet
;
ULONG
MaximumWorkingSet
;
ULONG
Unused
[
4
];
}
SYSTEM_CACHE_INFORMATION
;
/* SystemPageFileInformation (18) */
typedef
struct
_SYSTEM_PAGEFILE_INFORMATION
...
...
@@ -281,54 +58,8 @@ struct _SYSTEM_PAGEFILE_INFORMATION
ULONG
TotalUsedPages
;
ULONG
PeakUsedPages
;
UNICODE_STRING
PagefileFileName
;
}
SYSTEM_PAGEFILE_INFORMATION
,
*
PSYSTEM_PAGEFILE_INFORMATION
;
/* SystemHandleInformation (16) */
/* (see ontypes.h) */
typedef
struct
_SYSTEM_HANDLE_ENTRY
{
ULONG
OwnerPid
;
BYTE
ObjectType
;
BYTE
HandleFlags
;
USHORT
HandleValue
;
PVOID
ObjectPointer
;
ULONG
AccessMask
;
}
SYSTEM_HANDLE_ENTRY
,
*
PSYSTEM_HANDLE_ENTRY
;
typedef
struct
_SYSTEM_HANDLE_INFORMATION
{
ULONG
Count
;
SYSTEM_HANDLE_ENTRY
Handle
[
1
];
}
SYSTEM_HANDLE_INFORMATION
,
*
PSYSTEM_HANDLE_INFORMATION
;
/* SystemProcessorPerformanceInformation (8) */
typedef
struct
_SYSTEM_PROCESSORTIME_INFO
{
LARGE_INTEGER
IdleTime
;
LARGE_INTEGER
KernelTime
;
LARGE_INTEGER
UserTime
;
LARGE_INTEGER
DpcTime
;
LARGE_INTEGER
InterruptTime
;
ULONG
InterruptCount
;
ULONG
Unused
;
}
SYSTEM_PROCESSORTIME_INFO
,
*
PSYSTEM_PROCESSORTIME_INFO
;
#define SystemBasicInformation 0
#define SystemPerformanceInformation 2
#define SystemTimeInformation 3
#define SystemProcessInformation 5
#define SystemProcessorTimeInformation 8
#define SystemHandleInformation 16
#define SystemPageFileInformation 18
#define SystemCacheInformation 21
#define Li2Double(x) ((double)((x).QuadPart))
#define GR_GDIOBJECTS 0
/* Count of GDI objects */
...
...
@@ -339,7 +70,6 @@ typedef DWORD (WINAPI *PROCGGR)(HANDLE,DWORD);
typedef
BOOL
(
WINAPI
*
PROCGPIC
)(
HANDLE
,
PIO_COUNTERS
);
BOOL
PerfDataInitialize
(
void
);
void
PerfDataUninitialize
(
void
);
void
PerfDataRefresh
(
void
);
ULONG
PerfDataGetProcessCount
(
void
);
...
...
@@ -383,9 +113,4 @@ ULONG PerfDataGetSystemHandleCount(void);
ULONG
PerfDataGetTotalThreadCount
(
void
);
#ifdef __cplusplus
};
#endif
#endif
/* __PERFDATA_H */
programs/taskmgr/taskmgr.c
View file @
31f88936
...
...
@@ -1101,6 +1101,5 @@ int APIENTRY WinMain(HINSTANCE hInstance,
/* Save our settings to the registry */
SaveSettings
();
PerfDataUninitialize
();
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment