Changeset 78541 in vbox for trunk/src/VBox/Additions/WINNT/SharedFolders
- Timestamp:
- May 16, 2019 10:26:53 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp
r78536 r78541 21 21 *********************************************************************************************************************************/ 22 22 #include "vbsf.h" 23 #include <iprt/asm.h> 23 24 #include <iprt/err.h> 24 #include <iprt/ asm.h>25 #include <iprt/mem.h> 25 26 26 27 extern "C" NTSTATUS NTAPI RxSetEndOfFileInfo(PRX_CONTEXT, PIRP, PFCB, PFOBX); … … 522 523 return Status; 523 524 } 525 526 527 /********************************************************************************************************************************* 528 * NtQueryVolumeInformationFile * 529 *********************************************************************************************************************************/ 524 530 525 531 /** … … 583 589 } 584 590 585 586 591 /** 587 592 * Handles NtQueryVolumeInformationFile / FileFsVolumeInformation … … 699 704 */ 700 705 pRxContext->Info.LengthRemaining = cbInfo - cbCopied; 701 pRxContext->InformationToReturn = cbCopied; /* whatever */706 pRxContext->InformationToReturn = cbCopied; 702 707 703 708 return Status; … … 765 770 */ 766 771 pRxContext->Info.LengthRemaining = cbInfo - sizeof(*pInfo); 767 pRxContext->InformationToReturn = sizeof(*pInfo); /* whatever */772 pRxContext->InformationToReturn = sizeof(*pInfo); 768 773 return STATUS_SUCCESS; 769 774 } … … 833 838 */ 834 839 pRxContext->Info.LengthRemaining = cbInfo - sizeof(*pInfo); 835 pRxContext->InformationToReturn = sizeof(*pInfo); /* whatever */840 pRxContext->InformationToReturn = sizeof(*pInfo); 836 841 return STATUS_SUCCESS; 837 842 } … … 863 868 */ 864 869 pRxContext->Info.LengthRemaining = cbInfo - sizeof(*pInfo); 865 pRxContext->InformationToReturn = sizeof(*pInfo); /* whatever */870 pRxContext->InformationToReturn = sizeof(*pInfo); 866 871 return STATUS_SUCCESS; 867 872 } … … 935 940 */ 936 941 pRxContext->Info.LengthRemaining = cbInfo - cbStrCopied - RT_UOFFSETOF(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName); 937 pRxContext->InformationToReturn = cbStrCopied + RT_UOFFSETOF(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName); /* whatever */942 pRxContext->InformationToReturn = cbStrCopied + RT_UOFFSETOF(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName); 938 943 return cbInfo >= cbNeeded ? STATUS_SUCCESS : STATUS_BUFFER_OVERFLOW; 939 944 } … … 984 989 */ 985 990 pRxContext->Info.LengthRemaining = cbInfo - sizeof(*pInfo); 986 pRxContext->InformationToReturn = sizeof(*pInfo); /* whatever */991 pRxContext->InformationToReturn = sizeof(*pInfo); 987 992 return STATUS_SUCCESS; 988 993 } 989 994 990 995 991 #include <iprt/mem.h>992 996 /** 993 997 * Handles NtQueryVolumeInformationFile and similar. 994 998 * 995 999 * The RDBSS library does not do a whole lot for these queries. No FCB locking. 996 *997 *998 1000 * The IO_STATUS_BLOCK updating differs too, setting of Ios.Information is 999 * limited to cbInitialBuf 1000 * - RxContext->Info.LengthRemaining. 1001 * limited to cbInitialBuf - RxContext->Info.LengthRemaining. 1001 1002 */ 1002 1003 NTSTATUS VBoxMRxQueryVolumeInfo(IN OUT PRX_CONTEXT RxContext) … … 1012 1013 }; 1013 1014 #endif 1014 1015 NTSTATUS Status;1016 1017 1015 RxCaptureFcb; 1018 1016 RxCaptureFobx; 1019 1020 1017 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot); 1021 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 1022 1023 Log(("VBOXSF: MrxQueryVolumeInfo: pInfoBuffer = %p, cbInfoBuffer = %d\n", 1018 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 1019 NTSTATUS Status; 1020 1021 Log(("VBOXSF: VBoxMRxQueryVolumeInfo: pInfoBuffer = %p, cbInfoBuffer = %d\n", 1024 1022 RxContext->Info.Buffer, RxContext->Info.LengthRemaining)); 1025 Log(("VBOXSF: MrxQueryVolumeInfo: vboxFobx = %p, Handle = 0x%RX64\n",1023 Log(("VBOXSF: VBoxMRxQueryVolumeInfo: vboxFobx = %p, Handle = 0x%RX64\n", 1026 1024 pVBoxFobx, pVBoxFobx ? pVBoxFobx->hFile : 0)); 1027 1025 1028 /** @todo Consolidate the tail code that updates LengthRemaining. */1029 1026 switch (RxContext->Info.FsInformationClass) 1030 1027 { … … 1035 1032 RxContext->Info.Length, capFcb->pNetRoot, pNetRootExtension, pVBoxFobx, 1036 1033 VBoxMRxGetFcbExtension(capFcb)); 1037 return Status;1034 break; 1038 1035 1039 1036 case FileFsSizeInformation: … … 1043 1040 RxContext->Info.Length, pNetRootExtension, pVBoxFobx, 1044 1041 VBoxMRxGetFcbExtension(capFcb)); 1045 return Status;1042 break; 1046 1043 1047 1044 case FileFsFullSizeInformation: … … 1051 1048 RxContext->Info.Length, pNetRootExtension, pVBoxFobx, 1052 1049 VBoxMRxGetFcbExtension(capFcb)); 1053 return Status;1050 break; 1054 1051 1055 1052 case FileFsDeviceInformation: … … 1058 1055 Status = vbsfNtQueryFsDeviceInfo(RxContext, (PFILE_FS_DEVICE_INFORMATION)RxContext->Info.Buffer, 1059 1056 RxContext->Info.Length, capFcb->pNetRoot); 1060 return Status;1057 break; 1061 1058 1062 1059 case FileFsAttributeInformation: … … 1066 1063 RxContext->Info.Length, pNetRootExtension, pVBoxFobx, 1067 1064 VBoxMRxGetFcbExtension(capFcb)); 1068 return Status;1065 break; 1069 1066 1070 1067 case FileFsSectorSizeInformation: … … 1074 1071 RxContext->Info.Length, pNetRootExtension, pVBoxFobx, 1075 1072 VBoxMRxGetFcbExtension(capFcb)); 1076 return Status;1073 break; 1077 1074 1078 1075 case FileFsLabelInformation: … … 1080 1077 RT_FALL_THRU(); 1081 1078 default: 1082 { 1083 Log(("VBOXSF: MrxQueryVolumeInfo: Not supported FS_INFORMATION_CLASS value: %d (%s)!\n", 1079 Log(("VBOXSF: VBoxMRxQueryVolumeInfo: Not supported FS_INFORMATION_CLASS value: %d (%s)!\n", 1084 1080 RxContext->Info.FsInformationClass, 1085 1081 (ULONG)RxContext->Info.FsInformationClass < RT_ELEMENTS(s_apszNames) 1086 1082 ? s_apszNames[RxContext->Info.FsInformationClass] : "??")); 1087 /* Here is a weird issue I couldn't quite figure out. When working directories, I 1088 seem to get semi-random stuff back in the IO_STATUS_BLOCK. Difference between 1089 directories and files seemed to be the IRP_SYNCHRONOUS_API flag. Poking around 1090 a little bit more, the UserIosb seems to be a ring-0 stack address rather than 1091 the usermode one and IopSynchronousApiServiceTail being used for copying it back 1092 to user mode because the handle wasn't synchronous or something. 1093 1094 So, the following is kludge to make the IOS values 0,0 like FAT does it. The 1095 real fix for this escapes me, but this should do the trick... */ 1096 PIRP pIrp = RxContext->CurrentIrp; 1097 if ( pIrp 1098 && (pIrp->Flags & IRP_SYNCHRONOUS_API) 1099 && RTR0MemKernelIsValidAddr(pIrp->UserIosb)) 1100 { 1101 Log9(("VBOXSF: MrxQueryVolumeInfo: IRP_SYNCHRONOUS_API hack: Setting UserIosb (%p) values to zero!\n", \ 1102 pIrp->UserIosb)); 1103 __try 1104 { 1105 pIrp->UserIosb->Status = 0; 1106 pIrp->UserIosb->Information = 0; 1107 } 1108 __except(EXCEPTION_EXECUTE_HANDLER) 1109 { 1083 Status = STATUS_INVALID_PARAMETER; 1084 RxContext->InformationToReturn = 0; 1085 break; 1086 } 1087 1088 /* Here is a weird issue I couldn't quite figure out. When working directories, I 1089 seem to get semi-random stuff back in the IO_STATUS_BLOCK when returning failures 1090 for unsupported classes. The difference between directories and files seemed to 1091 be the IRP_SYNCHRONOUS_API flag. Poking around a little bit more, the UserIosb 1092 seems to be a ring-0 stack address rather than the usermode one and 1093 IopSynchronousApiServiceTail being used for copying it back to user mode because 1094 the handle wasn't synchronous or something. 1095 1096 So, the following is kludge to make the IOS values 0,0 like FAT does it. The 1097 real fix for this escapes me, but this should do the trick for now... */ 1098 PIRP pIrp = RxContext->CurrentIrp; 1099 if ( pIrp 1100 && (pIrp->Flags & IRP_SYNCHRONOUS_API) 1101 && RTR0MemKernelIsValidAddr(pIrp->UserIosb)) 1102 { 1103 Log2(("VBOXSF: VBoxMRxQueryVolumeInfo: IRP_SYNCHRONOUS_API hack: Setting UserIosb (%p) values!\n", pIrp->UserIosb)); 1104 __try 1105 { 1106 pIrp->UserIosb->Status = 0; 1107 pIrp->UserIosb->Information = RxContext->InformationToReturn; 1108 } 1109 __except(EXCEPTION_EXECUTE_HANDLER) 1110 { 1110 1111 #ifdef LOG_ENABLED 1111 1112 Log(("VBOXSF: MrxQueryVolumeInfo: Oops %#x accessing %p\n", rcNt, pIrp->UserIosb));1112 NTSTATUS rcNt = GetExceptionCode(); 1113 Log(("VBOXSF: VBoxMRxQueryVolumeInfo: Oops %#x accessing %p\n", rcNt, pIrp->UserIosb)); 1113 1114 #endif 1114 } 1115 } 1116 return STATUS_INVALID_PARAMETER; 1117 } 1118 } 1115 } 1116 } 1117 Log(("VBOXSF: VBoxMRxQueryVolumeInfo: Returned %#010x\n", Status)); 1118 return Status; 1119 1119 } 1120 1120
Note:
See TracChangeset
for help on using the changeset viewer.