Changeset 51254 in vbox for trunk/src/VBox/Additions
- Timestamp:
- May 15, 2014 8:00:46 AM (11 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.c
r48944 r51254 115 115 116 116 if (cbToTransfer > pCtx->cbData - cbTransferred) 117 {118 117 cbToTransfer = pCtx->cbData - cbTransferred; 119 }120 118 121 119 if (cbToTransfer == 0) … … 131 129 132 130 for (iPage = 0; iPage < cPagesToTransfer; iPage++) 133 {134 131 paPages[iPage] = (RTGCPHYS64)paPfns[iPage + cPagesTransferred] << PAGE_SHIFT; 135 }136 132 137 133 rc = pCtx->pfnTransferPages(pCtx->pClient, pCtx->pMap, pCtx->hFile, … … 144 140 /* If some data was transferred, then it is no error. */ 145 141 if (cbTransferred > 0) 146 {147 142 rc = VINF_SUCCESS; 148 }149 143 150 144 break; … … 164 158 cPagesToTransfer = cPages - cPagesTransferred; 165 159 if (cPagesToTransfer > VBSF_MAX_READ_WRITE_PAGES) 166 {167 160 cPagesToTransfer = VBSF_MAX_READ_WRITE_PAGES; 168 }169 161 } 170 162 … … 201 193 /* If some data was transferred, then it is no error. */ 202 194 if (cbTransferred > 0) 203 {204 195 rc = VINF_SUCCESS; 205 }206 196 207 197 break; … … 218 208 cbToTransfer = pCtx->cbData - cbTransferred; 219 209 if (cbToTransfer > VBSF_MAX_READ_WRITE_PAGES * PAGE_SIZE) 220 {221 210 cbToTransfer = VBSF_MAX_READ_WRITE_PAGES * PAGE_SIZE; 222 }223 211 } 224 212 } … … 277 265 278 266 if (ByteCount > FileSize - ByteOffset) 279 {280 267 ByteCount = (ULONG)(FileSize - ByteOffset); 281 }282 268 } 283 269 284 270 /* @todo read 0 bytes == always success? */ 285 if ( BufferMdl == NULL271 if ( !BufferMdl 286 272 || ByteCount == 0) 287 273 { … … 343 329 RxContext); 344 330 345 Log(("VBOXSF: MRxRead: RxDispatchToWorkerThread: Status 0x%08X\n", 346 Status)); 331 Log(("VBOXSF: MRxRead: RxDispatchToWorkerThread: Status 0x%08X\n", Status)); 347 332 348 333 if (Status == STATUS_SUCCESS) 349 {350 334 Status = STATUS_PENDING; 351 }352 335 353 336 return Status; … … 389 372 390 373 /* @todo allow to write 0 bytes. */ 391 if ( BufferMdl == NULL374 if ( !BufferMdl 392 375 || ByteCount == 0) 393 376 { … … 452 435 453 436 if (Status == STATUS_SUCCESS) 454 {455 437 Status = STATUS_PENDING; 456 }457 438 458 439 return Status; … … 505 486 506 487 if (LowIoContext->ParamsFor.Locks.Flags & LOWIO_LOCKSFLAG_FAIL_IMMEDIATELY) 507 {508 488 fu32Lock |= SHFL_LOCK_NOWAIT; 509 }510 489 else 511 {512 490 fu32Lock |= SHFL_LOCK_WAIT; 513 }514 491 515 492 vboxRC = vboxCallLock(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile, … … 518 495 Status = VBoxErrorToNTStatus(vboxRC); 519 496 520 Log(("VBOXSF: MRxLocks: Returned 0x%08X\n", 521 Status)); 497 Log(("VBOXSF: MRxLocks: Returned 0x%08X\n", Status)); 522 498 return Status; 523 499 } … … 551 527 Status = VBoxErrorToNTStatus(vboxRC); 552 528 553 Log(("VBOXSF: MRxFlush: Returned 0x%08X\n", 554 Status)); 529 Log(("VBOXSF: MRxFlush: Returned 0x%08X\n", Status)); 555 530 return Status; 556 531 } … … 580 555 cbBuffer = sizeof(SHFLFSOBJINFO); 581 556 pObjInfo = (SHFLFSOBJINFO *)vbsfAllocNonPagedMem(cbBuffer); 582 if ( pObjInfo == NULL)557 if (!pObjInfo) 583 558 { 584 559 AssertFailed(); … … 592 567 SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, (PSHFLDIRINFO)pObjInfo); 593 568 594 Log(("VBOXSF: vbsfSetEndOfFile: vboxCallFSInfo returned %Rrc\n", 595 vboxRC)); 569 Log(("VBOXSF: vbsfSetEndOfFile: vboxCallFSInfo returned %Rrc\n", vboxRC)); 596 570 597 571 Status = VBoxErrorToNTStatus(vboxRC); … … 606 580 607 581 if (pObjInfo) 608 {609 582 vbsfFreeNonPagedMem(pObjInfo); 610 } 611 612 Log(("VBOXSF: vbsfSetEndOfFile: Returned 0x%08X\n", 613 Status)); 583 584 Log(("VBOXSF: vbsfSetEndOfFile: Returned 0x%08X\n", Status)); 614 585 return Status; 615 586 } -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.c
r40532 r51254 54 54 55 55 ULONG *pNextOffset = 0; 56 PSHFLSTRING ParsedPath = 0;56 PSHFLSTRING ParsedPath = NULL; 57 57 58 58 Log(("VBOXSF: MrxQueryDirectory: FileInformationClass %d, pVBoxFobx %p, hFile %RX64, pInfoBuffer %p\n", 59 59 FileInformationClass, pVBoxFobx, pVBoxFobx->hFile, pInfoBuffer)); 60 60 61 if ( NULL ==pVBoxFobx)61 if (!pVBoxFobx) 62 62 { 63 63 Log(("VBOXSF: MrxQueryDirectory: pVBoxFobx is invalid!\n")); … … 65 65 } 66 66 67 if (NULL == DirectoryName) 68 { 67 if (!DirectoryName) 69 68 return STATUS_INVALID_PARAMETER; 70 }71 69 72 70 if (DirectoryName->Length == 0) 73 {74 71 Log(("VBOXSF: MrxQueryDirectory: DirectoryName = \\ (null string)\n")); 75 }76 72 else 77 {78 73 Log(("VBOXSF: MrxQueryDirectory: DirectoryName = %.*ls\n", 79 74 DirectoryName->Length / sizeof(WCHAR), DirectoryName->Buffer)); 80 } 81 82 if (NULL == Template) 83 { 75 76 if (!Template) 84 77 return STATUS_INVALID_PARAMETER; 85 }86 78 87 79 if (Template->Length == 0) 88 {89 80 Log(("VBOXSF: MrxQueryDirectory: Template = \\ (null string)\n")); 90 }91 81 else 92 {93 82 Log(("VBOXSF: MrxQueryDirectory: Template = %.*ls\n", 94 83 Template->Length / sizeof(WCHAR), Template->Buffer)); 95 }96 84 97 85 cbHGCMBuffer = RT_MAX(cbMaxSize, PAGE_SIZE); … … 101 89 102 90 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer); 103 if ( pHGCMBuffer == NULL)91 if (!pHGCMBuffer) 104 92 { 105 93 AssertFailed(); … … 128 116 129 117 /* Calculate length required for parsed path. */ 130 ParsedPathSize = sizeof(*ParsedPath) + (DirectoryName->Length + Template->Length + 3 * sizeof(WCHAR)); 131 132 Log(("VBOXSF: MrxQueryDirectory: ParsedPathSize = %d\n", 133 ParsedPathSize)); 118 ParsedPathSize = sizeof(SHFLSTRING) + DirectoryName->Length + Template->Length + 3 * sizeof(WCHAR); 119 Log(("VBOXSF: MrxQueryDirectory: ParsedPathSize = %d\n", ParsedPathSize)); 134 120 135 121 ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize); … … 141 127 142 128 RtlZeroMemory(ParsedPath, ParsedPathSize); 143 ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING)); 129 if (!ShflStringInitBuffer(ParsedPath, ParsedPathSize)) 130 { 131 Status = STATUS_INSUFFICIENT_RESOURCES; 132 goto end; 133 } 144 134 145 135 ParsedPath->u16Size = DirectoryName->Length + Template->Length + sizeof(WCHAR); … … 223 213 224 214 if (Status != STATUS_SUCCESS) 225 {226 215 goto end; 227 }228 216 229 217 /* Verify that the returned buffer length is not greater than the original one. */ … … 483 471 } 484 472 else 485 { 486 break; 487 } 473 break; 488 474 489 475 if (RxContext->QueryDirectory.ReturnSingleEntry) 490 { 491 break; 492 } 476 break; 493 477 494 478 /* More left? */ 495 479 if (cbHGCMBuffer <= 0) 496 { 497 break; 498 } 480 break; 499 481 500 482 index++; /* File Index. */ … … 504 486 505 487 if (pNextOffset) 506 {507 488 *pNextOffset = 0; /* Last pInfo->NextEntryOffset should be set to zero! */ 508 }509 489 510 490 end: 511 491 if (pHGCMBuffer) 512 {513 492 vbsfFreeNonPagedMem(pHGCMBuffer); 514 }515 493 516 494 if (ParsedPath) 517 {518 495 vbsfFreeNonPagedMem(ParsedPath); 519 }520 496 521 497 Log(("VBOXSF: MrxQueryDirectory: Returned 0x%08X\n", … … 567 543 Log(("VBOXSF: MrxQueryVolumeInfo: FileFsVolumeInformation\n")); 568 544 569 if ( pVBoxFobx == NULL)545 if (!pVBoxFobx) 570 546 { 571 547 Log(("VBOXSF: MrxQueryVolumeInfo: pVBoxFobx is NULL!\n")); … … 602 578 cbHGCMBuffer = sizeof(SHFLVOLINFO); 603 579 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer); 604 if ( pHGCMBuffer == NULL)580 if (!pHGCMBuffer) 605 581 { 606 582 Status = STATUS_INSUFFICIENT_RESOURCES; … … 758 734 } 759 735 760 if ( pVBoxFobx == NULL)736 if (!pVBoxFobx) 761 737 { 762 738 Log(("VBOXSF: MrxQueryVolumeInfo: pVBoxFobx is NULL!\n")); … … 775 751 cbHGCMBuffer = sizeof(SHFLVOLINFO); 776 752 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer); 777 if ( pHGCMBuffer == NULL)753 if (!pHGCMBuffer) 778 754 { 779 755 Status = STATUS_INSUFFICIENT_RESOURCES; … … 916 892 917 893 if (Status == STATUS_SUCCESS) 918 {919 894 RxContext->Info.LengthRemaining = cbInfoBuffer - cbToCopy; 920 }921 895 else if (Status == STATUS_BUFFER_TOO_SMALL) 922 896 { … … 956 930 PSHFLFSOBJINFO pFileEntry = NULL; 957 931 958 if ( NULL ==pLengthRemaining)932 if (!pLengthRemaining) 959 933 { 960 934 Log(("VBOXSF: MrxQueryFileInfo: length pointer is NULL!\n")); … … 965 939 pInfoBuffer, cbInfoBuffer, *pLengthRemaining)); 966 940 967 if ( NULL ==pVBoxFobx)941 if (!pVBoxFobx) 968 942 { 969 943 Log(("VBOXSF: MrxQueryFileInfo: pVBoxFobx is NULL!\n")); … … 971 945 } 972 946 973 if ( NULL ==pInfoBuffer)947 if (!pInfoBuffer) 974 948 { 975 949 Log(("VBOXSF: MrxQueryFileInfo: pInfoBuffer is NULL!\n")); … … 1012 986 1013 987 if (*pLengthRemaining >= cbToCopy) 1014 {1015 988 *pInfo = pVBoxFobx->FileStandardInfo; 1016 } 1017 else 1018 { 989 else 1019 990 Status = STATUS_BUFFER_TOO_SMALL; 1020 }1021 991 break; 1022 992 } … … 1041 1011 } 1042 1012 else 1043 {1044 1013 Status = STATUS_BUFFER_TOO_SMALL; 1045 }1046 1014 break; 1047 1015 } … … 1060 1028 } 1061 1029 else 1062 {1063 1030 Status = STATUS_BUFFER_TOO_SMALL; 1064 }1065 1031 break; 1066 1032 } … … 1077 1043 } 1078 1044 else 1079 {1080 1045 Status = STATUS_BUFFER_TOO_SMALL; 1081 }1082 1046 break; 1083 1047 } … … 1101 1065 } 1102 1066 else 1103 {1104 1067 Status = STATUS_BUFFER_TOO_SMALL; 1105 }1106 1068 break; 1107 1069 } … … 1124 1086 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer); 1125 1087 1126 if (pHGCMBuffer == NULL) 1127 { 1088 if (!pHGCMBuffer) 1128 1089 return STATUS_INSUFFICIENT_RESOURCES; 1129 }1130 1090 1131 1091 Assert(pVBoxFobx && pNetRootExtension && pDeviceExtension); … … 1163 1123 } 1164 1124 else 1165 {1166 1125 Status = STATUS_BUFFER_TOO_SMALL; 1167 }1168 1126 break; 1169 1127 } … … 1184 1142 1185 1143 if (pFileEntry->Attr.fMode & RTFS_DOS_DIRECTORY) 1186 {1187 1144 pInfo->Directory = TRUE; 1188 }1189 1145 else 1190 {1191 1146 pInfo->Directory = FALSE; 1192 } 1193 } 1194 else 1195 { 1147 } 1148 else 1196 1149 Status = STATUS_BUFFER_TOO_SMALL; 1197 }1198 1150 break; 1199 1151 } … … 1218 1170 } 1219 1171 else 1220 {1221 1172 Status = STATUS_BUFFER_TOO_SMALL; 1222 }1223 1173 break; 1224 1174 } … … 1237 1187 } 1238 1188 else 1239 {1240 1189 Status = STATUS_BUFFER_TOO_SMALL; 1241 }1242 1190 break; 1243 1191 } … … 1251 1199 1252 1200 if (*pLengthRemaining >= cbToCopy) 1253 {1254 1201 pInfo->EaSize = 0; 1255 } 1256 else 1257 { 1202 else 1258 1203 Status = STATUS_BUFFER_TOO_SMALL; 1259 }1260 1204 break; 1261 1205 } … … 1274 1218 } 1275 1219 else 1276 {1277 1220 Status = STATUS_BUFFER_TOO_SMALL; 1278 }1279 1221 break; 1280 1222 } … … 1288 1230 1289 1231 if (*pLengthRemaining >= cbToCopy) 1290 {1291 1232 pInfo->EndOfFile.QuadPart = pFileEntry->cbObject; 1292 } 1293 else 1294 { 1233 else 1295 1234 Status = STATUS_BUFFER_TOO_SMALL; 1296 }1297 1235 break; 1298 1236 } … … 1306 1244 1307 1245 if (*pLengthRemaining >= cbToCopy) 1308 {1309 1246 pInfo->AllocationSize.QuadPart = pFileEntry->cbAllocated; 1310 } 1311 else 1312 { 1247 else 1313 1248 Status = STATUS_BUFFER_TOO_SMALL; 1314 }1315 1249 break; 1316 1250 } … … 1334 1268 } 1335 1269 else 1336 {1337 1270 Status = STATUS_BUFFER_TOO_SMALL; 1338 }1339 1271 break; 1340 1272 } … … 1378 1310 1379 1311 if (pHGCMBuffer) 1380 {1381 1312 vbsfFreeNonPagedMem(pHGCMBuffer); 1382 }1383 1313 1384 1314 if (Status == STATUS_SUCCESS) … … 1388 1318 } 1389 1319 1390 Log(("VBOXSF: MrxQueryFileInfo: Returned 0x%08X\n", 1391 Status)); 1320 Log(("VBOXSF: MrxQueryFileInfo: Returned 0x%08X\n", Status)); 1392 1321 return Status; 1393 1322 } … … 1454 1383 cbBuffer = sizeof(SHFLFSOBJINFO); 1455 1384 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer); 1456 if ( pHGCMBuffer == NULL)1385 if (!pHGCMBuffer) 1457 1386 { 1458 1387 AssertFailed(); … … 1504 1433 /* Update our internal copy. Ignore zero fields! */ 1505 1434 if (pInfo->CreationTime.QuadPart && !pVBoxFobx->fKeepCreationTime) 1506 {1507 1435 pVBoxFobx->FileBasicInfo.CreationTime = pInfo->CreationTime; 1508 }1509 1436 if (pInfo->LastAccessTime.QuadPart && !pVBoxFobx->fKeepLastAccessTime) 1510 {1511 1437 pVBoxFobx->FileBasicInfo.LastAccessTime = pInfo->LastAccessTime; 1512 }1513 1438 if (pInfo->LastWriteTime.QuadPart && !pVBoxFobx->fKeepLastWriteTime) 1514 {1515 1439 pVBoxFobx->FileBasicInfo.LastWriteTime = pInfo->LastWriteTime; 1516 }1517 1440 if (pInfo->ChangeTime.QuadPart && !pVBoxFobx->fKeepChangeTime) 1518 {1519 1441 pVBoxFobx->FileBasicInfo.ChangeTime = pInfo->ChangeTime; 1520 }1521 1442 if (pInfo->FileAttributes) 1522 {1523 1443 pVBoxFobx->FileBasicInfo.FileAttributes = pInfo->FileAttributes; 1524 }1525 1444 } 1526 1445 … … 1536 1455 1537 1456 if (pInfo->DeleteFile && capFcb->OpenCount == 1) 1538 {1539 1457 Status = vbsfRemove(RxContext); 1540 }1541 1458 else 1542 {1543 1459 Status = STATUS_SUCCESS; 1544 }1545 1460 break; 1546 1461 } … … 1629 1544 end: 1630 1545 if (pHGCMBuffer) 1631 {1632 1546 vbsfFreeNonPagedMem(pHGCMBuffer); 1633 } 1634 1635 Log(("VBOXSF: MrxSetFileInfo: Returned 0x%08X\n", 1636 Status)); 1547 1548 Log(("VBOXSF: MrxSetFileInfo: Returned 0x%08X\n", Status)); 1637 1549 return Status; 1638 1550 } -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.c
r51253 r51254 145 145 } 146 146 147 if ( pNetRoot->Context == NULL)147 if (!pNetRoot->Context) 148 148 { 149 149 /* MRxNetRootSize is not zero in VBoxSF, so it is expected … … 195 195 RootNameLength -= sizeof(WCHAR); 196 196 197 if ( pNetRootExtension->phgcmClient == NULL)197 if (!pNetRootExtension->phgcmClient) 198 198 { 199 199 Log(("VBOXSF: MRxCreateVNetRoot: Initialize netroot length = %d, name = %.*ls\n", … … 209 209 } 210 210 memset(ParsedPath, 0, ParsedPathSize); 211 212 ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING)); 213 ParsedPath->u16Size = (uint16_t)RootNameLength + sizeof(WCHAR); 211 if (!ShflStringInitBuffer(ParsedPath, ParsedPathSize)) 212 { 213 vbsfFreeNonPagedMem(ParsedPath); 214 Status = STATUS_INSUFFICIENT_RESOURCES; 215 goto l_Exit; 216 } 214 217 ParsedPath->u16Length = ParsedPath->u16Size - sizeof(WCHAR); /* without terminating null */ 215 218 RtlCopyMemory(ParsedPath->String.ucs2, pRootName, ParsedPath->u16Length); … … 230 233 } 231 234 else 232 {233 235 Log(("VBOXSF: MRxCreateVNetRoot: Creating V_NET_ROOT on existing NET_ROOT!\n")); 234 }235 236 236 237 vbsfUpdateNetRoot(pNetRoot); … … 239 240 if (Status != STATUS_PENDING) 240 241 { 241 Log(("VBOXSF: MRxCreateVNetRoot: Returning 0x%08X\n", 242 Status)); 242 Log(("VBOXSF: MRxCreateVNetRoot: Returning 0x%08X\n", Status)); 243 243 pCreateNetRootContext->VirtualNetRootStatus = Status; 244 244 if (fInitializeNetRoot) 245 {246 245 pCreateNetRootContext->NetRootStatus = Status; 247 }248 246 else 249 {250 247 pCreateNetRootContext->NetRootStatus = STATUS_SUCCESS; 251 }252 248 253 249 /* Inform RDBSS. */ … … 276 272 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(pNetRoot); 277 273 278 Log(("VBOXSF: MRxFinalizeNetRoot: NET_ROOT %p\n", 279 pNetRoot)); 274 Log(("VBOXSF: MRxFinalizeNetRoot: NET_ROOT %p\n", pNetRoot)); 280 275 281 276 if (pNetRootExtension->phgcmClient) … … 283 278 int vboxRC = vboxCallUnmapFolder(pNetRootExtension->phgcmClient, &pNetRootExtension->map); 284 279 if (vboxRC != VINF_SUCCESS) 285 {286 280 Log(("VBOXSF: MRxFinalizeVNetRoot: vboxCallUnmapFolder failed with %d\n", 287 281 vboxRC)); 288 }289 282 pNetRootExtension->phgcmClient = NULL; 290 283 } … … 401 394 } 402 395 else 403 {404 396 Verifier = FALSE; 405 }406 397 407 398 if (Verifier) … … 425 416 PMRX_SRVCALLDOWN_STRUCTURE SrvCalldownStructure = (PMRX_SRVCALLDOWN_STRUCTURE)(pCallbackContext->SrvCalldownStructure); 426 417 427 Log(("VBOXSF: MRxCreateSrvCall: %p.\n", 428 pSrvCall)); 418 Log(("VBOXSF: MRxCreateSrvCall: %p.\n", pSrvCall)); 429 419 430 420 if (IoGetCurrentProcess() == RxGetRDBSSProcess()) … … 445 435 446 436 if (Status == STATUS_SUCCESS) 447 {448 437 Log(("VBOXSF: MRxCreateSrvCall: queued\n")); 449 }450 438 else 451 439 { … … 462 450 BOOLEAN Force) 463 451 { 464 Log(("VBOXSF: MRxFinalizeSrvCall %p, ctx = %p.\n", 465 pSrvCall, pSrvCall->Context)); 452 Log(("VBOXSF: MRxFinalizeSrvCall %p, ctx = %p.\n", pSrvCall, pSrvCall->Context)); 466 453 467 454 pSrvCall->Context = NULL; -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.c
r42154 r51254 253 253 */ 254 254 ParsedPathSize = sizeof(*ParsedPath) + (RemainingName->Length + sizeof(WCHAR)); 255 256 Log(("VBOXSF: vbsfProcessCreate: ParsedPathSize = %d\n", 257 ParsedPathSize)); 255 Log(("VBOXSF: vbsfProcessCreate: ParsedPathSize = %d\n", ParsedPathSize)); 258 256 259 257 ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize); 260 if ( ParsedPath == NULL)258 if (!ParsedPath) 261 259 { 262 260 Status = STATUS_INSUFFICIENT_RESOURCES; … … 264 262 } 265 263 266 ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING)); 267 268 ParsedPath->u16Size = RemainingName->Length + sizeof(WCHAR); 264 if (!ShflStringInitBuffer(ParsedPath, ParsedPathSize)) 265 { 266 vbsfFreeNonPagedMem(ParsedPath); 267 Status = STATUS_INSUFFICIENT_RESOURCES; 268 goto failure; 269 } 270 269 271 ParsedPath->u16Length = ParsedPath->u16Size - sizeof(WCHAR); /* without terminating null */ 270 272 RtlCopyMemory (ParsedPath->String.ucs2, RemainingName->Buffer, ParsedPath->u16Length); … … 292 294 Status = STATUS_OBJECT_NAME_COLLISION; 293 295 goto failure; 294 } break;296 } 295 297 296 298 /* On POSIX systems, the "mkdir" command returns VERR_FILE_NOT_FOUND when … … 299 301 { 300 302 pCreateParms->Result = SHFL_PATH_NOT_FOUND; 301 } break; 303 break; 304 } 302 305 303 306 default: … … 306 309 Status = VBoxErrorToNTStatus(vboxRC); 307 310 goto failure; 308 } break;311 } 309 312 } 310 313 } … … 370 373 { 371 374 /* A new file was created. */ 372 373 375 Assert(pCreateParms->Handle != SHFL_HANDLE_NIL); 374 376 … … 382 384 { 383 385 /* Existing file was replaced or overwriting. */ 384 385 386 Assert(pCreateParms->Handle != SHFL_HANDLE_NIL); 386 387 387 388 if (CreateDisposition == FILE_SUPERSEDE) 388 {389 389 *pulCreateAction = FILE_SUPERSEDED; 390 }391 390 else 392 {393 391 *pulCreateAction = FILE_OVERWRITTEN; 394 }395 392 /* Go check flags and create FCB. */ 396 393 break; … … 469 466 470 467 if (pCreateParms) 471 {472 468 vbsfFreeNonPagedMem(pCreateParms); 473 }474 469 475 470 return Status; … … 549 544 550 545 RxContext->pFobx = RxCreateNetFobx(RxContext, SrvOpen); 551 if ( RxContext->pFobx == NULL)546 if (!RxContext->pFobx) 552 547 { 553 548 Log(("VBOXSF: MRxCreate: RxCreateNetFobx failed\n")); … … 657 652 pVBoxFobx, pVBoxFobx? pVBoxFobx->hFile: 0)); 658 653 659 if (NULL == pVBoxFobx) 660 { 654 if (!pVBoxFobx) 661 655 return STATUS_INVALID_PARAMETER; 662 }663 656 664 657 return STATUS_SUCCESS; … … 700 693 cbBuffer = sizeof(SHFLFSOBJINFO); 701 694 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer); 702 if ( pHGCMBuffer == NULL)695 if (!pHGCMBuffer) 703 696 { 704 697 AssertFailed(); … … 710 703 /* The properties, that need to be changed, are set to something other than zero */ 711 704 if (pInfo->CreationTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CREATION_TIME) != 0) 712 {713 705 RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pInfo->CreationTime.QuadPart); 714 }715 706 if (pInfo->LastAccessTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTACCESS_TIME) != 0) 716 {717 707 RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pInfo->LastAccessTime.QuadPart); 718 }719 708 if (pInfo->LastWriteTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTWRITE_TIME) != 0) 720 {721 709 RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pInfo->LastWriteTime.QuadPart); 722 }723 710 if (pInfo->ChangeTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CHANGE_TIME) != 0) 724 {725 711 RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart); 726 }727 712 if (pInfo->FileAttributes && (SetAttrFlags & VBOX_FOBX_F_INFO_ATTRIBUTES) != 0) 728 {729 713 pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pInfo->FileAttributes); 730 }731 714 732 715 vboxRC = vboxCallFSInfo(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile, … … 734 717 735 718 if (vboxRC != VINF_SUCCESS) 736 {737 719 Status = VBoxErrorToNTStatus(vboxRC); 738 }739 720 740 721 if (pHGCMBuffer) 741 {742 722 vbsfFreeNonPagedMem(pHGCMBuffer); 743 } 744 745 Log(("VBOXSF: vbsfSetFileInfo: Returned 0x%08X\n", 746 Status)); 723 724 Log(("VBOXSF: vbsfSetFileInfo: Returned 0x%08X\n", Status)); 747 725 return Status; 748 726 } … … 788 766 789 767 if (vboxRC != VINF_SUCCESS) 790 {791 768 Status = VBoxErrorToNTStatus(vboxRC); 792 } 793 794 Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X\n", 795 Status)); 769 770 Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X\n", Status)); 796 771 return Status; 797 772 } … … 820 795 RemainingName->Length / sizeof(WCHAR), RemainingName->Buffer, RemainingName->Length)); 821 796 822 if (NULL == pVBoxFobx) 823 { 797 if (!pVBoxFobx) 824 798 return STATUS_INVALID_PARAMETER; 825 }826 799 827 800 if (FlagOn(pSrvOpen->Flags, (SRVOPEN_FLAG_FILE_RENAMED | SRVOPEN_FLAG_FILE_DELETED))) … … 836 809 /* Close file */ 837 810 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 838 {839 811 vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx); 840 }841 812 842 813 if (capFcb->FcbState & FCB_STATE_DELETE_ON_CLOSE) … … 847 818 /* Remove file or directory if delete action is pending. */ 848 819 if (capFcb->OpenCount == 0) 849 {850 820 Status = vbsfRemove(RxContext); 851 }852 821 } 853 822 … … 877 846 /* Close file first if not already done. */ 878 847 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 879 {880 848 vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx); 881 } 882 883 /* Calculate length required for parsed path. 884 */ 885 ParsedPathSize = sizeof(*ParsedPath) + (RemainingName->Length + sizeof(WCHAR)); 886 887 Log(("VBOXSF: vbsfRemove: ParsedPathSize %d\n", 888 ParsedPathSize)); 849 850 /* Calculate length required for parsed path. */ 851 ParsedPathSize = sizeof(SHFLSTRING) + RemainingName->Length + sizeof(WCHAR); 852 Log(("VBOXSF: vbsfRemove: ParsedPathSize %d\n", ParsedPathSize)); 889 853 890 854 ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize); 891 855 if (!ParsedPath) 892 {893 856 return STATUS_INSUFFICIENT_RESOURCES; 894 } 895 896 ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING)); 857 858 if (!ShflStringInitBuffer(ParsedPath, ParsedPathSize)) 859 { 860 vbsfFreeNonPagedMem(ParsedPath); 861 return STATUS_INSUFFICIENT_RESOURCES; 862 } 897 863 898 864 Log(("VBOXSF: vbsfRemove: Setup ParsedPath\n")); 899 ParsedPath->u16Size = RemainingName->Length + sizeof(WCHAR);900 865 ParsedPath->u16Length = ParsedPath->u16Size - sizeof(WCHAR); /* without terminating null */ 901 866 RtlCopyMemory(ParsedPath->String.ucs2, RemainingName->Buffer, ParsedPath->u16Length); … … 907 872 908 873 if (ParsedPath) 909 {910 874 vbsfFreeNonPagedMem(ParsedPath); 911 }912 875 913 876 if (vboxRC == VINF_SUCCESS) 914 {915 877 SetFlag(capFobx->pSrvOpen->Flags, SRVOPEN_FLAG_FILE_DELETED); 916 }917 878 918 879 Status = VBoxErrorToNTStatus(vboxRC); 919 880 if (vboxRC != VINF_SUCCESS) 920 { 921 Log(("VBOXSF: vbsfRemove: vboxCallRemove failed with %Rrc\n", 922 vboxRC)); 923 } 924 925 Log(("VBOXSF: vbsfRemove: Returned 0x%08X\n", 926 Status)); 881 Log(("VBOXSF: vbsfRemove: vboxCallRemove failed with %Rrc\n", vboxRC)); 882 883 Log(("VBOXSF: vbsfRemove: Returned 0x%08X\n", Status)); 927 884 return Status; 928 885 } … … 957 914 /* Must close the file before renaming it! */ 958 915 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 959 {960 916 vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx); 961 }962 917 963 918 /* Mark it as renamed, so we do nothing during close */ … … 965 920 966 921 /* Calculate length required for destination path. */ 967 ParsedPathSize = sizeof(*DestPath) + (RenameInformation->FileNameLength + sizeof(WCHAR)); 968 969 Log(("VBOXSF: vbsfRename: ParsedPathSize = %d\n", 970 ParsedPathSize)); 922 ParsedPathSize = sizeof(SHFLSTRING) + RenameInformation->FileNameLength + sizeof(WCHAR); 923 Log(("VBOXSF: vbsfRename: ParsedPathSize = %d\n", ParsedPathSize)); 971 924 972 925 DestPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize); 973 974 if (NULL == DestPath) 975 { 926 if (!DestPath) 976 927 return STATUS_INSUFFICIENT_RESOURCES; 977 }978 928 979 929 RtlZeroMemory(DestPath, ParsedPathSize); 980 ShflStringInitBuffer(DestPath, ParsedPathSize - sizeof(SHFLSTRING)); 930 if (!ShflStringInitBuffer(DestPath, ParsedPathSize)) 931 { 932 vbsfFreeNonPagedMem(DestPath); 933 return STATUS_INSUFFICIENT_RESOURCES; 934 } 981 935 982 936 Log(("VBOXSF: vbsfRename: Setting up destination path\n")); 983 984 DestPath->u16Size = (USHORT)(RenameInformation->FileNameLength + sizeof(WCHAR));985 937 DestPath->u16Length = DestPath->u16Size - sizeof(WCHAR); /* without terminating null */ 986 938 RtlCopyMemory(DestPath->String.ucs2, RenameInformation->FileName, DestPath->u16Length); … … 995 947 996 948 SrcPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize); 997 998 if (NULL == SrcPath) 949 if (!SrcPath) 999 950 { 1000 951 vbsfFreeNonPagedMem(DestPath); … … 1003 954 1004 955 RtlZeroMemory(SrcPath, ParsedPathSize); 1005 ShflStringInitBuffer(SrcPath, ParsedPathSize - sizeof(SHFLSTRING)); 956 if (!ShflStringInitBuffer(SrcPath, ParsedPathSize)) 957 { 958 vbsfFreeNonPagedMem(DestPath); 959 vbsfFreeNonPagedMem(SrcPath); 960 return STATUS_INSUFFICIENT_RESOURCES; 961 } 1006 962 1007 963 Log(("VBOXSF: vbsfRename: Setting up source path\n")); 1008 964 1009 SrcPath->u16Size = RemainingName->Length + sizeof(WCHAR);1010 965 SrcPath->u16Length = SrcPath->u16Size - sizeof(WCHAR); /* without terminating null */ 1011 966 RtlCopyMemory(SrcPath->String.ucs2, RemainingName->Buffer, SrcPath->u16Length); … … 1017 972 flags = pVBoxFobx->FileStandardInfo.Directory? SHFL_RENAME_DIR : SHFL_RENAME_FILE; 1018 973 if (RenameInformation->ReplaceIfExists) 1019 {1020 974 flags |= SHFL_RENAME_REPLACE_IF_EXISTS; 1021 }1022 975 1023 976 Log(("VBOXSF: vbsfRename: Calling vboxCallRename\n")); … … 1029 982 Status = VBoxErrorToNTStatus(vboxRC); 1030 983 if (vboxRC != VINF_SUCCESS) 1031 { 1032 Log(("VBOXSF: vbsfRename: vboxCallRename failed with %Rrc\n", 1033 vboxRC)); 1034 } 1035 1036 Log(("VBOXSF: vbsfRename: Returned 0x%08X\n", 1037 Status)); 984 Log(("VBOXSF: vbsfRename: vboxCallRename failed with %Rrc\n", vboxRC)); 985 986 Log(("VBOXSF: vbsfRename: Returned 0x%08X\n", Status)); 1038 987 return Status; 1039 988 } -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.c
r49394 r51254 103 103 104 104 if (State != MRX_VBOX_STARTABLE) 105 {106 105 Status = STATUS_REDIRECTOR_STARTED; 107 }108 106 } 109 107 … … 111 109 } 112 110 else 113 {114 111 Status = STATUS_INSUFFICIENT_RESOURCES; 115 }116 112 117 113 RxUnregisterMinirdr(VBoxMRxDeviceObject); … … 121 117 Status = IoDeleteSymbolicLink(&UserModeDeviceName); 122 118 if (Status != STATUS_SUCCESS) 123 { 124 Log(("VBOXSF: MRxUnload: IoDeleteSymbolicLink Status 0x%08X\n", 125 Status)); 126 } 119 Log(("VBOXSF: MRxUnload: IoDeleteSymbolicLink Status 0x%08X\n", Status)); 127 120 128 121 RxUnload(DriverObject); 129 122 130 Log(("VBOXSF: MRxUnload: VBoxSF.sys driver object %p unloaded\n", 131 DriverObject)); 123 Log(("VBOXSF: MRxUnload: VBoxSF.sys driver object %p unloaded\n", DriverObject)); 132 124 } 133 125 … … 234 226 } 235 227 else 236 {237 228 PrefixOK = FALSE; 238 }239 229 240 230 return PrefixOK; … … 425 415 Log(("VBOXSF: DriverEntry: Driver object %p\n", DriverObject)); 426 416 427 if ( DriverObject == NULL)417 if (!DriverObject) 428 418 { 429 419 Log(("VBOXSF: DriverEntry: driver object is NULL.\n")); … … 435 425 if (RT_FAILURE(vboxRC)) 436 426 { 437 Log(("VBOXSF: DriverEntry: ERROR while initializing VBox subsystem (%Rrc)!\n", 438 vboxRC)); 427 Log(("VBOXSF: DriverEntry: ERROR while initializing VBox subsystem (%Rrc)!\n", vboxRC)); 439 428 return STATUS_UNSUCCESSFUL; 440 429 } … … 639 628 Log(("VBOXSF: MRxDevFcbXXXControlFile: IRP_MN_USER_FS_REQUEST: 0x%08X\n", 640 629 LowIoContext->ParamsFor.FsCtl.MinorFunction)); 641 642 630 Status = STATUS_INVALID_DEVICE_REQUEST; 643 631 break; … … 652 640 Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_ADDCONN\n")); 653 641 Status = vbsfCreateConnection(RxContext, &RxContext->PostRequest); 654 } break; 642 break; 643 } 655 644 656 645 case IOCTL_MRX_VBOX_DELCONN: … … 658 647 Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_DELCONN\n")); 659 648 Status = vbsfDeleteConnection(RxContext, &RxContext->PostRequest); 660 } break; 649 break; 650 } 661 651 662 652 case IOCTL_MRX_VBOX_GETLIST: … … 667 657 Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_GETLIST\n")); 668 658 669 if ( NULL ==pDeviceExtension)659 if (!pDeviceExtension) 670 660 { 671 661 RxContext->InformationToReturn = 0; … … 673 663 } 674 664 675 if ( (cbOut >= _MRX_MAX_DRIVE_LETTERS) && (NULL != pu8Out))665 if (cbOut >= _MRX_MAX_DRIVE_LETTERS && !pu8Out) 676 666 { 677 667 BOOLEAN fLocked = FALSE; … … 713 703 RxContext->InformationToReturn = 0; 714 704 715 if (NULL == pDeviceExtension) 716 { 705 if (!pDeviceExtension) 717 706 break; 718 } 719 720 if ((cbOut >= _MRX_MAX_DRIVE_LETTERS) && (NULL != pu8Out)) 707 708 if (cbOut >= _MRX_MAX_DRIVE_LETTERS && !pu8Out) 721 709 { 722 710 SHFLMAPPING mappings[_MRX_MAX_DRIVE_LETTERS]; … … 766 754 cbConnectName / sizeof(WCHAR), pwcConnectName, cbConnectName, pwcRemoteName, cbRemoteName)); 767 755 768 if ( NULL ==pDeviceExtension)756 if (!pDeviceExtension) 769 757 { 770 758 Status = STATUS_INVALID_PARAMETER; … … 774 762 Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_GETCONN: Looking up connection name and connections\n")); 775 763 776 if ( (cbConnectName > sizeof(WCHAR)) && (NULL != pwcConnectName))764 if (cbConnectName > sizeof(WCHAR) && !pwcConnectName) 777 765 { 778 766 ULONG cbLocalConnectionName; … … 791 779 ExAcquireFastMutex(&pDeviceExtension->mtxLocalCon); 792 780 793 if ( NULL ==pDeviceExtension->wszLocalConnectionName[idx])781 if (!pDeviceExtension->wszLocalConnectionName[idx]) 794 782 { 795 783 Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_GETCONN: LocalConnectionName is NULL!\n")); … … 840 828 841 829 int vboxRC; 842 843 830 PSHFLSTRING pString; 844 831 uint32_t cbString; … … 855 842 } 856 843 memset(pString, 0, cbString); 857 ShflStringInitBuffer(pString, cbRemoteName); 844 if (!ShflStringInitBuffer(pString, cbString)) 845 { 846 vbsfFreeNonPagedMem(pString); 847 Status = STATUS_BAD_NETWORK_NAME; 848 break; 849 } 858 850 859 851 vboxRC = vboxCallQueryMapName(&pDeviceExtension->hgcmClient, 860 852 (*pConnectId) & ~0x80 /** @todo fix properly */, 861 pString, 862 cbString); 853 pString, cbString); 863 854 if ( vboxRC == VINF_SUCCESS 864 855 && pString->u16Length < cbRemoteName) … … 871 862 } 872 863 else 873 {874 864 Status = STATUS_BAD_NETWORK_NAME; 875 }876 865 877 866 vbsfFreeNonPagedMem(pString); 878 867 879 868 RxContext->InformationToReturn = ReturnedSize; 880 } break; 869 break; 870 } 881 871 882 872 case IOCTL_MRX_VBOX_START: … … 1019 1009 1020 1010 if (Status == STATUS_PENDING && RxContext->PostRequest == TRUE) 1021 {1022 1011 Status = STATUS_MORE_PROCESSING_REQUIRED; 1023 } 1024 1025 } break; 1012 break; 1013 } 1026 1014 1027 1015 default: 1028 1016 Status = STATUS_INVALID_DEVICE_REQUEST; 1029 1017 break; 1030 } break; 1018 } 1019 break; 1031 1020 } 1032 1021 … … 1073 1062 { 1074 1063 if (*pwc1 == 0 || *pwc == 0 || *pwc1 != *pwc) 1075 {1076 1064 break; 1077 }1078 1065 } 1079 1066 … … 1096 1083 /* @todo should also check that the drive letter corresponds to the name. */ 1097 1084 if (vboxIsPrefixOK(pwc, cRemainingName * sizeof (WCHAR))) 1098 {1099 1085 Status = STATUS_SUCCESS; 1100 }1101 1086 } 1102 1087 } … … 1180 1165 pwcConnectName = (PWCHAR)LowIoContext->ParamsFor.IoCtl.pInputBuffer; 1181 1166 1182 if (pDeviceExtension == NULL) 1183 { 1167 if (!pDeviceExtension) 1184 1168 return STATUS_INVALID_PARAMETER; 1185 } 1186 1187 if (cbConnectName == 0 || pwcConnectName == NULL) 1169 1170 if (cbConnectName == 0 || !pwcConnectName) 1188 1171 { 1189 1172 Log(("VBOXSF: vbsfCreateConnection: Connection name / length is invalid!\n")); … … 1212 1195 { 1213 1196 if (*pwc == L':') 1214 {1215 1197 break; 1216 }1217 1198 pwc++; 1218 1199 } … … 1244 1225 pDeviceExtension->wszLocalConnectionName[idx] = (PUNICODE_STRING)vbsfAllocNonPagedMem(sizeof(UNICODE_STRING) + cbConnectName); 1245 1226 1246 if ( pDeviceExtension->wszLocalConnectionName[idx] == NULL)1227 if (!pDeviceExtension->wszLocalConnectionName[idx]) 1247 1228 { 1248 1229 Log(("VBOXSF: vbsfCreateConnection: LocalConnectionName at index %d NOT allocated!\n", … … 1457 1438 return STATUS_SUCCESS; 1458 1439 } 1459 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
r44529 r51254 250 250 { 251 251 RT_ZERO(*pString); 252 ShflStringInitBuffer(pString, SHFL_MAX_LEN); 252 if (!ShflStringInitBuffer(pString, SHFL_MAX_LEN)) 253 { 254 RTMemFree(pString); 255 return VERR_INVALID_PARAMETER; 256 } 253 257 254 258 VbglHGCMParmUInt32Set(&Msg.root, u32Root);
Note:
See TracChangeset
for help on using the changeset viewer.