VirtualBox

Changeset 68559 in vbox for trunk


Ignore:
Timestamp:
Aug 31, 2017 12:10:07 PM (7 years ago)
Author:
vboxsync
Message:

merging vbglioc r117711: VBoxTray/WinMain: RTR3Init shall always be the very first thing. Don't call VbglR3Term if VbglR3Init failed, it will assert.

File:
1 edited

Legend:

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

    r68437 r68559  
    953953{
    954954    RT_NOREF(hPrevInstance, lpCmdLine, nCmdShow);
     955    int rc = RTR3InitExeNoArguments(0);
     956    if (RT_FAILURE(rc))
     957        return RTEXITCODE_INIT;
    955958
    956959    /* Note: Do not use a global namespace ("Global\\") for mutex name here,
     
    968971    LogRel(("%s r%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr()));
    969972
    970     int rc = RTR3InitExeNoArguments(0);
     973    rc = vboxTrayLogCreate(NULL /* pszLogFile */);
    971974    if (RT_SUCCESS(rc))
    972         rc = vboxTrayLogCreate(NULL /* pszLogFile */);
    973 
    974     if (RT_SUCCESS(rc))
     975    {
    975976        rc = VbglR3Init();
    976     if (RT_SUCCESS(rc))
    977     {
    978         /* Save instance handle. */
    979         g_hInstance = hInstance;
    980 
    981         hlpReportStatus(VBoxGuestFacilityStatus_Init);
    982         rc = vboxTrayCreateToolWindow();
    983977        if (RT_SUCCESS(rc))
    984978        {
    985             VBoxCapsInit();
    986 
    987             rc = vboxStInit(g_hwndToolWindow);
    988             if (!RT_SUCCESS(rc))
    989             {
    990                 LogFlowFunc(("vboxStInit failed, rc=%Rrc\n", rc));
    991                 /* ignore the St Init failure. this can happen for < XP win that do not support WTS API
    992                  * in that case the session is treated as active connected to the physical console
    993                  * (i.e. fallback to the old behavior that was before introduction of VBoxSt) */
    994                 Assert(vboxStIsActiveConsole());
    995             }
    996 
    997             rc = vboxDtInit();
    998             if (!RT_SUCCESS(rc))
    999             {
    1000                 LogFlowFunc(("vboxDtInit failed, rc=%Rrc\n", rc));
    1001                 /* ignore the Dt Init failure. this can happen for < XP win that do not support WTS API
    1002                  * in that case the session is treated as active connected to the physical console
    1003                  * (i.e. fallback to the old behavior that was before introduction of VBoxSt) */
    1004                 Assert(vboxDtIsInputDesktop());
    1005             }
    1006 
    1007             rc = VBoxAcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS | VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, true);
    1008             if (!RT_SUCCESS(rc))
    1009                 LogFlowFunc(("VBoxAcquireGuestCaps failed with rc=%Rrc, ignoring ...\n", rc));
    1010 
    1011             rc = vboxTraySetupSeamless(); /** @todo r=andy Do we really want to be this critical for the whole application? */
     979            /* Save instance handle. */
     980            g_hInstance = hInstance;
     981
     982            hlpReportStatus(VBoxGuestFacilityStatus_Init);
     983            rc = vboxTrayCreateToolWindow();
    1012984            if (RT_SUCCESS(rc))
    1013985            {
    1014                 rc = vboxTrayServiceMain();
     986                VBoxCapsInit();
     987
     988                rc = vboxStInit(g_hwndToolWindow);
     989                if (!RT_SUCCESS(rc))
     990                {
     991                    LogFlowFunc(("vboxStInit failed, rc=%Rrc\n", rc));
     992                    /* ignore the St Init failure. this can happen for < XP win that do not support WTS API
     993                     * in that case the session is treated as active connected to the physical console
     994                     * (i.e. fallback to the old behavior that was before introduction of VBoxSt) */
     995                    Assert(vboxStIsActiveConsole());
     996                }
     997
     998                rc = vboxDtInit();
     999                if (!RT_SUCCESS(rc))
     1000                {
     1001                    LogFlowFunc(("vboxDtInit failed, rc=%Rrc\n", rc));
     1002                    /* ignore the Dt Init failure. this can happen for < XP win that do not support WTS API
     1003                     * in that case the session is treated as active connected to the physical console
     1004                     * (i.e. fallback to the old behavior that was before introduction of VBoxSt) */
     1005                    Assert(vboxDtIsInputDesktop());
     1006                }
     1007
     1008                rc = VBoxAcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS | VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, true);
     1009                if (!RT_SUCCESS(rc))
     1010                    LogFlowFunc(("VBoxAcquireGuestCaps failed with rc=%Rrc, ignoring ...\n", rc));
     1011
     1012                rc = vboxTraySetupSeamless(); /** @todo r=andy Do we really want to be this critical for the whole application? */
    10151013                if (RT_SUCCESS(rc))
    1016                     hlpReportStatus(VBoxGuestFacilityStatus_Terminating);
    1017                 vboxTrayShutdownSeamless();
     1014                {
     1015                    rc = vboxTrayServiceMain();
     1016                    if (RT_SUCCESS(rc))
     1017                        hlpReportStatus(VBoxGuestFacilityStatus_Terminating);
     1018                    vboxTrayShutdownSeamless();
     1019                }
     1020
     1021                /* it should be safe to call vboxDtTerm even if vboxStInit above failed */
     1022                vboxDtTerm();
     1023
     1024                /* it should be safe to call vboxStTerm even if vboxStInit above failed */
     1025                vboxStTerm();
     1026
     1027                VBoxCapsTerm();
     1028
     1029                vboxTrayDestroyToolWindow();
    10181030            }
    1019 
    1020             /* it should be safe to call vboxDtTerm even if vboxStInit above failed */
    1021             vboxDtTerm();
    1022 
    1023             /* it should be safe to call vboxStTerm even if vboxStInit above failed */
    1024             vboxStTerm();
    1025 
    1026             VBoxCapsTerm();
    1027 
    1028             vboxTrayDestroyToolWindow();
    1029         }
    1030         if (RT_SUCCESS(rc))
    1031             hlpReportStatus(VBoxGuestFacilityStatus_Terminated);
    1032     }
    1033 
    1034     if (RT_FAILURE(rc))
    1035     {
    1036         LogRel(("Error while starting, rc=%Rrc\n", rc));
    1037         hlpReportStatus(VBoxGuestFacilityStatus_Failed);
    1038     }
    1039     LogRel(("Ended\n"));
     1031            if (RT_SUCCESS(rc))
     1032                hlpReportStatus(VBoxGuestFacilityStatus_Terminated);
     1033            else
     1034            {
     1035                LogRel(("Error while starting, rc=%Rrc\n", rc));
     1036                hlpReportStatus(VBoxGuestFacilityStatus_Failed);
     1037            }
     1038
     1039            LogRel(("Ended\n"));
     1040            VbglR3Term();
     1041        }
     1042        else
     1043            LogRel(("VbglR3Init failed: %Rrc\n", rc));
     1044    }
    10401045
    10411046    /* Release instance mutex. */
     
    10451050        hMutexAppRunning = NULL;
    10461051    }
    1047 
    1048     VbglR3Term();
    10491052
    10501053    vboxTrayLogDestroy();
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