Changeset 6967 in vbox for trunk/src/VBox/Frontends/VBoxBFE
- Timestamp:
- Feb 14, 2008 7:14:34 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 28137
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/HGCM.cpp
r6953 r6967 97 97 char *m_pszSvcName; 98 98 char *m_pszSvcLibrary; 99 99 100 100 RTLDRMOD m_hLdrMod; 101 101 PFNVBOXHGCMSVCLOAD m_pfnLoad; … … 107 107 108 108 uint32_t *m_paClientIds; 109 109 110 110 HGCMSVCEXTHANDLE m_hExtension; 111 111 … … 126 126 127 127 static DECLCALLBACK(void) svcHlpCallComplete (VBOXHGCMCALLHANDLE callHandle, int32_t rc); 128 128 129 129 public: 130 130 … … 239 239 * If only library name is specified, then try to load it from: 240 240 * - RTPathAppPrivateArch 241 * - RTPathSharedLibs 242 * - default system LIBPATH. 241 * - RTPathSharedLibs (legacy) 243 242 */ 244 243 int rc = VINF_SUCCESS; 245 244 246 245 if (RTPathHavePath (pszName)) 247 246 { … … 251 250 else 252 251 { 253 if (strlen (pszName) >= RTPATH_MAX)254 {255 return VERR_FILENAME_TOO_LONG;256 }257 258 252 /* Try default locations. */ 259 253 char szBase[RTPATH_MAX]; 260 254 261 255 /* Get the appropriate base path. */ 262 256 int i; 263 for (i = 0; i < 3; i++)257 for (i = 0; i < 2; i++) 264 258 { 265 259 if (i == 0) … … 267 261 rc = RTPathAppPrivateArch(szBase, sizeof (szBase)); 268 262 } 269 else if (i == 1)263 else 270 264 { 271 265 rc = RTPathSharedLibs(szBase, sizeof (szBase)); 272 266 } 273 else 274 { 275 szBase[0] = 0; 276 rc = VINF_SUCCESS; 277 } 278 267 279 268 if (RT_SUCCESS(rc)) 280 269 { 281 270 char szPath[RTPATH_MAX]; 282 271 283 272 /* szPath = pszBase + pszName */ 284 if (szBase[0] != 0) 285 { 286 rc = RTPathAbsEx (szBase, pszName, szPath, sizeof (szPath)); 287 } 288 else 289 { 290 strcpy (szPath, pszName); 291 } 292 273 rc = RTPathAbsEx (szBase, pszName, szPath, sizeof (szPath)); 274 293 275 if (RT_SUCCESS(rc)) 294 276 { 295 277 rc = RTLdrLoad (szPath, phLdrMod); 296 278 297 279 if (RT_SUCCESS(rc)) 298 280 { … … 304 286 } 305 287 } 306 288 307 289 return rc; 308 290 } … … 448 430 public: 449 431 HGCMMsgHeader () : pCmd (NULL), pHGCMPort (NULL) {}; 450 432 451 433 /* Command pointer/identifier. */ 452 434 PVBOXHGCMCMD pCmd; … … 519 501 case SVC_MSG_HOSTCALL: return new HGCMMsgHostCallSvc (); 520 502 case SVC_MSG_GUESTCALL: return new HGCMMsgCall (); 521 case SVC_MSG_LOADSTATE: 503 case SVC_MSG_LOADSTATE: 522 504 case SVC_MSG_SAVESTATE: return new HGCMMsgLoadSaveStateClient (); 523 505 case SVC_MSG_REGEXT: return new HGCMMsgSvcRegisterExtension (); … … 694 676 } 695 677 } break; 696 678 697 679 case SVC_MSG_REGEXT: 698 680 { … … 700 682 701 683 LogFlowFunc(("SVC_MSG_REGEXT handle = %p, pfn = %p\n", pMsg->handle, pMsg->pfnExtension)); 702 684 703 685 if (pSvc->m_hExtension) 704 686 { … … 715 697 rc = VERR_NOT_SUPPORTED; 716 698 } 717 699 718 700 if (VBOX_SUCCESS (rc)) 719 701 { … … 728 710 729 711 LogFlowFunc(("SVC_MSG_UNREGEXT handle = %p\n", pMsg->handle)); 730 712 731 713 if (pSvc->m_hExtension != pMsg->handle) 732 714 { … … 743 725 rc = VERR_NOT_SUPPORTED; 744 726 } 745 727 746 728 pSvc->m_hExtension = NULL; 747 729 } … … 771 753 if (pMsgCore->MsgId () == SVC_MSG_GUESTCALL) 772 754 { 773 /* Only call the completion for these messages. The helper 755 /* Only call the completion for these messages. The helper 774 756 * is called by the service, and the service does not get 775 757 * any other messages. … … 821 803 RTStrFree (m_pszSvcLibrary); 822 804 m_pszSvcLibrary = NULL; 823 805 824 806 RTStrFree (m_pszSvcName); 825 807 m_pszSvcName = NULL; 826 808 827 809 rc = VERR_NO_MEMORY; 828 810 } … … 832 814 m_svcHelpers.pfnCallComplete = svcHlpCallComplete; 833 815 m_svcHelpers.pvInstance = this; 834 816 835 817 /* Execute the load request on the service thread. */ 836 818 HGCMMSGHANDLE hMsg; … … 942 924 HGCMService *pSvc; 943 925 int rc = HGCMService::ResolveService (&pSvc, pszServiceName); 944 926 945 927 if (VBOX_SUCCESS (rc)) 946 928 { … … 968 950 pSvc->m_pSvcNext = sm_pSvcListHead; 969 951 pSvc->m_pSvcPrev = NULL; 970 952 971 953 if (sm_pSvcListHead) 972 954 { … … 1097 1079 ASMAtomicIncU32 (&m_u32RefCnt); 1098 1080 LogFlowFunc(("m_u32RefCnt = %d\n", m_u32RefCnt)); 1099 } 1081 } 1100 1082 1101 1083 /** The method dereferences a service and deletes it when no more refs. … … 1156 1138 1157 1139 LogFlowFunc(("%d services to be saved:\n", sm_cServices)); 1158 1140 1159 1141 /* Save number of services. */ 1160 1142 rc = SSMR3PutU32(pSSM, sm_cServices); … … 1228 1210 rc = SSMR3GetU32(pSSM, &cServices); 1229 1211 AssertRCReturn(rc, rc); 1230 1212 1231 1213 LogFlowFunc(("%d services to be restored:\n", cServices)); 1232 1214 … … 1237 1219 AssertRCReturn(rc, rc); 1238 1220 AssertReturn(u32 <= VBOX_HGCM_SVC_NAME_MAX_BYTES, VERR_SSM_UNEXPECTED_DATA); 1239 1221 1240 1222 char *pszServiceName = (char *)alloca (u32); 1241 1223 … … 1243 1225 rc = SSMR3GetStrZ(pSSM, pszServiceName, u32); 1244 1226 AssertRCReturn(rc, rc); 1245 1227 1246 1228 LogFlowFunc(("Restoring service [%s]\n", pszServiceName)); 1247 1229 1248 1230 /* Resolve the service instance. */ 1249 HGCMService *pSvc; 1231 HGCMService *pSvc; 1250 1232 rc = ResolveService (&pSvc, pszServiceName); 1251 1233 AssertReturn(pSvc, VERR_SSM_UNEXPECTED_DATA); 1252 1234 1253 1235 /* Get the number of clients. */ 1254 1236 uint32_t cClients; … … 1319 1301 1320 1302 uint32_t handle; 1321 1303 1322 1304 if (pu32ClientIdOut != NULL) 1323 1305 { … … 1353 1335 1354 1336 rc = hgcmMsgSend (hMsg); 1355 1337 1356 1338 if (VBOX_SUCCESS (rc)) 1357 1339 { … … 1363 1345 m_cClientsAllocated += 64; 1364 1346 } 1365 1347 1366 1348 m_paClientIds[m_cClients] = handle; 1367 1349 m_cClients++; … … 1383 1365 ReferenceService (); 1384 1366 } 1385 1367 1386 1368 LogFlowFunc(("rc = %Vrc\n", rc)); 1387 1369 return rc; … … 1412 1394 1413 1395 rc = hgcmMsgSend (hMsg); 1414 1396 1415 1397 /* Remove the client id from the array in any case. */ 1416 1398 int i; … … 1421 1403 { 1422 1404 m_cClients--; 1423 1405 1424 1406 if (m_cClients > i) 1425 1407 { 1426 1408 memmove (&m_paClientIds[i], &m_paClientIds[i + 1], m_cClients - i); 1427 1409 } 1428 1410 1429 1411 break; 1430 1412 } … … 1570 1552 1571 1553 1572 /* 1554 /* 1573 1555 * Main HGCM thread that manages services. 1574 1556 */ 1575 1557 1576 1558 /* Messages processed by the main HGCM thread. */ 1577 1559 #define HGCM_MSG_CONNECT (10) /* Connect a client to a service. */ … … 1667 1649 case HGCM_MSG_LOAD: return new HGCMMsgMainLoad (); 1668 1650 case HGCM_MSG_HOSTCALL: return new HGCMMsgMainHostCall (); 1669 case HGCM_MSG_LOADSTATE: 1651 case HGCM_MSG_LOADSTATE: 1670 1652 case HGCM_MSG_SAVESTATE: return new HGCMMsgMainLoadSaveState (); 1671 1653 case HGCM_MSG_RESET: return new HGCMMsgMainReset (); … … 1819 1801 { 1820 1802 HGCMMsgMainRegisterExtension *pMsg = (HGCMMsgMainRegisterExtension *)pMsgCore; 1821 1803 1822 1804 LogFlowFunc(("HGCM_MSG_REGEXT\n")); 1823 1805 1824 1806 /* Allocate the handle data. */ 1825 1807 HGCMSVCEXTHANDLE handle = (HGCMSVCEXTHANDLE)RTMemAllocZ (sizeof (struct _HGCMSVCEXTHANDLEDATA) 1826 1808 + strlen (pMsg->pszServiceName) 1827 1809 + sizeof (char)); 1828 1810 1829 1811 if (handle == NULL) 1830 1812 { … … 1835 1817 handle->pszServiceName = (char *)((uint8_t *)handle + sizeof (struct _HGCMSVCEXTHANDLEDATA)); 1836 1818 strcpy (handle->pszServiceName, pMsg->pszServiceName); 1837 1819 1838 1820 HGCMService *pService; 1839 1821 rc = HGCMService::ResolveService (&pService, handle->pszServiceName); … … 1845 1827 pService->ReleaseService (); 1846 1828 } 1847 1829 1848 1830 if (VBOX_FAILURE (rc)) 1849 1831 { … … 1872 1854 pService->ReleaseService (); 1873 1855 } 1874 1856 1875 1857 RTMemFree (pMsg->handle); 1876 1858 } break; … … 2237 2219 HGCMMsgMainHostCall *pMsg = (HGCMMsgMainHostCall *)hgcmObjReference (hMsg, HGCMOBJ_MSG); 2238 2220 AssertRelease(pMsg); 2239 2221 2240 2222 pMsg->pszServiceName = (char *)pszServiceName; 2241 2223 pMsg->u32Function = u32Function; … … 2255 2237 { 2256 2238 LogFlowFunc(("\n")); 2257 2239 2258 2240 /* Disconnect all clients. 2259 2241 */
Note:
See TracChangeset
for help on using the changeset viewer.