ReactOS  0.4.15-dev-2144-g2282205
ioctl.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS InPort (Bus) Mouse Driver
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: I/O control handling
5  * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6  */
7 
8 /* INCLUDES *******************************************************************/
9 
10 #include "inport.h"
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* FUNCTIONS ******************************************************************/
16 
18 NTAPI
22 {
24  PCONNECT_DATA ConnectData;
25  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
27 
28  DPRINT("%s(%p, %p) 0x%X\n", __FUNCTION__, DeviceObject, Irp,
29  IrpSp->Parameters.DeviceIoControl.IoControlCode);
30 
31  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
32  {
34  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
35  {
37  break;
38  }
39 
40  /* Already connected */
41  if (DeviceExtension->ClassService)
42  {
44  break;
45  }
46 
47  ConnectData = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
48 
49  DeviceExtension->ClassDeviceObject = ConnectData->ClassDeviceObject;
50  DeviceExtension->ClassService = ConnectData->ClassService;
51 
53  break;
54 
56  DeviceExtension->ClassService = NULL;
57 
59  break;
60 
62  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUSE_ATTRIBUTES))
63  {
65  break;
66  }
67 
68  *(PMOUSE_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer = DeviceExtension->MouseAttributes;
69  Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
70 
72  break;
73 
74  default:
76  break;
77  }
78 
79  Irp->IoStatus.Status = Status;
81 
82  return Status;
83 }
PDEVICE_OBJECT ClassDeviceObject
Definition: inport.h:64
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI InPortInternalDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: ioctl.c:19
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
struct _MOUSE_ATTRIBUTES * PMOUSE_ATTRIBUTES
#define _Inout_
Definition: no_sal2.h:162
#define IOCTL_INTERNAL_MOUSE_DISCONNECT
Definition: kbdmou.h:71
PVOID ClassService
Definition: kbdmou.h:82
#define IOCTL_INTERNAL_MOUSE_CONNECT
Definition: kbdmou.h:68
#define IOCTL_MOUSE_QUERY_ATTRIBUTES
Definition: ntddmou.h:32
#define _In_
Definition: no_sal2.h:158
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
MOUSE_ATTRIBUTES MouseAttributes
Definition: inport.h:74
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124
#define __FUNCTION__
Definition: types.h:112
PDEVICE_OBJECT ClassDeviceObject
Definition: kbdmou.h:81