-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathWin32_Process.hpp
149 lines (111 loc) · 3.64 KB
/
Win32_Process.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
////////////////////////////////////////////////////////////////////////////////
//! \file Win32_Process.hpp
//! \brief The Win32_Process class declaration.
//! \author Chris Oldwood
// Check for previous inclusion
#ifndef WMI_WIN32_PROCESS_HPP
#define WMI_WIN32_PROCESS_HPP
#if _MSC_VER > 1000
#pragma once
#endif
#include "TypedObject.hpp"
#include "DateTime.hpp"
#include <Core/StringUtils.hpp>
namespace WMI
{
////////////////////////////////////////////////////////////////////////////////
//! The C++ facade for the Win32_Process WMI class.
class Win32_Process : public TypedObject<Win32_Process>
{
public:
//! Construction from the underlying COM object and connection.
Win32_Process(IWbemClassObjectPtr object, const Connection& connection);
//! Destructor.
virtual ~Win32_Process();
//
// WMI typed properties.
//
//! The command line.
tstring CommandLine() const;
//! The number of handles it has open.
uint32 HandleCount() const;
//! The name of the process.
tstring Name() const;
//! The number of privately allocated pages.
uint64 PrivatePageCount() const;
//! The unique ID of the process.
uint32 ProcessId() const;
//! The number of threads it has running.
uint32 ThreadCount() const;
//! The amount of virtual address space used, in bytes.
uint64 VirtualSize() const;
//! The size of its working set, in bytes.
uint64 WorkingSetSize() const;
//
// WMI methods.
//
//! Terminate the process.
uint32 Terminate(uint32 reason = 0);
//
// Constants.
//
//! The WMI class name this type mirrors.
static const tchar* WMI_CLASS_NAME;
};
////////////////////////////////////////////////////////////////////////////////
//! The command line.
inline tstring Win32_Process::CommandLine() const
{
return getProperty<tstring>(TXT("CommandLine"));
}
////////////////////////////////////////////////////////////////////////////////
//! The number of handles it has open.
inline uint32 Win32_Process::HandleCount() const
{
return getProperty<int32>(TXT("HandleCount"));
}
////////////////////////////////////////////////////////////////////////////////
//! The name of the process.
inline tstring Win32_Process::Name() const
{
return getProperty<tstring>(TXT("Name"));
}
////////////////////////////////////////////////////////////////////////////////
//! The number of privately allocated pages.
inline uint64 Win32_Process::PrivatePageCount() const
{
// 64-bit values are passed as BSTR values.
const tstring value = getProperty<tstring>(TXT("PrivatePageCount"));
return Core::parse<uint64>(value);
}
////////////////////////////////////////////////////////////////////////////////
//! The unique ID of the process.
inline uint32 Win32_Process::ProcessId() const
{
return getProperty<int32>(TXT("ProcessId"));
}
////////////////////////////////////////////////////////////////////////////////
//! The number of threads it has running.
inline uint32 Win32_Process::ThreadCount() const
{
return getProperty<int32>(TXT("ThreadCount"));
}
////////////////////////////////////////////////////////////////////////////////
//! The amount of virtual address space used, in bytes.
inline uint64 Win32_Process::VirtualSize() const
{
// 64-bit values are passed as BSTR values.
const tstring value = getProperty<tstring>(TXT("VirtualSize"));
return Core::parse<uint64>(value);
}
////////////////////////////////////////////////////////////////////////////////
//! The size of its working set in bytes.
inline uint64 Win32_Process::WorkingSetSize() const
{
// 64-bit values are passed as BSTR values.
const tstring value = getProperty<tstring>(TXT("WorkingSetSize"));
return Core::parse<uint64>(value);
}
//namespace WMI
}
#endif // WMI_WIN32_PROCESS_HPP