2005-11-09 11:57:58 +00:00
|
|
|
|
/*
|
2006-04-23 08:46:25 +00:00
|
|
|
|
* PROJECT: ReactOS Serial mouse driver
|
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
|
* FILE: drivers/input/sermouse/fdo.c
|
|
|
|
|
* PURPOSE: Serial mouse driver entry point
|
|
|
|
|
* PROGRAMMERS: Copyright 2005-2006 Herv<EFBFBD> Poussineau (hpoussin@reactos.org)
|
2005-11-09 11:57:58 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "sermouse.h"
|
|
|
|
|
|
2014-01-29 10:56:25 +00:00
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
2007-03-18 00:27:02 +00:00
|
|
|
|
static DRIVER_UNLOAD DriverUnload;
|
|
|
|
|
static DRIVER_DISPATCH IrpStub;
|
|
|
|
|
DRIVER_INITIALIZE DriverEntry;
|
|
|
|
|
|
|
|
|
|
static VOID NTAPI
|
2005-11-09 11:57:58 +00:00
|
|
|
|
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
|
|
|
|
{
|
|
|
|
|
// nothing to do here yet
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-18 00:27:02 +00:00
|
|
|
|
static NTSTATUS NTAPI
|
2005-11-09 11:57:58 +00:00
|
|
|
|
IrpStub(
|
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
|
IN PIRP Irp)
|
|
|
|
|
{
|
2007-12-28 21:10:07 +00:00
|
|
|
|
ERR_(SERMOUSE, "Irp stub for major function 0x%lx\n",
|
2005-11-09 11:57:58 +00:00
|
|
|
|
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
|
|
|
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
|
ReadRegistryEntries(
|
|
|
|
|
IN PUNICODE_STRING RegistryPath,
|
|
|
|
|
IN PSERMOUSE_DRIVER_EXTENSION DriverExtension)
|
|
|
|
|
{
|
|
|
|
|
UNICODE_STRING ParametersRegistryKey;
|
2006-04-23 08:46:25 +00:00
|
|
|
|
RTL_QUERY_REGISTRY_TABLE Parameters[2];
|
2005-11-09 11:57:58 +00:00
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
2006-04-23 08:46:25 +00:00
|
|
|
|
ULONG DefaultNumberOfButtons = 2;
|
2005-11-09 11:57:58 +00:00
|
|
|
|
|
|
|
|
|
ParametersRegistryKey.Length = 0;
|
|
|
|
|
ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
|
2007-06-04 09:25:04 +00:00
|
|
|
|
ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, SERMOUSE_TAG);
|
2005-11-09 11:57:58 +00:00
|
|
|
|
if (!ParametersRegistryKey.Buffer)
|
|
|
|
|
{
|
2007-12-28 21:10:07 +00:00
|
|
|
|
WARN_(SERMOUSE, "ExAllocatePoolWithTag() failed\n");
|
2007-06-04 09:25:04 +00:00
|
|
|
|
return STATUS_NO_MEMORY;
|
2005-11-09 11:57:58 +00:00
|
|
|
|
}
|
|
|
|
|
RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
|
|
|
|
|
RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
|
|
|
|
|
ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
|
|
|
|
|
|
|
|
|
RtlZeroMemory(Parameters, sizeof(Parameters));
|
|
|
|
|
|
|
|
|
|
Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL;
|
2006-04-23 08:46:25 +00:00
|
|
|
|
Parameters[0].Name = L"NumberOfButtons";
|
|
|
|
|
Parameters[0].EntryContext = &DriverExtension->NumberOfButtons;
|
2005-11-09 11:57:58 +00:00
|
|
|
|
Parameters[0].DefaultType = REG_DWORD;
|
2006-04-23 08:46:25 +00:00
|
|
|
|
Parameters[0].DefaultData = &DefaultNumberOfButtons;
|
2005-11-09 11:57:58 +00:00
|
|
|
|
Parameters[0].DefaultLength = sizeof(ULONG);
|
|
|
|
|
|
|
|
|
|
Status = RtlQueryRegistryValues(
|
|
|
|
|
RTL_REGISTRY_ABSOLUTE,
|
|
|
|
|
ParametersRegistryKey.Buffer,
|
|
|
|
|
Parameters,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
/* Check values */
|
|
|
|
|
}
|
|
|
|
|
else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
|
|
|
|
{
|
|
|
|
|
/* Registry path doesn't exist. Set defaults */
|
2007-03-18 00:27:02 +00:00
|
|
|
|
DriverExtension->NumberOfButtons = (USHORT)DefaultNumberOfButtons;
|
2006-04-23 08:46:25 +00:00
|
|
|
|
Status = STATUS_SUCCESS;
|
2005-11-09 11:57:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-04 09:25:04 +00:00
|
|
|
|
ExFreePoolWithTag(ParametersRegistryKey.Buffer, SERMOUSE_TAG);
|
2005-11-09 11:57:58 +00:00
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Standard DriverEntry method.
|
|
|
|
|
*/
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
|
DriverEntry(
|
|
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
|
IN PUNICODE_STRING RegistryPath)
|
|
|
|
|
{
|
|
|
|
|
PSERMOUSE_DRIVER_EXTENSION DriverExtension;
|
|
|
|
|
ULONG i;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
|
|
Status = IoAllocateDriverObjectExtension(
|
|
|
|
|
DriverObject,
|
|
|
|
|
DriverObject,
|
|
|
|
|
sizeof(SERMOUSE_DRIVER_EXTENSION),
|
|
|
|
|
(PVOID*)&DriverExtension);
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
2007-12-28 21:10:07 +00:00
|
|
|
|
WARN_(SERMOUSE, "IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status);
|
2005-11-09 11:57:58 +00:00
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
RtlZeroMemory(DriverExtension, sizeof(SERMOUSE_DRIVER_EXTENSION));
|
|
|
|
|
|
|
|
|
|
Status = ReadRegistryEntries(RegistryPath, DriverExtension);
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
2007-12-28 21:10:07 +00:00
|
|
|
|
WARN_(SERMOUSE, "ReadRegistryEntries() failed with status 0x%08lx\n", Status);
|
2005-11-09 11:57:58 +00:00
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DriverObject->DriverUnload = DriverUnload;
|
|
|
|
|
DriverObject->DriverExtension->AddDevice = SermouseAddDevice;
|
|
|
|
|
|
2005-12-18 20:50:26 +00:00
|
|
|
|
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
2005-11-09 11:57:58 +00:00
|
|
|
|
DriverObject->MajorFunction[i] = IrpStub;
|
|
|
|
|
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = SermouseCreate;
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = SermouseClose;
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = SermouseCleanup;
|
|
|
|
|
//DriverObject->MajorFunction[IRP_MJ_READ] = SermouseRead;
|
|
|
|
|
//DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SermouseDeviceControl;
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = SermouseInternalDeviceControl;
|
|
|
|
|
//DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SermouseQueryInformation;
|
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_PNP] = SermousePnp;
|
|
|
|
|
//DriverObject->MajorFunction[IRP_MJ_POWER] = SermousePower;
|
|
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
}
|