VirtualBox

Changeset 66358 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 30, 2017 11:05:26 AM (8 years ago)
Author:
vboxsync
Message:

VBoxProxyStub.c: Fixed incorrect error handling and work duplication in VbpsRegisterAppId. Merged SDS registration function into RegisterXidlModulesAndClassesGenerated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/win/VBoxProxyStub.c

    r66353 r66358  
    10191019 * @param   pszAppId            The application UUID string.
    10201020 * @param   pszDescription      The description string.
    1021  * @param   fIsService          The application is windows service
     1021 * @param   pszServiceName      The window service name if the application is a
     1022 *                              service, otherwise this must be NULL.
    10221023 */
    10231024LSTATUS VbpsRegisterAppId(VBPSREGSTATE *pState, const char *pszModuleName, const char *pszAppId,
    1024                           const char *pszDescription, bool fIsService)
     1025                          const char *pszDescription, const char *pszServiceName)
    10251026{
    10261027    LSTATUS rc;
     
    10631064    }
    10641065
     1066    /*
     1067     * Register / update.
     1068     */
    10651069    if (pState->fUpdate)
    10661070    {
    1067         HKEY hkeyServiceExe;
    1068 
    1069         vbpsCreateRegKeyWithDefaultValueAA(pState, hkeyAppIds, pszAppId, pszDescription, __LINE__);
    1070 
    1071         if (fIsService)
     1071        HKEY hkey;
     1072        rc = vbpsCreateRegKeyA(pState, hkeyAppIds, pszAppId, &hkey, __LINE__);
     1073        if (rc == ERROR_SUCCESS)
    10721074        {
    1073             char szModule[MAX_PATH + 2];
    1074             HKEY hkeyApp;
    1075             size_t len = RTStrNLen(pszModuleName, MAX_PATH);
    1076             Assert(len);
    1077             Assert(len < MAX_PATH);
    1078             rc = RTStrCopy(szModule, sizeof(szModule), pszModuleName);
    1079             AssertRC(rc);
    1080             szModule[len - 4] = '\0';
    1081 
    1082             rc = RegOpenKeyExA(hkeyAppIds, pszAppId, 0 /*fOptions*/, pState->fSamBoth, &hkeyApp);
    1083             if (rc == ERROR_FILE_NOT_FOUND)
    1084                 return ERROR_SUCCESS;
    1085             // create the value "Service" with the service name
    1086             vbpsSetRegValueAA(pState, hkeyApp, "LocalService", szModule, __LINE__);
    1087             vbpsCloseKey(pState, hkeyApp, __LINE__);
     1075            vbpsSetRegValueAA(pState, hkey, NULL /*pszValueNm*/, pszDescription, __LINE__);
     1076            if (pszServiceName)
     1077                vbpsSetRegValueAA(pState, hkey, "LocalService", pszServiceName, __LINE__);
     1078            vbpsCloseKey(pState, hkey, __LINE__);
    10881079        }
    10891080
    1090         vbpsCreateRegKeyWithDefaultValueAA(pState, hkeyAppIds, pszModuleName, "", __LINE__);
    1091 
    1092         rc = RegOpenKeyExA(hkeyAppIds, pszModuleName, 0 /*fOptions*/, pState->fSamBoth, &hkeyServiceExe);
    1093         if (rc == ERROR_FILE_NOT_FOUND)
    1094             return ERROR_SUCCESS;
    1095         vbpsSetRegValueAA(pState, hkeyServiceExe, "AppID", pszAppId, __LINE__);
    1096         vbpsCloseKey(pState, hkeyServiceExe, __LINE__);
     1081        rc = vbpsCreateRegKeyA(pState, hkeyAppIds, pszModuleName, &hkey, __LINE__);
     1082        if (rc == ERROR_SUCCESS)
     1083        {
     1084            vbpsSetRegValueAA(pState, hkey, NULL /*pszValueNm*/, "", __LINE__);
     1085            vbpsSetRegValueAA(pState, hkey, "AppID", pszAppId, __LINE__);
     1086            vbpsCloseKey(pState, hkey, __LINE__);
     1087        }
    10971088    }
    10981089
     
    12931284
    12941285
    1295 #ifdef VBOX_WITH_SDS
    1296 /**
    1297 * Register VBoxSDS classes from the VirtualBox.xidl file.
    1298 *
    1299 * @returns COM status code.
    1300 * @param   pState
    1301 * @param   pwszVBoxDir         The VirtualBox application directory.
    1302 *
    1303 * @todo convert to XSLT.
    1304 */
    1305 void RegisterVBoxSDSXidl(VBPSREGSTATE *pState, PCRTUTF16 pwszVBoxDir)
    1306 {
    1307     const char *pszServiceAppId   = "{EC0E78E8-FA43-43E8-AC0A-02C784C4A4FA}";
    1308     const char *pszWindowsService = "VBoxSDS.exe";
    1309 
    1310     /* VBoxSDS */
    1311     VbpsRegisterAppId(pState, pszWindowsService, pszServiceAppId, "VirtualBox System Service", true);
    1312     VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxSDS.1", "VirtualBoxSDS Class", &CLSID_VirtualBoxSDS, NULL);
    1313     VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxSDS", "VirtualBoxSDS Class", &CLSID_VirtualBoxSDS, ".1");
    1314     VbpsRegisterClassId(pState, &CLSID_VirtualBoxSDS, "VirtualBoxSDS Class", pszServiceAppId, "VirtualBox.VirtualBoxSDS", ".1",
    1315                         &LIBID_VirtualBox, "LocalServer32", pwszVBoxDir, pszWindowsService, NULL /*N/A*/);
    1316 }
    1317 #endif /* VBOX_WITH_SDS */
    1318 
    1319 
    13201286/**
    13211287 * Register modules and classes from the VirtualBox.xidl file.
     
    13301296void RegisterXidlModulesAndClassesGenerated(VBPSREGSTATE *pState, PCRTUTF16 pwszVBoxDir, bool fIs32On64)
    13311297{
    1332     const char *pszAppId        = "{819B4D85-9CEE-493C-B6FC-64FFE759B3C9}";
    1333     const char *pszInprocDll    = !fIs32On64 ? "VBoxC.dll" : "x86\\VBoxClient-x86.dll";
    1334     const char *pszLocalServer  = "VBoxSVC.exe";
     1298    const char *pszAppId            = "{819B4D85-9CEE-493C-B6FC-64FFE759B3C9}";
     1299    const char *pszInprocDll        = !fIs32On64 ? "VBoxC.dll" : "x86\\VBoxClient-x86.dll";
     1300    const char *pszLocalServer      = "VBoxSVC.exe";
     1301#ifdef VBOX_WITH_SDS
     1302    const char *pszSdsAppId         = "{EC0E78E8-FA43-43E8-AC0A-02C784C4A4FA}";
     1303    const char *pszSdsExe           = "VBoxSDS.exe";
     1304    const char *pszSdsServiceName   = "VBoxSDS";
     1305#endif
    13351306
    13361307    /* VBoxSVC */
    1337     VbpsRegisterAppId(pState, pszLocalServer, pszAppId, "VirtualBox Application", false);
     1308    VbpsRegisterAppId(pState, pszLocalServer, pszAppId, "VirtualBox Application", NULL);
    13381309    VbpsRegisterClassName(pState, "VirtualBox.VirtualBox.1", "VirtualBox Class", &CLSID_VirtualBox, NULL);
    13391310    VbpsRegisterClassName(pState, "VirtualBox.VirtualBox",   "VirtualBox Class", &CLSID_VirtualBox, ".1");
     
    13531324
    13541325#ifdef VBOX_WITH_SDS
    1355     RegisterVBoxSDSXidl(pState, pwszVBoxDir);
     1326    /* VBoxSDS */
     1327    VbpsRegisterAppId(pState, pszSdsExe, pszSdsAppId, "VirtualBox System Service", pszSdsServiceName);
     1328    VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxSDS.1", "VirtualBoxSDS Class", &CLSID_VirtualBoxSDS, NULL);
     1329    VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxSDS", "VirtualBoxSDS Class", &CLSID_VirtualBoxSDS, ".1");
     1330    VbpsRegisterClassId(pState, &CLSID_VirtualBoxSDS, "VirtualBoxSDS Class", pszSdsAppId, "VirtualBox.VirtualBoxSDS", ".1",
     1331                        &LIBID_VirtualBox, "LocalServer32", pwszVBoxDir, pszSdsExe, NULL /*N/A*/);
    13561332#endif
    13571333}
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