Changeset 49394 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Nov 5, 2013 4:09:13 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.c
r48944 r49394 1050 1050 } 1051 1051 1052 static NTSTATUS vbsfVerifyConnectionName(PUNICODE_STRING ConnectionName) 1053 { 1054 /* Check that the connection name is valid: 1055 * "\Device\VBoxMiniRdr\;X:\vboxsvr\sf" 1056 */ 1057 NTSTATUS Status = STATUS_BAD_NETWORK_NAME; 1058 1059 ULONG i; 1060 PWCHAR pwc; 1061 PWCHAR pwc1; 1062 1063 static PWCHAR spwszPrefix = L"\\Device\\VBoxMiniRdr\\;"; 1064 1065 /* Unicode chars in the string. */ 1066 ULONG cConnectionName = ConnectionName->Length / sizeof(WCHAR); 1067 ULONG cRemainingName; 1068 1069 /* Check that the name starts with correct prefix. */ 1070 pwc1 = &spwszPrefix[0]; 1071 pwc = ConnectionName->Buffer; 1072 for (i = 0; i < cConnectionName; i++, pwc1++, pwc++) 1073 { 1074 if (*pwc1 == 0 || *pwc == 0 || *pwc1 != *pwc) 1075 { 1076 break; 1077 } 1078 } 1079 1080 cRemainingName = cConnectionName - i; 1081 1082 Log(("VBOXSF: vbsfVerifyConnectionName: prefix %d remaining %d [%.*ls]\n", 1083 *pwc1 == 0, cRemainingName, cRemainingName, &ConnectionName->Buffer[i])); 1084 1085 if (*pwc1 == 0) 1086 { 1087 /* pwc should point to a drive letter followed by ':\' that is at least 3 chars more. */ 1088 if (cRemainingName >= 3) 1089 { 1090 if ( pwc[0] >= L'A' && pwc[0] <= L'Z' 1091 && pwc[1] == L':') 1092 { 1093 pwc += 2; 1094 cRemainingName -= 2; 1095 1096 /* @todo should also check that the drive letter corresponds to the name. */ 1097 if (vboxIsPrefixOK(pwc, cRemainingName * sizeof (WCHAR))) 1098 { 1099 Status = STATUS_SUCCESS; 1100 } 1101 } 1102 } 1103 } 1104 1105 return Status; 1106 } 1107 1052 1108 static HANDLE vbsfOpenConnectionHandle(PUNICODE_STRING ConnectionName) 1053 1109 { … … 1061 1117 ConnectionName->Length / sizeof(WCHAR), ConnectionName->Buffer)); 1062 1118 1063 /* Have to create a OBJ_KERNEL_HANDLE. Otherwise the driver verifier on Windows 7 bugchecks. */ 1064 InitializeObjectAttributes(&ObjectAttributes, 1065 ConnectionName, 1066 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 1067 NULL, 1068 NULL); 1069 1070 Status = ZwCreateFile(&Handle, 1071 SYNCHRONIZE, 1072 &ObjectAttributes, 1073 &IoStatusBlock, 1074 NULL, 1075 FILE_ATTRIBUTE_NORMAL, 1076 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 1077 FILE_OPEN_IF, 1078 FILE_CREATE_TREE_CONNECTION | FILE_SYNCHRONOUS_IO_NONALERT, 1079 NULL, 1080 0); 1119 Status = vbsfVerifyConnectionName(ConnectionName); 1120 1121 if (NT_SUCCESS(Status)) 1122 { 1123 /* Have to create a OBJ_KERNEL_HANDLE. Otherwise the driver verifier on Windows 7 bugchecks. */ 1124 InitializeObjectAttributes(&ObjectAttributes, 1125 ConnectionName, 1126 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 1127 NULL, 1128 NULL); 1129 1130 Status = ZwCreateFile(&Handle, 1131 SYNCHRONIZE, 1132 &ObjectAttributes, 1133 &IoStatusBlock, 1134 NULL, 1135 FILE_ATTRIBUTE_NORMAL, 1136 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 1137 FILE_OPEN_IF, 1138 FILE_CREATE_TREE_CONNECTION | FILE_SYNCHRONOUS_IO_NONALERT, 1139 NULL, 1140 0); 1141 } 1081 1142 1082 1143 if ( Status != STATUS_SUCCESS … … 1266 1327 { 1267 1328 PFOBX Fobx = (PFOBX)pFileObject->FsContext2; 1268 1269 if (NodeType(Fobx) == RDBSS_NTC_V_NETROOT) 1329 Log(("VBOXSF: vbsfDeleteConnection: Fobx %p\n", Fobx)); 1330 1331 if (Fobx && NodeType(Fobx) == RDBSS_NTC_V_NETROOT) 1270 1332 { 1271 1333 PV_NET_ROOT VNetRoot = (PV_NET_ROOT)Fobx; … … 1329 1391 1330 1392 ExReleaseFastMutex(&pDeviceExtension->mtxLocalCon); 1393 1394 Log(("VBOXSF: vbsfDeleteConnection: deleted index 0x%x\n", 1395 idx)); 1331 1396 } 1332 1397 } … … 1339 1404 } 1340 1405 1406 Log(("VBOXSF: vbsfDeleteConnection: Status 0x%08X\n", Status)); 1341 1407 return Status; 1342 1408 }
Note:
See TracChangeset
for help on using the changeset viewer.