Author: hpoussin
Date: Tue Jul 11 17:38:59 2006
New Revision: 23010
URL:
http://svn.reactos.org/svn/reactos?rev=23010&view=rev
Log:
Don't change PortData pointer, as it is allocated memory, and so, it is easier to free
it when needed.
Modified:
trunk/reactos/drivers/input/kbdclass/kbdclass.c
trunk/reactos/drivers/input/mouclass/mouclass.c
Modified: trunk/reactos/drivers/input/kbdclass/kbdclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/kbdclass/kbd…
==============================================================================
--- trunk/reactos/drivers/input/kbdclass/kbdclass.c (original)
+++ trunk/reactos/drivers/input/kbdclass/kbdclass.c Tue Jul 11 17:38:59 2006
@@ -370,6 +370,11 @@
DeviceExtension->ReadIsPending = FALSE;
DeviceExtension->InputCount = 0;
DeviceExtension->PortData = ExAllocatePool(NonPagedPool,
DeviceExtension->DriverExtension->DataQueueSize * sizeof(KEYBOARD_INPUT_DATA));
+ if (!DeviceExtension->PortData)
+ {
+ ExFreePool(DeviceNameU.Buffer);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
Fdo->Flags |= DO_POWER_PAGABLE;
Fdo->Flags |= DO_BUFFERED_IO; /* FIXME: Why is it needed for 1st stage setup? */
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
@@ -509,13 +514,12 @@
* Move the input data from the port data queue to our class data
* queue.
*/
- RtlMoveMemory(
- ClassDeviceExtension->PortData,
+ RtlCopyMemory(
+ &ClassDeviceExtension->PortData[ClassDeviceExtension->InputCount],
(PCHAR)DataStart,
sizeof(KEYBOARD_INPUT_DATA) * ReadSize);
- /* Move the pointer and counter up */
- ClassDeviceExtension->PortData += ReadSize;
+ /* Move the counter up */
ClassDeviceExtension->InputCount += ReadSize;
(*ConsumedCount) += ReadSize;
@@ -681,6 +685,8 @@
return STATUS_SUCCESS;
cleanup:
+ if (!(Fdo->Flags & DO_DEVICE_INITIALIZING))
+ DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
if (DeviceExtension)
{
if (DeviceExtension->LowerDevice)
@@ -717,19 +723,18 @@
Status = FillOneEntry(
DeviceObject,
Irp,
- DeviceExtension->PortData - DeviceExtension->InputCount);
+ &DeviceExtension->PortData[DeviceExtension->InputCount - 1]);
if (NT_SUCCESS(Status))
{
if (DeviceExtension->InputCount > 1)
{
RtlMoveMemory(
- DeviceExtension->PortData - DeviceExtension->InputCount,
- DeviceExtension->PortData - DeviceExtension->InputCount + 1,
+ &DeviceExtension->PortData[1],
+ &DeviceExtension->PortData[0],
(DeviceExtension->InputCount - 1) * sizeof(KEYBOARD_INPUT_DATA));
}
- DeviceExtension->PortData--;
DeviceExtension->InputCount--;
DeviceExtension->ReadIsPending = FALSE;
Modified: trunk/reactos/drivers/input/mouclass/mouclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/mouclass/mou…
==============================================================================
--- trunk/reactos/drivers/input/mouclass/mouclass.c (original)
+++ trunk/reactos/drivers/input/mouclass/mouclass.c Tue Jul 11 17:38:59 2006
@@ -347,6 +347,11 @@
DeviceExtension->ReadIsPending = FALSE;
DeviceExtension->InputCount = 0;
DeviceExtension->PortData = ExAllocatePool(NonPagedPool,
DeviceExtension->DriverExtension->DataQueueSize * sizeof(MOUSE_INPUT_DATA));
+ if (!DeviceExtension->PortData)
+ {
+ ExFreePool(DeviceNameU.Buffer);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
Fdo->Flags |= DO_POWER_PAGABLE;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
@@ -485,13 +490,12 @@
* Move the input data from the port data queue to our class data
* queue.
*/
- RtlMoveMemory(
- ClassDeviceExtension->PortData,
+ RtlCopyMemory(
+ &ClassDeviceExtension->PortData[ClassDeviceExtension->InputCount],
(PCHAR)DataStart,
sizeof(MOUSE_INPUT_DATA) * ReadSize);
- /* Move the pointer and counter up */
- ClassDeviceExtension->PortData += ReadSize;
+ /* Move the counter up */
ClassDeviceExtension->InputCount += ReadSize;
(*ConsumedCount) += ReadSize;
@@ -657,6 +661,8 @@
return STATUS_SUCCESS;
cleanup:
+ if (!(Fdo->Flags & DO_DEVICE_INITIALIZING))
+ DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
if (DeviceExtension)
{
if (DeviceExtension->LowerDevice)
@@ -693,19 +699,18 @@
Status = FillOneEntry(
DeviceObject,
Irp,
- DeviceExtension->PortData - DeviceExtension->InputCount);
+ &DeviceExtension->PortData[DeviceExtension->InputCount - 1]);
if (NT_SUCCESS(Status))
{
if (DeviceExtension->InputCount > 1)
{
RtlMoveMemory(
- DeviceExtension->PortData - DeviceExtension->InputCount,
- DeviceExtension->PortData - DeviceExtension->InputCount + 1,
+ &DeviceExtension->PortData[1],
+ &DeviceExtension->PortData[0],
(DeviceExtension->InputCount - 1) * sizeof(MOUSE_INPUT_DATA));
}
- DeviceExtension->PortData--;
DeviceExtension->InputCount--;
DeviceExtension->ReadIsPending = FALSE;