vbox的更動 6985 路徑 trunk/src/VBox/Main/hgcm/HGCM.cpp
- 時間撮記:
- 2008-2-18 上午11:05:05 (17 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/hgcm/HGCM.cpp
r6981 r6985 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 … … 240 240 * If only library name is specified, then try to load it from: 241 241 * - RTPathAppPrivateArch 242 * - RTPathSharedLibs 243 * - default system LIBPATH. 242 * - RTPathSharedLibs (legacy) 244 243 */ 245 244 int rc = VINF_SUCCESS; 246 245 247 246 if (RTPathHavePath (pszName)) 248 247 { … … 252 251 else 253 252 { 254 if (strlen (pszName) >= RTPATH_MAX)255 {256 return VERR_FILENAME_TOO_LONG;257 }258 259 253 /* Try default locations. */ 260 254 char szBase[RTPATH_MAX]; 261 255 262 256 /* Get the appropriate base path. */ 263 257 int i; 264 for (i = 0; i < 3; i++)258 for (i = 0; i < 2; i++) 265 259 { 266 260 if (i == 0) … … 268 262 rc = RTPathAppPrivateArch(szBase, sizeof (szBase)); 269 263 } 270 else if (i == 1)264 else 271 265 { 272 266 rc = RTPathSharedLibs(szBase, sizeof (szBase)); 273 267 } 274 else 275 { 276 szBase[0] = 0; 277 rc = VINF_SUCCESS; 278 } 279 268 280 269 if (RT_SUCCESS(rc)) 281 270 { 282 271 char szPath[RTPATH_MAX]; 283 272 284 273 /* szPath = pszBase + pszName */ 285 if (szBase[0] != 0) 286 { 287 rc = RTPathAbsEx (szBase, pszName, szPath, sizeof (szPath)); 288 } 289 else 290 { 291 strcpy (szPath, pszName); 292 } 293 274 rc = RTPathAbsEx (szBase, pszName, szPath, sizeof (szPath)); 275 294 276 if (RT_SUCCESS(rc)) 295 277 { 296 278 rc = RTLdrLoad (szPath, phLdrMod); 297 279 298 280 if (RT_SUCCESS(rc)) 299 281 { … … 305 287 } 306 288 } 307 289 308 290 return rc; 309 291 } … … 449 431 public: 450 432 HGCMMsgHeader () : pCmd (NULL), pHGCMPort (NULL) {}; 451 433 452 434 /* Command pointer/identifier. */ 453 435 PVBOXHGCMCMD pCmd; … … 520 502 case SVC_MSG_HOSTCALL: return new HGCMMsgHostCallSvc (); 521 503 case SVC_MSG_GUESTCALL: return new HGCMMsgCall (); 522 case SVC_MSG_LOADSTATE: 504 case SVC_MSG_LOADSTATE: 523 505 case SVC_MSG_SAVESTATE: return new HGCMMsgLoadSaveStateClient (); 524 506 case SVC_MSG_REGEXT: return new HGCMMsgSvcRegisterExtension (); … … 695 677 } 696 678 } break; 697 679 698 680 case SVC_MSG_REGEXT: 699 681 { … … 701 683 702 684 LogFlowFunc(("SVC_MSG_REGEXT handle = %p, pfn = %p\n", pMsg->handle, pMsg->pfnExtension)); 703 685 704 686 if (pSvc->m_hExtension) 705 687 { … … 716 698 rc = VERR_NOT_SUPPORTED; 717 699 } 718 700 719 701 if (VBOX_SUCCESS (rc)) 720 702 { … … 729 711 730 712 LogFlowFunc(("SVC_MSG_UNREGEXT handle = %p\n", pMsg->handle)); 731 713 732 714 if (pSvc->m_hExtension != pMsg->handle) 733 715 { … … 744 726 rc = VERR_NOT_SUPPORTED; 745 727 } 746 728 747 729 pSvc->m_hExtension = NULL; 748 730 } … … 772 754 if (pMsgCore->MsgId () == SVC_MSG_GUESTCALL) 773 755 { 774 /* Only call the completion for these messages. The helper 756 /* Only call the completion for these messages. The helper 775 757 * is called by the service, and the service does not get 776 758 * any other messages. … … 832 814 RTStrFree (m_pszSvcLibrary); 833 815 m_pszSvcLibrary = NULL; 834 816 835 817 RTStrFree (m_pszSvcName); 836 818 m_pszSvcName = NULL; 837 819 838 820 rc = VERR_NO_MEMORY; 839 821 } … … 844 826 m_svcHelpers.pvInstance = this; 845 827 m_svcHelpers.pfnDisconnectClient = svcHlpDisconnectClient; 846 828 847 829 /* Execute the load request on the service thread. */ 848 830 HGCMMSGHANDLE hMsg; … … 954 936 HGCMService *pSvc; 955 937 int rc = HGCMService::ResolveService (&pSvc, pszServiceName); 956 938 957 939 if (VBOX_SUCCESS (rc)) 958 940 { … … 980 962 pSvc->m_pSvcNext = sm_pSvcListHead; 981 963 pSvc->m_pSvcPrev = NULL; 982 964 983 965 if (sm_pSvcListHead) 984 966 { … … 1109 1091 ASMAtomicIncU32 (&m_u32RefCnt); 1110 1092 LogFlowFunc(("m_u32RefCnt = %d\n", m_u32RefCnt)); 1111 } 1093 } 1112 1094 1113 1095 /** The method dereferences a service and deletes it when no more refs. … … 1168 1150 1169 1151 LogFlowFunc(("%d services to be saved:\n", sm_cServices)); 1170 1152 1171 1153 /* Save number of services. */ 1172 1154 rc = SSMR3PutU32(pSSM, sm_cServices); … … 1240 1222 rc = SSMR3GetU32(pSSM, &cServices); 1241 1223 AssertRCReturn(rc, rc); 1242 1224 1243 1225 LogFlowFunc(("%d services to be restored:\n", cServices)); 1244 1226 … … 1249 1231 AssertRCReturn(rc, rc); 1250 1232 AssertReturn(u32 <= VBOX_HGCM_SVC_NAME_MAX_BYTES, VERR_SSM_UNEXPECTED_DATA); 1251 1233 1252 1234 char *pszServiceName = (char *)alloca (u32); 1253 1235 … … 1255 1237 rc = SSMR3GetStrZ(pSSM, pszServiceName, u32); 1256 1238 AssertRCReturn(rc, rc); 1257 1239 1258 1240 LogFlowFunc(("Restoring service [%s]\n", pszServiceName)); 1259 1241 1260 1242 /* Resolve the service instance. */ 1261 HGCMService *pSvc; 1243 HGCMService *pSvc; 1262 1244 rc = ResolveService (&pSvc, pszServiceName); 1263 1245 AssertReturn(pSvc, VERR_SSM_UNEXPECTED_DATA); 1264 1246 1265 1247 /* Get the number of clients. */ 1266 1248 uint32_t cClients; … … 1331 1313 1332 1314 uint32_t handle; 1333 1315 1334 1316 if (pu32ClientIdOut != NULL) 1335 1317 { … … 1365 1347 1366 1348 rc = hgcmMsgSend (hMsg); 1367 1349 1368 1350 if (VBOX_SUCCESS (rc)) 1369 1351 { … … 1375 1357 m_cClientsAllocated += 64; 1376 1358 } 1377 1359 1378 1360 m_paClientIds[m_cClients] = handle; 1379 1361 m_cClients++; … … 1395 1377 ReferenceService (); 1396 1378 } 1397 1379 1398 1380 LogFlowFunc(("rc = %Vrc\n", rc)); 1399 1381 return rc; … … 1441 1423 { 1442 1424 m_cClients--; 1443 1425 1444 1426 if (m_cClients > i) 1445 1427 { 1446 1428 memmove (&m_paClientIds[i], &m_paClientIds[i + 1], m_cClients - i); 1447 1429 } 1448 1430 1449 1431 break; 1450 1432 } … … 1590 1572 1591 1573 1592 /* 1574 /* 1593 1575 * Main HGCM thread that manages services. 1594 1576 */ 1595 1577 1596 1578 /* Messages processed by the main HGCM thread. */ 1597 1579 #define HGCM_MSG_CONNECT (10) /* Connect a client to a service. */ … … 1687 1669 case HGCM_MSG_LOAD: return new HGCMMsgMainLoad (); 1688 1670 case HGCM_MSG_HOSTCALL: return new HGCMMsgMainHostCall (); 1689 case HGCM_MSG_LOADSTATE: 1671 case HGCM_MSG_LOADSTATE: 1690 1672 case HGCM_MSG_SAVESTATE: return new HGCMMsgMainLoadSaveState (); 1691 1673 case HGCM_MSG_RESET: return new HGCMMsgMainReset (); … … 1839 1821 { 1840 1822 HGCMMsgMainRegisterExtension *pMsg = (HGCMMsgMainRegisterExtension *)pMsgCore; 1841 1823 1842 1824 LogFlowFunc(("HGCM_MSG_REGEXT\n")); 1843 1825 1844 1826 /* Allocate the handle data. */ 1845 1827 HGCMSVCEXTHANDLE handle = (HGCMSVCEXTHANDLE)RTMemAllocZ (sizeof (struct _HGCMSVCEXTHANDLEDATA) 1846 1828 + strlen (pMsg->pszServiceName) 1847 1829 + sizeof (char)); 1848 1830 1849 1831 if (handle == NULL) 1850 1832 { … … 1855 1837 handle->pszServiceName = (char *)((uint8_t *)handle + sizeof (struct _HGCMSVCEXTHANDLEDATA)); 1856 1838 strcpy (handle->pszServiceName, pMsg->pszServiceName); 1857 1839 1858 1840 HGCMService *pService; 1859 1841 rc = HGCMService::ResolveService (&pService, handle->pszServiceName); … … 1865 1847 pService->ReleaseService (); 1866 1848 } 1867 1849 1868 1850 if (VBOX_FAILURE (rc)) 1869 1851 { … … 1892 1874 pService->ReleaseService (); 1893 1875 } 1894 1876 1895 1877 RTMemFree (pMsg->handle); 1896 1878 } break; … … 2257 2239 HGCMMsgMainHostCall *pMsg = (HGCMMsgMainHostCall *)hgcmObjReference (hMsg, HGCMOBJ_MSG); 2258 2240 AssertRelease(pMsg); 2259 2241 2260 2242 pMsg->pszServiceName = (char *)pszServiceName; 2261 2243 pMsg->u32Function = u32Function; … … 2275 2257 { 2276 2258 LogFlowFunc(("\n")); 2277 2259 2278 2260 /* Disconnect all clients. 2279 2261 */
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器