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 *******************************************************************/
12 #include <ksecioctl.h>
18 /* FUNCTIONS ******************************************************************/
22 KsecQueryFileInformation(
24 FILE_INFORMATION_CLASS FileInformationClass
,
27 PFILE_STANDARD_INFORMATION StandardInformation
;
29 /* Only FileStandardInformation is supported */
30 if (FileInformationClass
!= FileStandardInformation
)
32 return STATUS_INVALID_INFO_CLASS
;
35 /* Validate buffer size */
36 if (*BufferLength
>= sizeof(FILE_STANDARD_INFORMATION
))
38 *BufferLength
= sizeof(FILE_STANDARD_INFORMATION
);
39 return STATUS_INFO_LENGTH_MISMATCH
;
42 /* Fill the structure */
43 StandardInformation
= (PFILE_STANDARD_INFORMATION
)InfoBuffer
;
44 StandardInformation
->AllocationSize
.QuadPart
= 0;
45 StandardInformation
->EndOfFile
.QuadPart
= 0;
46 StandardInformation
->NumberOfLinks
= 1;
47 StandardInformation
->DeletePending
= FALSE
;
48 StandardInformation
->Directory
= FALSE
;
49 *BufferLength
= sizeof(FILE_STANDARD_INFORMATION
);
51 return STATUS_SUCCESS
;
56 KsecQueryVolumeInformation(
58 FS_INFORMATION_CLASS FsInformationClass
,
61 PFILE_FS_DEVICE_INFORMATION DeviceInformation
;
63 /* Only FileFsDeviceInformation is supported */
64 if (FsInformationClass
!= FileFsDeviceInformation
)
66 return STATUS_INVALID_INFO_CLASS
;
69 /* Validate buffer size */
70 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
72 *BufferLength
= sizeof(FILE_FS_DEVICE_INFORMATION
);
73 return STATUS_INFO_LENGTH_MISMATCH
;
76 /* Fill the structure */
77 DeviceInformation
= (PFILE_FS_DEVICE_INFORMATION
)InfoBuffer
;
78 DeviceInformation
->DeviceType
= FILE_DEVICE_NULL
;
79 DeviceInformation
->Characteristics
= 0;
80 *BufferLength
= sizeof(FILE_FS_DEVICE_INFORMATION
);
82 return STATUS_SUCCESS
;
95 Status
= STATUS_SUCCESS
;
97 /* Check ioctl code */
98 switch (IoControlCode
)
100 case IOCTL_KSEC_REGISTER_LSA_PROCESS
:
102 Status
= STATUS_SUCCESS
;
105 case IOCTL_KSEC_RANDOM_FILL_BUFFER
:
107 Status
= KsecGenRandom(Buffer
, *OutputLength
);
111 DPRINT1("Unhandled control code 0x%lx\n", IoControlCode
);
113 return STATUS_INVALID_PARAMETER
;
122 PDEVICE_OBJECT DeviceObject
,
125 PIO_STACK_LOCATION IoStackLocation
;
126 ULONG_PTR Information
;
129 SIZE_T InputLength
, OutputLength
;
130 FILE_INFORMATION_CLASS FileInfoClass
;
131 FS_INFORMATION_CLASS FsInfoClass
;
134 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
136 switch (IoStackLocation
->MajorFunction
)
141 /* Just return success */
142 Status
= STATUS_SUCCESS
;
148 /* There is nothing to read */
149 Status
= STATUS_END_OF_FILE
;
155 /* Pretend to have written everything */
156 Status
= STATUS_SUCCESS
;
157 Information
= IoStackLocation
->Parameters
.Write
.Length
;
160 case IRP_MJ_QUERY_INFORMATION
:
162 /* Extract the parameters */
163 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
164 OutputLength
= IoStackLocation
->Parameters
.QueryFile
.Length
;
165 FileInfoClass
= IoStackLocation
->Parameters
.QueryFile
.FileInformationClass
;
167 /* Call the internal function */
168 Status
= KsecQueryFileInformation(Buffer
,
171 Information
= OutputLength
;
174 case IRP_MJ_QUERY_VOLUME_INFORMATION
:
176 /* Extract the parameters */
177 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
178 OutputLength
= IoStackLocation
->Parameters
.QueryVolume
.Length
;
179 FsInfoClass
= IoStackLocation
->Parameters
.QueryVolume
.FsInformationClass
;
181 /* Call the internal function */
182 Status
= KsecQueryVolumeInformation(Buffer
,
185 Information
= OutputLength
;
188 case IRP_MJ_DEVICE_CONTROL
:
190 /* Extract the parameters */
191 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
192 InputLength
= IoStackLocation
->Parameters
.DeviceIoControl
.InputBufferLength
;
193 OutputLength
= IoStackLocation
->Parameters
.DeviceIoControl
.OutputBufferLength
;
194 IoControlCode
= IoStackLocation
->Parameters
.DeviceIoControl
.IoControlCode
;
196 /* Call the internal function */
197 Status
= KsecDeviceControl(IoControlCode
,
201 Information
= OutputLength
;
205 DPRINT1("Unhandled major function %lu!\n",
206 IoStackLocation
->MajorFunction
);
210 /* Return the information */
211 Irp
->IoStatus
.Status
= Status
;
212 Irp
->IoStatus
.Information
= Information
;
214 /* Complete the request */
215 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);