dll: UmFileContextIsUserContext2, UmFileContextIsFullContext support

This commit is contained in:
Bill Zissimopoulos 2016-11-01 18:49:28 -07:00
parent ec2cf5106d
commit 3e3aa7651f
5 changed files with 178 additions and 127 deletions

View File

@ -78,8 +78,6 @@ FSP_FSCTL_STATIC_ASSERT(FSP_FSCTL_VOLUME_NAME_SIZEMAX <= 260 * sizeof(WCHAR),
#define FSP_FSCTL_TRANSACT_BATCH_BUFFER_SIZEMIN (64 * 1024) #define FSP_FSCTL_TRANSACT_BATCH_BUFFER_SIZEMIN (64 * 1024)
#define FSP_FSCTL_TRANSACT_BUFFER_SIZEMIN FSP_FSCTL_TRANSACT_REQ_SIZEMAX #define FSP_FSCTL_TRANSACT_BUFFER_SIZEMIN FSP_FSCTL_TRANSACT_REQ_SIZEMAX
#define FSP_FSCTL_TRANSACT_USERCONTEXT(s,i) (((PUINT64)&(s).UserContext)[i])
/* marshalling */ /* marshalling */
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4200) /* zero-sized array in struct/union */ #pragma warning(disable:4200) /* zero-sized array in struct/union */
@ -151,8 +149,9 @@ typedef struct
UINT32 PostCleanupOnDeleteOnly:1; /* post Cleanup when deleting a file only */ UINT32 PostCleanupOnDeleteOnly:1; /* post Cleanup when deleting a file only */
UINT32 KmReservedFlags:5; UINT32 KmReservedFlags:5;
/* user-mode flags */ /* user-mode flags */
UINT32 UmFileNodeIsUserContext2:1; /* user mode: FileNode parameter is UserContext2 */ UINT32 UmFileContextIsUserContext2:1; /* user mode: FileContext parameter is UserContext2 */
UINT32 UmReservedFlags:15; UINT32 UmFileContextIsFullContext:1; /* user mode: FileContext parameter is FullContext */
UINT32 UmReservedFlags:14;
WCHAR Prefix[FSP_FSCTL_VOLUME_PREFIX_SIZE / sizeof(WCHAR)]; /* UNC prefix (\Server\Share) */ WCHAR Prefix[FSP_FSCTL_VOLUME_PREFIX_SIZE / sizeof(WCHAR)]; /* UNC prefix (\Server\Share) */
WCHAR FileSystemName[FSP_FSCTL_VOLUME_FSNAME_SIZE / sizeof(WCHAR)]; WCHAR FileSystemName[FSP_FSCTL_VOLUME_FSNAME_SIZE / sizeof(WCHAR)];
} FSP_FSCTL_VOLUME_PARAMS; } FSP_FSCTL_VOLUME_PARAMS;
@ -198,6 +197,11 @@ typedef struct
WCHAR StreamNameBuf[]; WCHAR StreamNameBuf[];
} FSP_FSCTL_STREAM_INFO; } FSP_FSCTL_STREAM_INFO;
typedef struct typedef struct
{
UINT64 UserContext;
UINT64 UserContext2;
} FSP_FSCTL_TRANSACT_FULL_CONTEXT;
typedef struct
{ {
UINT16 Offset; UINT16 Offset;
UINT16 Size; UINT16 Size;

View File

@ -127,7 +127,35 @@ typedef enum
* File system interface. * File system interface.
* *
* The operations in this interface must be implemented by the user mode * The operations in this interface must be implemented by the user mode
* file system. * file system. Not all operations need be implemented. For example,
* a user mode file system that does not wish to support reparse points,
* need not implement the reparse point operations.
*
* Most of the operations accept a FileContext parameter. This parameter
* has different meanings depending on the value of the FSP_FSCTL_VOLUME_PARAMS
* flags UmFileContextIsUserContext2 and UmFileContextIsFullContext.
*
* There are three cases to consider:
* <ul>
* <li>When both of these flags are unset (default), the FileContext parameter
* represents the file node. The file node is a void pointer (or an integer
* that can fit in a pointer) that is used to uniquely identify an open file.
* Opening the same file name should always yield the same file node value
* for as long as the file with that name remains open anywhere in the system.
* </li>
* <li>When the UmFileContextIsUserContext2 is set, the FileContext parameter
* represents the file descriptor. The file descriptor is a void pointer (or
* an integer that can fit in a pointer) that is used to identify an open
* instance of a file. Opening the same file name may yield a different file
* descriptor.
* </li>
* <li>When the UmFileContextIsFullContext is set, the FileContext parameter
* is a pointer to a FSP_FSCTL_TRANSACT_FULL_CONTEXT. This allows a user mode
* file system to access the low-level UserContext and UserContext2 values.
* The UserContext is used to store the file node and the UserContext2 is
* used to store the file descriptor for an open file.
* </li>
* </ul>
*/ */
typedef struct _FSP_FILE_SYSTEM_INTERFACE typedef struct _FSP_FILE_SYSTEM_INTERFACE
{ {
@ -219,12 +247,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* Windows GetSecurityDescriptorLength API. Will be NULL for named streams. * Windows GetSecurityDescriptorLength API. Will be NULL for named streams.
* @param AllocationSize * @param AllocationSize
* Allocation size for the newly created file. * Allocation size for the newly created file.
* @param PFileNode [out] * @param PFileContext [out]
* Pointer that will receive the file node on successful return from this call. The file * Pointer that will receive the file context on successful return from this call.
* node is a void pointer (or an integer that can fit in a pointer) that is used to
* uniquely identify an open file. Opening the same file name should always return the same
* file node value for as long as the file with that name remains open anywhere in the
* system. The file system can place any value it needs here.
* @param FileInfo [out] * @param FileInfo [out]
* Pointer to a structure that will receive the file information on successful return * Pointer to a structure that will receive the file information on successful return
* from this call. This information includes file attributes, file times, etc. * from this call. This information includes file attributes, file times, etc.
@ -234,7 +258,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
NTSTATUS (*Create)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Create)(FSP_FILE_SYSTEM *FileSystem,
PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize,
PVOID *PFileNode, FSP_FSCTL_FILE_INFO *FileInfo); PVOID *PFileContext, FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Open a file or directory. * Open a file or directory.
* *
@ -254,12 +278,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* need not perform any additional checks. However this parameter may be useful to a user * need not perform any additional checks. However this parameter may be useful to a user
* mode file system; for example the WinFsp-FUSE layer uses this parameter to determine * mode file system; for example the WinFsp-FUSE layer uses this parameter to determine
* which flags to use in its POSIX open() call. * which flags to use in its POSIX open() call.
* @param PFileNode [out] * @param PFileContext [out]
* Pointer that will receive the file node on successful return from this call. The file * Pointer that will receive the file context on successful return from this call.
* node is a void pointer (or an integer that can fit in a pointer) that is used to
* uniquely identify an open file. Opening the same file name should always return the same
* file node value for as long as the file with that name remains open anywhere in the
* system. The file system can place any value it needs here.
* @param FileInfo [out] * @param FileInfo [out]
* Pointer to a structure that will receive the file information on successful return * Pointer to a structure that will receive the file information on successful return
* from this call. This information includes file attributes, file times, etc. * from this call. This information includes file attributes, file times, etc.
@ -268,14 +288,14 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
*/ */
NTSTATUS (*Open)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Open)(FSP_FILE_SYSTEM *FileSystem,
PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
PVOID *PFileNode, FSP_FSCTL_FILE_INFO *FileInfo); PVOID *PFileContext, FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Overwrite a file. * Overwrite a file.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file to overwrite. * The file context of the file to overwrite.
* @param FileAttributes * @param FileAttributes
* File attributes to apply to the overwritten file. * File attributes to apply to the overwritten file.
* @param ReplaceFileAttributes * @param ReplaceFileAttributes
@ -288,7 +308,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*Overwrite)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Overwrite)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes,
FSP_FSCTL_FILE_INFO *FileInfo); FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Cleanup a file. * Cleanup a file.
@ -315,8 +335,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to cleanup. * The file context of the file or directory to cleanup.
* @param FileName * @param FileName
* The name of the file or directory to cleanup. Sent only when a Delete is requested. * The name of the file or directory to cleanup. Sent only when a Delete is requested.
* @param Delete * @param Delete
@ -328,24 +348,24 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* CanDelete * CanDelete
*/ */
VOID (*Cleanup)(FSP_FILE_SYSTEM *FileSystem, VOID (*Cleanup)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PWSTR FileName, BOOLEAN Delete); PVOID FileContext, PWSTR FileName, BOOLEAN Delete);
/** /**
* Close a file. * Close a file.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to be closed. * The file context of the file or directory to be closed.
*/ */
VOID (*Close)(FSP_FILE_SYSTEM *FileSystem, VOID (*Close)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode); PVOID FileContext);
/** /**
* Read a file. * Read a file.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file to be read. * The file context of the file to be read.
* @param Buffer * @param Buffer
* Pointer to a buffer that will receive the results of the read operation. * Pointer to a buffer that will receive the results of the read operation.
* @param Offset * @param Offset
@ -359,15 +379,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* operation. * operation.
*/ */
NTSTATUS (*Read)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Read)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID Buffer, UINT64 Offset, ULONG Length, PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
PULONG PBytesTransferred); PULONG PBytesTransferred);
/** /**
* Write a file. * Write a file.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file to be written. * The file context of the file to be written.
* @param Buffer * @param Buffer
* Pointer to a buffer that contains the data to write. * Pointer to a buffer that contains the data to write.
* @param Offset * @param Offset
@ -389,7 +409,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* operation. * operation.
*/ */
NTSTATUS (*Write)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Write)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID Buffer, UINT64 Offset, ULONG Length, PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
BOOLEAN WriteToEndOfFile, BOOLEAN ConstrainedIo, BOOLEAN WriteToEndOfFile, BOOLEAN ConstrainedIo,
PULONG PBytesTransferred, FSP_FSCTL_FILE_INFO *FileInfo); PULONG PBytesTransferred, FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
@ -399,20 +419,20 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file to be flushed. When NULL the whole volume is being flushed. * The file context of the file to be flushed. When NULL the whole volume is being flushed.
* @return * @return
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*Flush)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Flush)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode); PVOID FileContext);
/** /**
* Get file or directory information. * Get file or directory information.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to get information for. * The file context of the file or directory to get information for.
* @param FileInfo [out] * @param FileInfo [out]
* Pointer to a structure that will receive the file information on successful return * Pointer to a structure that will receive the file information on successful return
* from this call. This information includes file attributes, file times, etc. * from this call. This information includes file attributes, file times, etc.
@ -420,15 +440,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*GetFileInfo)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*GetFileInfo)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
FSP_FSCTL_FILE_INFO *FileInfo); FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Set file or directory basic information. * Set file or directory basic information.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to set information for. * The file context of the file or directory to set information for.
* @param FileAttributes * @param FileAttributes
* File attributes to apply to the file or directory. If the value INVALID_FILE_ATTRIBUTES * File attributes to apply to the file or directory. If the value INVALID_FILE_ATTRIBUTES
* is sent, the file attributes should not be changed. * is sent, the file attributes should not be changed.
@ -448,7 +468,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*SetBasicInfo)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*SetBasicInfo)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, UINT32 FileAttributes, PVOID FileContext, UINT32 FileAttributes,
UINT64 CreationTime, UINT64 LastAccessTime, UINT64 LastWriteTime, UINT64 CreationTime, UINT64 LastAccessTime, UINT64 LastWriteTime,
FSP_FSCTL_FILE_INFO *FileInfo); FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
@ -473,8 +493,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file to set the file/allocation size for. * The file context of the file to set the file/allocation size for.
* @param NewSize * @param NewSize
* New file/allocation size to apply to the file. * New file/allocation size to apply to the file.
* @param SetAllocationSize * @param SetAllocationSize
@ -486,7 +506,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*SetFileSize)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*SetFileSize)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, UINT64 NewSize, BOOLEAN SetAllocationSize, PVOID FileContext, UINT64 NewSize, BOOLEAN SetAllocationSize,
FSP_FSCTL_FILE_INFO *FileInfo); FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Determine whether a file or directory can be deleted. * Determine whether a file or directory can be deleted.
@ -503,8 +523,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to test for deletion. * The file context of the file or directory to test for deletion.
* @param FileName * @param FileName
* The name of the file or directory to test for deletion. * The name of the file or directory to test for deletion.
* @return * @return
@ -513,7 +533,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* Cleanup * Cleanup
*/ */
NTSTATUS (*CanDelete)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*CanDelete)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PWSTR FileName); PVOID FileContext, PWSTR FileName);
/** /**
* Renames a file or directory. * Renames a file or directory.
* *
@ -528,8 +548,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to be renamed. * The file context of the file or directory to be renamed.
* @param FileName * @param FileName
* The current name of the file or directory to rename. * The current name of the file or directory to rename.
* @param NewFileName * @param NewFileName
@ -540,15 +560,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*Rename)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Rename)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
PWSTR FileName, PWSTR NewFileName, BOOLEAN ReplaceIfExists); PWSTR FileName, PWSTR NewFileName, BOOLEAN ReplaceIfExists);
/** /**
* Get file or directory security descriptor. * Get file or directory security descriptor.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to get the security descriptor for. * The file context of the file or directory to get the security descriptor for.
* @param SecurityDescriptor * @param SecurityDescriptor
* Pointer to a buffer that will receive the file security descriptor on successful return * Pointer to a buffer that will receive the file security descriptor on successful return
* from this call. May be NULL. * from this call. May be NULL.
@ -560,15 +580,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*GetSecurity)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*GetSecurity)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T *PSecurityDescriptorSize); PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T *PSecurityDescriptorSize);
/** /**
* Set file or directory security descriptor. * Set file or directory security descriptor.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to set the security descriptor for. * The file context of the file or directory to set the security descriptor for.
* @param SecurityInformation * @param SecurityInformation
* Describes what parts of the file or directory security descriptor should * Describes what parts of the file or directory security descriptor should
* be modified. * be modified.
@ -584,7 +604,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* FspDeleteSecurityDescriptor * FspDeleteSecurityDescriptor
*/ */
NTSTATUS (*SetSecurity)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*SetSecurity)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR ModificationDescriptor, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR ModificationDescriptor,
HANDLE AccessToken); HANDLE AccessToken);
/** /**
@ -592,8 +612,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the directory to be read. * The file context of the directory to be read.
* @param Buffer * @param Buffer
* Pointer to a buffer that will receive the results of the read operation. * Pointer to a buffer that will receive the results of the read operation.
* @param Offset * @param Offset
@ -617,7 +637,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* FspFileSystemAddDirInfo * FspFileSystemAddDirInfo
*/ */
NTSTATUS (*ReadDirectory)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*ReadDirectory)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID Buffer, UINT64 Offset, ULONG Length, PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
PWSTR Pattern, PWSTR Pattern,
PULONG PBytesTransferred); PULONG PBytesTransferred);
/** /**
@ -669,8 +689,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the reparse point. * The file context of the reparse point.
* @param FileName * @param FileName
* The file name of the reparse point. * The file name of the reparse point.
* @param Buffer * @param Buffer
@ -685,15 +705,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* SetReparsePoint * SetReparsePoint
*/ */
NTSTATUS (*GetReparsePoint)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*GetReparsePoint)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
PWSTR FileName, PVOID Buffer, PSIZE_T PSize); PWSTR FileName, PVOID Buffer, PSIZE_T PSize);
/** /**
* Set reparse point. * Set reparse point.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the reparse point. * The file context of the reparse point.
* @param FileName * @param FileName
* The file name of the reparse point. * The file name of the reparse point.
* @param Buffer * @param Buffer
@ -707,15 +727,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* GetReparsePoint * GetReparsePoint
*/ */
NTSTATUS (*SetReparsePoint)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*SetReparsePoint)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
PWSTR FileName, PVOID Buffer, SIZE_T Size); PWSTR FileName, PVOID Buffer, SIZE_T Size);
/** /**
* Delete reparse point. * Delete reparse point.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the reparse point. * The file context of the reparse point.
* @param FileName * @param FileName
* The file name of the reparse point. * The file name of the reparse point.
* @param Buffer * @param Buffer
@ -726,15 +746,15 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*DeleteReparsePoint)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*DeleteReparsePoint)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID FileContext,
PWSTR FileName, PVOID Buffer, SIZE_T Size); PWSTR FileName, PVOID Buffer, SIZE_T Size);
/** /**
* Get named streams information. * Get named streams information.
* *
* @param FileSystem * @param FileSystem
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileNode * @param FileContext
* The file node of the file or directory to get stream information for. * The file context of the file or directory to get stream information for.
* @param Buffer * @param Buffer
* Pointer to a buffer that will receive the stream information. * Pointer to a buffer that will receive the stream information.
* @param Length * @param Length
@ -747,7 +767,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* FspFileSystemAddStreamInfo * FspFileSystemAddStreamInfo
*/ */
NTSTATUS (*GetStreamInfo)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*GetStreamInfo)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode, PVOID Buffer, ULONG Length, PVOID FileContext, PVOID Buffer, ULONG Length,
PULONG PBytesTransferred); PULONG PBytesTransferred);
/* /*
@ -775,7 +795,7 @@ typedef struct _FSP_FILE_SYSTEM
UINT32 DebugLog; UINT32 DebugLog;
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY OpGuardStrategy; FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY OpGuardStrategy;
SRWLOCK OpGuardLock; SRWLOCK OpGuardLock;
BOOLEAN UmFileNodeIsUserContext2; BOOLEAN UmFileContextIsUserContext2, UmFileContextIsFullContext;
} FSP_FILE_SYSTEM; } FSP_FILE_SYSTEM;
typedef struct _FSP_FILE_SYSTEM_OPERATION_CONTEXT typedef struct _FSP_FILE_SYSTEM_OPERATION_CONTEXT
{ {

View File

@ -82,6 +82,10 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath,
*PFileSystem = 0; *PFileSystem = 0;
if (VolumeParams->UmFileContextIsUserContext2 &&
VolumeParams->UmFileContextIsFullContext)
return STATUS_INVALID_PARAMETER;
if (0 == Interface) if (0 == Interface)
Interface = &FspFileSystemNullInterface; Interface = &FspFileSystemNullInterface;
@ -126,7 +130,8 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath,
FileSystem->EnterOperation = FspFileSystemOpEnter; FileSystem->EnterOperation = FspFileSystemOpEnter;
FileSystem->LeaveOperation = FspFileSystemOpLeave; FileSystem->LeaveOperation = FspFileSystemOpLeave;
FileSystem->UmFileNodeIsUserContext2 = !!VolumeParams->UmFileNodeIsUserContext2; FileSystem->UmFileContextIsUserContext2 = !!VolumeParams->UmFileContextIsUserContext2;
FileSystem->UmFileContextIsFullContext = !!VolumeParams->UmFileContextIsFullContext;
*PFileSystem = FileSystem; *PFileSystem = FileSystem;

View File

@ -17,8 +17,16 @@
#include <dll/library.h> #include <dll/library.h>
#define USERCONTEXT(s) \ #define AddrOfFileContext(s) \
FSP_FSCTL_TRANSACT_USERCONTEXT(s, FileSystem->UmFileNodeIsUserContext2) ( \
(PVOID)&(((PUINT64)&(s).UserContext)[FileSystem->UmFileContextIsUserContext2])\
)
#define ValOfFileContext(s) \
( \
FileSystem->UmFileContextIsFullContext ?\
(PVOID)(&(s)) : \
(PVOID)(((PUINT64)&(s).UserContext)[FileSystem->UmFileContextIsUserContext2])\
)
FSP_API NTSTATUS FspFileSystemOpEnter(FSP_FILE_SYSTEM *FileSystem, FSP_API NTSTATUS FspFileSystemOpEnter(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response)
@ -361,7 +369,7 @@ static NTSTATUS FspFileSystemOpCreate_FileCreate(FSP_FILE_SYSTEM *FileSystem,
NTSTATUS Result; NTSTATUS Result;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor; PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
Result = FspFileSystemCreateCheck(FileSystem, Request, Response, TRUE, Result = FspFileSystemCreateCheck(FileSystem, Request, Response, TRUE,
@ -374,14 +382,15 @@ static NTSTATUS FspFileSystemOpCreate_FileCreate(FSP_FILE_SYSTEM *FileSystem,
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Create(FileSystem, Result = FileSystem->Interface->Create(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize, Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor); FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -394,7 +403,8 @@ static NTSTATUS FspFileSystemOpCreate_FileCreate(FSP_FILE_SYSTEM *FileSystem,
} }
Response->IoStatus.Information = FILE_CREATED; Response->IoStatus.Information = FILE_CREATED;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -406,20 +416,21 @@ static NTSTATUS FspFileSystemOpCreate_FileOpen(FSP_FILE_SYSTEM *FileSystem,
{ {
NTSTATUS Result; NTSTATUS Result;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
Result = FspFileSystemOpenCheck(FileSystem, Request, Response, TRUE, &GrantedAccess); Result = FspFileSystemOpenCheck(FileSystem, Request, Response, TRUE, &GrantedAccess);
if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result) if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result)
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Open(FileSystem, Result = FileSystem->Interface->Open(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -431,7 +442,8 @@ static NTSTATUS FspFileSystemOpCreate_FileOpen(FSP_FILE_SYSTEM *FileSystem,
} }
Response->IoStatus.Information = FILE_OPENED; Response->IoStatus.Information = FILE_OPENED;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -444,7 +456,7 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenIf(FSP_FILE_SYSTEM *FileSystem,
NTSTATUS Result; NTSTATUS Result;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor; PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
BOOLEAN Create = FALSE; BOOLEAN Create = FALSE;
@ -458,13 +470,14 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenIf(FSP_FILE_SYSTEM *FileSystem,
if (!Create) if (!Create)
{ {
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Open(FileSystem, Result = FileSystem->Interface->Open(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
{ {
if (STATUS_OBJECT_NAME_NOT_FOUND != Result) if (STATUS_OBJECT_NAME_NOT_FOUND != Result)
@ -485,14 +498,15 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenIf(FSP_FILE_SYSTEM *FileSystem,
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Create(FileSystem, Result = FileSystem->Interface->Create(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize, Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor); FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -506,7 +520,8 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenIf(FSP_FILE_SYSTEM *FileSystem,
} }
Response->IoStatus.Information = Create ? FILE_CREATED : FILE_OPENED; Response->IoStatus.Information = Create ? FILE_CREATED : FILE_OPENED;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -518,7 +533,7 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwrite(FSP_FILE_SYSTEM *FileSystem,
{ {
NTSTATUS Result; NTSTATUS Result;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
BOOLEAN Supersede = FILE_SUPERSEDE == ((Request->Req.Create.CreateOptions >> 24) & 0xff); BOOLEAN Supersede = FILE_SUPERSEDE == ((Request->Req.Create.CreateOptions >> 24) & 0xff);
@ -526,13 +541,14 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwrite(FSP_FILE_SYSTEM *FileSystem,
if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result) if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result)
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Open(FileSystem, Result = FileSystem->Interface->Open(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -544,7 +560,8 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwrite(FSP_FILE_SYSTEM *FileSystem,
} }
Response->IoStatus.Information = Supersede ? FILE_SUPERSEDED : FILE_OVERWRITTEN; Response->IoStatus.Information = Supersede ? FILE_SUPERSEDED : FILE_OVERWRITTEN;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -557,7 +574,7 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwriteIf(FSP_FILE_SYSTEM *FileSyste
NTSTATUS Result; NTSTATUS Result;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor; PSECURITY_DESCRIPTOR ParentDescriptor, ObjectDescriptor;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
BOOLEAN Create = FALSE; BOOLEAN Create = FALSE;
@ -571,13 +588,14 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwriteIf(FSP_FILE_SYSTEM *FileSyste
if (!Create) if (!Create)
{ {
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Open(FileSystem, Result = FileSystem->Interface->Open(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
{ {
if (STATUS_OBJECT_NAME_NOT_FOUND != Result) if (STATUS_OBJECT_NAME_NOT_FOUND != Result)
@ -598,14 +616,15 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwriteIf(FSP_FILE_SYSTEM *FileSyste
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->Create(FileSystem, Result = FileSystem->Interface->Create(FileSystem,
(PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess, (PWSTR)Request->Buffer, Request->Req.Create.CreateOptions, GrantedAccess,
Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize, Request->Req.Create.FileAttributes, ObjectDescriptor, Request->Req.Create.AllocationSize,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor); FspDeleteSecurityDescriptor(ObjectDescriptor, FspCreateSecurityDescriptor);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -619,7 +638,8 @@ static NTSTATUS FspFileSystemOpCreate_FileOverwriteIf(FSP_FILE_SYSTEM *FileSyste
} }
Response->IoStatus.Information = Create ? FILE_CREATED : FILE_OVERWRITTEN; Response->IoStatus.Information = Create ? FILE_CREATED : FILE_OVERWRITTEN;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -633,7 +653,7 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenTargetDirectory(FSP_FILE_SYSTEM *F
WCHAR Root[2] = L"\\"; WCHAR Root[2] = L"\\";
PWSTR Parent, Suffix; PWSTR Parent, Suffix;
UINT32 GrantedAccess; UINT32 GrantedAccess;
PVOID FileNode; FSP_FSCTL_TRANSACT_FULL_CONTEXT FullContext;
FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo; FSP_FSCTL_OPEN_FILE_INFO OpenFileInfo;
UINT32 Information; UINT32 Information;
@ -641,14 +661,15 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenTargetDirectory(FSP_FILE_SYSTEM *F
if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result) if (!NT_SUCCESS(Result) || STATUS_REPARSE == Result)
return Result; return Result;
FileNode = 0; FullContext.UserContext = 0;
FullContext.UserContext2 = 0;
memset(&OpenFileInfo, 0, sizeof OpenFileInfo); memset(&OpenFileInfo, 0, sizeof OpenFileInfo);
OpenFileInfo.NormalizedName = (PVOID)Response->Buffer; OpenFileInfo.NormalizedName = (PVOID)Response->Buffer;
OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; OpenFileInfo.NormalizedNameSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
FspPathSuffix((PWSTR)Request->Buffer, &Parent, &Suffix, Root); FspPathSuffix((PWSTR)Request->Buffer, &Parent, &Suffix, Root);
Result = FileSystem->Interface->Open(FileSystem, Result = FileSystem->Interface->Open(FileSystem,
Parent, Request->Req.Create.CreateOptions, GrantedAccess, Parent, Request->Req.Create.CreateOptions, GrantedAccess,
&FileNode, &OpenFileInfo.FileInfo); AddrOfFileContext(FullContext), &OpenFileInfo.FileInfo);
FspPathCombine((PWSTR)Request->Buffer, Suffix); FspPathCombine((PWSTR)Request->Buffer, Suffix);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -668,7 +689,8 @@ static NTSTATUS FspFileSystemOpCreate_FileOpenTargetDirectory(FSP_FILE_SYSTEM *F
} }
Response->IoStatus.Information = Information; Response->IoStatus.Information = Information;
USERCONTEXT(Response->Rsp.Create.Opened) = (UINT_PTR)FileNode; Response->Rsp.Create.Opened.UserContext = FullContext.UserContext;
Response->Rsp.Create.Opened.UserContext2 = FullContext.UserContext2;
Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess; Response->Rsp.Create.Opened.GrantedAccess = GrantedAccess;
memcpy(&Response->Rsp.Create.Opened.FileInfo, memcpy(&Response->Rsp.Create.Opened.FileInfo,
&OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo); &OpenFileInfo.FileInfo, sizeof OpenFileInfo.FileInfo);
@ -816,7 +838,7 @@ FSP_API NTSTATUS FspFileSystemOpOverwrite(FSP_FILE_SYSTEM *FileSystem,
memset(&FileInfo, 0, sizeof FileInfo); memset(&FileInfo, 0, sizeof FileInfo);
Result = FileSystem->Interface->Overwrite(FileSystem, Result = FileSystem->Interface->Overwrite(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Overwrite), (PVOID)ValOfFileContext(Request->Req.Overwrite),
Request->Req.Overwrite.FileAttributes, Request->Req.Overwrite.FileAttributes,
Request->Req.Overwrite.Supersede, Request->Req.Overwrite.Supersede,
&FileInfo); &FileInfo);
@ -824,7 +846,7 @@ FSP_API NTSTATUS FspFileSystemOpOverwrite(FSP_FILE_SYSTEM *FileSystem,
{ {
if (0 != FileSystem->Interface->Close) if (0 != FileSystem->Interface->Close)
FileSystem->Interface->Close(FileSystem, FileSystem->Interface->Close(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Overwrite)); (PVOID)ValOfFileContext(Request->Req.Overwrite));
return Result; return Result;
} }
@ -837,7 +859,7 @@ FSP_API NTSTATUS FspFileSystemOpCleanup(FSP_FILE_SYSTEM *FileSystem,
{ {
if (0 != FileSystem->Interface->Cleanup) if (0 != FileSystem->Interface->Cleanup)
FileSystem->Interface->Cleanup(FileSystem, FileSystem->Interface->Cleanup(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Cleanup), (PVOID)ValOfFileContext(Request->Req.Cleanup),
0 != Request->FileName.Size ? (PWSTR)Request->Buffer : 0, 0 != Request->FileName.Size ? (PWSTR)Request->Buffer : 0,
0 != Request->Req.Cleanup.Delete); 0 != Request->Req.Cleanup.Delete);
@ -849,7 +871,7 @@ FSP_API NTSTATUS FspFileSystemOpClose(FSP_FILE_SYSTEM *FileSystem,
{ {
if (0 != FileSystem->Interface->Close) if (0 != FileSystem->Interface->Close)
FileSystem->Interface->Close(FileSystem, FileSystem->Interface->Close(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Close)); (PVOID)ValOfFileContext(Request->Req.Close));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -865,7 +887,7 @@ FSP_API NTSTATUS FspFileSystemOpRead(FSP_FILE_SYSTEM *FileSystem,
BytesTransferred = 0; BytesTransferred = 0;
Result = FileSystem->Interface->Read(FileSystem, Result = FileSystem->Interface->Read(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Read), (PVOID)ValOfFileContext(Request->Req.Read),
(PVOID)Request->Req.Read.Address, (PVOID)Request->Req.Read.Address,
Request->Req.Read.Offset, Request->Req.Read.Offset,
Request->Req.Read.Length, Request->Req.Read.Length,
@ -891,7 +913,7 @@ FSP_API NTSTATUS FspFileSystemOpWrite(FSP_FILE_SYSTEM *FileSystem,
BytesTransferred = 0; BytesTransferred = 0;
Result = FileSystem->Interface->Write(FileSystem, Result = FileSystem->Interface->Write(FileSystem,
(PVOID)USERCONTEXT(Request->Req.Write), (PVOID)ValOfFileContext(Request->Req.Write),
(PVOID)Request->Req.Write.Address, (PVOID)Request->Req.Write.Address,
Request->Req.Write.Offset, Request->Req.Write.Offset,
Request->Req.Write.Length, Request->Req.Write.Length,
@ -918,7 +940,7 @@ FSP_API NTSTATUS FspFileSystemOpFlushBuffers(FSP_FILE_SYSTEM *FileSystem,
return STATUS_SUCCESS; /* liar! */ return STATUS_SUCCESS; /* liar! */
return FileSystem->Interface->Flush(FileSystem, return FileSystem->Interface->Flush(FileSystem,
(PVOID)USERCONTEXT(Request->Req.FlushBuffers)); (PVOID)ValOfFileContext(Request->Req.FlushBuffers));
} }
FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem,
@ -932,7 +954,7 @@ FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem,
memset(&FileInfo, 0, sizeof FileInfo); memset(&FileInfo, 0, sizeof FileInfo);
Result = FileSystem->Interface->GetFileInfo(FileSystem, Result = FileSystem->Interface->GetFileInfo(FileSystem,
(PVOID)USERCONTEXT(Request->Req.QueryInformation), &FileInfo); (PVOID)ValOfFileContext(Request->Req.QueryInformation), &FileInfo);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
@ -953,7 +975,7 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
case 4/*FileBasicInformation*/: case 4/*FileBasicInformation*/:
if (0 != FileSystem->Interface->SetBasicInfo) if (0 != FileSystem->Interface->SetBasicInfo)
Result = FileSystem->Interface->SetBasicInfo(FileSystem, Result = FileSystem->Interface->SetBasicInfo(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), (PVOID)ValOfFileContext(Request->Req.SetInformation),
Request->Req.SetInformation.Info.Basic.FileAttributes, Request->Req.SetInformation.Info.Basic.FileAttributes,
Request->Req.SetInformation.Info.Basic.CreationTime, Request->Req.SetInformation.Info.Basic.CreationTime,
Request->Req.SetInformation.Info.Basic.LastAccessTime, Request->Req.SetInformation.Info.Basic.LastAccessTime,
@ -963,14 +985,14 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
case 19/*FileAllocationInformation*/: case 19/*FileAllocationInformation*/:
if (0 != FileSystem->Interface->SetFileSize) if (0 != FileSystem->Interface->SetFileSize)
Result = FileSystem->Interface->SetFileSize(FileSystem, Result = FileSystem->Interface->SetFileSize(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), (PVOID)ValOfFileContext(Request->Req.SetInformation),
Request->Req.SetInformation.Info.Allocation.AllocationSize, TRUE, Request->Req.SetInformation.Info.Allocation.AllocationSize, TRUE,
&FileInfo); &FileInfo);
break; break;
case 20/*FileEndOfFileInformation*/: case 20/*FileEndOfFileInformation*/:
if (0 != FileSystem->Interface->SetFileSize) if (0 != FileSystem->Interface->SetFileSize)
Result = FileSystem->Interface->SetFileSize(FileSystem, Result = FileSystem->Interface->SetFileSize(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), (PVOID)ValOfFileContext(Request->Req.SetInformation),
Request->Req.SetInformation.Info.EndOfFile.FileSize, FALSE, Request->Req.SetInformation.Info.EndOfFile.FileSize, FALSE,
&FileInfo); &FileInfo);
break; break;
@ -978,7 +1000,7 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
if (0 != FileSystem->Interface->GetFileInfo) if (0 != FileSystem->Interface->GetFileInfo)
{ {
Result = FileSystem->Interface->GetFileInfo(FileSystem, Result = FileSystem->Interface->GetFileInfo(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), &FileInfo); (PVOID)ValOfFileContext(Request->Req.SetInformation), &FileInfo);
if (NT_SUCCESS(Result) && 0 != (FileInfo.FileAttributes & FILE_ATTRIBUTE_READONLY)) if (NT_SUCCESS(Result) && 0 != (FileInfo.FileAttributes & FILE_ATTRIBUTE_READONLY))
{ {
Result = STATUS_CANNOT_DELETE; Result = STATUS_CANNOT_DELETE;
@ -988,7 +1010,7 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
if (0 != FileSystem->Interface->CanDelete) if (0 != FileSystem->Interface->CanDelete)
if (Request->Req.SetInformation.Info.Disposition.Delete) if (Request->Req.SetInformation.Info.Disposition.Delete)
Result = FileSystem->Interface->CanDelete(FileSystem, Result = FileSystem->Interface->CanDelete(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), (PVOID)ValOfFileContext(Request->Req.SetInformation),
(PWSTR)Request->Buffer); (PWSTR)Request->Buffer);
else else
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;
@ -1005,7 +1027,7 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
break; break;
} }
Result = FileSystem->Interface->Rename(FileSystem, Result = FileSystem->Interface->Rename(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetInformation), (PVOID)ValOfFileContext(Request->Req.SetInformation),
(PWSTR)Request->Buffer, (PWSTR)Request->Buffer,
(PWSTR)(Request->Buffer + Request->Req.SetInformation.Info.Rename.NewFileName.Offset), (PWSTR)(Request->Buffer + Request->Req.SetInformation.Info.Rename.NewFileName.Offset),
0 != Request->Req.SetInformation.Info.Rename.AccessToken); 0 != Request->Req.SetInformation.Info.Rename.AccessToken);
@ -1074,7 +1096,7 @@ FSP_API NTSTATUS FspFileSystemOpQueryDirectory(FSP_FILE_SYSTEM *FileSystem,
BytesTransferred = 0; BytesTransferred = 0;
Result = FileSystem->Interface->ReadDirectory(FileSystem, Result = FileSystem->Interface->ReadDirectory(FileSystem,
(PVOID)USERCONTEXT(Request->Req.QueryDirectory), (PVOID)ValOfFileContext(Request->Req.QueryDirectory),
(PVOID)Request->Req.QueryDirectory.Address, (PVOID)Request->Req.QueryDirectory.Address,
Request->Req.QueryDirectory.Offset, Request->Req.QueryDirectory.Offset,
Request->Req.QueryDirectory.Length, Request->Req.QueryDirectory.Length,
@ -1108,7 +1130,7 @@ FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem,
Size = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; Size = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->GetReparsePoint(FileSystem, Result = FileSystem->Interface->GetReparsePoint(FileSystem,
(PVOID)USERCONTEXT(Request->Req.FileSystemControl), (PVOID)ValOfFileContext(Request->Req.FileSystemControl),
(PWSTR)Request->Buffer, ReparseData, &Size); (PWSTR)Request->Buffer, ReparseData, &Size);
if (NT_SUCCESS(Result)) if (NT_SUCCESS(Result))
{ {
@ -1125,7 +1147,7 @@ FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem,
(Request->Buffer + Request->Req.FileSystemControl.Buffer.Offset); (Request->Buffer + Request->Req.FileSystemControl.Buffer.Offset);
Result = FileSystem->Interface->SetReparsePoint(FileSystem, Result = FileSystem->Interface->SetReparsePoint(FileSystem,
(PVOID)USERCONTEXT(Request->Req.FileSystemControl), (PVOID)ValOfFileContext(Request->Req.FileSystemControl),
(PWSTR)Request->Buffer, (PWSTR)Request->Buffer,
ReparseData, ReparseData,
Request->Req.FileSystemControl.Buffer.Size); Request->Req.FileSystemControl.Buffer.Size);
@ -1138,7 +1160,7 @@ FSP_API NTSTATUS FspFileSystemOpFileSystemControl(FSP_FILE_SYSTEM *FileSystem,
(Request->Buffer + Request->Req.FileSystemControl.Buffer.Offset); (Request->Buffer + Request->Req.FileSystemControl.Buffer.Offset);
Result = FileSystem->Interface->DeleteReparsePoint(FileSystem, Result = FileSystem->Interface->DeleteReparsePoint(FileSystem,
(PVOID)USERCONTEXT(Request->Req.FileSystemControl), (PVOID)ValOfFileContext(Request->Req.FileSystemControl),
(PWSTR)Request->Buffer, (PWSTR)Request->Buffer,
ReparseData, ReparseData,
Request->Req.FileSystemControl.Buffer.Size); Request->Req.FileSystemControl.Buffer.Size);
@ -1160,7 +1182,7 @@ FSP_API NTSTATUS FspFileSystemOpQuerySecurity(FSP_FILE_SYSTEM *FileSystem,
SecurityDescriptorSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX; SecurityDescriptorSize = FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX;
Result = FileSystem->Interface->GetSecurity(FileSystem, Result = FileSystem->Interface->GetSecurity(FileSystem,
(PVOID)USERCONTEXT(Request->Req.QuerySecurity), (PVOID)ValOfFileContext(Request->Req.QuerySecurity),
Response->Buffer, &SecurityDescriptorSize); Response->Buffer, &SecurityDescriptorSize);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return STATUS_BUFFER_OVERFLOW != Result ? Result : STATUS_INVALID_SECURITY_DESCR; return STATUS_BUFFER_OVERFLOW != Result ? Result : STATUS_INVALID_SECURITY_DESCR;
@ -1178,7 +1200,7 @@ FSP_API NTSTATUS FspFileSystemOpSetSecurity(FSP_FILE_SYSTEM *FileSystem,
return STATUS_INVALID_DEVICE_REQUEST; return STATUS_INVALID_DEVICE_REQUEST;
return FileSystem->Interface->SetSecurity(FileSystem, return FileSystem->Interface->SetSecurity(FileSystem,
(PVOID)USERCONTEXT(Request->Req.SetSecurity), (PVOID)ValOfFileContext(Request->Req.SetSecurity),
Request->Req.SetSecurity.SecurityInformation, Request->Req.SetSecurity.SecurityInformation,
(PSECURITY_DESCRIPTOR)Request->Buffer, (PSECURITY_DESCRIPTOR)Request->Buffer,
(HANDLE)Request->Req.SetSecurity.AccessToken); (HANDLE)Request->Req.SetSecurity.AccessToken);
@ -1195,7 +1217,7 @@ FSP_API NTSTATUS FspFileSystemOpQueryStreamInformation(FSP_FILE_SYSTEM *FileSyst
BytesTransferred = 0; BytesTransferred = 0;
Result = FileSystem->Interface->GetStreamInfo(FileSystem, Result = FileSystem->Interface->GetStreamInfo(FileSystem,
(PVOID)USERCONTEXT(Request->Req.QueryStreamInformation), (PVOID)ValOfFileContext(Request->Req.QueryStreamInformation),
Response->Buffer, Response->Buffer,
FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX, FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX,
&BytesTransferred); &BytesTransferred);

View File

@ -524,7 +524,7 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
opt_data.VolumeParams.NamedStreams = FALSE; opt_data.VolumeParams.NamedStreams = FALSE;
opt_data.VolumeParams.ReadOnlyVolume = !!opt_data.ReadOnlyVolume; opt_data.VolumeParams.ReadOnlyVolume = !!opt_data.ReadOnlyVolume;
opt_data.VolumeParams.PostCleanupOnDeleteOnly = TRUE; opt_data.VolumeParams.PostCleanupOnDeleteOnly = TRUE;
opt_data.VolumeParams.UmFileNodeIsUserContext2 = TRUE; opt_data.VolumeParams.UmFileContextIsUserContext2 = TRUE;
if (L'\0' == opt_data.VolumeParams.FileSystemName[0]) if (L'\0' == opt_data.VolumeParams.FileSystemName[0])
memcpy(opt_data.VolumeParams.FileSystemName, L"FUSE", 5 * sizeof(WCHAR)); memcpy(opt_data.VolumeParams.FileSystemName, L"FUSE", 5 * sizeof(WCHAR));