VirtualBox

Changeset 53004 in vbox for trunk


Ignore:
Timestamp:
Oct 9, 2014 1:10:20 AM (10 years ago)
Author:
vboxsync
Message:

SUP: Resolve and call RTLogRelPrintf dynamically to put errors in the release log (makes them more visible to the user).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r53002 r53004  
    119119typedef FNRTR3INITEX *PFNRTR3INITEX;
    120120
     121/** @see RTLogRelPrintf */
     122typedef DECLCALLBACK(void) FNRTLOGRELPRINTF(const char *pszFormat, ...);
     123typedef FNRTLOGRELPRINTF *PFNRTLOGRELPRINTF;
     124
    121125
    122126/*******************************************************************************
     
    160164SUPR3HARDENEDMAINSTATE  g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_NOT_YET_CALLED;
    161165AssertCompileSize(g_enmSupR3HardenedMainState, sizeof(uint32_t));
     166
     167#ifdef RT_OS_WINDOWS
     168/** Pointer to VBoxRT's RTLogRelPrintf function so we can write errors to the
     169 * release log at runtime. */
     170static PFNRTLOGRELPRINTF g_pfnRTLogRelPrintf = NULL;
     171#endif
    162172
    163173
     
    10661076    va_end(vaCopy);
    10671077
     1078#ifdef RT_OS_WINDOWS
     1079    /*
     1080     * The release log.
     1081     */
     1082    if (g_pfnRTLogRelPrintf)
     1083    {
     1084        va_copy(vaCopy, va);
     1085        g_pfnRTLogRelPrintf("supR3HardenedFatalMsgV: %s enmWhat=%d rc=%Rrc (%#x)\n", pszWhere, enmWhat, rc);
     1086        g_pfnRTLogRelPrintf("supR3HardenedFatalMsgV: %N\n", pszMsgFmt, &vaCopy);
     1087        va_end(vaCopy);
     1088    }
     1089#endif
     1090
    10681091    /*
    10691092     * Then to the console.
     
    11011124
    11021125    /*
    1103      * Don't call TrustedError if it's too early.
     1126     * Finally, TrustedError if appropriate.
    11041127     */
    11051128    if (g_enmSupR3HardenedMainState >= SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED)
     
    11801203#endif
    11811204    {
     1205#ifdef RT_OS_WINDOWS
     1206        if (g_pfnRTLogRelPrintf)
     1207        {
     1208            va_copy(vaCopy, va);
     1209            g_pfnRTLogRelPrintf("supR3HardenedFatalV: %N", pszFormat, &vaCopy);
     1210            va_end(vaCopy);
     1211        }
     1212#endif
     1213
    11821214        suplibHardenedPrintPrefix();
    11831215        suplibHardenedPrintFV(pszFormat, va);
     
    12081240    va_end(vaCopy);
    12091241
     1242#ifdef RT_OS_WINDOWS
     1243    if (g_pfnRTLogRelPrintf)
     1244    {
     1245        va_copy(vaCopy, va);
     1246        g_pfnRTLogRelPrintf("supR3HardenedErrorV: %N", pszFormat, &vaCopy);
     1247        va_end(vaCopy);
     1248    }
     1249#endif
     1250
    12101251    suplibHardenedPrintPrefix();
    12111252    suplibHardenedPrintFV(pszFormat, va);
     1253
    12121254    return rc;
    12131255}
     
    15261568                              szPath, RtlGetLastWin32Error());
    15271569
     1570    g_pfnRTLogRelPrintf = (PFNRTLOGRELPRINTF)GetProcAddress(hMod, SUP_HARDENED_SYM("RTLogRelPrintf"));
     1571    Assert(g_pfnRTLogRelPrintf);  /* Not fatal in non-strict builds. */
     1572
    15281573#else
    15291574    /* the dlopen crowd */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette