FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TaskExplorer/TaskExplorer/API/ProcessInfo.cpp at master · imhugy/TaskExplorer · GitHub
imhugy
/
TaskExplorer
Public
forked from
DavidXanatos/TaskExplorer
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TaskExplorer
/
TaskExplorer
/
API
/
ProcessInfo.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
179 lines (147 loc) · 4.21 KB
Breadcrumbs
TaskExplorer
/
TaskExplorer
/
API
/
ProcessInfo.cpp
Copy path
File metadata and controls
179 lines (147 loc) · 4.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
include
"
stdafx.h
"
#
include
"
ProcessInfo.h
"
#
include
"
SocketInfo.h
"
#
include
"
SystemAPI.h
"
#
include
"
../../MiscHelpers/Common/Settings.h
"
CProcessInfo::CProcessInfo
(QObject *parent) : CAbstractTask(parent)
{
//
Basic
m_ProcessId = -
1
;
m_ParentProcessId = -
1
;
//
Dynamic
m_NumberOfThreads =
0
;
m_NumberOfHandles =
0
;
m_PeakNumberOfThreads =
0
;
m_PeakPagefileUsage =
0
;
m_WorkingSetSize =
0
;
m_PeakWorkingSetSize =
0
;
m_WorkingSetPrivateSize =
0
;
m_VirtualSize =
0
;
m_PeakVirtualSize =
0
;
//
m_PageFaultCount = 0;
m_NetworkUsageFlags =
0
;
m_DebugMessageCount =
0
;
}
CProcessInfo::~CProcessInfo
()
{
}
QString
CProcessInfo::GetNetworkUsageString
()
const
{
QReadLocker
Locker
(&m_StatsMutex);
QStringList NetworkUsage;
if
(m_NetworkUsageFlags &
NET_TYPE_PROTOCOL_TCP_SRV
)
NetworkUsage.
append
(
tr
(
"
TCP/Server
"
));
else
if
(m_NetworkUsageFlags &
NET_TYPE_PROTOCOL_TCP
)
NetworkUsage.
append
(
tr
(
"
TCP
"
));
if
(m_NetworkUsageFlags &
NET_TYPE_PROTOCOL_UDP
)
NetworkUsage.
append
(
tr
(
"
UDP
"
));
return
NetworkUsage.
join
(
"
,
"
);
}
void
CProcessInfo::UpdateDns
(
const
QString& HostName,
const
QList<QHostAddress>& Addresses)
{
QWriteLocker
Locker
(&m_DnsMutex);
CDnsLogEntryPtr& DnsEntry = m_DnsLog[HostName];
QList<QHostAddress> NewAddresses;
if
(DnsEntry.
isNull
())
{
DnsEntry =
CDnsLogEntryPtr
(
new
CDnsLogEntry
(HostName, Addresses));
NewAddresses = Addresses;
}
else
NewAddresses = DnsEntry->
UpdateAddresses
(Addresses);
foreach
(
const
QHostAddress& Address, NewAddresses)
m_DnsRevLog.
insertMulti
(Address, HostName);
}
QString
CProcessInfo::GetHostName
(
const
QHostAddress& Address)
{
QList<QString> HostNames = m_DnsRevLog.
values
(Address);
return
HostNames.
join
(
"
;
"
);
}
void
CProcessInfo::ClearPersistence
()
{
CAbstractTask::ClearPersistence
();
foreach
(
const
CThreadPtr& pThread,
GetThreadList
())
pThread->
ClearPersistence
();
foreach
(
const
CHandlePtr& pHandle,
GetHandleList
())
pHandle->
ClearPersistence
();
}
void
CProcessInfo::UpdatePresets
()
{
QWriteLocker
Locker
(&m_Mutex);
m_PersistentPreset.
clear
();
InitPresets
();
}
void
CProcessInfo::InitPresets
()
{
m_PersistentPreset = theAPI->
FindPersistentPreset
(m_FileName, m_CommandLine);
if
(!m_PersistentPreset.
isNull
())
QTimer::singleShot
(
0
,
this
,
SLOT
(
ApplyPresets
()));
}
CPersistentPresetPtr
CProcessInfo::GetPresets
()
const
{
QReadLocker
Locker
(&m_Mutex);
return
m_PersistentPreset;
}
void
CProcessInfo::ApplyPresets
()
{
CPersistentPresetPtr PersistentPreset =
GetPresets
();
if
(PersistentPreset.
isNull
())
return
;
CPersistentPresetDataPtr Preset = PersistentPreset->
GetData
();
if
(Preset->
bTerminate
) {
Terminate
(
true
);
return
;
}
if
(Preset->
bPriority
)
SetPriority
(Preset->
iPriority
);
if
(Preset->
bAffinity
)
SetAffinityMask
(Preset->
uAffinity
);
if
(Preset->
bIOPriority
)
SetIOPriority
(Preset->
iIOPriority
);
if
(Preset->
bPagePriority
)
SetPagePriority
(Preset->
iPagePriority
);
}
void
CProcessInfo::AddDebugMessage
(
const
QString& Text,
const
QDateTime& TimeStamp)
{
QWriteLocker
Locker
(&m_DebugMutex);
int
AddedCount =
0
;
QStringList Texts = Text.
split
(
"
\n
"
);
if
(m_DebugMessages.
count
() >
0
)
{
SDebugMessage& Message = m_DebugMessages.
last
();
if
(Message.
Text
.
right
(
1
) !=
'
\n
'
)
{
Message.
Text
+= Texts.
takeFirst
();
if
(!Texts.
isEmpty
())
Message.
Text
+=
"
\n
"
;
}
}
for
(
int
i=
0
; i < Texts.
count
();)
{
QString Text = Texts[i++];
bool
Last = i >= Texts.
count
();
if
(Last && Text.
isEmpty
())
break
;
SDebugMessage Message = { TimeStamp, Text };
if
(!Last)
Message.
Text
+=
"
\n
"
;
m_DebugMessages.
append
(Message);
AddedCount++;
}
while
(m_DebugMessages.
count
() > theConf->
GetInt
(
"
Options/MaxDebugLog
"
,
1000
))
m_DebugMessages.
removeFirst
();
m_DebugMessageCount += AddedCount;
}
QList<CProcessInfo::SDebugMessage>
CProcessInfo::GetDebugMessages
(quint32* pDebugMessageCount)
const
{
QReadLocker
Locker
(&m_DebugMutex);
if
(pDebugMessageCount)
*pDebugMessageCount = m_DebugMessageCount;
return
m_DebugMessages;
}
void
CProcessInfo::ClearDebugMessages
()
{
QReadLocker
Locker
(&m_DebugMutex);
m_DebugMessages.
clear
();
m_DebugMessageCount =
0
;
}
Back
|
FazBrowse Home
|
New Git URL