Changeset 78285 in vbox for trunk/src/VBox
- Timestamp:
- Apr 25, 2019 12:30:32 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/SharedFolders/driver
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.c
r78283 r78285 49 49 ULONG DeleteOnClose :1; 50 50 ULONG TemporaryFile :1; 51 ULONG SlashHack :1; 51 52 } bf; 52 53 … … 112 113 bf.TemporaryFile = TRUE; 113 114 114 Log(("VBOXSF: vbsfProcessCreate: bf.TemporaryFile %d, bf.CreateDirectory %d, bf.DirectoryFile = %d\n", 115 (ULONG)bf.TemporaryFile, (ULONG)bf.CreateDirectory, (ULONG)bf.DirectoryFile)); 115 bf.SlashHack = RxContext->CurrentIrpSp 116 && (RxContext->CurrentIrpSp->Parameters.Create.ShareAccess & VBOX_MJ_CREATE_SLASH_HACK); 117 118 Log(("VBOXSF: vbsfProcessCreate: bf.TemporaryFile %d, bf.CreateDirectory %d, bf.DirectoryFile = %d, bf.SlashHack = %d\n", 119 bf.TemporaryFile, bf.CreateDirectory, bf.DirectoryFile, bf.SlashHack)); 116 120 117 121 /* Check consistency in specified flags. */ … … 125 129 if (bf.DirectoryFile && bf.NonDirectoryFile) 126 130 { 131 /** @todo r=bird: Check if FILE_DIRECTORY_FILE+FILE_NON_DIRECTORY_FILE really is illegal in all combinations... */ 127 132 Log(("VBOXSF: vbsfProcessCreate: Unsupported combination: dir && !dir\n")); 128 133 Status = STATUS_INVALID_PARAMETER; … … 252 257 Log(("VBOXSF: vbsfProcessCreate: RemainingName->Length = %d\n", RemainingName->Length)); 253 258 254 Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length); 255 if (Status != STATUS_SUCCESS) 256 { 257 goto failure; 259 260 if (!bf.SlashHack) 261 { 262 Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length); 263 if (Status != STATUS_SUCCESS) 264 goto failure; 265 } 266 else 267 { 268 /* Add back the slash we had to hide from RDBSS. */ 269 Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, NULL, RemainingName->Length + sizeof(RTUTF16)); 270 if (Status != STATUS_SUCCESS) 271 goto failure; 272 memcpy(ParsedPath->String.utf16, RemainingName->Buffer, RemainingName->Length); 273 ParsedPath->String.utf16[RemainingName->Length / sizeof(RTUTF16)] = '\\'; 274 ParsedPath->String.utf16[RemainingName->Length / sizeof(RTUTF16) + 1] = '\0'; 275 ParsedPath->u16Length = RemainingName->Length + sizeof(RTUTF16); 258 276 } 259 277 -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.c
r78280 r78285 398 398 } 399 399 400 /** 401 * Intercepts IRP_MJ_CREATE to workaround a RDBSS quirk. 402 * 403 * Our RDBSS library will return STATUS_OBJECT_NAME_INVALID when FILE_NON_DIRECTORY_FILE 404 * is set and the path ends with a slash. NTFS and FAT will fail with 405 * STATUS_OBJECT_NAME_NOT_FOUND if the final component does not exist or isn't a directory, 406 * STATUS_OBJECT_PATH_NOT_FOUND if some path component doesn't exist or isn't a directory, 407 * or STATUS_ACCESS_DENIED if the final component is a directory. 408 * 409 * So, our HACK is to drop the trailing slash and set an unused flag in the ShareAccess 410 * parameter to tell vbsfProcessCreate about it. 411 * 412 */ 413 static NTSTATUS VBoxHookMjCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp) 414 { 415 PMRX_VBOX_DEVICE_EXTENSION pDevExt = (PMRX_VBOX_DEVICE_EXTENSION)((PBYTE)pDevObj + sizeof(RDBSS_DEVICE_OBJECT)); 416 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 417 PFILE_OBJECT pFileObj = pStack->FileObject; 418 NTSTATUS rcNt; 419 420 Log(("VBOXSF: VBoxHookMjCreate: pDevObj %p, pDevExt %p, pFileObj %p, options %#x, attr %#x, share %#x, ealength %#x, secctx %p\n", 421 pDevObj, pDevObj->DeviceExtension, pFileObj, pStack->Parameters.Create.Options, pStack->Parameters.Create.FileAttributes, 422 pStack->Parameters.Create.ShareAccess, pStack->Parameters.Create.EaLength, pStack->Parameters.Create.SecurityContext)); 423 if (pFileObj) 424 Log(("VBOXSF: VBoxHookMjCreate: FileName=%.*ls\n", pFileObj->FileName.Length / sizeof(WCHAR), pFileObj->FileName.Buffer)); 425 426 /* 427 * Check if we need to apply the hack. If we do, we grab a reference to 428 * the file object to be absolutely sure it's around for the cleanup work. 429 */ 430 AssertMsg(!(pStack->Parameters.Create.ShareAccess & VBOX_MJ_CREATE_SLASH_HACK), ("%#x\n", pStack->Parameters.Create.ShareAccess)); 431 if ( (pStack->Parameters.Create.Options & (FILE_NON_DIRECTORY_FILE | FILE_DIRECTORY_FILE)) == FILE_NON_DIRECTORY_FILE 432 && pFileObj 433 && pFileObj->FileName.Length > 18 434 && pFileObj->FileName.Buffer 435 && pFileObj->FileName.Buffer[pFileObj->FileName.Length / sizeof(WCHAR) - 1] == '\\' 436 && pFileObj->FileName.Buffer[pFileObj->FileName.Length / sizeof(WCHAR) - 2] != '\\') 437 { 438 NTSTATUS rcNtRef = ObReferenceObjectByPointer(pFileObj, (ACCESS_MASK)0, *IoFileObjectType, KernelMode); 439 pFileObj->FileName.Length -= 2; 440 pStack->Parameters.Create.ShareAccess |= VBOX_MJ_CREATE_SLASH_HACK; /* secret flag for vbsfProcessCreate */ 441 442 rcNt = pDevExt->pfnRDBSSCreate(pDevObj, pIrp); 443 444 if (rcNt != STATUS_PENDING) 445 pStack->Parameters.Create.ShareAccess &= ~VBOX_MJ_CREATE_SLASH_HACK; 446 if (NT_SUCCESS(rcNtRef)) 447 { 448 pFileObj->FileName.Length += 2; 449 ObDereferenceObject(pFileObj); 450 } 451 452 Log(("VBOXSF: VBoxHookMjCreate: returns %#x (hacked; rcNtRef=%#x)\n", rcNt, rcNtRef)); 453 } 454 /* 455 * No hack needed. 456 */ 457 else 458 { 459 rcNt = pDevExt->pfnRDBSSCreate(pDevObj, pIrp); 460 Log(("VBOXSF: VBoxHookMjCreate: returns %#x\n", rcNt)); 461 } 462 return rcNt; 463 } 464 400 465 NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, 401 466 IN PUNICODE_STRING RegistryPath) … … 542 607 pDeviceExtension->pfnRDBSSDeviceControl = DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]; 543 608 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VBoxMRXDeviceControl; 609 610 /* Intercept IRP_MJ_CREATE to fix incorrect (wrt NTFS, FAT, ++) return 611 * codes for NtOpenFile("r:\\asdf\\", FILE_NON_DIRECTORY_FILE). 612 */ 613 pDeviceExtension->pfnRDBSSCreate = DriverObject->MajorFunction[IRP_MJ_CREATE]; 614 DriverObject->MajorFunction[IRP_MJ_CREATE] = VBoxHookMjCreate; 615 544 616 545 617 /** @todo start the redirector here RxStartMiniRdr. */ -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h
r76563 r78285 70 70 VBGLSFCLIENT hgcmClient; 71 71 72 /* Saved pointer to the original IRP_MJ_DEVICE_CONTROL handler. */72 /** Saved pointer to the original IRP_MJ_DEVICE_CONTROL handler. */ 73 73 NTSTATUS (* pfnRDBSSDeviceControl) (PDEVICE_OBJECT pDevObj, PIRP pIrp); 74 /** Saved pointer to the original IRP_MJ_CREATE handler. */ 75 NTSTATUS (NTAPI * pfnRDBSSCreate)(PDEVICE_OBJECT pDevObj, PIRP pIrp); 74 76 75 77 } MRX_VBOX_DEVICE_EXTENSION, *PMRX_VBOX_DEVICE_EXTENSION; … … 121 123 (((pFobx) == NULL) ? NULL : (PMRX_VBOX_FOBX)((pFobx)->Context)) 122 124 125 /** HACK ALERT: Special Create.ShareAccess indicating trailing slash for 126 * non-directory IRP_MJ_CREATE request. 127 * Set by VBoxHookMjCreate, used by VBoxMRxCreate. */ 128 #define VBOX_MJ_CREATE_SLASH_HACK UINT16_C(0x0400) 129 123 130 /* 124 131 * Prototypes for the dispatch table routines. -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsfhlp.c
r78282 r78285 186 186 case VERR_NOT_SUPPORTED: 187 187 Status = STATUS_NOT_SUPPORTED; 188 break; 189 190 case VERR_INVALID_NAME: 191 Status = STATUS_OBJECT_NAME_INVALID; 188 192 break; 189 193 … … 409 413 410 414 PSHFLSTRING pShflString; 411 ULONG ulShflStringSize;415 ULONG cbShflString; 412 416 413 417 /* Calculate length required for the SHFL structure: header + chars + nul. */ 414 ulShflStringSize= SHFLSTRING_HEADER_SIZE + cb + sizeof(WCHAR);415 pShflString = (PSHFLSTRING)vbsfAllocNonPagedMem( ulShflStringSize);418 cbShflString = SHFLSTRING_HEADER_SIZE + cb + sizeof(WCHAR); 419 pShflString = (PSHFLSTRING)vbsfAllocNonPagedMem(cbShflString); 416 420 if (pShflString) 417 421 { 418 if (ShflStringInitBuffer(pShflString, ulShflStringSize))422 if (ShflStringInitBuffer(pShflString, cbShflString)) 419 423 { 420 424 if (pwc) … … 428 432 else 429 433 { 434 /** @todo r=bird: vbsfAllocNonPagedMem already zero'ed it... */ 430 435 RtlZeroMemory(pShflString->String.ucs2, cb + sizeof(WCHAR)); 431 436 pShflString->u16Length = 0; /* without terminating null */
Note:
See TracChangeset
for help on using the changeset viewer.