- Timestamp:
- Dec 19, 2008 3:44:42 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuest.h
r14352 r15699 1383 1383 # define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo)) 1384 1384 # define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo)) 1385 # define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size)) 1385 /*@todo, r=Leonid 1386 *This change is made to allow guest driver to distinguish between 32 and 64 bit calls on 64bit vista. 1387 *FIXME: "| VBOXGUEST_IOCTL_FLAG" should be moved into IOCTL_CODE define, 1388 *but I'm more than sure it will require more changes in vboxguest.cpp 1389 *Same goes for RT_OS_WINDOWS which is to make sure the change doesn't break something on other platforms. 1390 */ 1391 # ifdef RT_OS_WINDOWS 1392 # define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18 | VBOXGUEST_IOCTL_FLAG, (Size)) 1393 # else 1394 # define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size)) 1395 # endif 1386 1396 # define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size) VBOXGUEST_IOCTL_CODE(20, (Size)) 1387 1397 # define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t)) 1398 1399 # ifdef VBOX_WITH_64_BITS_GUESTS 1400 # ifndef VBOX_HGCM_HOST_CODE 1401 # define VBOXGUEST_IOCTL_HGCM_CALL_32(Size) VBOXGUEST_IOCTL_CODE(18, (Size)) 1402 # endif /* !VBOX_HGCM_HOST_CODE */ 1403 # endif /* VBOX_WITH_64_BITS_GUESTS */ 1388 1404 1389 1405 # define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo))) -
trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp
r14359 r15699 36 36 #include <iprt/assert.h> 37 37 #include <iprt/asm.h> 38 #include <iprt/mem.h> 38 39 #include <stdio.h> 39 40 #include <VBox/VBoxGuestLib.h> … … 1018 1019 1019 1020 } break; 1021 1022 #ifdef VBOX_WITH_64_BITS_GUESTS 1023 case VBOXGUEST_IOCTL_HGCM_CALL_32(0): /* (The size isn't relevant on NT.) */ 1024 { 1025 dprintf(("VBoxGuest::VBoxGuestDeviceControl: VBOXGUEST_IOCTL_HGCM_CALL_32\n")); 1026 1027 Status = vboxHGCMVerifyIOBuffers (pStack, 1028 sizeof (VBoxGuestHGCMCallInfo)); 1029 1030 if (Status != STATUS_SUCCESS) 1031 { 1032 dprintf(("VBoxGuest::VBoxGuestDeviceControl: invalid parameter. Status: %p\n", Status)); 1033 break; 1034 } 1035 1036 VBoxGuestHGCMCallInfo *ptr32 = (VBoxGuestHGCMCallInfo *)pBuf; 1037 VBoxGuestHGCMCallInfo *ptr64; 1038 1039 unsigned cbPtr32 = sizeof(*ptr32)+ptr32->cParms*sizeof(HGCMFunctionParameter32); 1040 unsigned cbPtr64 = sizeof(*ptr32)+ptr32->cParms*sizeof(HGCMFunctionParameter); 1041 1042 /*@todo r=Leonid, same should be applied to case VBOXGUEST_IOCTL_HGCM_CALL(0) as well, 1043 * because vboxHGCMVerifyIOBuffers, checks for sizeof (VBoxGuestHGCMCallInfo) only. 1044 */ 1045 if (pStack->Parameters.DeviceIoControl.InputBufferLength < cbPtr32) 1046 { 1047 dprintf(("VBoxGuest::vboxHGCMVerifyIOBuffers: InputBufferLength %d < %d\n", 1048 pStack->Parameters.DeviceIoControl.InputBufferLength, cbPtr32)); 1049 Status = STATUS_INVALID_PARAMETER; 1050 break; 1051 } 1052 1053 ptr64 = (VBoxGuestHGCMCallInfo *) RTMemTmpAlloc(cbPtr64); 1054 1055 if (!ptr64) 1056 { 1057 dprintf(("VBoxGuest::VBoxGuestDeviceControl: No memory\n")); 1058 Status = STATUS_UNSUCCESSFUL; 1059 break; 1060 } 1061 1062 /*copy 32bit call info into 64bit*/ 1063 { 1064 unsigned iParm; 1065 HGCMFunctionParameter *pParm64; 1066 HGCMFunctionParameter32 *pParm32; 1067 1068 /*copy header*/ 1069 memcpy(ptr64, ptr32, sizeof(VBoxGuestHGCMCallInfo)); 1070 1071 pParm64 = VBOXGUEST_HGCM_CALL_PARMS(ptr64); 1072 pParm32 = (HGCMFunctionParameter32*) VBOXGUEST_HGCM_CALL_PARMS(ptr32); 1073 1074 for (iParm = 0; iParm < ptr32->cParms; ++iParm) 1075 { 1076 pParm64->type = pParm32->type; 1077 1078 switch(pParm64->type) 1079 { 1080 case VMMDevHGCMParmType_PhysAddr: 1081 pParm64->u.Pointer.size = pParm32->u.Pointer.size; 1082 pParm64->u.Pointer.u.physAddr = pParm32->u.Pointer.u.physAddr; 1083 break; 1084 case VMMDevHGCMParmType_LinAddr: 1085 case VMMDevHGCMParmType_LinAddr_In: 1086 case VMMDevHGCMParmType_LinAddr_Out: 1087 case VMMDevHGCMParmType_LinAddr_Locked: 1088 case VMMDevHGCMParmType_LinAddr_Locked_In: 1089 case VMMDevHGCMParmType_LinAddr_Locked_Out: 1090 pParm64->u.Pointer.size = pParm32->u.Pointer.size; 1091 pParm64->u.Pointer.u.linearAddr = pParm32->u.Pointer.u.linearAddr; 1092 break; 1093 case VMMDevHGCMParmType_32bit: 1094 pParm64->u.value32 = pParm32->u.value32; 1095 break; 1096 case VMMDevHGCMParmType_64bit: 1097 pParm64->u.value64 = pParm32->u.value64; 1098 break; 1099 default: 1100 Status = STATUS_UNSUCCESSFUL; 1101 break; 1102 } 1103 1104 ++pParm32; 1105 ++pParm64; 1106 } 1107 1108 if (Status != STATUS_SUCCESS) 1109 { 1110 dprintf(("VBoxGuest::VBoxGuestDeviceControl: invalid parameter. Status: %p\n", Status)); 1111 break; 1112 } 1113 } 1114 1115 int rc = VbglHGCMCall (ptr64, VBoxHGCMCallback, pDevExt, RT_INDEFINITE_WAIT); 1116 1117 if (RT_FAILURE(rc)) 1118 { 1119 dprintf(("VBOXGUEST_IOCTL_HGCM_CALL: vbox rc = %Rrc\n", rc)); 1120 Status = STATUS_UNSUCCESSFUL; 1121 } 1122 else 1123 { 1124 cbOut = pStack->Parameters.DeviceIoControl.OutputBufferLength; 1125 } 1126 1127 /*copy results back*/ 1128 { 1129 unsigned iParm; 1130 HGCMFunctionParameter *pParm64; 1131 HGCMFunctionParameter32 *pParm32; 1132 1133 /*copy header*/ 1134 memcpy(ptr32, ptr64, sizeof(VBoxGuestHGCMCallInfo)); 1135 1136 pParm64 = VBOXGUEST_HGCM_CALL_PARMS(ptr64); 1137 pParm32 = (HGCMFunctionParameter32*) VBOXGUEST_HGCM_CALL_PARMS(ptr32); 1138 1139 /*@todo r=Leonid, FIXME: I think pointer values couldn't change but not sure so better play it safe*/ 1140 for (iParm = 0; iParm < ptr32->cParms; ++iParm) 1141 { 1142 pParm32->type = pParm64->type; 1143 1144 switch(pParm64->type) 1145 { 1146 case VMMDevHGCMParmType_PhysAddr: 1147 pParm32->u.Pointer.size = pParm64->u.Pointer.size; 1148 pParm32->u.Pointer.u.physAddr = pParm64->u.Pointer.u.physAddr; 1149 break; 1150 case VMMDevHGCMParmType_LinAddr: 1151 case VMMDevHGCMParmType_LinAddr_In: 1152 case VMMDevHGCMParmType_LinAddr_Out: 1153 case VMMDevHGCMParmType_LinAddr_Locked: 1154 case VMMDevHGCMParmType_LinAddr_Locked_In: 1155 case VMMDevHGCMParmType_LinAddr_Locked_Out: 1156 pParm32->u.Pointer.size = pParm64->u.Pointer.size; 1157 pParm32->u.Pointer.u.linearAddr = pParm64->u.Pointer.u.linearAddr; 1158 break; 1159 case VMMDevHGCMParmType_32bit: 1160 pParm32->u.value32 = pParm64->u.value32; 1161 break; 1162 case VMMDevHGCMParmType_64bit: 1163 pParm32->u.value64 = pParm64->u.value64; 1164 break; 1165 default: 1166 Status = STATUS_UNSUCCESSFUL; 1167 break; 1168 } 1169 1170 ++pParm32; 1171 ++pParm64; 1172 } 1173 1174 if (Status != STATUS_SUCCESS) 1175 { 1176 dprintf(("VBoxGuest::VBoxGuestDeviceControl: invalid parameter. Status: %p\n", Status)); 1177 break; 1178 } 1179 } 1180 1181 RTMemTmpFree(ptr64); 1182 1183 } break; 1184 #endif 1020 1185 1021 1186 case VBOXGUEST_IOCTL_HGCM_CALL_TIMED(0): /* (The size isn't relevant on NT.) */
Note:
See TracChangeset
for help on using the changeset viewer.