ReactOS  0.4.15-dev-3324-gda4e15f
sermouse.c File Reference
#include "sermouse.h"
#include <debug.h>
Include dependency graph for sermouse.c:

Go to the source code of this file.

Functions

static VOID NTAPI DriverUnload (IN PDRIVER_OBJECT DriverObject)
 
static NTSTATUS NTAPI IrpStub (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS ReadRegistryEntries (IN PUNICODE_STRING RegistryPath, IN PSERMOUSE_DRIVER_EXTENSION DriverExtension)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

static DRIVER_UNLOAD DriverUnload
 
static DRIVER_DISPATCH IrpStub
 
DRIVER_INITIALIZE DriverEntry
 

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 92 of file sermouse.c.

95 {
97  ULONG i;
99 
101  DriverObject,
102  DriverObject,
105  if (!NT_SUCCESS(Status))
106  {
107  WARN_(SERMOUSE, "IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status);
108  return Status;
109  }
111 
113  if (!NT_SUCCESS(Status))
114  {
115  WARN_(SERMOUSE, "ReadRegistryEntries() failed with status 0x%08lx\n", Status);
116  return Status;
117  }
118 
119  DriverObject->DriverUnload = DriverUnload;
120  DriverObject->DriverExtension->AddDevice = SermouseAddDevice;
121 
122  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
123  DriverObject->MajorFunction[i] = IrpStub;
124 
125  DriverObject->MajorFunction[IRP_MJ_CREATE] = SermouseCreate;
126  DriverObject->MajorFunction[IRP_MJ_CLOSE] = SermouseClose;
127  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = SermouseCleanup;
128  //DriverObject->MajorFunction[IRP_MJ_READ] = SermouseRead;
129  //DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SermouseDeviceControl;
131  //DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SermouseQueryInformation;
132  DriverObject->MajorFunction[IRP_MJ_PNP] = SermousePnp;
133  //DriverObject->MajorFunction[IRP_MJ_POWER] = SermousePower;
134 
135  return STATUS_SUCCESS;
136 }
DRIVER_DISPATCH SermouseCreate
Definition: sermouse.h:77
static DRIVER_UNLOAD DriverUnload
Definition: sermouse.c:13
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1799
DRIVER_ADD_DEVICE SermouseAddDevice
Definition: sermouse.h:91
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
DRIVER_DISPATCH SermouseClose
Definition: sermouse.h:79
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
static NTSTATUS ReadRegistryEntries(IN PUNICODE_STRING RegistryPath, IN PSERMOUSE_DRIVER_EXTENSION DriverExtension)
Definition: sermouse.c:35
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
DRIVER_DISPATCH SermouseInternalDeviceControl
Definition: sermouse.h:97
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static DRIVER_DISPATCH IrpStub
Definition: sermouse.c:14
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IRP_MJ_CLEANUP
DRIVER_DISPATCH SermousePnp
Definition: sermouse.h:93
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
#define WARN_(ch,...)
Definition: debug.h:157
DRIVER_DISPATCH SermouseCleanup
Definition: sermouse.h:81

◆ DriverUnload()

static VOID NTAPI DriverUnload ( IN PDRIVER_OBJECT  DriverObject)
static

Definition at line 18 of file sermouse.c.

19 {
20  // nothing to do here yet
21 }

◆ IrpStub()

static NTSTATUS NTAPI IrpStub ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 24 of file sermouse.c.

27 {
28  ERR_(SERMOUSE, "Irp stub for major function 0x%lx\n",
31  return STATUS_NOT_SUPPORTED;
32 }
return STATUS_NOT_SUPPORTED
#define ERR_(ch,...)
Definition: debug.h:156
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ ReadRegistryEntries()

static NTSTATUS ReadRegistryEntries ( IN PUNICODE_STRING  RegistryPath,
IN PSERMOUSE_DRIVER_EXTENSION  DriverExtension 
)
static

Definition at line 35 of file sermouse.c.

38 {
39  UNICODE_STRING ParametersRegistryKey;
42 
43  ULONG DefaultNumberOfButtons = 2;
44 
45  ParametersRegistryKey.Length = 0;
46  ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
47  ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, SERMOUSE_TAG);
48  if (!ParametersRegistryKey.Buffer)
49  {
50  WARN_(SERMOUSE, "ExAllocatePoolWithTag() failed\n");
51  return STATUS_NO_MEMORY;
52  }
53  RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
54  RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
55  ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
56 
58 
60  Parameters[0].Name = L"NumberOfButtons";
61  Parameters[0].EntryContext = &DriverExtension->NumberOfButtons;
62  Parameters[0].DefaultType = REG_DWORD;
63  Parameters[0].DefaultData = &DefaultNumberOfButtons;
64  Parameters[0].DefaultLength = sizeof(ULONG);
65 
68  ParametersRegistryKey.Buffer,
69  Parameters,
70  NULL,
71  NULL);
72 
73  if (NT_SUCCESS(Status))
74  {
75  /* Check values */
76  }
78  {
79  /* Registry path doesn't exist. Set defaults */
80  DriverExtension->NumberOfButtons = (USHORT)DefaultNumberOfButtons;
82  }
83 
84  ExFreePoolWithTag(ParametersRegistryKey.Buffer, SERMOUSE_TAG);
85  return Status;
86 }
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define SERMOUSE_TAG
Definition: sermouse.h:8
#define UNICODE_NULL
#define RTL_REGISTRY_OPTIONAL
Definition: nt_native.h:169
Status
Definition: gdiplustypes.h:24
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REG_DWORD
Definition: sdbapi.c:596
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define WARN_(ch,...)
Definition: debug.h:157
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144

Referenced by DriverEntry().

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 15 of file sermouse.c.

◆ DriverUnload

DRIVER_UNLOAD DriverUnload
static

Definition at line 13 of file sermouse.c.

Referenced by DriverEntry().

◆ IrpStub

DRIVER_DISPATCH IrpStub
static

Definition at line 14 of file sermouse.c.

Referenced by DriverEntry().