- Timestamp:
- Apr 26, 2019 12:44:17 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/SharedFolders/driver
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/Makefile.kmk
r76553 r78302 34 34 VBoxSF_SOURCES = \ 35 35 file.c \ 36 info.c \37 vbsf.c \36 info.cpp \ 37 vbsf.cpp \ 38 38 net.c \ 39 39 path.c \ -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.c
r78280 r78302 328 328 } 329 329 330 331 330 NTSTATUS VBoxMRxRead(IN PRX_CONTEXT RxContext) 332 331 { 333 NTSTATUS Status = RxDispatchToWorkerThread(VBoxMRxDeviceObject, DelayedWorkQueue, 334 vbsfReadWorker, 335 RxContext); 336 337 Log(("VBOXSF: MRxRead: RxDispatchToWorkerThread: Status 0x%08X\n", Status)); 338 339 if (Status == STATUS_SUCCESS) 340 Status = STATUS_PENDING; 332 NTSTATUS Status; 333 334 #if 0 335 if ( IoIsOperationSynchronous(RxContext->CurrentIrp) 336 /*&& IoGetRemainingStackSize() >= 1024 - not necessary, checked by RxFsdCommonDispatch already */) 337 { 338 RxContext->IoStatusBlock.Status = Status = vbsfReadInternal(RxContext); 339 Assert(Status != STATUS_PENDING); 340 341 Log(("VBOXSF: MRxRead: vbsfReadInternal: Status %#08X\n", Status)); 342 } 343 else 344 #endif 345 { 346 Status = RxDispatchToWorkerThread(VBoxMRxDeviceObject, DelayedWorkQueue, vbsfReadWorker, RxContext); 347 348 Log(("VBOXSF: MRxRead: RxDispatchToWorkerThread: Status 0x%08X\n", Status)); 349 350 if (Status == STATUS_SUCCESS) 351 Status = STATUS_PENDING; 352 } 341 353 342 354 return Status; -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp
r78301 r78302 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VirtualBox Windows Guest Shared Folders 5 * 6 * File System Driver query and set information routines 3 * VirtualBox Windows Guest Shared Folders FSD - Information Querying & Setting Routines. 7 4 */ 8 5 … … 922 919 } 923 920 921 void vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo) 922 { 923 pVBoxFobx->FileBasicInfo.CreationTime.QuadPart = RTTimeSpecGetNtTime(&pInfo->BirthTime); 924 pVBoxFobx->FileBasicInfo.LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pInfo->AccessTime); 925 pVBoxFobx->FileBasicInfo.LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pInfo->ModificationTime); 926 pVBoxFobx->FileBasicInfo.ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pInfo->ChangeTime); 927 pVBoxFobx->FileBasicInfo.FileAttributes = VBoxToNTFileAttributes(pInfo->Attr.fMode); 928 } 929 930 static void vbsfNtCopyInfo(PMRX_VBOX_FOBX pVBoxFobx, PSHFLFSOBJINFO pObjInfo, uint32_t fOverrides) 931 { 932 if (pObjInfo->cbObject != pVBoxFobx->Info.cbObject) 933 { 934 /** @todo tell RDBSS about this? */ 935 } 936 937 /* To simplify stuff, copy user timestamps to the input structure before copying. */ 938 if ( pVBoxFobx->fKeepCreationTime 939 || pVBoxFobx->fKeepLastAccessTime 940 || pVBoxFobx->fKeepLastWriteTime 941 || pVBoxFobx->fKeepChangeTime) 942 { 943 if (pVBoxFobx->fKeepCreationTime && !(fOverrides & VBOX_FOBX_F_INFO_CREATION_TIME)) 944 pObjInfo->BirthTime = pVBoxFobx->Info.BirthTime; 945 if (pVBoxFobx->fKeepLastAccessTime && !(fOverrides & VBOX_FOBX_F_INFO_LASTACCESS_TIME)) 946 pObjInfo->AccessTime = pVBoxFobx->Info.AccessTime; 947 if (pVBoxFobx->fKeepLastWriteTime && !(fOverrides & VBOX_FOBX_F_INFO_LASTWRITE_TIME)) 948 pObjInfo->ModificationTime = pVBoxFobx->Info.ModificationTime; 949 if (pVBoxFobx->fKeepChangeTime && !(fOverrides & VBOX_FOBX_F_INFO_CHANGE_TIME)) 950 pObjInfo->ChangeTime = pVBoxFobx->Info.ChangeTime; 951 } 952 pVBoxFobx->Info = *pObjInfo; 953 954 vbsfNtCopyInfoToLegacy(pVBoxFobx, pObjInfo); 955 } 956 957 924 958 NTSTATUS VBoxMRxQueryFileInfo(IN PRX_CONTEXT RxContext) 959 { 960 RxCaptureFcb; 961 RxCaptureFobx; 962 NTSTATUS Status = STATUS_SUCCESS; 963 //PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension = VBoxMRxGetDeviceExtension(RxContext); 964 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot); 965 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 966 ULONG cbToCopy = 0; 967 968 Log(("VBOXSF: MrxQueryFileInfo: InfoBuffer = %p, Size = %d bytes, FileInformationClass = %d\n", 969 RxContext->Info.Buffer, RxContext->Info.Length, RxContext->Info.FileInformationClass)); 970 971 AssertReturn(pVBoxFobx, STATUS_INVALID_PARAMETER); 972 AssertReturn(RxContext->Info.Buffer, STATUS_INVALID_PARAMETER); 973 974 #define CHECK_SIZE_BREAK(a_RxContext, a_cbNeeded) \ 975 /* IO_STACK_LOCATION::Parameters::SetFile::Length is signed, the RxContext bugger is LONG. See end of function for why. */ \ 976 if ((ULONG)(a_RxContext)->Info.Length >= (a_cbNeeded)) \ 977 { /*likely */ } \ 978 else if (1) { Status = STATUS_BUFFER_TOO_SMALL; break; } else do { } while (0) 979 980 switch (RxContext->Info.FileInformationClass) 981 { 982 /* 983 * Queries we can satisfy without calling the host: 984 */ 985 986 case FileNamesInformation: 987 { 988 PFILE_NAMES_INFORMATION pInfo = (PFILE_NAMES_INFORMATION)RxContext->Info.Buffer; 989 PUNICODE_STRING FileName = GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(RxContext); 990 Log(("VBOXSF: MrxQueryFileInfo: FileNamesInformation\n")); 991 992 cbToCopy = RT_UOFFSETOF_DYN(FILE_NAMES_INFORMATION, FileName[FileName->Length / 2 + 1]); 993 CHECK_SIZE_BREAK(RxContext, cbToCopy); 994 995 pInfo->NextEntryOffset = 0; 996 pInfo->FileIndex = 0; 997 pInfo->FileNameLength = FileName->Length; 998 999 RtlCopyMemory(pInfo->FileName, FileName->Buffer, FileName->Length); 1000 pInfo->FileName[FileName->Length] = 0; 1001 break; 1002 } 1003 1004 case FileInternalInformation: 1005 { 1006 PFILE_INTERNAL_INFORMATION pInfo = (PFILE_INTERNAL_INFORMATION)RxContext->Info.Buffer; 1007 Log(("VBOXSF: MrxQueryFileInfo: FileInternalInformation\n")); 1008 1009 cbToCopy = sizeof(FILE_INTERNAL_INFORMATION); 1010 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1011 1012 /* A 8-byte file reference number for the file. */ 1013 pInfo->IndexNumber.QuadPart = (ULONG_PTR)capFcb; 1014 break; 1015 } 1016 1017 case FileEaInformation: 1018 { 1019 PFILE_EA_INFORMATION pInfo = (PFILE_EA_INFORMATION)RxContext->Info.Buffer; 1020 Log(("VBOXSF: MrxQueryFileInfo: FileEaInformation\n")); 1021 1022 cbToCopy = sizeof(FILE_EA_INFORMATION); 1023 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1024 1025 pInfo->EaSize = 0; 1026 break; 1027 } 1028 1029 case FileStreamInformation: 1030 Log(("VBOXSF: MrxQueryFileInfo: FileStreamInformation: not supported\n")); 1031 Status = STATUS_INVALID_PARAMETER; 1032 break; 1033 1034 case FileAlternateNameInformation: 1035 Log(("VBOXSF: MrxQueryFileInfo: FileStreamInformation: not implemented\n")); 1036 Status = STATUS_OBJECT_NAME_NOT_FOUND; 1037 break; 1038 1039 case FileNumaNodeInformation: 1040 Log(("VBOXSF: MrxQueryFileInfo: FileNumaNodeInformation: not supported\n")); 1041 Status = STATUS_NO_SUCH_DEVICE; /* what's returned on a samba share */ 1042 break; 1043 1044 case FileStandardLinkInformation: 1045 Log(("VBOXSF: MrxQueryFileInfo: FileStandardLinkInformation: not supported\n")); 1046 Status = STATUS_NOT_SUPPORTED; /* what's returned on a samba share */ 1047 break; 1048 1049 /* 1050 * Queries where we need info from the host. 1051 * 1052 * For directories we don't necessarily go to the host but use info from when we 1053 * opened the them, why we do this is a little unclear as all the clues that r9630 1054 * give is "fixes". 1055 * 1056 * Note! We verify the buffer size after talking to the host, assuming that there 1057 * won't be a problem and saving an extra switch statement. IIRC the 1058 * NtQueryInformationFile code verfies the sizes too. 1059 */ 1060 /** @todo r=bird: install a hack so we get FileAllInformation directly up here 1061 * rather than 5 individual queries. We may end up going 3 times to 1062 * the host (depending on the TTL hack) to fetch the same info over 1063 * and over again. */ 1064 case FileEndOfFileInformation: 1065 case FileAllocationInformation: 1066 case FileBasicInformation: 1067 case FileStandardInformation: 1068 case FileNetworkOpenInformation: 1069 case FileAttributeTagInformation: 1070 case FileCompressionInformation: 1071 { 1072 /* Query the information if necessary. */ 1073 if ( !(pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY) /** @todo figure out why we don't return up-to-date info for directories! */ 1074 && ( !pVBoxFobx->nsUpToDate 1075 || pVBoxFobx->nsUpToDate - RTTimeSystemNanoTS() < RT_NS_100US /** @todo implement proper TTL */ ) ) 1076 { 1077 int vrc; 1078 VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 1079 AssertBreakStmt(pReq, Status = STATUS_NO_MEMORY); 1080 1081 vrc = VbglR0SfHostReqQueryObjInfo(pNetRootExtension->map.root, pReq, pVBoxFobx->hFile); 1082 if (RT_SUCCESS(vrc)) 1083 vbsfNtCopyInfo(pVBoxFobx, &pReq->ObjInfo, 0); 1084 else 1085 { 1086 Status = VBoxErrorToNTStatus(vrc); 1087 VbglR0PhysHeapFree(pReq); 1088 break; 1089 } 1090 VbglR0PhysHeapFree(pReq); 1091 } 1092 1093 /* Copy it into the return buffer. */ 1094 switch (RxContext->Info.FileInformationClass) 1095 { 1096 case FileBasicInformation: 1097 { 1098 PFILE_BASIC_INFORMATION pInfo = (PFILE_BASIC_INFORMATION)RxContext->Info.Buffer; 1099 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation\n")); 1100 1101 cbToCopy = sizeof(FILE_BASIC_INFORMATION); 1102 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1103 1104 pInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.BirthTime); 1105 pInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.AccessTime); 1106 pInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.ModificationTime); 1107 pInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.ChangeTime); 1108 pInfo->FileAttributes = VBoxToNTFileAttributes(pVBoxFobx->Info.Attr.fMode); 1109 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation: File attributes: 0x%x\n", 1110 pInfo->FileAttributes)); 1111 break; 1112 } 1113 1114 case FileStandardInformation: 1115 { 1116 PFILE_STANDARD_INFORMATION pInfo = (PFILE_STANDARD_INFORMATION)RxContext->Info.Buffer; 1117 Log(("VBOXSF: MrxQueryFileInfo: FileStandardInformation\n")); 1118 1119 cbToCopy = sizeof(FILE_STANDARD_INFORMATION); 1120 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1121 1122 /* Note! We didn't used to set allocation size and end-of-file for directories. 1123 NTFS reports these, though, so why shouldn't we. */ 1124 pInfo->AllocationSize.QuadPart = pVBoxFobx->Info.cbAllocated; 1125 pInfo->EndOfFile.QuadPart = pVBoxFobx->Info.cbObject; 1126 pInfo->NumberOfLinks = 1; /** @todo 0? */ 1127 pInfo->DeletePending = FALSE; 1128 pInfo->Directory = pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY ? TRUE : FALSE; 1129 break; 1130 } 1131 1132 case FileNetworkOpenInformation: 1133 { 1134 PFILE_NETWORK_OPEN_INFORMATION pInfo = (PFILE_NETWORK_OPEN_INFORMATION)RxContext->Info.Buffer; 1135 Log(("VBOXSF: MrxQueryFileInfo: FileNetworkOpenInformation\n")); 1136 1137 cbToCopy = sizeof(FILE_NETWORK_OPEN_INFORMATION); 1138 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1139 1140 pInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.BirthTime); 1141 pInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.AccessTime); 1142 pInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.ModificationTime); 1143 pInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxFobx->Info.ChangeTime); 1144 /* Note! We didn't used to set allocation size and end-of-file for directories. 1145 NTFS reports these, though, so why shouldn't we. */ 1146 pInfo->AllocationSize.QuadPart = pVBoxFobx->Info.cbAllocated; 1147 pInfo->EndOfFile.QuadPart = pVBoxFobx->Info.cbObject; 1148 pInfo->FileAttributes = VBoxToNTFileAttributes(pVBoxFobx->Info.Attr.fMode); 1149 break; 1150 } 1151 1152 case FileEndOfFileInformation: 1153 { 1154 PFILE_END_OF_FILE_INFORMATION pInfo = (PFILE_END_OF_FILE_INFORMATION)RxContext->Info.Buffer; 1155 Log(("VBOXSF: MrxQueryFileInfo: FileEndOfFileInformation\n")); 1156 1157 cbToCopy = sizeof(FILE_END_OF_FILE_INFORMATION); 1158 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1159 1160 /* Note! We didn't used to set allocation size and end-of-file for directories. 1161 NTFS reports these, though, so why shouldn't we. */ 1162 pInfo->EndOfFile.QuadPart = pVBoxFobx->Info.cbObject; 1163 break; 1164 } 1165 1166 case FileAllocationInformation: 1167 { 1168 PFILE_ALLOCATION_INFORMATION pInfo = (PFILE_ALLOCATION_INFORMATION)RxContext->Info.Buffer; 1169 Log(("VBOXSF: MrxQueryFileInfo: FileAllocationInformation\n")); 1170 1171 cbToCopy = sizeof(FILE_ALLOCATION_INFORMATION); 1172 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1173 1174 /* Note! We didn't used to set allocation size and end-of-file for directories. 1175 NTFS reports these, though, so why shouldn't we. */ 1176 pInfo->AllocationSize.QuadPart = pVBoxFobx->Info.cbAllocated; 1177 break; 1178 } 1179 1180 case FileAttributeTagInformation: 1181 { 1182 PFILE_ATTRIBUTE_TAG_INFORMATION pInfo = (PFILE_ATTRIBUTE_TAG_INFORMATION)RxContext->Info.Buffer; 1183 Log(("VBOXSF: MrxQueryFileInfo: FileAttributeTagInformation\n")); 1184 1185 cbToCopy = sizeof(FILE_ATTRIBUTE_TAG_INFORMATION); 1186 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1187 1188 pInfo->FileAttributes = VBoxToNTFileAttributes(pVBoxFobx->Info.Attr.fMode); 1189 pInfo->ReparseTag = 0; 1190 break; 1191 } 1192 1193 case FileCompressionInformation: 1194 { 1195 //PFILE_COMPRESSION_INFO pInfo = (PFILE_COMPRESSION_INFO)RxContext->Info.Buffer; 1196 struct MY_FILE_COMPRESSION_INFO 1197 { 1198 LARGE_INTEGER CompressedFileSize; 1199 WORD CompressionFormat; 1200 UCHAR CompressionUnitShift; 1201 UCHAR ChunkShift; 1202 UCHAR ClusterShift; 1203 UCHAR Reserved[3]; 1204 } *pInfo = (struct MY_FILE_COMPRESSION_INFO *)RxContext->Info.Buffer; 1205 Log(("VBOXSF: MrxQueryFileInfo: FileCompressionInformation\n")); 1206 1207 cbToCopy = sizeof(*pInfo); 1208 CHECK_SIZE_BREAK(RxContext, cbToCopy); 1209 1210 pInfo->CompressedFileSize.QuadPart = pVBoxFobx->Info.cbObject; 1211 pInfo->CompressionFormat = 0; 1212 pInfo->CompressionUnitShift = 0; 1213 pInfo->ChunkShift = 0; 1214 pInfo->ClusterShift = 0; 1215 pInfo->Reserved[0] = 0; 1216 pInfo->Reserved[1] = 0; 1217 pInfo->Reserved[2] = 0; 1218 AssertCompile(sizeof(pInfo->Reserved) == 3); 1219 break; 1220 } 1221 1222 default: 1223 AssertLogRelMsgFailed(("FileInformationClass=%d\n", 1224 RxContext->Info.FileInformationClass)); 1225 Status = STATUS_INTERNAL_ERROR; 1226 break; 1227 } 1228 break; 1229 } 1230 1231 1232 /** @todo Implement: 1233 * FileHardLinkInformation: rcNt=0 (STATUS_SUCCESS) Ios.Status=0 (STATUS_SUCCESS) Ios.Information=0000000000000048 1234 * FileProcessIdsUsingFileInformation: rcNt=0 (STATUS_SUCCESS) Ios.Status=0 (STATUS_SUCCESS) Ios.Information=0000000000000010 1235 * FileNormalizedNameInformation: rcNt=0 (STATUS_SUCCESS) Ios.Status=0 (STATUS_SUCCESS) Ios.Information=00000000000000AA 1236 * FileNetworkPhysicalNameInformation: rcNt=0xc000000d (STATUS_INVALID_PARAMETER) Ios={not modified} 1237 * FileShortNameInformation? 1238 * FileNetworkPhysicalNameInformation 1239 */ 1240 1241 /* 1242 * Unsupported ones (STATUS_INVALID_PARAMETER is correct here if you 1243 * go by what fat + ntfs return, however samba mounts generally returns 1244 * STATUS_INVALID_INFO_CLASS except for pipe info - see queryfileinfo-1). 1245 */ 1246 default: 1247 Log(("VBOXSF: MrxQueryFileInfo: Not supported FileInformationClass: %d!\n", 1248 RxContext->Info.FileInformationClass)); 1249 Status = STATUS_INVALID_PARAMETER; 1250 break; 1251 1252 } 1253 #undef CHECK_SIZE_BREAK 1254 1255 /* Note! InformationToReturn doesn't seem to be used, instead Info.LengthRemaining should underflow 1256 so it can be used together with RxContext->CurrentIrpSp->Parameters.QueryFile.Length 1257 to calc the Ios.Information value. This explain the weird LONG type choice. */ 1258 RxContext->InformationToReturn = cbToCopy; 1259 RxContext->Info.LengthRemaining -= cbToCopy; 1260 AssertStmt(RxContext->Info.LengthRemaining >= 0 || Status != STATUS_SUCCESS, Status = STATUS_BUFFER_TOO_SMALL); 1261 1262 Log(("VBOXSF: MrxQueryFileInfo: Returns %#x, Remaining length = %d, cbToCopy = %u (%#x)\n", 1263 Status, RxContext->Info.Length, cbToCopy)); 1264 return Status; 1265 } 1266 1267 NTSTATUS VBoxMRxSetFileInfo(IN PRX_CONTEXT RxContext) 925 1268 { 926 1269 NTSTATUS Status = STATUS_SUCCESS; … … 933 1276 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 934 1277 935 PUNICODE_STRING FileName = GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(RxContext);936 FILE_INFORMATION_CLASS FunctionalityRequested = RxContext->Info.FileInformationClass;937 PCHAR pInfoBuffer = (PCHAR)RxContext->Info.Buffer;938 uint32_t cbInfoBuffer = RxContext->Info.Length;939 ULONG *pLengthRemaining = (PULONG) & RxContext->Info.LengthRemaining;940 941 int vrc = 0;942 943 ULONG cbToCopy = 0;944 uint8_t *pHGCMBuffer = 0;945 uint32_t cbHGCMBuffer;946 PSHFLFSOBJINFO pFileEntry = NULL;947 948 if (!pLengthRemaining)949 {950 Log(("VBOXSF: MrxQueryFileInfo: length pointer is NULL!\n"));951 return STATUS_INVALID_PARAMETER;952 }953 954 Log(("VBOXSF: MrxQueryFileInfo: InfoBuffer = %p, Size = %d bytes, LenRemain = %d bytes\n",955 pInfoBuffer, cbInfoBuffer, *pLengthRemaining));956 957 if (!pVBoxFobx)958 {959 Log(("VBOXSF: MrxQueryFileInfo: pVBoxFobx is NULL!\n"));960 return STATUS_INVALID_PARAMETER;961 }962 963 if (!pInfoBuffer)964 {965 Log(("VBOXSF: MrxQueryFileInfo: pInfoBuffer is NULL!\n"));966 return STATUS_INVALID_PARAMETER;967 }968 969 if (pVBoxFobx->FileStandardInfo.Directory == TRUE)970 {971 Log(("VBOXSF: MrxQueryFileInfo: Directory -> Copy info retrieved during the create call\n"));972 Status = STATUS_SUCCESS;973 974 switch (FunctionalityRequested)975 {976 case FileBasicInformation:977 {978 PFILE_BASIC_INFORMATION pInfo = (PFILE_BASIC_INFORMATION)pInfoBuffer;979 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation\n"));980 981 cbToCopy = sizeof(FILE_BASIC_INFORMATION);982 983 if (*pLengthRemaining >= cbToCopy)984 {985 *pInfo = pVBoxFobx->FileBasicInfo;986 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation: File attributes: 0x%x\n",987 pInfo->FileAttributes));988 }989 else990 {991 Status = STATUS_BUFFER_TOO_SMALL;992 }993 break;994 }995 996 case FileStandardInformation:997 {998 PFILE_STANDARD_INFORMATION pInfo = (PFILE_STANDARD_INFORMATION)pInfoBuffer;999 Log(("VBOXSF: MrxQueryFileInfo: FileStandardInformation\n"));1000 1001 cbToCopy = sizeof(FILE_STANDARD_INFORMATION);1002 1003 if (*pLengthRemaining >= cbToCopy)1004 *pInfo = pVBoxFobx->FileStandardInfo;1005 else1006 Status = STATUS_BUFFER_TOO_SMALL;1007 break;1008 }1009 1010 case FileNamesInformation:1011 {1012 PFILE_NAMES_INFORMATION pInfo = (PFILE_NAMES_INFORMATION)pInfoBuffer;1013 Log(("VBOXSF: MrxQueryFileInfo: FileNamesInformation\n"));1014 1015 cbToCopy = sizeof(FILE_NAMES_INFORMATION);1016 /* And size in bytes of the WCHAR name. */1017 cbToCopy += FileName->Length;1018 1019 if (*pLengthRemaining >= cbToCopy)1020 {1021 RtlZeroMemory(pInfo, cbToCopy);1022 1023 pInfo->FileNameLength = FileName->Length;1024 1025 RtlCopyMemory(pInfo->FileName, FileName->Buffer, FileName->Length);1026 pInfo->FileName[FileName->Length] = 0; /* FILE_NAMES_INFORMATION had space for the nul. */1027 }1028 else1029 Status = STATUS_BUFFER_TOO_SMALL;1030 break;1031 }1032 1033 case FileInternalInformation:1034 {1035 PFILE_INTERNAL_INFORMATION pInfo = (PFILE_INTERNAL_INFORMATION)pInfoBuffer;1036 Log(("VBOXSF: MrxQueryFileInfo: FileInternalInformation\n"));1037 1038 cbToCopy = sizeof(FILE_INTERNAL_INFORMATION);1039 1040 if (*pLengthRemaining >= cbToCopy)1041 {1042 /* A 8-byte file reference number for the file. */1043 pInfo->IndexNumber.QuadPart = (ULONG_PTR)capFcb;1044 }1045 else1046 Status = STATUS_BUFFER_TOO_SMALL;1047 break;1048 }1049 case FileEaInformation:1050 {1051 PFILE_EA_INFORMATION pInfo = (PFILE_EA_INFORMATION)pInfoBuffer;1052 Log(("VBOXSF: MrxQueryFileInfo: FileEaInformation\n"));1053 1054 cbToCopy = sizeof(FILE_EA_INFORMATION);1055 1056 if (*pLengthRemaining >= cbToCopy)1057 {1058 pInfo->EaSize = 0;1059 }1060 else1061 Status = STATUS_BUFFER_TOO_SMALL;1062 break;1063 }1064 1065 case FileNetworkOpenInformation:1066 {1067 PFILE_NETWORK_OPEN_INFORMATION pInfo = (PFILE_NETWORK_OPEN_INFORMATION)pInfoBuffer;1068 Log(("VBOXSF: MrxQueryFileInfo: FileNetworkOpenInformation\n"));1069 1070 cbToCopy = sizeof(FILE_NETWORK_OPEN_INFORMATION);1071 1072 if (*pLengthRemaining >= cbToCopy)1073 {1074 pInfo->CreationTime = pVBoxFobx->FileBasicInfo.CreationTime;1075 pInfo->LastAccessTime = pVBoxFobx->FileBasicInfo.LastAccessTime;1076 pInfo->LastWriteTime = pVBoxFobx->FileBasicInfo.LastWriteTime;1077 pInfo->ChangeTime = pVBoxFobx->FileBasicInfo.ChangeTime;1078 pInfo->AllocationSize.QuadPart = 0;1079 pInfo->EndOfFile.QuadPart = 0;1080 pInfo->FileAttributes = pVBoxFobx->FileBasicInfo.FileAttributes;1081 }1082 else1083 Status = STATUS_BUFFER_TOO_SMALL;1084 break;1085 }1086 1087 case FileStreamInformation:1088 Log(("VBOXSF: MrxQueryFileInfo: FileStreamInformation: not supported\n"));1089 Status = STATUS_INVALID_PARAMETER;1090 goto end;1091 1092 default:1093 Log(("VBOXSF: MrxQueryFileInfo: Not supported FunctionalityRequested %d!\n",1094 FunctionalityRequested));1095 Status = STATUS_INVALID_PARAMETER;1096 goto end;1097 }1098 }1099 else /* Entry is a file. */1100 {1101 cbHGCMBuffer = RT_MAX(cbInfoBuffer, PAGE_SIZE);1102 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer);1103 1104 if (!pHGCMBuffer)1105 return STATUS_INSUFFICIENT_RESOURCES;1106 1107 Assert(pVBoxFobx && pNetRootExtension && pDeviceExtension);1108 vrc = VbglR0SfFsInfo(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile,1109 SHFL_INFO_GET | SHFL_INFO_FILE, &cbHGCMBuffer, (PSHFLDIRINFO)pHGCMBuffer);1110 1111 if (vrc != VINF_SUCCESS)1112 {1113 Status = VBoxErrorToNTStatus(vrc);1114 goto end;1115 }1116 1117 pFileEntry = (PSHFLFSOBJINFO)pHGCMBuffer;1118 Status = STATUS_SUCCESS;1119 1120 switch (FunctionalityRequested)1121 {1122 case FileBasicInformation:1123 {1124 PFILE_BASIC_INFORMATION pInfo = (PFILE_BASIC_INFORMATION)pInfoBuffer;1125 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation\n"));1126 1127 cbToCopy = sizeof(FILE_BASIC_INFORMATION);1128 1129 if (*pLengthRemaining >= cbToCopy)1130 {1131 pInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->BirthTime); /* Ridiculous name. */1132 pInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->AccessTime);1133 pInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->ModificationTime);1134 pInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->ChangeTime);1135 pInfo->FileAttributes = VBoxToNTFileAttributes(pFileEntry->Attr.fMode);1136 1137 Log(("VBOXSF: MrxQueryFileInfo: FileBasicInformation: File attributes = 0x%x\n",1138 pInfo->FileAttributes));1139 }1140 else1141 Status = STATUS_BUFFER_TOO_SMALL;1142 break;1143 }1144 1145 case FileStandardInformation:1146 {1147 PFILE_STANDARD_INFORMATION pInfo = (PFILE_STANDARD_INFORMATION)pInfoBuffer;1148 Log(("VBOXSF: MrxQueryFileInfo: FileStandardInformation\n"));1149 1150 cbToCopy = sizeof(FILE_STANDARD_INFORMATION);1151 1152 if (*pLengthRemaining >= cbToCopy)1153 {1154 pInfo->AllocationSize.QuadPart = pFileEntry->cbAllocated;1155 pInfo->EndOfFile.QuadPart = pFileEntry->cbObject;1156 pInfo->NumberOfLinks = 1; /** @todo 0? */1157 pInfo->DeletePending = FALSE;1158 1159 if (pFileEntry->Attr.fMode & RTFS_DOS_DIRECTORY)1160 pInfo->Directory = TRUE;1161 else1162 pInfo->Directory = FALSE;1163 }1164 else1165 Status = STATUS_BUFFER_TOO_SMALL;1166 break;1167 }1168 1169 case FileNamesInformation:1170 {1171 PFILE_NAMES_INFORMATION pInfo = (PFILE_NAMES_INFORMATION)pInfoBuffer;1172 Log(("VBOXSF: MrxQueryFileInfo: FileNamesInformation\n"));1173 1174 cbToCopy = sizeof(FILE_NAMES_INFORMATION);1175 /* And size in bytes of the WCHAR name. */1176 cbToCopy += FileName->Length;1177 1178 if (*pLengthRemaining >= cbToCopy)1179 {1180 RtlZeroMemory(pInfo, cbToCopy);1181 1182 pInfo->FileNameLength = FileName->Length;1183 1184 RtlCopyMemory(pInfo->FileName, FileName->Buffer, FileName->Length);1185 pInfo->FileName[FileName->Length] = 0; /* FILE_NAMES_INFORMATION had space for the nul. */1186 }1187 else1188 Status = STATUS_BUFFER_TOO_SMALL;1189 break;1190 }1191 1192 case FileInternalInformation:1193 {1194 PFILE_INTERNAL_INFORMATION pInfo = (PFILE_INTERNAL_INFORMATION)pInfoBuffer;1195 Log(("VBOXSF: MrxQueryFileInfo: FileInternalInformation\n"));1196 1197 cbToCopy = sizeof(FILE_INTERNAL_INFORMATION);1198 1199 if (*pLengthRemaining >= cbToCopy)1200 {1201 /* A 8-byte file reference number for the file. */1202 pInfo->IndexNumber.QuadPart = (ULONG_PTR)capFcb;1203 }1204 else1205 Status = STATUS_BUFFER_TOO_SMALL;1206 break;1207 }1208 1209 case FileEaInformation:1210 {1211 PFILE_EA_INFORMATION pInfo = (PFILE_EA_INFORMATION)pInfoBuffer;1212 Log(("VBOXSF: MrxQueryFileInfo: FileEaInformation\n"));1213 1214 cbToCopy = sizeof(FILE_EA_INFORMATION);1215 1216 if (*pLengthRemaining >= cbToCopy)1217 pInfo->EaSize = 0;1218 else1219 Status = STATUS_BUFFER_TOO_SMALL;1220 break;1221 }1222 1223 case FileAttributeTagInformation:1224 {1225 PFILE_ATTRIBUTE_TAG_INFORMATION pInfo = (PFILE_ATTRIBUTE_TAG_INFORMATION)pInfoBuffer;1226 Log(("VBOXSF: MrxQueryFileInfo: FileAttributeTagInformation\n"));1227 1228 cbToCopy = sizeof(FILE_ATTRIBUTE_TAG_INFORMATION);1229 1230 if (*pLengthRemaining >= cbToCopy)1231 {1232 pInfo->FileAttributes = VBoxToNTFileAttributes(pFileEntry->Attr.fMode);1233 pInfo->ReparseTag = 0;1234 }1235 else1236 Status = STATUS_BUFFER_TOO_SMALL;1237 break;1238 }1239 1240 case FileEndOfFileInformation:1241 {1242 PFILE_END_OF_FILE_INFORMATION pInfo = (PFILE_END_OF_FILE_INFORMATION)pInfoBuffer;1243 Log(("VBOXSF: MrxQueryFileInfo: FileEndOfFileInformation\n"));1244 1245 cbToCopy = sizeof(FILE_END_OF_FILE_INFORMATION);1246 1247 if (*pLengthRemaining >= cbToCopy)1248 pInfo->EndOfFile.QuadPart = pFileEntry->cbObject;1249 else1250 Status = STATUS_BUFFER_TOO_SMALL;1251 break;1252 }1253 1254 case FileAllocationInformation:1255 {1256 PFILE_ALLOCATION_INFORMATION pInfo = (PFILE_ALLOCATION_INFORMATION)pInfoBuffer;1257 Log(("VBOXSF: MrxQueryFileInfo: FileAllocationInformation\n"));1258 1259 cbToCopy = sizeof(FILE_ALLOCATION_INFORMATION);1260 1261 if (*pLengthRemaining >= cbToCopy)1262 pInfo->AllocationSize.QuadPart = pFileEntry->cbAllocated;1263 else1264 Status = STATUS_BUFFER_TOO_SMALL;1265 break;1266 }1267 1268 case FileNetworkOpenInformation:1269 {1270 PFILE_NETWORK_OPEN_INFORMATION pInfo = (PFILE_NETWORK_OPEN_INFORMATION)pInfoBuffer;1271 Log(("VBOXSF: MrxQueryFileInfo: FileNetworkOpenInformation\n"));1272 1273 cbToCopy = sizeof(FILE_NETWORK_OPEN_INFORMATION);1274 1275 if (*pLengthRemaining >= cbToCopy)1276 {1277 pInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->BirthTime); /* Ridiculous name. */1278 pInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->AccessTime);1279 pInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->ModificationTime);1280 pInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pFileEntry->ChangeTime);1281 pInfo->AllocationSize.QuadPart = pFileEntry->cbAllocated;1282 pInfo->EndOfFile.QuadPart = pFileEntry->cbObject;1283 pInfo->FileAttributes = VBoxToNTFileAttributes(pFileEntry->Attr.fMode);1284 }1285 else1286 Status = STATUS_BUFFER_TOO_SMALL;1287 break;1288 }1289 1290 case FileStreamInformation:1291 Log(("VBOXSF: MrxQueryFileInfo: FileStreamInformation: not supported\n"));1292 Status = STATUS_INVALID_PARAMETER;1293 goto end;1294 1295 default:1296 Log(("VBOXSF: MrxQueryFileInfo: Not supported FunctionalityRequested %d!\n",1297 FunctionalityRequested));1298 Status = STATUS_INVALID_PARAMETER;1299 goto end;1300 }1301 }1302 1303 if (Status == STATUS_SUCCESS)1304 {1305 if (*pLengthRemaining < cbToCopy)1306 {1307 /* This situation must be already taken into account by the above code. */1308 AssertMsgFailed(("VBOXSF: MrxQueryFileInfo: Length remaining is below 0! (%d - %d)!\n",1309 *pLengthRemaining, cbToCopy));1310 Status = STATUS_BUFFER_TOO_SMALL;1311 }1312 else1313 {1314 pInfoBuffer += cbToCopy;1315 *pLengthRemaining -= cbToCopy;1316 }1317 }1318 1319 end:1320 if (Status == STATUS_BUFFER_TOO_SMALL)1321 {1322 Log(("VBOXSF: MrxQueryFileInfo: Buffer too small %d, required %d!\n",1323 *pLengthRemaining, cbToCopy));1324 RxContext->InformationToReturn = cbToCopy;1325 }1326 1327 if (pHGCMBuffer)1328 vbsfFreeNonPagedMem(pHGCMBuffer);1329 1330 if (Status == STATUS_SUCCESS)1331 {1332 Log(("VBOXSF: MrxQueryFileInfo: Remaining length = %d\n",1333 *pLengthRemaining));1334 }1335 1336 Log(("VBOXSF: MrxQueryFileInfo: Returned 0x%08X\n", Status));1337 return Status;1338 }1339 1340 NTSTATUS VBoxMRxSetFileInfo(IN PRX_CONTEXT RxContext)1341 {1342 NTSTATUS Status = STATUS_SUCCESS;1343 1344 RxCaptureFcb;1345 RxCaptureFobx;1346 1347 PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension = VBoxMRxGetDeviceExtension(RxContext);1348 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);1349 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);1350 1351 1278 FILE_INFORMATION_CLASS FunctionalityRequested = RxContext->Info.FileInformationClass; 1352 1279 PVOID pInfoBuffer = (PVOID)RxContext->Info.Buffer; … … 1366 1293 PFILE_BASIC_INFORMATION pInfo = (PFILE_BASIC_INFORMATION)pInfoBuffer; 1367 1294 PSHFLFSOBJINFO pSHFLFileInfo; 1295 uint32_t fModified; 1368 1296 1369 1297 Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: CreationTime %RX64\n", pInfo->CreationTime.QuadPart)); … … 1373 1301 Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: FileAttributes %RX32\n", pInfo->FileAttributes)); 1374 1302 1375 /* When setting file attributes, a value of -1 indicates to the server that it MUST NOT change this attribute 1376 * for all subsequent operations on the same file handle. 1303 /* 1304 * Note! If a timestamp value is non-zero, the client disables implicit updating of 1305 * that timestamp via this handle when reading, writing and changing attributes. 1306 * The special -1 value is used to just disable implicit updating without 1307 * modifying the timestamp. While the value is allowed for the CreationTime 1308 * field, it will be treated as zero. 1309 * 1310 * More clues can be found here: 1311 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/16023025-8a78-492f-8b96-c873b042ac50 1312 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/d4bc551b-7aaf-4b4f-ba0e-3a75e7c528f0#Appendix_A_86 1377 1313 */ 1314 1315 /** @todo r=bird: The attempt at implementing the disable-timestamp-update 1316 * behaviour here needs a little adjusting. I'll get to that later. 1317 * 1318 * Reminders: 1319 * 1320 * 1. Drop VBOX_FOBX_F_INFO_CREATION_TIME. 1321 * 1322 * 2. Drop unused VBOX_FOBX_F_INFO_ATTRIBUTES. 1323 * 1324 * 3. Only act on VBOX_FOBX_F_INFO_CHANGE_TIME if modified attributes or grown 1325 * the file (?) so we don't cancel out updates by other parties (like the 1326 * host). 1327 * 1328 * 4. Only act on VBOX_FOBX_F_INFO_LASTWRITE_TIME if we've written to the file. 1329 * 1330 * 5. Only act on VBOX_FOBX_F_INFO_LASTACCESS_TIME if we've read from the file 1331 * or done whatever else might modify the access time. 1332 * 1333 * 6. Don't bother calling the host if there are only zeros and -1 values. 1334 * 1335 * 7. Client application should probably be allowed to modify the timestamps 1336 * explicitly using this API after disabling updating, given the wording of 1337 * the footnote referenced above. 1338 * 1339 * 8. Extend the host interface to let the host handle this crap instead as it 1340 * can do a better job, like on windows it's done implicitly if we let -1 1341 * pass thru IPRT. 1342 * 1343 * One worry here is that we hide timestamp updates made by the host or other 1344 * guest side processes. This could account for some of the issues we've been 1345 * having with the guest not noticing host side changes. 1346 */ 1347 1378 1348 if (pInfo->CreationTime.QuadPart == -1) 1379 1349 { … … 1399 1369 cbBuffer = sizeof(SHFLFSOBJINFO); 1400 1370 pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer); 1401 if (!pHGCMBuffer) 1402 { 1403 AssertFailed(); 1404 return STATUS_INSUFFICIENT_RESOURCES; 1405 } 1371 AssertReturn(pHGCMBuffer, STATUS_INSUFFICIENT_RESOURCES); 1406 1372 RtlZeroMemory(pHGCMBuffer, cbBuffer); 1407 1373 pSHFLFileInfo = (PSHFLFSOBJINFO)pHGCMBuffer; … … 1411 1377 1412 1378 /* The properties, that need to be changed, are set to something other than zero */ 1379 fModified = 0; 1413 1380 if (pInfo->CreationTime.QuadPart && !pVBoxFobx->fKeepCreationTime) 1414 1381 { 1415 1382 RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pInfo->CreationTime.QuadPart); 1416 pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CREATION_TIME; 1417 } 1383 fModified |= VBOX_FOBX_F_INFO_CREATION_TIME; 1384 } 1385 /** @todo FsPerf need to check what is supposed to happen if modified 1386 * against after -1 is specified. */ 1418 1387 if (pInfo->LastAccessTime.QuadPart && !pVBoxFobx->fKeepLastAccessTime) 1419 1388 { 1420 1389 RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pInfo->LastAccessTime.QuadPart); 1421 pVBoxFobx->SetFileInfoOnCloseFlags|= VBOX_FOBX_F_INFO_LASTACCESS_TIME;1390 fModified |= VBOX_FOBX_F_INFO_LASTACCESS_TIME; 1422 1391 } 1423 1392 if (pInfo->LastWriteTime.QuadPart && !pVBoxFobx->fKeepLastWriteTime) 1424 1393 { 1425 1394 RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pInfo->LastWriteTime.QuadPart); 1426 pVBoxFobx->SetFileInfoOnCloseFlags|= VBOX_FOBX_F_INFO_LASTWRITE_TIME;1395 fModified |= VBOX_FOBX_F_INFO_LASTWRITE_TIME; 1427 1396 } 1428 1397 if (pInfo->ChangeTime.QuadPart && !pVBoxFobx->fKeepChangeTime) 1429 1398 { 1430 1399 RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart); 1431 pVBoxFobx->SetFileInfoOnCloseFlags|= VBOX_FOBX_F_INFO_CHANGE_TIME;1400 fModified |= VBOX_FOBX_F_INFO_CHANGE_TIME; 1432 1401 } 1433 1402 if (pInfo->FileAttributes) 1434 {1435 1403 pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pInfo->FileAttributes); 1436 }1437 1404 1438 1405 Assert(pVBoxFobx && pNetRootExtension && pDeviceExtension); … … 1440 1407 SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, (PSHFLDIRINFO)pSHFLFileInfo); 1441 1408 1442 if (vrc != VINF_SUCCESS) 1409 if (RT_SUCCESS(vrc)) 1410 { 1411 vbsfNtCopyInfo(pVBoxFobx, pSHFLFileInfo, fModified); 1412 pVBoxFobx->SetFileInfoOnCloseFlags |= fModified; 1413 } 1414 else 1443 1415 { 1444 1416 Status = VBoxErrorToNTStatus(vrc); 1445 1417 goto end; 1446 1418 } 1447 else1448 {1449 /* Update our internal copy. Ignore zero fields! */1450 if (pInfo->CreationTime.QuadPart && !pVBoxFobx->fKeepCreationTime)1451 pVBoxFobx->FileBasicInfo.CreationTime = pInfo->CreationTime;1452 if (pInfo->LastAccessTime.QuadPart && !pVBoxFobx->fKeepLastAccessTime)1453 pVBoxFobx->FileBasicInfo.LastAccessTime = pInfo->LastAccessTime;1454 if (pInfo->LastWriteTime.QuadPart && !pVBoxFobx->fKeepLastWriteTime)1455 pVBoxFobx->FileBasicInfo.LastWriteTime = pInfo->LastWriteTime;1456 if (pInfo->ChangeTime.QuadPart && !pVBoxFobx->fKeepChangeTime)1457 pVBoxFobx->FileBasicInfo.ChangeTime = pInfo->ChangeTime;1458 if (pInfo->FileAttributes)1459 pVBoxFobx->FileBasicInfo.FileAttributes = pInfo->FileAttributes;1460 }1461 1462 1419 break; 1463 1420 } -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.c
r78285 r78302 24 24 static NTSTATUS vbsfProcessCreate(PRX_CONTEXT RxContext, 25 25 PUNICODE_STRING RemainingName, 26 FILE_BASIC_INFORMATION *pFileBasicInfo, 27 FILE_STANDARD_INFORMATION *pFileStandardInfo, 26 SHFLFSOBJINFO *pInfo, 28 27 PVOID EaBuffer, 29 28 ULONG EaLength, … … 429 428 430 429 *pHandle = pCreateParms->Handle; 431 432 /* Translate attributes */ 433 pFileBasicInfo->FileAttributes = VBoxToNTFileAttributes(pCreateParms->Info.Attr.fMode); 434 435 /* Translate file times */ 436 pFileBasicInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pCreateParms->Info.BirthTime); /* ridiculous name */ 437 pFileBasicInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pCreateParms->Info.AccessTime); 438 pFileBasicInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pCreateParms->Info.ModificationTime); 439 pFileBasicInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pCreateParms->Info.ChangeTime); 440 441 if (!FlagOn(pCreateParms->Info.Attr.fMode, RTFS_DOS_DIRECTORY)) 442 { 443 pFileStandardInfo->AllocationSize.QuadPart = pCreateParms->Info.cbAllocated; 444 pFileStandardInfo->EndOfFile.QuadPart = pCreateParms->Info.cbObject; 445 pFileStandardInfo->Directory = FALSE; 446 447 Log(("VBOXSF: vbsfProcessCreate: AllocationSize = 0x%RX64, EndOfFile = 0x%RX64\n", 448 pCreateParms->Info.cbAllocated, pCreateParms->Info.cbObject)); 449 } 450 else 451 { 452 pFileStandardInfo->AllocationSize.QuadPart = 0; 453 pFileStandardInfo->EndOfFile.QuadPart = 0; 454 pFileStandardInfo->Directory = TRUE; 455 } 456 pFileStandardInfo->NumberOfLinks = 0; 457 pFileStandardInfo->DeletePending = FALSE; 430 *pInfo = pCreateParms->Info; 458 431 459 432 vbsfFreeNonPagedMem(pCreateParms); … … 489 462 PUNICODE_STRING RemainingName = GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(RxContext); 490 463 491 FILE_BASIC_INFORMATION FileBasicInfo; 492 FILE_STANDARD_INFORMATION FileStandardInfo; 464 SHFLFSOBJINFO Info = {0}; 493 465 494 466 ULONG CreateAction = FILE_CREATED; … … 531 503 } 532 504 533 FileBasicInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;534 535 505 Status = vbsfProcessCreate(RxContext, 536 506 RemainingName, 537 &FileBasicInfo, 538 &FileStandardInfo, 507 &Info, 539 508 RxContext->Create.EaBuffer, 540 509 RxContext->Create.EaLength, … … 550 519 551 520 Log(("VBOXSF: MRxCreate: EOF is 0x%RX64 AllocSize is 0x%RX64\n", 552 FileStandardInfo.EndOfFile.QuadPart, FileStandardInfo.AllocationSize.QuadPart));521 Info.cbObject, Info.cbAllocated)); 553 522 554 523 RxContext->pFobx = RxCreateNetFobx(RxContext, SrvOpen); … … 567 536 if (capFcb->OpenCount == 0) 568 537 { 569 FCB_INIT_PACKET InitPacket; 538 FCB_INIT_PACKET InitPacket; 539 FILE_NETWORK_OPEN_INFORMATION Data; 540 ULONG NumberOfLinks = 0; /** @todo ?? */ 541 Data.CreationTime.QuadPart = RTTimeSpecGetNtTime(&Info.BirthTime); 542 Data.LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&Info.AccessTime); 543 Data.LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&Info.ModificationTime); 544 Data.ChangeTime.QuadPart = RTTimeSpecGetNtTime(&Info.ChangeTime); 545 Data.AllocationSize.QuadPart = Info.cbAllocated; 546 Data.EndOfFile.QuadPart = Info.cbObject; 547 Data.FileAttributes = VBoxToNTFileAttributes(Info.Attr.fMode); 570 548 RxFormInitPacket(InitPacket, 571 &FileBasicInfo.FileAttributes, 572 &FileStandardInfo.NumberOfLinks, 573 &FileBasicInfo.CreationTime, 574 &FileBasicInfo.LastAccessTime, 575 &FileBasicInfo.LastWriteTime, 576 &FileBasicInfo.ChangeTime, 577 &FileStandardInfo.AllocationSize, 578 &FileStandardInfo.EndOfFile, 579 &FileStandardInfo.EndOfFile); 549 &Data.FileAttributes, 550 &NumberOfLinks, 551 &Data.CreationTime, 552 &Data.LastAccessTime, 553 &Data.LastWriteTime, 554 &Data.ChangeTime, 555 &Data.AllocationSize, 556 &Data.EndOfFile, 557 &Data.EndOfFile); 558 /** @todo r=bird: Use FileTypeDirectory/RDBSS_NTC_STORAGE_TYPE_DIRECTORY here 559 * for directories? */ 580 560 RxFinishFcbInitialization(capFcb, RDBSS_STORAGE_NTC(FileTypeFile), &InitPacket); 581 561 } … … 598 578 } 599 579 600 Log(("VBOXSF: MRxCreate: FileBasicInformation: CreationTime %RX64\n", FileBasicInfo.CreationTime.QuadPart));601 Log(("VBOXSF: MRxCreate: FileBasicInformation: LastAccessTime %RX64\n", FileBasicInfo.LastAccessTime.QuadPart));602 Log(("VBOXSF: MRxCreate: FileBasicInformation: LastWriteTime %RX64\n", FileBasicInfo.LastWriteTime.QuadPart));603 Log(("VBOXSF: MRxCreate: FileBasicInformation: ChangeTime %RX64\n", FileBasicInfo.ChangeTime.QuadPart));604 Log(("VBOXSF: MRxCreate: FileBasicInformation: FileAttributes %RX32\n", FileBasicInfo.FileAttributes));605 606 580 pVBoxFobx->hFile = Handle; 607 581 pVBoxFobx->pSrvCall = RxContext->Create.pSrvCall; 608 pVBoxFobx->FileStandardInfo = FileStandardInfo; 609 pVBoxFobx->FileBasicInfo = FileBasicInfo; 610 pVBoxFobx->fKeepCreationTime = FALSE; 611 pVBoxFobx->fKeepLastAccessTime = FALSE; 612 pVBoxFobx->fKeepLastWriteTime = FALSE; 613 pVBoxFobx->fKeepChangeTime = FALSE; 614 pVBoxFobx->SetFileInfoOnCloseFlags = 0; 582 pVBoxFobx->Info = Info; 583 vbsfNtCopyInfoToLegacy(pVBoxFobx, &Info); 584 Log(("VBOXSF: MRxCreate: FileBasicInformation: CreationTime %RX64\n", pVBoxFobx->FileBasicInfo.CreationTime.QuadPart)); 585 Log(("VBOXSF: MRxCreate: FileBasicInformation: LastAccessTime %RX64\n", pVBoxFobx->FileBasicInfo.LastAccessTime.QuadPart)); 586 Log(("VBOXSF: MRxCreate: FileBasicInformation: LastWriteTime %RX64\n", pVBoxFobx->FileBasicInfo.LastWriteTime.QuadPart)); 587 Log(("VBOXSF: MRxCreate: FileBasicInformation: ChangeTime %RX64\n", pVBoxFobx->FileBasicInfo.ChangeTime.QuadPart)); 588 Log(("VBOXSF: MRxCreate: FileBasicInformation: FileAttributes %RX32\n", pVBoxFobx->FileBasicInfo.FileAttributes)); 589 if (!(Info.Attr.fMode & RTFS_DOS_DIRECTORY)) 590 Log(("VBOXSF: MRxCreate: AllocationSize = %#RX64, EndOfFile = %#RX64\n", 591 Info.cbAllocated, Info.cbObject)); 615 592 616 593 if (!RxIsFcbAcquiredExclusive(capFcb)) … … 675 652 } 676 653 677 NTSTATUS vbsfSetFileInfo(PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension,678 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,679 PMRX_VBOX_FOBX pVBoxFobx,680 PFILE_BASIC_INFORMATION pInfo,681 BYTE SetAttrFlags)654 static NTSTATUS vbsfSetFileInfoOnClose(PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension, 655 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, 656 PMRX_VBOX_FOBX pVBoxFobx, 657 PFILE_BASIC_INFORMATION pInfo, 658 BYTE SetAttrFlags) 682 659 { 683 660 NTSTATUS Status = STATUS_SUCCESS; … … 689 666 uint32_t cbBuffer = 0; 690 667 691 Log(("VBOXSF: vbsfSetFileInfo : SetAttrFlags 0x%02X\n", SetAttrFlags));692 Log(("VBOXSF: vbsfSetFileInfo : FileBasicInformation: CreationTime %RX64\n", pInfo->CreationTime.QuadPart));693 Log(("VBOXSF: vbsfSetFileInfo : FileBasicInformation: LastAccessTime %RX64\n", pInfo->LastAccessTime.QuadPart));694 Log(("VBOXSF: vbsfSetFileInfo : FileBasicInformation: LastWriteTime %RX64\n", pInfo->LastWriteTime.QuadPart));695 Log(("VBOXSF: vbsfSetFileInfo : FileBasicInformation: ChangeTime %RX64\n", pInfo->ChangeTime.QuadPart));696 Log(("VBOXSF: vbsfSetFileInfo : FileBasicInformation: FileAttributes %RX32\n", pInfo->FileAttributes));668 Log(("VBOXSF: vbsfSetFileInfoOnClose: SetAttrFlags 0x%02X\n", SetAttrFlags)); 669 Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: CreationTime %RX64\n", pInfo->CreationTime.QuadPart)); 670 Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: LastAccessTime %RX64\n", pInfo->LastAccessTime.QuadPart)); 671 Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: LastWriteTime %RX64\n", pInfo->LastWriteTime.QuadPart)); 672 Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: ChangeTime %RX64\n", pInfo->ChangeTime.QuadPart)); 673 Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: FileAttributes %RX32\n", pInfo->FileAttributes)); 697 674 698 675 if (SetAttrFlags == 0) … … 721 698 if (pInfo->ChangeTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CHANGE_TIME) != 0) 722 699 RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart); 723 if (pInfo->FileAttributes && (SetAttrFlags & VBOX_FOBX_F_INFO_ATTRIBUTES) != 0) 700 if (pInfo->FileAttributes && (SetAttrFlags & VBOX_FOBX_F_INFO_ATTRIBUTES) != 0) /// @todo r=bird: never ever set. 724 701 pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pInfo->FileAttributes); 725 702 … … 763 740 * to cancel any effect of the file read/write operations on the host. 764 741 */ 765 Status = vbsfSetFileInfo (pDeviceExtension,766 pNetRootExtension,767 pVBoxFobx,768 &pVBoxFobx->FileBasicInfo,769 pVBoxFobx->SetFileInfoOnCloseFlags);742 Status = vbsfSetFileInfoOnClose(pDeviceExtension, 743 pNetRootExtension, 744 pVBoxFobx, 745 &pVBoxFobx->FileBasicInfo, 746 pVBoxFobx->SetFileInfoOnCloseFlags); 770 747 } 771 748 … … 865 842 vrc = VbglR0SfRemove(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, 866 843 ParsedPath, 867 (pVBoxFobx->FileStandardInfo.Directory)? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE);844 pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE); 868 845 869 846 if (ParsedPath) … … 937 914 938 915 /* Call host. */ 939 flags = pVBoxFobx-> FileStandardInfo.Directory? SHFL_RENAME_DIR : SHFL_RENAME_FILE;916 flags = pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY ? SHFL_RENAME_DIR : SHFL_RENAME_FILE; 940 917 if (RenameInformation->ReplaceIfExists) 941 918 flags |= SHFL_RENAME_REPLACE_IF_EXISTS; -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.cpp
r78301 r78302 19 19 20 20 21 /* 21 /** 22 22 * The current state of the driver. 23 23 */ … … 31 31 static MRX_VBOX_STATE VBoxMRxState = MRX_VBOX_STARTABLE; 32 32 33 /* 33 /** 34 34 * The VBoxSF dispatch table. 35 35 */ 36 36 static struct _MINIRDR_DISPATCH VBoxMRxDispatch; 37 37 38 /* 38 /** 39 39 * The VBoxSF device object. 40 40 */ 41 41 PRDBSS_DEVICE_OBJECT VBoxMRxDeviceObject; 42 43 uint64_t g_abPadding111[256] = {0}; 44 /** The shared folder service client structure. */ 45 VBGLSFCLIENT g_SfClient; 46 /** VMMDEV_HVF_XXX (set during init). */ 47 uint32_t g_fHostFeatures = 0; 48 /** Last valid shared folders function number. */ 49 uint32_t g_uSfLastFunction = SHFL_FN_SET_FILE_SIZE; 50 /** Shared folders features (SHFL_FEATURE_XXX). */ 51 uint64_t g_fSfFeatures = 0; 52 uint64_t g_abPadding222[256] = {0}; 53 54 42 55 43 56 static NTSTATUS VBoxMRxFsdDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) … … 78 91 PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension; 79 92 pDeviceExtension = (PMRX_VBOX_DEVICE_EXTENSION)((PBYTE)VBoxMRxDeviceObject + sizeof(RDBSS_DEVICE_OBJECT)); 80 VbglR0SfDisconnect(&pDeviceExtension->hgcmClient); 81 } 82 83 VbglR0SfTerm(); 93 } 84 94 85 95 if (VBoxMRxDeviceObject) … … 116 126 117 127 RxUnload(DriverObject); 128 129 VbglR0SfDisconnect(&g_SfClient); 130 VbglR0SfTerm(); 118 131 119 132 Log(("VBOXSF: MRxUnload: VBoxSF.sys driver object %p unloaded\n", DriverObject)); … … 472 485 ULONG i; 473 486 int vrc; 474 VBGLSFCLIENT hgcmClient;475 487 476 488 Log(("VBOXSF: DriverEntry: Driver object %p\n", DriverObject)); … … 491 503 492 504 /* Connect the HGCM client */ 493 RT_ZERO(hgcmClient); 494 vrc = VbglR0SfConnect(&hgcmClient); 505 vrc = VbglR0SfConnect(&g_SfClient); 495 506 if (RT_FAILURE(vrc)) 496 507 { … … 500 511 return STATUS_UNSUCCESSFUL; 501 512 } 513 514 vrc = VbglR0QueryHostFeatures(&g_fHostFeatures); 515 if (RT_FAILURE(vrc)) 516 { 517 LogRel(("vboxsf: VbglR0QueryHostFeatures failed: vrc=%Rrc (ignored)\n", vrc)); 518 g_fHostFeatures = 0; 519 } 520 VbglR0SfHostReqQueryFeaturesSimple(&g_fSfFeatures, &g_uSfLastFunction); 521 LogRel(("VBoxSF: g_fHostFeatures=%#x g_fSfFeatures=%#RX64 g_uSfLastFunction=%u\n", 522 g_fHostFeatures, g_fSfFeatures, g_uSfLastFunction)); 502 523 503 524 /* Init the driver object. */ … … 598 619 599 620 AssertPtr(pDeviceExtension); 600 pDeviceExtension->hgcmClient = hgcmClient;621 pDeviceExtension->hgcmClient = g_SfClient; 601 622 602 623 /* The redirector driver must intercept the IOCTL to avoid VBOXSVR name resolution … … 624 645 Log(("VBOXSF: DriverEntry: Failure! Status = 0x%08X\n", Status)); 625 646 626 VbglR0SfDisconnect(& hgcmClient);647 VbglR0SfDisconnect(&g_SfClient); 627 648 VbglR0SfTerm(); 628 649 … … 1436 1457 PV_NET_ROOT VNetRoot = (PV_NET_ROOT)Fobx; 1437 1458 1459 #ifdef __cplusplus /* C version points at NET_ROOT, C++ points at MRX_NET_ROOT. Weird. */ 1460 Status = RxFinalizeConnection((PNET_ROOT)VNetRoot->pNetRoot, VNetRoot, TRUE); 1461 #else 1438 1462 Status = RxFinalizeConnection(VNetRoot->NetRoot, VNetRoot, TRUE); 1463 #endif 1439 1464 } 1440 1465 else … … 1653 1678 * WML stubs which are referenced by rdbsslib. 1654 1679 */ 1655 NTSTATUS WmlTinySystemControl(IN OUT PVOID pWmiLibInfo, IN PVOID pDevObj, IN PVOID pIrp)1680 extern "C" NTSTATUS WmlTinySystemControl(IN OUT PVOID pWmiLibInfo, IN PVOID pDevObj, IN PVOID pIrp) 1656 1681 { 1657 1682 RT_NOREF(pWmiLibInfo, pDevObj, pIrp); … … 1659 1684 } 1660 1685 1661 ULONG WmlTrace(IN ULONG ulType, IN PVOID pTraceUuid, IN ULONG64 ullLogger, ...)1686 extern "C" ULONG WmlTrace(IN ULONG ulType, IN PVOID pTraceUuid, IN ULONG64 ullLogger, ...) 1662 1687 { 1663 1688 RT_NOREF(ulType, pTraceUuid, ullLogger); -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h
r78285 r78302 43 43 #include "vbsfhlp.h" 44 44 #include "vbsfshared.h" 45 #ifdef __cplusplus /* mixes code and variables */ 46 # include <VBox/VBoxGuestLibSharedFoldersInline.h> 47 #endif 48 49 RT_C_DECLS_BEGIN 45 50 46 51 extern PRDBSS_DEVICE_OBJECT VBoxMRxDeviceObject; … … 76 81 77 82 } MRX_VBOX_DEVICE_EXTENSION, *PMRX_VBOX_DEVICE_EXTENSION; 83 #ifdef RT_ARCH_AMD64 84 AssertCompileMemberOffset(MRX_VBOX_DEVICE_EXTENSION, cLocalConnections, 8); 85 AssertCompileMemberOffset(MRX_VBOX_DEVICE_EXTENSION, wszLocalConnectionName, 0x28); 86 AssertCompileMemberOffset(MRX_VBOX_DEVICE_EXTENSION, mtxLocalCon, 0xF8); 87 AssertCompileMemberSize(MRX_VBOX_DEVICE_EXTENSION, mtxLocalCon, 7 * 8); 88 AssertCompileMemberOffset(MRX_VBOX_DEVICE_EXTENSION, hgcmClient, 0x130); 89 AssertCompileMemberOffset(MRX_VBOX_DEVICE_EXTENSION, pfnRDBSSDeviceControl, 0x130 + 16); 90 #endif 78 91 79 92 /* … … 95 108 #define VBOX_FOBX_F_INFO_ATTRIBUTES 0x10 96 109 97 /* 110 /** 98 111 * The shared folders file extension. 99 112 */ 100 typedef struct _MRX_VBOX_FOBX_113 typedef struct MRX_VBOX_FOBX 101 114 { 102 SHFLHANDLE hFile; 103 PMRX_SRV_CALL pSrvCall; 104 FILE_BASIC_INFORMATION FileBasicInfo; 105 FILE_STANDARD_INFORMATION FileStandardInfo; 115 /** The host file handle. */ 116 SHFLHANDLE hFile; 117 PMRX_SRV_CALL pSrvCall; 118 /** The RTTimeSystemNanoTS value when Info was retrieved, 0 to force update. */ 119 uint64_t nsUpToDate; 120 /** Cached object info. */ 121 SHFLFSOBJINFO Info; 122 /** NT version of Info. 123 * @todo try eliminate */ 124 FILE_BASIC_INFORMATION FileBasicInfo; 125 106 126 BOOLEAN fKeepCreationTime; 107 127 BOOLEAN fKeepLastAccessTime; … … 216 236 PMRX_VBOX_FOBX pVBoxFobx); 217 237 238 void vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo); 239 240 241 RT_C_DECLS_END 242 218 243 #endif /* !GA_INCLUDED_SRC_WINNT_SharedFolders_driver_vbsf_h */ -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsfhlp.h
r78280 r78302 28 28 #include <VBox/VBoxGuestLibSharedFolders.h> 29 29 30 RT_C_DECLS_BEGIN 30 31 31 32 void vbsfHlpSleep(ULONG ulMillies); … … 45 46 NTSTATUS vbsfShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb); 46 47 48 RT_C_DECLS_END 49 47 50 #endif /* !GA_INCLUDED_SRC_WINNT_SharedFolders_driver_vbsfhlp_h */ 48 51
Note:
See TracChangeset
for help on using the changeset viewer.