ReactOS 0.4.15-dev-8419-g7f0e8a3
dispatch.c File Reference
#include "ksecdd.h"
#include <ksecioctl.h>
#include <debug.h>
Include dependency graph for dispatch.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS KsecQueryFileInformation (PVOID InfoBuffer, FILE_INFORMATION_CLASS FileInformationClass, PSIZE_T BufferLength)
 
static NTSTATUS KsecQueryVolumeInformation (PVOID InfoBuffer, FS_INFORMATION_CLASS FsInformationClass, PSIZE_T BufferLength)
 
static NTSTATUS KsecDeviceControl (ULONG IoControlCode, PVOID Buffer, SIZE_T InputLength, PSIZE_T OutputLength)
 
NTSTATUS NTAPI KsecDdDispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file dispatch.c.

Function Documentation

◆ KsecDdDispatch()

NTSTATUS NTAPI KsecDdDispatch ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 184 of file dispatch.c.

187{
188 PIO_STACK_LOCATION IoStackLocation;
192 SIZE_T InputLength, OutputLength;
193 FILE_INFORMATION_CLASS FileInfoClass;
194 FS_INFORMATION_CLASS FsInfoClass;
196
197 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
198
199 switch (IoStackLocation->MajorFunction)
200 {
201 case IRP_MJ_CREATE:
202 case IRP_MJ_CLOSE:
203
204 /* Just return success */
206 Information = 0;
207 break;
208
209 case IRP_MJ_READ:
210
211 /* There is nothing to read */
213 Information = 0;
214 break;
215
216 case IRP_MJ_WRITE:
217
218 /* Pretend to have written everything */
220 Information = IoStackLocation->Parameters.Write.Length;
221 break;
222
224
225 /* Extract the parameters */
226 Buffer = Irp->AssociatedIrp.SystemBuffer;
227 OutputLength = IoStackLocation->Parameters.QueryFile.Length;
228 FileInfoClass = IoStackLocation->Parameters.QueryFile.FileInformationClass;
229
230 /* Call the internal function */
232 FileInfoClass,
233 &OutputLength);
234 Information = OutputLength;
235 break;
236
238
239 /* Extract the parameters */
240 Buffer = Irp->AssociatedIrp.SystemBuffer;
241 OutputLength = IoStackLocation->Parameters.QueryVolume.Length;
242 FsInfoClass = IoStackLocation->Parameters.QueryVolume.FsInformationClass;
243
244 /* Call the internal function */
246 FsInfoClass,
247 &OutputLength);
248 Information = OutputLength;
249 break;
250
252
253 /* Extract the parameters */
254 InputLength = IoStackLocation->Parameters.DeviceIoControl.InputBufferLength;
255 OutputLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
256 IoControlCode = IoStackLocation->Parameters.DeviceIoControl.IoControlCode;
257
258 /* Check for METHOD_OUT_DIRECT method */
260 (OutputLength != 0))
261 {
262 /* Use the provided MDL */
263 OutputLength = Irp->MdlAddress->ByteCount;
266 if (Buffer == NULL)
267 {
269 Information = 0;
270 break;
271 }
272 }
273 else
274 {
275 /* Otherwise this is METHOD_BUFFERED, use the SystemBuffer */
276 Buffer = Irp->AssociatedIrp.SystemBuffer;
277 }
278
279 /* Call the internal function */
281 Buffer,
282 InputLength,
283 &OutputLength);
284 Information = OutputLength;
285 break;
286
287 default:
288 DPRINT1("Unhandled major function %lu!\n",
289 IoStackLocation->MajorFunction);
290 ASSERT(FALSE);
292 }
293
294 /* Return the information */
295 Irp->IoStatus.Status = Status;
296 Irp->IoStatus.Information = Information;
297
298 /* Complete the request */
300
301 return Status;
302}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static NTSTATUS KsecDeviceControl(ULONG IoControlCode, PVOID Buffer, SIZE_T InputLength, PSIZE_T OutputLength)
Definition: dispatch.c:87
static NTSTATUS KsecQueryVolumeInformation(PVOID InfoBuffer, FS_INFORMATION_CLASS FsInformationClass, PSIZE_T BufferLength)
Definition: dispatch.c:56
static NTSTATUS KsecQueryFileInformation(PVOID InfoBuffer, FILE_INFORMATION_CLASS FileInformationClass, PSIZE_T BufferLength)
Definition: dispatch.c:22
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
enum _FSINFOCLASS FS_INFORMATION_CLASS
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
@ NormalPagePriority
Definition: imports.h:56
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _IO_STACK_LOCATION::@3976::@3989 QueryVolume
struct _IO_STACK_LOCATION::@3976::@3985 QueryFile
struct _IO_STACK_LOCATION::@3976::@3981 Write
union _IO_STACK_LOCATION::@1567 Parameters
struct _IO_STACK_LOCATION::@1567::@1568 DeviceIoControl
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define METHOD_FROM_CTL_CODE(ctrlCode)
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)

