| 1573 | |
| 1574 | # if !defined(DEATH_TARGET_EMSCRIPTEN) |
| 1575 | void Application::AppendLogFileHeader(Stream& s) |
| 1576 | { |
| 1577 | // Write TraceDigger metadata header |
| 1578 | |
| 1579 | std::int64_t timestampMs = DateTime::UtcNow().ToUnixMilliseconds() - 300; |
| 1580 | |
| 1581 | std::uint32_t flags = 0; |
| 1582 | if (Environment::GetCurrentElevation() == Environment::ElevationState::Full) { |
| 1583 | flags |= 0x01; // Elevated |
| 1584 | } |
| 1585 | # if defined(DEATH_TARGET_32BIT) |
| 1586 | flags |= 0x40; // Is32Bit |
| 1587 | # endif |
| 1588 | # if defined(DEATH_TARGET_BIG_ENDIAN) |
| 1589 | flags |= 0x80; // IsBigEndian |
| 1590 | # endif |
| 1591 | |
| 1592 | # if defined(DEATH_TARGET_WINDOWS) |
| 1593 | std::uint32_t processId = (std::uint32_t)::GetCurrentProcessId(); |
| 1594 | wchar_t bufferW[128]; DWORD hostNameWLength = (DWORD)arraySize(bufferW); |
| 1595 | if (!::GetComputerNameW(bufferW, &hostNameWLength)) { |
| 1596 | hostNameWLength = 0; |
| 1597 | } |
| 1598 | char hostName[128]; |
| 1599 | std::int32_t hostNameLength = Utf8::FromUtf16(hostName, bufferW, hostNameWLength); |
| 1600 | |
| 1601 | DWORD compatLayerLength = ::GetEnvironmentVariable(L"__COMPAT_LAYER", bufferW, (DWORD)arraySize(bufferW)); |
| 1602 | if (compatLayerLength > 0) { |
| 1603 | flags |= 0x1000; // HasAppCompatLayer |
| 1604 | } |
| 1605 | if (Environment::IsWine()) { |
| 1606 | flags |= 0x2000; // IsWine |
| 1607 | } |
| 1608 | # elif defined(DEATH_TARGET_ANDROID) |
| 1609 | flags |= 0x04 | 0x20; // ProcessIdEqualsToMainThreadId | RemoteDevice |
| 1610 | std::uint32_t processId = (std::uint32_t)::getpid(); |
| 1611 | auto androidId = nCine::Backends::AndroidJniWrap_Secure::getAndroidId(); |
| 1612 | const char* hostName = androidId.data(); |
| 1613 | std::int32_t hostNameLength = (std::int32_t)androidId.size(); |
| 1614 | # else |
| 1615 | # if !defined(DEATH_TARGET_APPLE) && !defined(DEATH_TARGET_EMSCRIPTEN) |
| 1616 | flags |= 0x04; // ProcessIdEqualsToMainThreadId |
| 1617 | # endif |
| 1618 | # if defined(DEATH_TARGET_SWITCH) |
| 1619 | flags |= 0x20; // RemoteDevice |
| 1620 | # endif |
| 1621 | std::uint32_t processId = (std::uint32_t)::getpid(); |
| 1622 | char hostName[128] {}; std::int32_t hostNameLength = 0; |
| 1623 | if (::gethostname(hostName, arraySize(hostName)) == 0) { |
| 1624 | hostName[arraySize(hostName) - 1] = '\0'; |
| 1625 | hostNameLength = std::strlen(hostName); |
| 1626 | } |
| 1627 | # endif |
| 1628 | |
| 1629 | char buffer[256]; |
| 1630 | MemoryStream ms(buffer, sizeof(buffer)); |
| 1631 | ms.WriteVariableUint32(1); // Version |
| 1632 | ms.WriteVariableUint32(flags); |
nothing calls this directly
no test coverage detected