Used the given registry path from DriverEntry to query the registry.
authorHartmut Birr <osexpert@googlemail.com>
Thu, 15 Sep 2005 16:46:17 +0000 (16:46 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Thu, 15 Sep 2005 16:46:17 +0000 (16:46 +0000)
This will also fix the bug in I8042ReadRegistry, which has append the string to an unicode string with an uninitialized length value.

svn path=/trunk/; revision=17862

reactos/drivers/input/i8042prt/i8042prt.c
reactos/drivers/input/i8042prt/i8042prt.h
reactos/drivers/input/i8042prt/registry.c

index e6ce9fa..8ea3d82 100644 (file)
@@ -27,6 +27,8 @@
 #define I8042_MAX_COMMAND_LENGTH 16
 #define I8042_MAX_UPWARDS_STACK 5
 
+UNICODE_STRING I8042RegistryPath;
+
 /* FUNCTIONS *****************************************************************/
 
 /*
@@ -794,6 +796,21 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
 {
        DPRINT("I8042 Driver 0.0.1\n");
 
+        I8042RegistryPath.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters");
+        I8042RegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, 
+                                                         I8042RegistryPath.MaximumLength,
+                                                         TAG_I8042);
+        if (I8042RegistryPath.Buffer == NULL) {
+
+            return STATUS_INSUFFICIENT_RESOURCES;
+        }
+
+        RtlCopyUnicodeString(&I8042RegistryPath, RegistryPath);
+        RtlAppendUnicodeToString(&I8042RegistryPath, L"\\Parameters");
+        I8042RegistryPath.Buffer[I8042RegistryPath.Length / sizeof(WCHAR)] = 0;
+
+
+
        DriverObject->MajorFunction[IRP_MJ_CREATE] = I8042CreateDispatch;
        DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
                                               I8042InternalDeviceControl;
index 6d7e56c..16cfe0e 100644 (file)
@@ -263,6 +263,8 @@ typedef struct _I8042_HOOK_WORKITEM
 #define MOUSE_NACK         0xFE
 
 /* i8042prt.c */
+extern UNICODE_STRING I8042RegistryPath;
+
 NTSTATUS I8042ReadData(UCHAR *Data);
 
 NTSTATUS I8042ReadStatus(UCHAR *Status);
index 09abbd6..8c25872 100644 (file)
@@ -30,9 +30,6 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject,
 
 {
        RTL_QUERY_REGISTRY_TABLE Parameters[19];
-       UNICODE_STRING ParametersPath;
-
-       PWSTR RegistryPath = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\i8042Prt\\Parameters";
 
        NTSTATUS Status;
 
@@ -55,23 +52,6 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject,
        ULONG DefaultNumberOfButtons = 2;
        ULONG DefaultEnableWheelDetection = 1;
 
-       RtlInitUnicodeString(&ParametersPath, NULL);
-       ParametersPath.MaximumLength = (wcslen(RegistryPath) *
-                                               sizeof(WCHAR)) +
-                                      sizeof(UNICODE_NULL);
-
-       ParametersPath.Buffer = ExAllocatePoolWithTag(PagedPool,
-                                             ParametersPath.MaximumLength,
-                                             TAG_I8042);
-
-       if (!ParametersPath.Buffer) {
-               DPRINT1("No buffer space for reading registry\n");
-               return;
-       }
-
-       RtlZeroMemory(ParametersPath.Buffer, ParametersPath.MaximumLength);
-       RtlAppendUnicodeToString(&ParametersPath, RegistryPath);
-
        RtlZeroMemory(Parameters, sizeof(Parameters));
 
        Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
@@ -202,9 +182,8 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject,
        Parameters[17].DefaultData = &DefaultEnableWheelDetection;
        Parameters[17].DefaultLength = sizeof(ULONG);
 
-       Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE |
-                                               RTL_REGISTRY_OPTIONAL,
-                                       ParametersPath.Buffer,
+       Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
+                                       I8042RegistryPath.Buffer,
                                        Parameters,
                                        NULL,
                                        NULL);
@@ -224,7 +203,6 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject,
                DPRINT1 ("Manually set defaults\n");
 
        }
-       ExFreePoolWithTag(ParametersPath.Buffer, TAG_I8042);
 
        if (DevExt->Settings.MouseResolution > 3)
                DevExt->Settings.MouseResolution = 3;