Changeset 17210 in vbox for trunk/src/VBox
- Timestamp:
- Feb 27, 2009 2:12:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r17196 r17210 1051 1051 PVBOXGUESTSESSION pSession, 1052 1052 VBoxGuestHGCMCallInfo *pInfo, 1053 uint32_t cMillies, bool fInterruptible, 1053 uint32_t cMillies, bool fInterruptible, bool f32bit, 1054 1054 size_t cbExtra, size_t cbData, size_t *pcbDataReturned) 1055 1055 { … … 1062 1062 return VERR_INVALID_PARAMETER; 1063 1063 } 1064 const size_t cbActual = cbExtra + sizeof(*pInfo) + pInfo->cParms * sizeof(HGCMFunctionParameter); 1064 size_t cbActual = cbExtra + sizeof(*pInfo); 1065 #ifdef RT_ARCH_AMD64 1066 if (f32bit) 1067 cbActual += pInfo->cParms * sizeof(HGCMFunctionParameter32); 1068 else 1069 #endif 1070 cbActual += pInfo->cParms * sizeof(HGCMFunctionParameter); 1065 1071 if (cbData < cbActual) 1066 1072 { … … 1097 1103 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: u32Client=%RX32\n", pInfo->u32ClientID)); 1098 1104 int rc; 1099 if (fInterruptible) 1100 rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallbackInterruptible, pDevExt, cMillies); 1105 #ifdef RT_ARCH_AMD64 1106 if (f32bit) 1107 { 1108 if (fInterruptible) 1109 rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallbackInterruptible, pDevExt, cMillies); 1110 else 1111 rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, cMillies); 1112 } 1101 1113 else 1102 rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, cMillies); 1114 #endif 1115 { 1116 if (fInterruptible) 1117 rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallbackInterruptible, pDevExt, cMillies); 1118 else 1119 rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, cMillies); 1120 } 1103 1121 if (RT_SUCCESS(rc)) 1104 1122 { … … 1110 1128 return rc; 1111 1129 } 1112 1113 1114 #ifdef RT_ARCH_AMD641115 /** The 32-bit version HGCM call for 64-bit driver. */1116 static int VBoxGuestCommonIOCtl_HGCMCall32(PVBOXGUESTDEVEXT pDevExt,1117 PVBOXGUESTSESSION pSession,1118 VBoxGuestHGCMCallInfo *pInfo,1119 uint32_t cMillies, bool fInterruptible,1120 size_t cbExtra, size_t cbData, size_t *pcbDataReturned)1121 {1122 /*1123 * Some more validations.1124 */1125 if (pInfo->cParms > 4096) /* (Just make sure it doesn't overflow the next check.) */1126 {1127 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: cParm=%RX32 is not sane\n", pInfo->cParms));1128 return VERR_INVALID_PARAMETER;1129 }1130 const size_t cbActual = cbExtra + sizeof(*pInfo) + pInfo->cParms * sizeof(HGCMFunctionParameter32);1131 if (cbData < cbActual)1132 {1133 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: cbData=%#zx (%zu) required size is %#zx (%zu)\n",1134 cbData, cbActual));1135 return VERR_INVALID_PARAMETER;1136 }1137 1138 /*1139 * Validate the client id.1140 */1141 const uint32_t u32ClientId = pInfo->u32ClientID;1142 unsigned i;1143 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1144 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);1145 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)1146 if (pSession->aHGCMClientIds[i] == u32ClientId)1147 break;1148 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);1149 if (RT_UNLIKELY(i >= RT_ELEMENTS(pSession->aHGCMClientIds)))1150 {1151 static unsigned s_cErrors = 0;1152 if (s_cErrors++ > 32)1153 LogRel(("VBoxGuestCommonIOCtl: HGCM_CALL: Invalid handle. u32Client=%RX32\n", u32ClientId));1154 return VERR_INVALID_HANDLE;1155 }1156 1157 /*1158 * The VbglHGCMCall call will invoke the callback if the HGCM1159 * call is performed in an ASYNC fashion. This function can1160 * deal with cancelled requests, so we let user more requests1161 * be interruptible (should add a flag for this later I guess).1162 */1163 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: u32Client=%RX32\n", pInfo->u32ClientID));1164 int rc;1165 if (fInterruptible)1166 rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallbackInterruptible, pDevExt, cMillies);1167 else1168 rc = VbglHGCMCall32(pInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, cMillies);1169 if (RT_SUCCESS(rc))1170 {1171 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: result=%Rrc\n", pInfo->result));1172 if (pcbDataReturned)1173 *pcbDataReturned = cbActual;1174 }1175 Log(("VBoxGuestCommonIOCtl: HGCM_CALL: Failed. rc=%Rrc.\n", rc));1176 return rc;1177 }1178 #endif1179 1130 1180 1131 … … 1329 1280 bool fInterruptible = pSession->R0Process != NIL_RTR0PROCESS; 1330 1281 rc = VBoxGuestCommonIOCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT, 1331 fInterruptible, 1282 fInterruptible, false /*f32bit*/, 1332 1283 0, cbData, pcbDataReturned); 1333 1284 } … … 1338 1289 rc = VBoxGuestCommonIOCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout, 1339 1290 !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS, 1291 false /*f32bit*/, 1340 1292 RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned); 1341 1293 } … … 1345 1297 CHECKRET_MIN_SIZE("HGCM_CALL", sizeof(VBoxGuestHGCMCallInfo)); 1346 1298 bool fInterruptible = pSession->R0Process != NIL_RTR0PROCESS; 1347 rc = VBoxGuestCommonIOCtl_HGCMCall 32(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT,1348 fInterruptible,1349 1299 rc = VBoxGuestCommonIOCtl_HGCMCall(pDevExt, pSession, (VBoxGuestHGCMCallInfo *)pvData, RT_INDEFINITE_WAIT, 1300 fInterruptible, true /*f32bit*/, 1301 0, cbData, pcbDataReturned); 1350 1302 } 1351 1303 else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(0))) … … 1353 1305 CHECKRET_MIN_SIZE("HGCM_CALL_TIMED", sizeof(VBoxGuestHGCMCallInfoTimed)); 1354 1306 VBoxGuestHGCMCallInfoTimed *pInfo = (VBoxGuestHGCMCallInfoTimed *)pvData; 1355 rc = VBoxGuestCommonIOCtl_HGCMCall32(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout, 1356 !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS, 1357 RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned); 1358 } 1359 # endif 1307 rc = VBoxGuestCommonIOCtl_HGCMCall(pDevExt, pSession, &pInfo->info, pInfo->u32Timeout, 1308 !!pInfo->fInterruptible || pSession->R0Process != NIL_RTR0PROCESS, 1309 true /*f32bit*/, 1310 RT_OFFSETOF(VBoxGuestHGCMCallInfoTimed, info), cbData, pcbDataReturned); 1311 } 1312 # endif 1360 1313 #endif /* VBOX_WITH_HGCM */ 1361 1314 else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_LOG(0))) … … 1389 1342 # ifdef RT_ARCH_AMD64 1390 1343 case VBOXGUEST_IOCTL_HGCM_CONNECT_32: 1391 # endif 1344 # endif 1392 1345 CHECKRET_MIN_SIZE("HGCM_CONNECT", sizeof(VBoxGuestHGCMConnectInfo)); 1393 1346 rc = VBoxGuestCommonIOCtl_HGCMConnect(pDevExt, pSession, (VBoxGuestHGCMConnectInfo *)pvData, pcbDataReturned); … … 1397 1350 # ifdef RT_ARCH_AMD64 1398 1351 case VBOXGUEST_IOCTL_HGCM_DISCONNECT_32: 1399 # endif 1352 # endif 1400 1353 CHECKRET_MIN_SIZE("HGCM_DISCONNECT", sizeof(VBoxGuestHGCMDisconnectInfo)); 1401 1354 rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned); … … 1406 1359 rc = VBoxGuestCommonIOCtl_HGCMClipboardReConnect(pDevExt, (uint32_t *)pvData, pcbDataReturned); 1407 1360 break; 1408 1409 1361 #endif /* VBOX_WITH_HGCM */ 1410 1362
Note:
See TracChangeset
for help on using the changeset viewer.