mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	dll: FspFileSystemOpRead, FspFileSystemOpWrite
This commit is contained in:
		| @@ -197,8 +197,7 @@ typedef struct | |||||||
|             UINT64 Offset; |             UINT64 Offset; | ||||||
|             UINT32 Length; |             UINT32 Length; | ||||||
|             UINT32 Key; |             UINT32 Key; | ||||||
|             UINT32 Append:1;            /* append to end of file */ |             UINT32 Constrained:1;       /* write's beyond EOF are NOP's (file size remains same) */ | ||||||
|             UINT32 PagingIo:1;          /* write's beyond EOF are NOP's (file size remains same) */ |  | ||||||
|         } Write; |         } Write; | ||||||
|         struct |         struct | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -64,6 +64,14 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE | |||||||
|     VOID (*Close)(FSP_FILE_SYSTEM *FileSystem, |     VOID (*Close)(FSP_FILE_SYSTEM *FileSystem, | ||||||
|         FSP_FSCTL_TRANSACT_REQ *Request, |         FSP_FSCTL_TRANSACT_REQ *Request, | ||||||
|         PVOID FileNode); |         PVOID FileNode); | ||||||
|  |     NTSTATUS (*Read)(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |         FSP_FSCTL_TRANSACT_REQ *Request, | ||||||
|  |         PVOID FileNode, PVOID Buffer, UINT64 Offset, ULONG Length, | ||||||
|  |         PULONG PBytesTransferred, FSP_FSCTL_FILE_INFO *FileInfo); | ||||||
|  |     NTSTATUS (*Write)(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |         FSP_FSCTL_TRANSACT_REQ *Request, | ||||||
|  |         PVOID FileNode, PVOID Buffer, UINT64 Offset, ULONG Length, BOOLEAN Constrained, | ||||||
|  |         PULONG PBytesTransferred, FSP_FSCTL_FILE_INFO *FileInfo); | ||||||
|     NTSTATUS (*GetFileInfo)(FSP_FILE_SYSTEM *FileSystem, |     NTSTATUS (*GetFileInfo)(FSP_FILE_SYSTEM *FileSystem, | ||||||
|         FSP_FSCTL_TRANSACT_REQ *Request, |         FSP_FSCTL_TRANSACT_REQ *Request, | ||||||
|         PVOID FileNode, |         PVOID FileNode, | ||||||
| @@ -117,6 +125,8 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath, | |||||||
| FSP_API VOID FspFileSystemDelete(FSP_FILE_SYSTEM *FileSystem); | FSP_API VOID FspFileSystemDelete(FSP_FILE_SYSTEM *FileSystem); | ||||||
| FSP_API NTSTATUS FspFileSystemStartDispatcher(FSP_FILE_SYSTEM *FileSystem, ULONG ThreadCount); | FSP_API NTSTATUS FspFileSystemStartDispatcher(FSP_FILE_SYSTEM *FileSystem, ULONG ThreadCount); | ||||||
| FSP_API VOID FspFileSystemStopDispatcher(FSP_FILE_SYSTEM *FileSystem); | FSP_API VOID FspFileSystemStopDispatcher(FSP_FILE_SYSTEM *FileSystem); | ||||||
|  | FSP_API VOID FspFileSystemSendResponse(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
| static inline | static inline | ||||||
| VOID FspFileSystemEnterOperation(FSP_FILE_SYSTEM *FileSystem, | VOID FspFileSystemEnterOperation(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) | ||||||
| @@ -174,6 +184,10 @@ FSP_API NTSTATUS FspFileSystemOpCleanup(FSP_FILE_SYSTEM *FileSystem, | |||||||
|     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
| FSP_API NTSTATUS FspFileSystemOpClose(FSP_FILE_SYSTEM *FileSystem, | FSP_API NTSTATUS FspFileSystemOpClose(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
|  | FSP_API NTSTATUS FspFileSystemOpRead(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
|  | FSP_API NTSTATUS FspFileSystemOpWrite(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
| FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, | FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response); | ||||||
| FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem, | FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem, | ||||||
|   | |||||||
| @@ -44,11 +44,13 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath, | |||||||
|     FileSystem->Operations[FspFsctlTransactOverwriteKind] = FspFileSystemOpOverwrite; |     FileSystem->Operations[FspFsctlTransactOverwriteKind] = FspFileSystemOpOverwrite; | ||||||
|     FileSystem->Operations[FspFsctlTransactCleanupKind] = FspFileSystemOpCleanup; |     FileSystem->Operations[FspFsctlTransactCleanupKind] = FspFileSystemOpCleanup; | ||||||
|     FileSystem->Operations[FspFsctlTransactCloseKind] = FspFileSystemOpClose; |     FileSystem->Operations[FspFsctlTransactCloseKind] = FspFileSystemOpClose; | ||||||
|  |     FileSystem->Operations[FspFsctlTransactReadKind] = FspFileSystemOpRead; | ||||||
|  |     FileSystem->Operations[FspFsctlTransactWriteKind] = FspFileSystemOpWrite; | ||||||
|  |     // !!!: ... | ||||||
|     FileSystem->Operations[FspFsctlTransactQueryInformationKind] = FspFileSystemOpQueryInformation; |     FileSystem->Operations[FspFsctlTransactQueryInformationKind] = FspFileSystemOpQueryInformation; | ||||||
|     FileSystem->Operations[FspFsctlTransactSetInformationKind] = FspFileSystemOpSetInformation; |     FileSystem->Operations[FspFsctlTransactSetInformationKind] = FspFileSystemOpSetInformation; | ||||||
|     FileSystem->Operations[FspFsctlTransactQueryVolumeInformationKind] = FspFileSystemOpQueryVolumeInformation; |     FileSystem->Operations[FspFsctlTransactQueryVolumeInformationKind] = FspFileSystemOpQueryVolumeInformation; | ||||||
|     FileSystem->Operations[FspFsctlTransactSetVolumeInformationKind] = FspFileSystemOpSetVolumeInformation; |     FileSystem->Operations[FspFsctlTransactSetVolumeInformationKind] = FspFileSystemOpSetVolumeInformation; | ||||||
|     // !!!: ... |  | ||||||
|     FileSystem->Operations[FspFsctlTransactQuerySecurityKind] = FspFileSystemOpQuerySecurity; |     FileSystem->Operations[FspFsctlTransactQuerySecurityKind] = FspFileSystemOpQuerySecurity; | ||||||
|     FileSystem->Operations[FspFsctlTransactSetSecurityKind] = FspFileSystemOpSetSecurity; |     FileSystem->Operations[FspFsctlTransactSetSecurityKind] = FspFileSystemOpSetSecurity; | ||||||
|     FileSystem->Interface = Interface; |     FileSystem->Interface = Interface; | ||||||
| @@ -132,6 +134,8 @@ static DWORD WINAPI FspFileSystemDispatcherThread(PVOID FileSystem0) | |||||||
|             Response->Hint = Request->Hint; |             Response->Hint = Request->Hint; | ||||||
|             Response->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; |             Response->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; | ||||||
|         } |         } | ||||||
|  |         else if (STATUS_PENDING == Response->IoStatus.Status) | ||||||
|  |             memset(Response, 0, sizeof *Response); | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             memset((PUINT8)Response + Response->Size, 0, ResponseSize - Response->Size); |             memset((PUINT8)Response + Response->Size, 0, ResponseSize - Response->Size); | ||||||
| @@ -194,3 +198,14 @@ FSP_API VOID FspFileSystemStopDispatcher(FSP_FILE_SYSTEM *FileSystem) | |||||||
|     WaitForSingleObject(FileSystem->DispatcherThread, INFINITE); |     WaitForSingleObject(FileSystem->DispatcherThread, INFINITE); | ||||||
|     CloseHandle(FileSystem->DispatcherThread); |     CloseHandle(FileSystem->DispatcherThread); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | FSP_API VOID FspFileSystemSendResponse(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_RSP *Response) | ||||||
|  | { | ||||||
|  |     NTSTATUS Result; | ||||||
|  |  | ||||||
|  |     Result = FspFsctlTransact(FileSystem->VolumeHandle, | ||||||
|  |         Response, Response->Size, 0, 0, FALSE); | ||||||
|  |     if (!NT_SUCCESS(Result)) | ||||||
|  |         FspFsctlStop(FileSystem->VolumeHandle); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -402,6 +402,65 @@ FSP_API NTSTATUS FspFileSystemOpClose(FSP_FILE_SYSTEM *FileSystem, | |||||||
|     return STATUS_SUCCESS; |     return STATUS_SUCCESS; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | FSP_API NTSTATUS FspFileSystemOpRead(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) | ||||||
|  | { | ||||||
|  |     NTSTATUS Result; | ||||||
|  |     ULONG BytesTransferred; | ||||||
|  |     FSP_FSCTL_FILE_INFO FileInfo; | ||||||
|  |  | ||||||
|  |     if (0 == FileSystem->Interface->Read) | ||||||
|  |         return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|  |  | ||||||
|  |     Result = FileSystem->Interface->Read(FileSystem, Request, | ||||||
|  |         (PVOID)Request->Req.Read.UserContext, | ||||||
|  |         (PVOID)Request->Req.Read.Address, | ||||||
|  |         Request->Req.Read.Offset, | ||||||
|  |         Request->Req.Read.Length, | ||||||
|  |         &BytesTransferred, | ||||||
|  |         &FileInfo); | ||||||
|  |     if (!NT_SUCCESS(Result)) | ||||||
|  |         return Result; | ||||||
|  |  | ||||||
|  |     if (STATUS_PENDING != Result) | ||||||
|  |     { | ||||||
|  |         Response->IoStatus.Information = BytesTransferred; | ||||||
|  |         memcpy(&Response->Rsp.Read.FileInfo, &FileInfo, sizeof FileInfo); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return Result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | FSP_API NTSTATUS FspFileSystemOpWrite(FSP_FILE_SYSTEM *FileSystem, | ||||||
|  |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) | ||||||
|  | { | ||||||
|  |     NTSTATUS Result; | ||||||
|  |     ULONG BytesTransferred; | ||||||
|  |     FSP_FSCTL_FILE_INFO FileInfo; | ||||||
|  |  | ||||||
|  |     if (0 == FileSystem->Interface->Write) | ||||||
|  |         return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|  |  | ||||||
|  |     Result = FileSystem->Interface->Write(FileSystem, Request, | ||||||
|  |         (PVOID)Request->Req.Write.UserContext, | ||||||
|  |         (PVOID)Request->Req.Write.Address, | ||||||
|  |         Request->Req.Write.Offset, | ||||||
|  |         Request->Req.Write.Length, | ||||||
|  |         Request->Req.Write.Constrained, | ||||||
|  |         &BytesTransferred, | ||||||
|  |         &FileInfo); | ||||||
|  |     if (!NT_SUCCESS(Result)) | ||||||
|  |         return Result; | ||||||
|  |  | ||||||
|  |     if (STATUS_PENDING != Result) | ||||||
|  |     { | ||||||
|  |         Response->IoStatus.Information = BytesTransferred; | ||||||
|  |         memcpy(&Response->Rsp.Read.FileInfo, &FileInfo, sizeof FileInfo); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return Result; | ||||||
|  | } | ||||||
|  |  | ||||||
| FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, | FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, | ||||||
|     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) |     FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -271,8 +271,7 @@ static NTSTATUS FspFsvolWriteNonCached( | |||||||
|     Request->Req.Write.Offset = WriteOffset.QuadPart; |     Request->Req.Write.Offset = WriteOffset.QuadPart; | ||||||
|     Request->Req.Write.Length = WriteLength; |     Request->Req.Write.Length = WriteLength; | ||||||
|     Request->Req.Write.Key = WriteKey; |     Request->Req.Write.Key = WriteKey; | ||||||
|     Request->Req.Write.Append = WriteToEndOfFile; |     Request->Req.Write.Constrained = PagingIo; | ||||||
|     Request->Req.Write.PagingIo = PagingIo; |  | ||||||
|  |  | ||||||
|     return FSP_STATUS_IOQ_POST; |     return FSP_STATUS_IOQ_POST; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user