| 193 | } |
| 194 | |
| 195 | std::wstring CEtwView::ProcessSpecialEvent(EventData* data) const { |
| 196 | std::wstring details; |
| 197 | CString text; |
| 198 | auto& name = data->GetEventName(); |
| 199 | if (name == L"Process/Start") { |
| 200 | text.Format(L"PID: %u; Image: %s; Command Line: %s", |
| 201 | data->GetProperty(L"ProcessId")->GetValue<DWORD>(), |
| 202 | CString(data->GetProperty(L"ImageFileName")->GetAnsiString()), |
| 203 | data->GetProperty(L"CommandLine")->GetUnicodeString()); |
| 204 | details = std::move(text); |
| 205 | } |
| 206 | if (name == L"PerfInfo/SysClEnter") { |
| 207 | DWORD64 address; |
| 208 | auto prop = data->GetProperty(L"SysCallAddress"); |
| 209 | if (prop->GetLength() == 4) |
| 210 | address = prop->GetValue<DWORD>(); |
| 211 | else |
| 212 | address = prop->GetValue<DWORD64>(); |
| 213 | DWORD64 offset = 0; |
| 214 | auto symbol = SymbolHelper::GetSymbolFromAddress(address, &offset); |
| 215 | if (symbol) { |
| 216 | auto sym = symbol->GetSymbolInfo(); |
| 217 | CStringA text; |
| 218 | text.Format("%s", sym->Name); |
| 219 | details = Helpers::StringToWstring(std::string(text)); |
| 220 | } |
| 221 | } |
| 222 | if (name == L"Thread/CSwitch") { |
| 223 | UCHAR processorNumber = data->GetProcessorNumber(); |
| 224 | DWORD tid = data->GetProperty(L"NewThreadId")->GetValue<DWORD>(); |
| 225 | if (tid != -1) { |
| 226 | _threadById[processorNumber] = tid; |
| 227 | } |
| 228 | if (_processById.count(tid) == 0) { |
| 229 | DWORD pid = AddNewProcess(tid); |
| 230 | if (pid != -1 && pid != 0) { |
| 231 | data->SetProcessId(pid); |
| 232 | } |
| 233 | } |
| 234 | tid = data->GetProperty(L"OldThreadId")->GetValue<DWORD>(); |
| 235 | if (_processById.count(tid) == 0) { |
| 236 | AddNewProcess(tid); |
| 237 | } |
| 238 | auto state = data->GetProperty(L"OldThreadState")->GetValue<uint8_t>(); |
| 239 | if (_processById.count(tid) != 0 && state == (uint8_t)WinSys::ThreadState::Terminated) { |
| 240 | if (_processNameById.count(_processById[tid]) != 0) { |
| 241 | _processNameById.erase(_processById[tid]); |
| 242 | } |
| 243 | _processById.erase(tid); |
| 244 | } |
| 245 | } |
| 246 | return details; |
| 247 | } |
| 248 | |
| 249 | std::wstring CEtwView::GetEventDetails(EventData* data) const { |
| 250 | auto details = ProcessSpecialEvent(data); |
nothing calls this directly
no test coverage detected