VirtualBox

Changeset 95863 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jul 27, 2022 1:10:09 AM (3 years ago)
Author:
vboxsync
Message:

VBoxTray/VBoxTray.cpp: Use RTStrPrintf instead of sprintf; in VBOX_WITH_NOCRT_STATIC we have main() function instead of WinMain. Left angry @todo about non-sensical argv handling. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r95827 r95863  
    225225    g_NotifyIconData.hIcon            = hIcon;
    226226
    227     sprintf(g_NotifyIconData.szTip, "%s Guest Additions %d.%d.%dr%d",
    228             VBOX_PRODUCT, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);
     227    RTStrPrintf(g_NotifyIconData.szTip, sizeof(g_NotifyIconData.szTip), "%s Guest Additions %d.%d.%dr%d",
     228                VBOX_PRODUCT, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);
    229229
    230230    int rc = VINF_SUCCESS;
     
    999999 * Main function
    10001000 */
     1001#ifdef IPRT_NO_CRT
     1002int main(int cArgs, char **papszArgs)
     1003#else
    10011004int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    1002 {
     1005#endif
     1006{
     1007    char szLogFile[RTPATH_MAX] = {0};
     1008
     1009#ifdef IPRT_NO_CRT
     1010    int rc = RTR3InitExe(cArgs, &papszArgs, RTR3INIT_FLAGS_STANDALONE_APP);
     1011    if (RT_FAILURE(rc))
     1012        return RTMsgInitFailure(rc);
     1013#else
    10031014    RT_NOREF(hPrevInstance, lpCmdLine, nCmdShow);
    1004 
     1015    /** @todo r=bird: WTF do you use __argc & __argv here only to parse the
     1016     *        command line furthe down?!? Makes no effing sense, espcially given
     1017     *        that RTR3InitExe will return valid UTF-8, doing exactly the
     1018     *        same stuff as you do here.
     1019     *        aaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAARG! */
    10051020    int rc = RTR3InitExe(__argc, &__argv, RTR3INIT_FLAGS_STANDALONE_APP);
    10061021    if (RT_FAILURE(rc))
     
    10161031        return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to convert the command line: %Rrc", rc);
    10171032
    1018     char szLogFile[RTPATH_MAX] = {0};
    1019 
    10201033    int    cArgs;
    10211034    char **papszArgs;
    10221035    rc = RTGetOptArgvFromString(&papszArgs, &cArgs, pszCmdLine, RTGETOPTARGV_CNV_QUOTE_MS_CRT, NULL);
    10231036    if (RT_SUCCESS(rc))
     1037#endif
    10241038    {
    10251039        /*
     
    10811095                        rc = RTPathAbs(ValueUnion.psz, szLogFile, sizeof(szLogFile));
    10821096                        if (RT_FAILURE(rc))
    1083                             return RTMsgErrorExit(RTEXITCODE_FAILURE, "Log file path is too long (%Rrc)", rc);
     1097                            return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs failed on log file path: %Rrc (%s)",
     1098                                                  rc, ValueUnion.psz);
    10841099                    }
    10851100                    break;
     
    11031118        RTGetOptArgvFree(papszArgs);
    11041119    }
     1120#ifndef IPRT_NO_CRT
    11051121    else
    11061122        return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTGetOptArgvFromString failed: %Rrc", rc);
     1123#endif
    11071124
    11081125    /* Note: Do not use a global namespace ("Global\\") for mutex name here,
     
    11311148                    RTSYSTEM_NT_VERSION_GET_MINOR(uNtVersion), RTSYSTEM_NT_VERSION_GET_BUILD(uNtVersion), uNtVersion ));
    11321149
    1133             /* Save instance handle. */
     1150            /* Set the instance handle. */
     1151#ifdef IPRT_NO_CRT
     1152            g_hInstance = GetModuleHandleW(NULL);
     1153#else
    11341154            g_hInstance = hInstance;
     1155#endif
    11351156
    11361157            hlpReportStatus(VBoxGuestFacilityStatus_Init);
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