Author: hyperion
Date: Thu May 22 06:46:46 2008
New Revision: 33633
URL:
http://svn.reactos.org/svn/reactos?rev=33633&view=rev
Log:
- Remove WINE-isms from KeDeviceQueue code
- Fix memory corruption that happened pretty much everytime you pressed a key or moved
the mouse -- reponsible for countless crashes, including the famous ASSERT during 1-stage
setup.
- Remove anti-memory-corruption-workaround from VFAT
- Note: If you're going to do use device queues in your driver, please learn how.
Kthxbye.
Patch by Alex Ionescu <alex.ionescu(a)reactos.org>
_____
Alex,
Marry me,
KJK::Hyperion
XOXOXO
See issue #3116 for more details.
Modified:
trunk/reactos/drivers/filesystems/fastfat/flush.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
trunk/reactos/drivers/input/kbdclass/kbdclass.c
trunk/reactos/drivers/input/mouclass/mouclass.c
trunk/reactos/ntoskrnl/ke/devqueue.c
Modified: trunk/reactos/drivers/filesystems/fastfat/flush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] Thu May 22 06:46:46
2008
@@ -52,7 +52,6 @@
ListEntry = ListEntry->Flink;
if (!vfatFCBIsDirectory(Fcb))
{
- if (Fcb->PadPad51) continue; // Corrupt FCB
ExAcquireResourceExclusiveLite(&Fcb->MainResource, TRUE);
Status = VfatFlushFile(DeviceExt, Fcb);
ExReleaseResourceLite (&Fcb->MainResource);
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Thu May 22 06:46:46
2008
@@ -322,21 +322,6 @@
{
/* FCB header required by ROS/NT */
FSRTL_COMMON_FCB_HEADER RFCB;
- ULONG PadPad;
- ULONG PadPad2;
- ULONG PadPad3;
- ULONG PadPad4;
- ULONG PadPad5;
- ULONG PadPad50;
- ULONG PadPad51;
- ULONG PadPad52;
- ULONG PadPad53;
- ULONG PadPad54;
- ULONG PadPad55;
- ULONG PadPad56;
- ULONG PadPad6;
- ULONG PadPad7;
- ULONG PadPad8;
SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
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 [iso-8859-1] (original)
+++ trunk/reactos/drivers/input/kbdclass/kbdclass.c [iso-8859-1] Thu May 22 06:46:46 2008
@@ -798,9 +798,6 @@
/* Go to next packet and complete this request */
Irp->IoStatus.Status = Status;
- if (IsInStartIo)
- IoStartNextPacket(DeviceObject, TRUE);
-
(VOID)IoSetCancelRoutine(Irp, NULL);
IoCompleteRequest(Irp, IO_KEYBOARD_INCREMENT);
DeviceExtension->PendingIrp = NULL;
@@ -818,8 +815,6 @@
IoMarkIrpPending(Irp);
DeviceExtension->PendingIrp = Irp;
Status = STATUS_PENDING;
- if (!IsInStartIo)
- IoStartPacket(DeviceObject, Irp, NULL, NULL);
}
}
return Status;
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 [iso-8859-1] (original)
+++ trunk/reactos/drivers/input/mouclass/mouclass.c [iso-8859-1] Thu May 22 06:46:46 2008
@@ -774,9 +774,6 @@
/* Go to next packet and complete this request */
Irp->IoStatus.Status = Status;
- if (IsInStartIo)
- IoStartNextPacket(DeviceObject, TRUE);
-
(VOID)IoSetCancelRoutine(Irp, NULL);
IoCompleteRequest(Irp, IO_MOUSE_INCREMENT);
DeviceExtension->PendingIrp = NULL;
@@ -794,8 +791,6 @@
IoMarkIrpPending(Irp);
DeviceExtension->PendingIrp = Irp;
Status = STATUS_PENDING;
- if (!IsInStartIo)
- IoStartPacket(DeviceObject, Irp, NULL, NULL);
}
}
return Status;
Modified: trunk/reactos/ntoskrnl/ke/devqueue.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/devqueue.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/devqueue.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/devqueue.c [iso-8859-1] Thu May 22 06:46:46 2008
@@ -86,6 +86,8 @@
{
KLOCK_QUEUE_HANDLE DeviceLock;
BOOLEAN Inserted;
+ PLIST_ENTRY NextEntry;
+ PKDEVICE_QUEUE_ENTRY LastEntry;
ASSERT_DEVICE_QUEUE(DeviceQueue);
DPRINT("KeInsertByKeyDeviceQueue() DevQueue %p, Entry %p, SortKey 0x%x\n",
DeviceQueue, DeviceQueueEntry, SortKey);
@@ -105,12 +107,34 @@
}
else
{
- /* Insert new entry after the last entry with SortKey less or equal to passed-in
SortKey */
- InsertAscendingListFIFO(&DeviceQueue->DeviceListHead,
- DeviceQueueEntry,
- KDEVICE_QUEUE_ENTRY,
- DeviceListEntry,
- SortKey);
+ /* Make sure the list isn't empty */
+ NextEntry = &DeviceQueue->DeviceListHead;
+ if (!IsListEmpty(NextEntry))
+ {
+ /* Get the last entry */
+ LastEntry = CONTAINING_RECORD(NextEntry->Blink,
+ KDEVICE_QUEUE_ENTRY,
+ DeviceListEntry);
+
+ /* Check if our sort key is lower */
+ if (SortKey < LastEntry->SortKey)
+ {
+ /* Loop each sort key */
+ do
+ {
+ /* Get the next entry */
+ NextEntry = NextEntry->Flink;
+ LastEntry = CONTAINING_RECORD(NextEntry,
+ KDEVICE_QUEUE_ENTRY,
+ DeviceListEntry);
+
+ /* Keep looping until we find a place to insert */
+ } while (SortKey >= LastEntry->SortKey);
+ }
+ }
+
+ /* Now insert us */
+ InsertTailList(NextEntry, &DeviceQueueEntry->DeviceListEntry);
Inserted = TRUE;
}
@@ -199,39 +223,33 @@
KDEVICE_QUEUE_ENTRY,
DeviceListEntry);
- if (SortKey >= ReturnEntry->SortKey)
- {
+ /* Check if we can just get the first entry */
+ if (ReturnEntry->SortKey <= SortKey)
+ {
+ /* Get the first entry */
ReturnEntry = CONTAINING_RECORD(ListEntry->Flink,
KDEVICE_QUEUE_ENTRY,
DeviceListEntry);
-
- /* Remove it from the list */
- RemoveEntryList(&ReturnEntry->DeviceListEntry);
}
else
{
- /* Find entry with SortKey greater than or equal to the passed-in SortKey */
- LIST_FOR_EACH(ReturnEntry, &DeviceQueue->DeviceListHead,
KDEVICE_QUEUE_ENTRY, DeviceListEntry)
+ /* Loop the list */
+ ListEntry = DeviceQueue->DeviceListHead.Flink;
+ while (TRUE)
{
- /* Check if keys match */
- if (ReturnEntry->SortKey >= SortKey)
- {
- /* We found it, so just remove it */
- RemoveEntryList(&ReturnEntry->DeviceListEntry);
- break;
- }
- }
-
- /* Check if we found something */
- if (!ReturnEntry)
- {
- /* Not found, return the first entry */
- ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead);
+ /* Get the next entry and check if the key is low enough */
ReturnEntry = CONTAINING_RECORD(ListEntry,
KDEVICE_QUEUE_ENTRY,
DeviceListEntry);
+ if (SortKey <= ReturnEntry->SortKey) break;
+
+ /* Try the next one */
+ ListEntry = ListEntry->Flink;
}
}
+
+ /* We have an entry, remove it now */
+ RemoveEntryList(&ReturnEntry->DeviceListEntry);
/* Set it as non-inserted */
ReturnEntry->Inserted = FALSE;