mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	sys: ProcessBuffer: improvements
This commit is contained in:
		| @@ -89,6 +89,7 @@ enum | |||||||
|     /* DirectoryControlComplete retry */ |     /* DirectoryControlComplete retry */ | ||||||
|     RequestDirInfoChangeNumber          = 0, |     RequestDirInfoChangeNumber          = 0, | ||||||
| }; | }; | ||||||
|  | FSP_FSCTL_STATIC_ASSERT(RequestCookie == RequestMdl, ""); | ||||||
|  |  | ||||||
| static NTSTATUS FspFsvolQueryDirectoryCopy( | static NTSTATUS FspFsvolQueryDirectoryCopy( | ||||||
|     PUNICODE_STRING DirectoryPattern, BOOLEAN CaseInsensitive, |     PUNICODE_STRING DirectoryPattern, BOOLEAN CaseInsensitive, | ||||||
| @@ -851,7 +852,7 @@ NTSTATUS FspFsvolDirectoryControlPrepare( | |||||||
|  |  | ||||||
|         Request->Req.QueryDirectory.Address = (UINT64)(UINT_PTR)Address; |         Request->Req.QueryDirectory.Address = (UINT64)(UINT_PTR)Address; | ||||||
|  |  | ||||||
|         FspIopRequestContext(Request, RequestCookie) = Cookie; |         FspIopRequestContext(Request, RequestCookie) = (PVOID)((UINT_PTR)Cookie | 1); | ||||||
|         FspIopRequestContext(Request, RequestAddress) = Address; |         FspIopRequestContext(Request, RequestAddress) = Address; | ||||||
|         FspIopRequestContext(Request, RequestProcess) = Process; |         FspIopRequestContext(Request, RequestProcess) = Process; | ||||||
|  |  | ||||||
| @@ -937,7 +938,7 @@ NTSTATUS FspFsvolDirectoryControlComplete( | |||||||
|  |  | ||||||
|     if (FspFsctlTransactQueryDirectoryKind == Request->Kind) |     if (FspFsctlTransactQueryDirectoryKind == Request->Kind) | ||||||
|     { |     { | ||||||
|         if (FspQueryDirectoryIrpShouldUseProcessBuffer(Irp, Request->Req.QueryDirectory.Length)) |         if ((UINT_PTR)FspIopRequestContext(Request, RequestCookie) & 1) | ||||||
|         { |         { | ||||||
|             PVOID Address = FspIopRequestContext(Request, RequestAddress); |             PVOID Address = FspIopRequestContext(Request, RequestAddress); | ||||||
|  |  | ||||||
| @@ -1055,9 +1056,9 @@ static VOID FspFsvolQueryDirectoryRequestFini(FSP_FSCTL_TRANSACT_REQ *Request, P | |||||||
|  |  | ||||||
|     PIRP Irp = Context[RequestIrp]; |     PIRP Irp = Context[RequestIrp]; | ||||||
|  |  | ||||||
|     if (0 != Irp && FspQueryDirectoryIrpShouldUseProcessBuffer(Irp, Request->Req.QueryDirectory.Length)) |     if ((UINT_PTR)Context[RequestCookie] & 1) | ||||||
|     { |     { | ||||||
|         PVOID Cookie = Context[RequestCookie]; |         PVOID Cookie = (PVOID)((UINT_PTR)Context[RequestCookie] & ~1); | ||||||
|         PVOID Address = Context[RequestAddress]; |         PVOID Address = Context[RequestAddress]; | ||||||
|         PEPROCESS Process = Context[RequestProcess]; |         PEPROCESS Process = Context[RequestProcess]; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -49,6 +49,7 @@ enum | |||||||
|     RequestAddress                      = 2, |     RequestAddress                      = 2, | ||||||
|     RequestProcess                      = 3, |     RequestProcess                      = 3, | ||||||
| }; | }; | ||||||
|  | FSP_FSCTL_STATIC_ASSERT(RequestCookie == RequestSafeMdl, ""); | ||||||
|  |  | ||||||
| static NTSTATUS FspFsvolRead( | static NTSTATUS FspFsvolRead( | ||||||
|     PDEVICE_OBJECT FsvolDeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp) |     PDEVICE_OBJECT FsvolDeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp) | ||||||
| @@ -367,7 +368,7 @@ NTSTATUS FspFsvolReadPrepare( | |||||||
|  |  | ||||||
|         Request->Req.Read.Address = (UINT64)(UINT_PTR)Address; |         Request->Req.Read.Address = (UINT64)(UINT_PTR)Address; | ||||||
|  |  | ||||||
|         FspIopRequestContext(Request, RequestCookie) = Cookie; |         FspIopRequestContext(Request, RequestCookie) = (PVOID)((UINT_PTR)Cookie | 1); | ||||||
|         FspIopRequestContext(Request, RequestAddress) = Address; |         FspIopRequestContext(Request, RequestAddress) = Address; | ||||||
|         FspIopRequestContext(Request, RequestProcess) = Process; |         FspIopRequestContext(Request, RequestProcess) = Process; | ||||||
|  |  | ||||||
| @@ -430,7 +431,7 @@ NTSTATUS FspFsvolReadComplete( | |||||||
|     if (Response->IoStatus.Information > Request->Req.Read.Length) |     if (Response->IoStatus.Information > Request->Req.Read.Length) | ||||||
|         FSP_RETURN(Result = STATUS_INTERNAL_ERROR); |         FSP_RETURN(Result = STATUS_INTERNAL_ERROR); | ||||||
|  |  | ||||||
|     if (FspReadIrpShouldUseProcessBuffer(Irp, Request->Req.Read.Length)) |     if ((UINT_PTR)FspIopRequestContext(Request, RequestCookie) & 1) | ||||||
|     { |     { | ||||||
|         PVOID Address = FspIopRequestContext(Request, RequestAddress); |         PVOID Address = FspIopRequestContext(Request, RequestAddress); | ||||||
|         PVOID SystemAddress = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority); |         PVOID SystemAddress = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority); | ||||||
| @@ -494,9 +495,9 @@ static VOID FspFsvolReadNonCachedRequestFini(FSP_FSCTL_TRANSACT_REQ *Request, PV | |||||||
|  |  | ||||||
|     PIRP Irp = Context[RequestIrp]; |     PIRP Irp = Context[RequestIrp]; | ||||||
|  |  | ||||||
|     if (0 != Irp && FspReadIrpShouldUseProcessBuffer(Irp, Request->Req.Read.Length)) |     if ((UINT_PTR)Context[RequestCookie] & 1) | ||||||
|     { |     { | ||||||
|         PVOID Cookie = Context[RequestCookie]; |         PVOID Cookie = (PVOID)((UINT_PTR)Context[RequestCookie] & ~1); | ||||||
|         PVOID Address = Context[RequestAddress]; |         PVOID Address = Context[RequestAddress]; | ||||||
|         PEPROCESS Process = Context[RequestProcess]; |         PEPROCESS Process = Context[RequestProcess]; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -50,6 +50,7 @@ enum | |||||||
|     RequestAddress                      = 2, |     RequestAddress                      = 2, | ||||||
|     RequestProcess                      = 3, |     RequestProcess                      = 3, | ||||||
| }; | }; | ||||||
|  | FSP_FSCTL_STATIC_ASSERT(RequestCookie == RequestSafeMdl, ""); | ||||||
|  |  | ||||||
| static NTSTATUS FspFsvolWrite( | static NTSTATUS FspFsvolWrite( | ||||||
|     PDEVICE_OBJECT FsvolDeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp) |     PDEVICE_OBJECT FsvolDeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp) | ||||||
| @@ -453,7 +454,7 @@ NTSTATUS FspFsvolWritePrepare( | |||||||
|  |  | ||||||
|         Request->Req.Write.Address = (UINT64)(UINT_PTR)Address; |         Request->Req.Write.Address = (UINT64)(UINT_PTR)Address; | ||||||
|  |  | ||||||
|         FspIopRequestContext(Request, RequestCookie) = Cookie; |         FspIopRequestContext(Request, RequestCookie) = (PVOID)((UINT_PTR)Cookie | 1); | ||||||
|         FspIopRequestContext(Request, RequestAddress) = Address; |         FspIopRequestContext(Request, RequestAddress) = Address; | ||||||
|         FspIopRequestContext(Request, RequestProcess) = Process; |         FspIopRequestContext(Request, RequestProcess) = Process; | ||||||
|  |  | ||||||
| @@ -571,9 +572,9 @@ static VOID FspFsvolWriteNonCachedRequestFini(FSP_FSCTL_TRANSACT_REQ *Request, P | |||||||
|  |  | ||||||
|     PIRP Irp = Context[RequestIrp]; |     PIRP Irp = Context[RequestIrp]; | ||||||
|  |  | ||||||
|     if (0 != Irp && FspWriteIrpShouldUseProcessBuffer(Irp, Request->Req.Write.Length)) |     if ((UINT_PTR)Context[RequestCookie] & 1) | ||||||
|     { |     { | ||||||
|         PVOID Cookie = Context[RequestCookie]; |         PVOID Cookie = (PVOID)((UINT_PTR)Context[RequestCookie] & ~1); | ||||||
|         PVOID Address = Context[RequestAddress]; |         PVOID Address = Context[RequestAddress]; | ||||||
|         PEPROCESS Process = Context[RequestProcess]; |         PEPROCESS Process = Context[RequestProcess]; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user