MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / FormatProperty

Method FormatProperty

WinArk/FormatHelper.cpp:476–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474}
475
476std::wstring FormatHelper::FormatProperty(const EventData* data, const EventProperty& prop){
477 static const auto statusFunction = [](auto, auto& p) {
478 CString result;
479 ATLASSERT(p.GetLength() == sizeof(DWORD));
480 result.Format(L"%0x%08X", p.GetValue<DWORD>());
481 return (PCWSTR)result;
482 };
483
484 static const auto int64ToHex = [](auto, auto& p)->std::wstring {
485 ATLASSERT(p.GetLength() == sizeof(LONGLONG));
486 CString text;
487 text.Format(L"0x%llX", p.GetValue<LONGLONG>());
488 return (PCWSTR)text;
489 };
490
491 static const auto initialTimeToString = [](auto, auto& p) -> std::wstring {
492 ATLASSERT(p.GetLength() == sizeof(LONGLONG));
493 auto time = p.GetValue<time_t>();
494 auto initTime = GetBootTime() + time;
495 return std::wstring(FormatTime(initTime));
496 };
497
498 static const std::unordered_map<std::wstring,
499 std::function<std::wstring(const EventData*, const EventProperty&)>> functions{
500 { L"Status", statusFunction },
501 { L"NtStatus", statusFunction },
502 { L"InitialTime", initialTimeToString },
503 { L"TimeDateStamp", statusFunction },
504 { L"PageFault/VirtualAlloc;Flags", [](auto, auto& p) -> std::wstring {
505 ATLASSERT(p.GetLength() == sizeof(DWORD));
506 return (PCWSTR)VirtualAllocFlagsToString(p.GetValue<DWORD>(), true);
507 } },
508 { L"MajorFunction", [](auto, auto& p) -> std::wstring {
509 ATLASSERT(p.GetLength() == sizeof(DWORD));
510 return (PCWSTR)MajorFunctionToString((UCHAR)p.GetValue<DWORD>());
511 } },
512 { L"FileName", [](auto data, auto& p) -> std::wstring {
513 auto value = data->FormatProperty(p);
514 if (value[0] == L'\\')
515 value = TraceManager::GetDosNameFromNtName(value.c_str());
516 return value;
517 } },
518 { L"ObjectType", [](auto, auto& p) -> std::wstring {
519 ATLASSERT(p.GetLength() == sizeof(USHORT));
520 auto type = p.GetValue<USHORT>();
521 return std::to_wstring(type) + L" (" + ObjectTypeToString(type) + L")";
522 } },
523 { L"Tag", [](auto data, auto& p) -> std::wstring {
524 if (p.GetLength() != sizeof(DWORD))
525 return data->FormatProperty(p);
526 auto tag = p.GetValue<DWORD>();
527 auto chars = (const char*)&tag;
528 CStringA str(chars[0]);
529 ((str += chars[1]) += chars[2]) += chars[3];
530 CStringA text;
531 text.Format("%s (0x%X)", str, tag);
532 return std::wstring(CString(text));
533 } },

Callers 2

GetEventDetailsMethod · 0.45
OnInitDialogMethod · 0.45

Calls 3

GetBootTimeFunction · 0.85
GetLengthMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected