2 * PROJECT: ReactOS Drivers
3 * COPYRIGHT: See COPYING in the top level directory
4 * PURPOSE: Kernel Security Support Provider Interface Driver
6 * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
9 /* INCLUDES *******************************************************************/
17 /* FUNCTIONS ******************************************************************/
21 KsecQueryFileInformation(
23 FILE_INFORMATION_CLASS FileInformationClass
,
26 PFILE_STANDARD_INFORMATION StandardInformation
;
28 /* Only FileStandardInformation is supported */
29 if (FileInformationClass
!= FileStandardInformation
)
31 return STATUS_INVALID_INFO_CLASS
;
34 /* Validate buffer size */
35 if (*BufferLength
>= sizeof(FILE_STANDARD_INFORMATION
))
37 *BufferLength
= sizeof(FILE_STANDARD_INFORMATION
);
38 return STATUS_INFO_LENGTH_MISMATCH
;
41 /* Fill the structure */
42 StandardInformation
= (PFILE_STANDARD_INFORMATION
)InfoBuffer
;
43 StandardInformation
->AllocationSize
.QuadPart
= 0;
44 StandardInformation
->EndOfFile
.QuadPart
= 0;
45 StandardInformation
->NumberOfLinks
= 1;
46 StandardInformation
->DeletePending
= FALSE
;
47 StandardInformation
->Directory
= FALSE
;
48 *BufferLength
= sizeof(FILE_STANDARD_INFORMATION
);
50 return STATUS_SUCCESS
;
55 KsecQueryVolumeInformation(
57 FS_INFORMATION_CLASS FsInformationClass
,
60 PFILE_FS_DEVICE_INFORMATION DeviceInformation
;
62 /* Only FileFsDeviceInformation is supported */
63 if (FsInformationClass
!= FileFsDeviceInformation
)
65 return STATUS_INVALID_INFO_CLASS
;
68 /* Validate buffer size */
69 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
71 *BufferLength
= sizeof(FILE_FS_DEVICE_INFORMATION
);
72 return STATUS_INFO_LENGTH_MISMATCH
;
75 /* Fill the structure */
76 DeviceInformation
= (PFILE_FS_DEVICE_INFORMATION
)InfoBuffer
;
77 DeviceInformation
->DeviceType
= FILE_DEVICE_NULL
;
78 DeviceInformation
->Characteristics
= 0;
79 *BufferLength
= sizeof(FILE_FS_DEVICE_INFORMATION
);
81 return STATUS_SUCCESS
;
94 Status
= STATUS_SUCCESS
;
96 /* Check ioctl code */
97 switch (IoControlCode
)
99 case IOCTL_KSEC_GEN_RANDOM
:
101 Status
= KsecGenRandom(Buffer
, *OutputLength
);
105 DPRINT1("Unhandled control code 0x%lx\n", IoControlCode
);
107 return STATUS_INVALID_PARAMETER
;
116 PDEVICE_OBJECT DeviceObject
,
119 PIO_STACK_LOCATION IoStackLocation
;
120 ULONG_PTR Information
;
123 SIZE_T InputLength
, OutputLength
;
124 FILE_INFORMATION_CLASS FileInfoClass
;
125 FS_INFORMATION_CLASS FsInfoClass
;
128 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
130 switch (IoStackLocation
->MajorFunction
)
135 /* Just return success */
136 Status
= STATUS_SUCCESS
;
142 /* There is nothing to read */
143 Status
= STATUS_END_OF_FILE
;
149 /* Pretend to have written everything */
150 Status
= STATUS_SUCCESS
;
151 Information
= IoStackLocation
->Parameters
.Write
.Length
;
154 case IRP_MJ_QUERY_INFORMATION
:
156 /* Extract the parameters */
157 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
158 OutputLength
= IoStackLocation
->Parameters
.QueryFile
.Length
;
159 FileInfoClass
= IoStackLocation
->Parameters
.QueryFile
.FileInformationClass
;
161 /* Call the internal function */
162 Status
= KsecQueryFileInformation(Buffer
,
165 Information
= OutputLength
;
168 case IRP_MJ_QUERY_VOLUME_INFORMATION
:
170 /* Extract the parameters */
171 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
172 OutputLength
= IoStackLocation
->Parameters
.QueryVolume
.Length
;
173 FsInfoClass
= IoStackLocation
->Parameters
.QueryVolume
.FsInformationClass
;
175 /* Call the internal function */
176 Status
= KsecQueryVolumeInformation(Buffer
,
179 Information
= OutputLength
;
182 case IRP_MJ_DEVICE_CONTROL
:
184 /* Extract the parameters */
185 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
186 InputLength
= IoStackLocation
->Parameters
.DeviceIoControl
.InputBufferLength
;
187 OutputLength
= IoStackLocation
->Parameters
.DeviceIoControl
.OutputBufferLength
;
188 IoControlCode
= IoStackLocation
->Parameters
.DeviceIoControl
.IoControlCode
;
190 /* Call the internal function */
191 Status
= KsecDeviceControl(IoControlCode
,
195 Information
= OutputLength
;
199 DPRINT1("Unhandled major function %lu!\n",
200 IoStackLocation
->MajorFunction
);
204 /* Return the information */
205 Irp
->IoStatus
.Status
= Status
;
206 Irp
->IoStatus
.Information
= Information
;
208 /* Complete the request */
209 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);