- 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@reactos.org>
_____

Alex,
 Marry me,
KJK::Hyperion
XOXOXO

See issue #3116 for more details.

svn path=/trunk/; revision=33633
This commit is contained in:
KJK::Hyperion 2008-05-22 11:46:46 +00:00
parent af1376546d
commit b16ac9683a
5 changed files with 44 additions and 52 deletions

View file

@ -52,7 +52,6 @@ NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
ListEntry = ListEntry->Flink;
if (!vfatFCBIsDirectory(Fcb))
{
if (Fcb->PadPad51) continue; // Corrupt FCB
ExAcquireResourceExclusiveLite(&Fcb->MainResource, TRUE);
Status = VfatFlushFile(DeviceExt, Fcb);
ExReleaseResourceLite (&Fcb->MainResource);

View file

@ -322,21 +322,6 @@ typedef struct _VFATFCB
{
/* 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;

View file

@ -798,9 +798,6 @@ HandleReadIrp(
/* 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 @@ HandleReadIrp(
IoMarkIrpPending(Irp);
DeviceExtension->PendingIrp = Irp;
Status = STATUS_PENDING;
if (!IsInStartIo)
IoStartPacket(DeviceObject, Irp, NULL, NULL);
}
}
return Status;

View file

@ -774,9 +774,6 @@ HandleReadIrp(
/* 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 @@ HandleReadIrp(
IoMarkIrpPending(Irp);
DeviceExtension->PendingIrp = Irp;
Status = STATUS_PENDING;
if (!IsInStartIo)
IoStartPacket(DeviceObject, Irp, NULL, NULL);
}
}
return Status;

View file

@ -86,6 +86,8 @@ KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
{
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 @@ KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
}
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,40 +223,34 @@ KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
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;
}