1 | /* $Id: vbsf.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Windows Guest Shared Folders - File System Driver header file
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef GA_INCLUDED_SRC_WINNT_SharedFolders_driver_vbsf_h
|
---|
29 | #define GA_INCLUDED_SRC_WINNT_SharedFolders_driver_vbsf_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * This must be defined before including RX headers.
|
---|
37 | */
|
---|
38 | #define MINIRDR__NAME VBoxMRx
|
---|
39 | #define ___MINIRDR_IMPORTS_NAME (VBoxMRxDeviceObject->RdbssExports)
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * System and RX headers.
|
---|
43 | */
|
---|
44 | #include <iprt/nt/nt.h> /* includes ntifs.h + wdm.h */
|
---|
45 | #include <iprt/win/windef.h>
|
---|
46 | #ifndef INVALID_HANDLE_VALUE
|
---|
47 | # define INVALID_HANDLE_VALUE RTNT_INVALID_HANDLE_VALUE /* (The rx.h definition causes warnings for amd64) */
|
---|
48 | #endif
|
---|
49 | #include <iprt/nt/rx.h>
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * VBox shared folders.
|
---|
53 | */
|
---|
54 | #include "vbsfshared.h"
|
---|
55 | #include <VBox/log.h>
|
---|
56 | #include <VBox/VBoxGuestLibSharedFolders.h>
|
---|
57 | #ifdef __cplusplus /* not for Win2kWorkarounds.c */
|
---|
58 | # include <VBox/VBoxGuestLibSharedFoldersInline.h>
|
---|
59 | #endif
|
---|
60 |
|
---|
61 |
|
---|
62 | RT_C_DECLS_BEGIN
|
---|
63 |
|
---|
64 | /*
|
---|
65 | * Global data.
|
---|
66 | */
|
---|
67 | extern PRDBSS_DEVICE_OBJECT VBoxMRxDeviceObject;
|
---|
68 | extern uint32_t g_uSfLastFunction;
|
---|
69 | /** Pointer to the CcCoherencyFlushAndPurgeCache API (since win 7). */
|
---|
70 | typedef VOID (NTAPI *PFNCCCOHERENCYFLUSHANDPURGECACHE)(PSECTION_OBJECT_POINTERS, PLARGE_INTEGER, ULONG, PIO_STATUS_BLOCK,ULONG);
|
---|
71 | extern PFNCCCOHERENCYFLUSHANDPURGECACHE g_pfnCcCoherencyFlushAndPurgeCache;
|
---|
72 | #ifndef CC_FLUSH_AND_PURGE_NO_PURGE
|
---|
73 | # define CC_FLUSH_AND_PURGE_NO_PURGE 1
|
---|
74 | #endif
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Maximum drive letters (A - Z).
|
---|
79 | */
|
---|
80 | #define _MRX_MAX_DRIVE_LETTERS 26
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * The shared folders device extension.
|
---|
84 | */
|
---|
85 | typedef struct _MRX_VBOX_DEVICE_EXTENSION
|
---|
86 | {
|
---|
87 | /** The shared folders device object pointer. */
|
---|
88 | PRDBSS_DEVICE_OBJECT pDeviceObject;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Keep a list of local connections used.
|
---|
92 | * The size (_MRX_MAX_DRIVE_LETTERS = 26) of the array presents the available drive letters C: - Z: of Windows.
|
---|
93 | */
|
---|
94 | CHAR cLocalConnections[_MRX_MAX_DRIVE_LETTERS];
|
---|
95 | PUNICODE_STRING wszLocalConnectionName[_MRX_MAX_DRIVE_LETTERS];
|
---|
96 | FAST_MUTEX mtxLocalCon;
|
---|
97 |
|
---|
98 | /** Saved pointer to the original IRP_MJ_DEVICE_CONTROL handler. */
|
---|
99 | NTSTATUS (* pfnRDBSSDeviceControl) (PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
100 | /** Saved pointer to the original IRP_MJ_CREATE handler. */
|
---|
101 | NTSTATUS (NTAPI * pfnRDBSSCreate)(PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
102 | /** Saved pointer to the original IRP_MJ_SET_INFORMATION handler. */
|
---|
103 | NTSTATUS (NTAPI * pfnRDBSSSetInformation)(PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
104 |
|
---|
105 | } MRX_VBOX_DEVICE_EXTENSION, *PMRX_VBOX_DEVICE_EXTENSION;
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * The shared folders NET_ROOT extension.
|
---|
109 | */
|
---|
110 | typedef struct _MRX_VBOX_NETROOT_EXTENSION
|
---|
111 | {
|
---|
112 | /** The shared folder map handle of this netroot. */
|
---|
113 | VBGLSFMAP map;
|
---|
114 | /** Simple initialized (mapped folder) indicator that works better with the
|
---|
115 | * zero filled defaults than SHFL_ROOT_NIL. */
|
---|
116 | bool fInitialized;
|
---|
117 | } MRX_VBOX_NETROOT_EXTENSION, *PMRX_VBOX_NETROOT_EXTENSION;
|
---|
118 |
|
---|
119 |
|
---|
120 | /** Pointer to the VBox file object extension data. */
|
---|
121 | typedef struct MRX_VBOX_FOBX *PMRX_VBOX_FOBX;
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * VBox extension data to the file control block (FCB).
|
---|
125 | *
|
---|
126 | * @note To unix people, think of the FCB as the inode structure. This is our
|
---|
127 | * private addition to the inode info.
|
---|
128 | */
|
---|
129 | typedef struct VBSFNTFCBEXT
|
---|
130 | {
|
---|
131 | /** @name Pointers to file object extensions currently sitting on the given timestamps.
|
---|
132 | *
|
---|
133 | * The file object extensions pointed to have disabled implicit updating the
|
---|
134 | * respective timestamp due to a FileBasicInformation set request. Should these
|
---|
135 | * timestamps be modified via any other file handle, these pointers will be
|
---|
136 | * updated or set to NULL to reflect this. So, when the cleaning up a file
|
---|
137 | * object it can be more accurately determined whether to restore timestamps on
|
---|
138 | * non-windows host systems or not.
|
---|
139 | *
|
---|
140 | * @{ */
|
---|
141 | PMRX_VBOX_FOBX pFobxLastAccessTime;
|
---|
142 | PMRX_VBOX_FOBX pFobxLastWriteTime;
|
---|
143 | PMRX_VBOX_FOBX pFobxChangeTime;
|
---|
144 | /** @} */
|
---|
145 |
|
---|
146 | /** @name Cached volume info.
|
---|
147 | * @{ */
|
---|
148 | /** The RTTimeSystemNanoTS value when VolInfo was retrieved, 0 to force update. */
|
---|
149 | uint64_t volatile nsVolInfoUpToDate;
|
---|
150 | /** Volume information. */
|
---|
151 | SHFLVOLINFO volatile VolInfo;
|
---|
152 | /** @} */
|
---|
153 | } VBSFNTFCBEXT;
|
---|
154 | /** Pointer to the VBox FCB extension data. */
|
---|
155 | typedef VBSFNTFCBEXT *PVBSFNTFCBEXT;
|
---|
156 |
|
---|
157 |
|
---|
158 | /** @name VBOX_FOBX_F_INFO_XXX
|
---|
159 | * @{ */
|
---|
160 | #define VBOX_FOBX_F_INFO_LASTACCESS_TIME UINT8_C(0x01)
|
---|
161 | #define VBOX_FOBX_F_INFO_LASTWRITE_TIME UINT8_C(0x02)
|
---|
162 | #define VBOX_FOBX_F_INFO_CHANGE_TIME UINT8_C(0x04)
|
---|
163 | /** @} */
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * The shared folders file extension.
|
---|
167 | */
|
---|
168 | typedef struct MRX_VBOX_FOBX
|
---|
169 | {
|
---|
170 | /** The host file handle. */
|
---|
171 | SHFLHANDLE hFile;
|
---|
172 | PMRX_SRV_CALL pSrvCall;
|
---|
173 | /** The RTTimeSystemNanoTS value when Info was retrieved, 0 to force update. */
|
---|
174 | uint64_t nsUpToDate;
|
---|
175 | /** Cached object info.
|
---|
176 | * @todo Consider moving it to VBSFNTFCBEXT. Better fit than on "handle". */
|
---|
177 | SHFLFSOBJINFO Info;
|
---|
178 |
|
---|
179 | /** VBOX_FOBX_F_INFO_XXX of timestamps which may need setting on close. */
|
---|
180 | uint8_t fTimestampsSetByUser;
|
---|
181 | /** VBOX_FOBX_F_INFO_XXX of timestamps which implicit updating is suppressed. */
|
---|
182 | uint8_t fTimestampsUpdatingSuppressed;
|
---|
183 | /** VBOX_FOBX_F_INFO_XXX of timestamps which may have implicitly update. */
|
---|
184 | uint8_t fTimestampsImplicitlyUpdated;
|
---|
185 | } MRX_VBOX_FOBX;
|
---|
186 |
|
---|
187 | #define VBoxMRxGetDeviceExtension(RxContext) \
|
---|
188 | ((PMRX_VBOX_DEVICE_EXTENSION)((PBYTE)(RxContext)->RxDeviceObject + sizeof(RDBSS_DEVICE_OBJECT)))
|
---|
189 |
|
---|
190 | #define VBoxMRxGetNetRootExtension(pNetRoot) ((pNetRoot) != NULL ? (PMRX_VBOX_NETROOT_EXTENSION)(pNetRoot)->Context : NULL)
|
---|
191 |
|
---|
192 | #define VBoxMRxGetFcbExtension(pFcb) ((pFcb) != NULL ? (PVBSFNTFCBEXT)(pFcb)->Context : NULL)
|
---|
193 |
|
---|
194 | #define VBoxMRxGetSrvOpenExtension(pSrvOpen) ((pSrvOpen) != NULL ? (PMRX_VBOX_SRV_OPEN)(pSrvOpen)->Context : NULL)
|
---|
195 |
|
---|
196 | #define VBoxMRxGetFileObjectExtension(pFobx) ((pFobx) != NULL ? (PMRX_VBOX_FOBX)(pFobx)->Context : NULL)
|
---|
197 |
|
---|
198 | /** HACK ALERT: Special Create.ShareAccess indicating trailing slash for
|
---|
199 | * non-directory IRP_MJ_CREATE request.
|
---|
200 | * Set by VBoxHookMjCreate, used by VBoxMRxCreate. */
|
---|
201 | #define VBOX_MJ_CREATE_SLASH_HACK UINT16_C(0x0400)
|
---|
202 |
|
---|
203 | /** @name Prototypes for the dispatch table routines.
|
---|
204 | * @{
|
---|
205 | */
|
---|
206 | NTSTATUS VBoxMRxStart(IN OUT struct _RX_CONTEXT * RxContext,
|
---|
207 | IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject);
|
---|
208 | NTSTATUS VBoxMRxStop(IN OUT struct _RX_CONTEXT * RxContext,
|
---|
209 | IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject);
|
---|
210 |
|
---|
211 | NTSTATUS VBoxMRxCreate(IN OUT PRX_CONTEXT RxContext);
|
---|
212 | NTSTATUS VBoxMRxCollapseOpen(IN OUT PRX_CONTEXT RxContext);
|
---|
213 | NTSTATUS VBoxMRxShouldTryToCollapseThisOpen(IN OUT PRX_CONTEXT RxContext);
|
---|
214 | NTSTATUS VBoxMRxFlush(IN OUT PRX_CONTEXT RxContext);
|
---|
215 | NTSTATUS VBoxMRxTruncate(IN OUT PRX_CONTEXT RxContext);
|
---|
216 | NTSTATUS VBoxMRxCleanupFobx(IN OUT PRX_CONTEXT RxContext);
|
---|
217 | NTSTATUS VBoxMRxCloseSrvOpen(IN OUT PRX_CONTEXT RxContext);
|
---|
218 | NTSTATUS VBoxMRxDeallocateForFcb(IN OUT PMRX_FCB pFcb);
|
---|
219 | NTSTATUS VBoxMRxDeallocateForFobx(IN OUT PMRX_FOBX pFobx);
|
---|
220 | NTSTATUS VBoxMRxForceClosed(IN OUT PMRX_SRV_OPEN SrvOpen);
|
---|
221 |
|
---|
222 | NTSTATUS VBoxMRxQueryDirectory(IN OUT PRX_CONTEXT RxContext);
|
---|
223 | NTSTATUS VBoxMRxQueryFileInfo(IN OUT PRX_CONTEXT RxContext);
|
---|
224 | NTSTATUS VBoxMRxSetFileInfo(IN OUT PRX_CONTEXT RxContext);
|
---|
225 | NTSTATUS VBoxMRxSetFileInfoAtCleanup(IN OUT PRX_CONTEXT RxContext);
|
---|
226 | NTSTATUS VBoxMRxQueryEaInfo(IN OUT PRX_CONTEXT RxContext);
|
---|
227 | NTSTATUS VBoxMRxSetEaInfo(IN OUT struct _RX_CONTEXT * RxContext);
|
---|
228 | NTSTATUS VBoxMRxQuerySdInfo(IN OUT PRX_CONTEXT RxContext);
|
---|
229 | NTSTATUS VBoxMRxSetSdInfo(IN OUT struct _RX_CONTEXT * RxContext);
|
---|
230 | NTSTATUS VBoxMRxQueryVolumeInfo(IN OUT PRX_CONTEXT RxContext);
|
---|
231 |
|
---|
232 | NTSTATUS VBoxMRxComputeNewBufferingState(IN OUT PMRX_SRV_OPEN pSrvOpen,
|
---|
233 | IN PVOID pMRxContext,
|
---|
234 | OUT ULONG *pNewBufferingState);
|
---|
235 |
|
---|
236 | NTSTATUS VBoxMRxRead(IN OUT PRX_CONTEXT RxContext);
|
---|
237 | NTSTATUS VBoxMRxWrite(IN OUT PRX_CONTEXT RxContext);
|
---|
238 | NTSTATUS VBoxMRxLocks(IN OUT PRX_CONTEXT RxContext);
|
---|
239 | NTSTATUS VBoxMRxFsCtl(IN OUT PRX_CONTEXT RxContext);
|
---|
240 | NTSTATUS VBoxMRxIoCtl(IN OUT PRX_CONTEXT RxContext);
|
---|
241 | NTSTATUS VBoxMRxNotifyChangeDirectory(IN OUT PRX_CONTEXT RxContext);
|
---|
242 |
|
---|
243 | ULONG NTAPI VBoxMRxExtendStub(IN OUT struct _RX_CONTEXT * RxContext,
|
---|
244 | IN OUT PLARGE_INTEGER pNewFileSize,
|
---|
245 | OUT PLARGE_INTEGER pNewAllocationSize);
|
---|
246 | NTSTATUS VBoxMRxCompleteBufferingStateChangeRequest(IN OUT PRX_CONTEXT RxContext,
|
---|
247 | IN OUT PMRX_SRV_OPEN SrvOpen,
|
---|
248 | IN PVOID pContext);
|
---|
249 |
|
---|
250 | NTSTATUS VBoxMRxCreateVNetRoot(IN OUT PMRX_CREATENETROOT_CONTEXT pContext);
|
---|
251 | NTSTATUS VBoxMRxFinalizeVNetRoot(IN OUT PMRX_V_NET_ROOT pVirtualNetRoot,
|
---|
252 | IN PBOOLEAN ForceDisconnect);
|
---|
253 | NTSTATUS VBoxMRxFinalizeNetRoot(IN OUT PMRX_NET_ROOT pNetRoot,
|
---|
254 | IN PBOOLEAN ForceDisconnect);
|
---|
255 | NTSTATUS VBoxMRxUpdateNetRootState(IN PMRX_NET_ROOT pNetRoot);
|
---|
256 | VOID VBoxMRxExtractNetRootName(IN PUNICODE_STRING FilePathName,
|
---|
257 | IN PMRX_SRV_CALL SrvCall,
|
---|
258 | OUT PUNICODE_STRING NetRootName,
|
---|
259 | OUT PUNICODE_STRING RestOfName OPTIONAL);
|
---|
260 |
|
---|
261 | NTSTATUS VBoxMRxCreateSrvCall(PMRX_SRV_CALL pSrvCall,
|
---|
262 | PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext);
|
---|
263 | NTSTATUS VBoxMRxSrvCallWinnerNotify(IN OUT PMRX_SRV_CALL pSrvCall,
|
---|
264 | IN BOOLEAN ThisMinirdrIsTheWinner,
|
---|
265 | IN OUT PVOID pSrvCallContext);
|
---|
266 | NTSTATUS VBoxMRxFinalizeSrvCall(PMRX_SRV_CALL pSrvCall,
|
---|
267 | BOOLEAN Force);
|
---|
268 |
|
---|
269 | NTSTATUS VBoxMRxDevFcbXXXControlFile(IN OUT PRX_CONTEXT RxContext);
|
---|
270 | /** @} */
|
---|
271 |
|
---|
272 | /** @name Support functions and helpers
|
---|
273 | * @{
|
---|
274 | */
|
---|
275 | NTSTATUS vbsfNtDeleteConnection(IN PRX_CONTEXT RxContext,
|
---|
276 | OUT PBOOLEAN PostToFsp);
|
---|
277 | NTSTATUS vbsfNtCreateConnection(IN PRX_CONTEXT RxContext,
|
---|
278 | OUT PBOOLEAN PostToFsp);
|
---|
279 | NTSTATUS vbsfNtCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
|
---|
280 | PMRX_VBOX_FOBX pVBoxFobx,
|
---|
281 | PVBSFNTFCBEXT pVBoxFcbx);
|
---|
282 | NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext);
|
---|
283 | NTSTATUS vbsfNtVBoxStatusToNt(int vrc);
|
---|
284 | PVOID vbsfNtAllocNonPagedMem(ULONG ulSize);
|
---|
285 | void vbsfNtFreeNonPagedMem(PVOID lpMem);
|
---|
286 | NTSTATUS vbsfNtShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb);
|
---|
287 | #if defined(DEBUG) || defined(LOG_ENABLED)
|
---|
288 | const char *vbsfNtMajorFunctionName(UCHAR MajorFunction, LONG MinorFunction);
|
---|
289 | #endif
|
---|
290 |
|
---|
291 | void vbsfNtUpdateFcbSize(PFILE_OBJECT pFileObj, PMRX_FCB pFcb, PMRX_VBOX_FOBX pVBoxFobX,
|
---|
292 | LONGLONG cbFileNew, LONGLONG cbFileOld, LONGLONG cbAllocated);
|
---|
293 | int vbsfNtQueryAndUpdateFcbSize(PMRX_VBOX_NETROOT_EXTENSION pNetRootX, PFILE_OBJECT pFileObj,
|
---|
294 | PMRX_VBOX_FOBX pVBoxFobX, PMRX_FCB pFcb, PVBSFNTFCBEXT pVBoxFcbX);
|
---|
295 |
|
---|
296 | /**
|
---|
297 | * Converts VBox (IPRT) file mode to NT file attributes.
|
---|
298 | *
|
---|
299 | * @returns NT file attributes
|
---|
300 | * @param fIprtMode IPRT file mode.
|
---|
301 | *
|
---|
302 | */
|
---|
303 | DECLINLINE(uint32_t) VBoxToNTFileAttributes(uint32_t fIprtMode)
|
---|
304 | {
|
---|
305 | AssertCompile((RTFS_DOS_READONLY >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_READONLY);
|
---|
306 | AssertCompile((RTFS_DOS_HIDDEN >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_HIDDEN);
|
---|
307 | AssertCompile((RTFS_DOS_SYSTEM >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_SYSTEM);
|
---|
308 | AssertCompile((RTFS_DOS_DIRECTORY >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_DIRECTORY);
|
---|
309 | AssertCompile((RTFS_DOS_ARCHIVED >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_ARCHIVE);
|
---|
310 | AssertCompile((RTFS_DOS_NT_DEVICE >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_DEVICE);
|
---|
311 | AssertCompile((RTFS_DOS_NT_NORMAL >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_NORMAL);
|
---|
312 | AssertCompile((RTFS_DOS_NT_TEMPORARY >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_TEMPORARY);
|
---|
313 | AssertCompile((RTFS_DOS_NT_SPARSE_FILE >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_SPARSE_FILE);
|
---|
314 | AssertCompile((RTFS_DOS_NT_REPARSE_POINT >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_REPARSE_POINT);
|
---|
315 | AssertCompile((RTFS_DOS_NT_COMPRESSED >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_COMPRESSED);
|
---|
316 | AssertCompile((RTFS_DOS_NT_OFFLINE >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_OFFLINE);
|
---|
317 | AssertCompile((RTFS_DOS_NT_NOT_CONTENT_INDEXED >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
|
---|
318 | AssertCompile((RTFS_DOS_NT_ENCRYPTED >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_ENCRYPTED);
|
---|
319 |
|
---|
320 | uint32_t fNtAttribs = (fIprtMode & (RTFS_DOS_MASK_NT & ~(RTFS_DOS_NT_OFFLINE | RTFS_DOS_NT_DEVICE | RTFS_DOS_NT_REPARSE_POINT)))
|
---|
321 | >> RTFS_DOS_SHIFT;
|
---|
322 | return fNtAttribs ? fNtAttribs : FILE_ATTRIBUTE_NORMAL;
|
---|
323 | }
|
---|
324 |
|
---|
325 | /**
|
---|
326 | * Converts NT file attributes to VBox (IPRT) ones.
|
---|
327 | *
|
---|
328 | * @returns IPRT file mode
|
---|
329 | * @param fNtAttribs NT file attributes
|
---|
330 | */
|
---|
331 | DECLINLINE(uint32_t) NTToVBoxFileAttributes(uint32_t fNtAttribs)
|
---|
332 | {
|
---|
333 | uint32_t fIprtMode = (fNtAttribs << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT;
|
---|
334 | fIprtMode &= ~(RTFS_DOS_NT_OFFLINE | RTFS_DOS_NT_DEVICE | RTFS_DOS_NT_REPARSE_POINT);
|
---|
335 | return fIprtMode ? fIprtMode : RTFS_DOS_NT_NORMAL;
|
---|
336 | }
|
---|
337 |
|
---|
338 | /**
|
---|
339 | * Helper for converting VBox object info to NT basic file info.
|
---|
340 | */
|
---|
341 | DECLINLINE(void) vbsfNtBasicInfoFromVBoxObjInfo(FILE_BASIC_INFORMATION *pNtBasicInfo, PCSHFLFSOBJINFO pVBoxInfo)
|
---|
342 | {
|
---|
343 | pNtBasicInfo->CreationTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxInfo->BirthTime);
|
---|
344 | pNtBasicInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxInfo->AccessTime);
|
---|
345 | pNtBasicInfo->LastWriteTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxInfo->ModificationTime);
|
---|
346 | pNtBasicInfo->ChangeTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxInfo->ChangeTime);
|
---|
347 | pNtBasicInfo->FileAttributes = VBoxToNTFileAttributes(pVBoxInfo->Attr.fMode);
|
---|
348 | }
|
---|
349 |
|
---|
350 |
|
---|
351 | /** @} */
|
---|
352 |
|
---|
353 | RT_C_DECLS_END
|
---|
354 |
|
---|
355 | #endif /* !GA_INCLUDED_SRC_WINNT_SharedFolders_driver_vbsf_h */
|
---|