mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
sys: testing
This commit is contained in:
parent
7f182ac04d
commit
cb25c6456d
@ -50,6 +50,7 @@ typedef struct
|
||||
{
|
||||
UINT16 Version;
|
||||
UINT16 SectorSize;
|
||||
UINT32 SerialNumber;
|
||||
} FSP_FSCTL_VOLUME_PARAMS;
|
||||
typedef struct
|
||||
{
|
||||
|
@ -113,7 +113,8 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
|
||||
}
|
||||
|
||||
if (!DeviceIoControl(DeviceHandle, FSP_FSCTL_CREATE,
|
||||
ParamsBuf, sizeof *ParamsBuf + SecurityDescriptorSize, VolumePathBuf, (DWORD)VolumePathSize,
|
||||
ParamsBuf, FSP_FSCTL_VOLUME_PARAMS_SIZE + SecurityDescriptorSize,
|
||||
VolumePathBuf, (DWORD)VolumePathSize,
|
||||
&Bytes, 0))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
|
@ -98,7 +98,7 @@
|
||||
(const char *)&FspDeviceExtension(IrpSp->DeviceObject)->Kind,\
|
||||
Irp->RequestorMode == KernelMode ? 'K' : 'U',\
|
||||
IrpMajorFunctionSym(IrpSp->MajorFunction),\
|
||||
IrpMinorFunctionSym(IrpSp->MajorFunction, IrpSp->MajorFunction),\
|
||||
IrpMinorFunctionSym(IrpSp->MajorFunction, IrpSp->MinorFunction),\
|
||||
__VA_ARGS__, \
|
||||
NtStatusSym(Result), \
|
||||
(LONGLONG)Irp->IoStatus.Information);\
|
||||
@ -135,7 +135,7 @@
|
||||
(const char *)&FspDeviceExtension(IrpSp->DeviceObject)->Kind,\
|
||||
Irp->RequestorMode == KernelMode ? 'K' : 'U',\
|
||||
IrpMajorFunctionSym(IrpSp->MajorFunction),\
|
||||
IrpMinorFunctionSym(IrpSp->MajorFunction, IrpSp->MajorFunction),\
|
||||
IrpMinorFunctionSym(IrpSp->MajorFunction, IrpSp->MinorFunction),\
|
||||
__VA_ARGS__, \
|
||||
NtStatusSym(Result), \
|
||||
(LONGLONG)Irp->IoStatus.Information);\
|
||||
|
@ -106,17 +106,18 @@ static NTSTATUS FspFsctlCreateVolume(
|
||||
ULONG InputBufferLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
|
||||
ULONG OutputBufferLength = IrpSp->Parameters.FileSystemControl.OutputBufferLength;
|
||||
PVOID SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
const FSP_FSCTL_VOLUME_PARAMS *Params = SystemBuffer;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = (PVOID)((PUINT8)Params + FSP_FSCTL_VOLUME_PARAMS_SIZE);
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor =
|
||||
(PVOID)((PUINT8)SystemBuffer + FSP_FSCTL_VOLUME_PARAMS_SIZE);
|
||||
DWORD SecurityDescriptorSize = InputBufferLength - FSP_FSCTL_VOLUME_PARAMS_SIZE;
|
||||
if (FSP_FSCTL_VOLUME_PARAMS_SIZE >= InputBufferLength || 0 == SystemBuffer ||
|
||||
!FspValidRelativeSecurityDescriptor(SecurityDescriptor, SecurityDescriptorSize,
|
||||
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION))
|
||||
DACL_SECURITY_INFORMATION))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
if (FSP_FSCTL_CREATE_BUFFER_SIZE > OutputBufferLength)
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
|
||||
NTSTATUS Result;
|
||||
FSP_FSCTL_VOLUME_PARAMS Params = *(FSP_FSCTL_VOLUME_PARAMS *)SystemBuffer;
|
||||
PVOID SecurityDescriptorBuf = 0;
|
||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension;
|
||||
|
||||
@ -150,9 +151,11 @@ static NTSTATUS FspFsctlCreateVolume(
|
||||
&FsvrtDeviceObject);
|
||||
if (NT_SUCCESS(Result))
|
||||
{
|
||||
#pragma prefast(suppress:28175, "We are a filesystem: ok to access SectorSize")
|
||||
FsvrtDeviceObject->SectorSize = Params.SectorSize;
|
||||
FsvrtDeviceExtension = FspFsvrtDeviceExtension(FsvrtDeviceObject);
|
||||
FsvrtDeviceExtension->FsctlDeviceObject = DeviceObject;
|
||||
FsvrtDeviceExtension->VolumeParams = *Params;
|
||||
FsvrtDeviceExtension->VolumeParams = Params;
|
||||
RtlCopyMemory(FsvrtDeviceExtension->SecurityDescriptorBuf,
|
||||
SecurityDescriptorBuf, SecurityDescriptorSize);
|
||||
ClearFlag(FsvrtDeviceObject->Flags, DO_DEVICE_INITIALIZING);
|
||||
@ -215,13 +218,14 @@ static NTSTATUS FspFsctlMountVolume(
|
||||
&FsvolDeviceObject);
|
||||
if (NT_SUCCESS(Result))
|
||||
{
|
||||
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
||||
#pragma prefast(suppress:28175, "We are a filesystem: ok to access SectorSize")
|
||||
FsvolDeviceObject->SectorSize = FsvrtDeviceExtension->VolumeParams.SectorSize;
|
||||
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
||||
FsvolDeviceExtension->FsvrtDeviceObject = FsvrtDeviceObject;
|
||||
FsvrtDeviceExtension->FsvolDeviceObject = FsvolDeviceObject;
|
||||
ClearFlag(FsvolDeviceObject->Flags, DO_DEVICE_INITIALIZING);
|
||||
Vpb->DeviceObject = FsvolDeviceObject;
|
||||
Vpb->SerialNumber = FsvrtDeviceExtension->VolumeParams.SerialNumber;
|
||||
Irp->IoStatus.Information = 0;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ void mount_invalid_test(void)
|
||||
HANDLE VolumeHandle;
|
||||
|
||||
Params.SectorSize = 16384;
|
||||
Params.SerialNumber = 0x12345678;
|
||||
Result = FspFsctlCreateVolume(L"WinFsp.DoesNotExist", &Params, 0, VolumePath, sizeof VolumePath);
|
||||
ASSERT(STATUS_NO_SUCH_DEVICE == Result);
|
||||
|
||||
@ -26,6 +27,7 @@ void mount_dotest(PWSTR DeviceName)
|
||||
HANDLE VolumeHandle;
|
||||
|
||||
Params.SectorSize = 16384;
|
||||
Params.SerialNumber = 0x12345678;
|
||||
Result = FspFsctlCreateVolume(DeviceName, &Params, 0, VolumePath, sizeof VolumePath);
|
||||
ASSERT(STATUS_SUCCESS == Result);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user