Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensermouse.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Serial mouse driver 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: drivers/input/sermouse/fdo.c 00005 * PURPOSE: Serial mouse driver entry point 00006 * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org) 00007 */ 00008 00009 #define INITGUID 00010 #include "sermouse.h" 00011 00012 static DRIVER_UNLOAD DriverUnload; 00013 static DRIVER_DISPATCH IrpStub; 00014 DRIVER_INITIALIZE DriverEntry; 00015 00016 static VOID NTAPI 00017 DriverUnload(IN PDRIVER_OBJECT DriverObject) 00018 { 00019 // nothing to do here yet 00020 } 00021 00022 static NTSTATUS NTAPI 00023 IrpStub( 00024 IN PDEVICE_OBJECT DeviceObject, 00025 IN PIRP Irp) 00026 { 00027 ERR_(SERMOUSE, "Irp stub for major function 0x%lx\n", 00028 IoGetCurrentIrpStackLocation(Irp)->MajorFunction); 00029 IoCompleteRequest(Irp, IO_NO_INCREMENT); 00030 return STATUS_NOT_SUPPORTED; 00031 } 00032 00033 static NTSTATUS 00034 ReadRegistryEntries( 00035 IN PUNICODE_STRING RegistryPath, 00036 IN PSERMOUSE_DRIVER_EXTENSION DriverExtension) 00037 { 00038 UNICODE_STRING ParametersRegistryKey; 00039 RTL_QUERY_REGISTRY_TABLE Parameters[2]; 00040 NTSTATUS Status; 00041 00042 ULONG DefaultNumberOfButtons = 2; 00043 00044 ParametersRegistryKey.Length = 0; 00045 ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL); 00046 ParametersRegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool, ParametersRegistryKey.MaximumLength, SERMOUSE_TAG); 00047 if (!ParametersRegistryKey.Buffer) 00048 { 00049 WARN_(SERMOUSE, "ExAllocatePoolWithTag() failed\n"); 00050 return STATUS_NO_MEMORY; 00051 } 00052 RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath); 00053 RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters"); 00054 ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL; 00055 00056 RtlZeroMemory(Parameters, sizeof(Parameters)); 00057 00058 Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL; 00059 Parameters[0].Name = L"NumberOfButtons"; 00060 Parameters[0].EntryContext = &DriverExtension->NumberOfButtons; 00061 Parameters[0].DefaultType = REG_DWORD; 00062 Parameters[0].DefaultData = &DefaultNumberOfButtons; 00063 Parameters[0].DefaultLength = sizeof(ULONG); 00064 00065 Status = RtlQueryRegistryValues( 00066 RTL_REGISTRY_ABSOLUTE, 00067 ParametersRegistryKey.Buffer, 00068 Parameters, 00069 NULL, 00070 NULL); 00071 00072 if (NT_SUCCESS(Status)) 00073 { 00074 /* Check values */ 00075 } 00076 else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) 00077 { 00078 /* Registry path doesn't exist. Set defaults */ 00079 DriverExtension->NumberOfButtons = (USHORT)DefaultNumberOfButtons; 00080 Status = STATUS_SUCCESS; 00081 } 00082 00083 ExFreePoolWithTag(ParametersRegistryKey.Buffer, SERMOUSE_TAG); 00084 return Status; 00085 } 00086 00087 /* 00088 * Standard DriverEntry method. 00089 */ 00090 NTSTATUS NTAPI 00091 DriverEntry( 00092 IN PDRIVER_OBJECT DriverObject, 00093 IN PUNICODE_STRING RegistryPath) 00094 { 00095 PSERMOUSE_DRIVER_EXTENSION DriverExtension; 00096 ULONG i; 00097 NTSTATUS Status; 00098 00099 Status = IoAllocateDriverObjectExtension( 00100 DriverObject, 00101 DriverObject, 00102 sizeof(SERMOUSE_DRIVER_EXTENSION), 00103 (PVOID*)&DriverExtension); 00104 if (!NT_SUCCESS(Status)) 00105 { 00106 WARN_(SERMOUSE, "IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status); 00107 return Status; 00108 } 00109 RtlZeroMemory(DriverExtension, sizeof(SERMOUSE_DRIVER_EXTENSION)); 00110 00111 Status = ReadRegistryEntries(RegistryPath, DriverExtension); 00112 if (!NT_SUCCESS(Status)) 00113 { 00114 WARN_(SERMOUSE, "ReadRegistryEntries() failed with status 0x%08lx\n", Status); 00115 return Status; 00116 } 00117 00118 DriverObject->DriverUnload = DriverUnload; 00119 DriverObject->DriverExtension->AddDevice = SermouseAddDevice; 00120 00121 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) 00122 DriverObject->MajorFunction[i] = IrpStub; 00123 00124 DriverObject->MajorFunction[IRP_MJ_CREATE] = SermouseCreate; 00125 DriverObject->MajorFunction[IRP_MJ_CLOSE] = SermouseClose; 00126 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = SermouseCleanup; 00127 //DriverObject->MajorFunction[IRP_MJ_READ] = SermouseRead; 00128 //DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SermouseDeviceControl; 00129 DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = SermouseInternalDeviceControl; 00130 //DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SermouseQueryInformation; 00131 DriverObject->MajorFunction[IRP_MJ_PNP] = SermousePnp; 00132 //DriverObject->MajorFunction[IRP_MJ_POWER] = SermousePower; 00133 00134 return STATUS_SUCCESS; 00135 } Generated on Sat May 26 2012 04:26:32 for ReactOS by
1.7.6.1
|