getsentry/sentry-native

Add WINE meta-data to OS context.

開放

#1,004 建立於 2024年6月5日

 (0 則留言) (0 個反應) (0 位負責人)C (212 個分叉)auto 404
ErrorsHelp WantedImprovementNative

倉庫指標

星標
 (557 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

One can also add Wine metadata to the context if the app is ran under that:

{
    // Add WINE version metadata if running under WINE
    HMODULE hntdll;
    typedef const char* (CDECL* wine_get_version_t)();
    typedef const char* (CDECL* wine_get_build_id_t)();
    typedef void (CDECL* wine_get_host_version_t)(const char** sysname, const char** release);
    wine_get_version_t wine_get_version;
    wine_get_build_id_t wine_get_build_id;
    wine_get_host_version_t wine_get_host_version;
    if ((hntdll = GetModuleHandleA("ntdll.dll")) && (wine_get_version = reinterpret_cast<wine_get_version_t>(GetProcAddress(hntdll, "wine_get_version"))))
    {
        sentry_value_t wine_ctx = sentry_value_new_object();

        sentry_value_set_by_key(wine_ctx, "version", sentry_value_new_string(wine_get_version())); // example: 7.11
        if (wine_get_build_id = reinterpret_cast<wine_get_build_id_t>(GetProcAddress(hntdll, "wine_get_build_id")))
            sentry_value_set_by_key(wine_ctx, "build", sentry_value_new_string(wine_get_build_id())); // example: wine-7.11
        if (wine_get_host_version = reinterpret_cast<wine_get_host_version_t>(GetProcAddress(hntdll, "wine_get_host_version")))
        {
            const char* sysname; // example: Linux
            const char* release; // example: 5.16.20-2-MANJARO
            wine_get_host_version(&sysname, &release);
            sentry_value_set_by_key(wine_ctx, "sysname", sentry_value_new_string(sysname));
            sentry_value_set_by_key(wine_ctx, "release", sentry_value_new_string(release));
        }

        sentry_set_context("wine", wine_ctx);
    }
}

Originally posted by @p0358 in https://github.com/getsentry/sentry-native/issues/943#issuecomment-2144103702

Adding this to Sentry must essentially follow the same steps as in this PR: https://github.com/getsentry/sentry-native/pull/963

貢獻者指南