Referenced by DriverEntry().

◆ KsecDeviceControl()

static NTSTATUS KsecDeviceControl ( ULONG  IoControlCode,
PVOID  Buffer,
SIZE_T  InputLength,
PSIZE_T  OutputLength 
)
static

Definition at line 87 of file dispatch.c.

92{
94
102 {
103 /* Make sure we have a valid output buffer */
104 if ((Buffer == NULL) || (OutputLength == NULL))
105 {
107 }
108
109 /* Check if the input is smaller than the output */
110 if (InputLength < *OutputLength)
111 {
112 /* We might have uninitialized memory, zero it out */
113 RtlSecureZeroMemory((PUCHAR)Buffer + InputLength,
114 *OutputLength - InputLength);
115 }
116 }
117
118 /* Check ioctl code */
119 switch (IoControlCode)
120 {
122
124 break;
125
127
128 Status = KsecGenRandom(Buffer, *OutputLength);
129 break;
130
132
134 *OutputLength,
136 break;
137
139
141 *OutputLength,
143 break;
144
146
148 *OutputLength,
150 break;
151
153
155 *OutputLength,
157 break;
158
160
162 *OutputLength,
164 break;
165
167
169 *OutputLength,
171 break;
172
173 default:
174 DPRINT1("Unhandled control code 0x%lx\n", IoControlCode);
175 __debugbreak();
177 }
178
179 return Status;
180}
NTSTATUS NTAPI KsecDecryptMemory(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:328
NTSTATUS NTAPI KsecEncryptMemory(_Inout_ PVOID Buffer, _In_ ULONG Length, _In_ ULONG OptionFlags)
Definition: crypt.c:293
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
NTSTATUS NTAPI KsecGenRandom(PVOID Buffer, SIZE_T Length)
Definition: random.c:26
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
#define RTL_ENCRYPT_OPTION_SAME_PROCESS
Definition: ksecdd.h:25
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS
Definition: ksecdd.h:26
#define IOCTL_KSEC_ENCRYPT_CROSS_PROCESS
Definition: ksecioctl.h:26
#define IOCTL_KSEC_DECRYPT_SAME_LOGON
Definition: ksecioctl.h:38
#define IOCTL_KSEC_DECRYPT_CROSS_PROCESS
Definition: ksecioctl.h:30
#define IOCTL_KSEC_ENCRYPT_SAME_PROCESS
Definition: ksecioctl.h:18
#define IOCTL_KSEC_ENCRYPT_SAME_LOGON
Definition: ksecioctl.h:34
#define IOCTL_KSEC_REGISTER_LSA_PROCESS
Definition: ksecioctl.h:6
#define IOCTL_KSEC_RANDOM_FILL_BUFFER
Definition: ksecioctl.h:14
#define IOCTL_KSEC_DECRYPT_SAME_PROCESS
Definition: ksecioctl.h:22
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FORCEINLINE PVOID RtlSecureZeroMemory(_Out_writes_bytes_all_(Size) PVOID Pointer, _In_ SIZE_T Size)
Definition: rtlfuncs.h:3125

Referenced by KsecDdDispatch().

◆ KsecQueryFileInformation()

static NTSTATUS KsecQueryFileInformation ( PVOID  InfoBuffer,
FILE_INFORMATION_CLASS  FileInformationClass,
PSIZE_T  BufferLength 
)
static

Definition at line 22 of file dispatch.c.

26{
27 PFILE_STANDARD_INFORMATION StandardInformation;
28
29 /* Only FileStandardInformation is supported */
31 {
33 }
34
35 /* Validate buffer size */
37 {
40 }
41
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;
50
51 return STATUS_SUCCESS;
52}
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
struct _FILE_STANDARD_INFORMATION * PFILE_STANDARD_INFORMATION
#define FileStandardInformation
Definition: propsheet.cpp:61
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by KsecDdDispatch().

◆ KsecQueryVolumeInformation()

static NTSTATUS KsecQueryVolumeInformation ( PVOID  InfoBuffer,
FS_INFORMATION_CLASS  FsInformationClass,
PSIZE_T  BufferLength 
)
static

Definition at line 56 of file dispatch.c.

60{
61 PFILE_FS_DEVICE_INFORMATION DeviceInformation;
62
63 /* Only FileFsDeviceInformation is supported */
65 {
67 }
68
69 /* Validate buffer size */
71 {
74 }
75
76 /* Fill the structure */
77 DeviceInformation = (PFILE_FS_DEVICE_INFORMATION)InfoBuffer;
78 DeviceInformation->DeviceType = FILE_DEVICE_NULL;
79 DeviceInformation->Characteristics = 0;
81
82 return STATUS_SUCCESS;
83}
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1330
@ FileFsDeviceInformation
Definition: from_kernel.h:222
struct _FILE_FS_DEVICE_INFORMATION * PFILE_FS_DEVICE_INFORMATION
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define FILE_DEVICE_NULL
Definition: winioctl.h:66

Referenced by KsecDdDispatch().