mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 14:53:16 +00:00
Add ASSERTs
Correct a bug when processing IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation (serenum) Don't breakpoint if NDEBUG is defined (serenum) Allow to write more than 16 bytes in one IRP_MJ_WRITE (serial) svn path=/trunk/; revision=14627
This commit is contained in:
parent
df118afc6f
commit
fc68dda45d
11 changed files with 74 additions and 24 deletions
|
@ -199,7 +199,7 @@ SerenumWait(ULONG milliseconds)
|
||||||
KTIMER Timer;
|
KTIMER Timer;
|
||||||
LARGE_INTEGER DueTime;
|
LARGE_INTEGER DueTime;
|
||||||
|
|
||||||
DueTime.QuadPart = -milliseconds * 10;
|
DueTime.QuadPart = milliseconds * -10;
|
||||||
KeInitializeTimer(&Timer);
|
KeInitializeTimer(&Timer);
|
||||||
KeSetTimer(&Timer, DueTime, NULL);
|
KeSetTimer(&Timer, DueTime, NULL);
|
||||||
return KeWaitForSingleObject(&Timer, Executive, KernelMode, FALSE, NULL);
|
return KeWaitForSingleObject(&Timer, Executive, KernelMode, FALSE, NULL);
|
||||||
|
|
|
@ -14,10 +14,12 @@
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
SerenumDuplicateUnicodeString(
|
SerenumDuplicateUnicodeString(
|
||||||
OUT PUNICODE_STRING Destination,
|
OUT PUNICODE_STRING Destination,
|
||||||
IN PUNICODE_STRING Source,
|
IN PUNICODE_STRING Source,
|
||||||
IN POOL_TYPE PoolType)
|
IN POOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
|
ASSERT(Destination);
|
||||||
|
|
||||||
if (Source == NULL)
|
if (Source == NULL)
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(Destination, NULL);
|
RtlInitUnicodeString(Destination, NULL);
|
||||||
|
@ -52,6 +54,8 @@ SerenumInitMultiSzString(
|
||||||
ULONG DestinationSize = 0;
|
ULONG DestinationSize = 0;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
ASSERT(Destination);
|
||||||
|
|
||||||
/* Calculate length needed for destination unicode string */
|
/* Calculate length needed for destination unicode string */
|
||||||
va_start(args, Destination);
|
va_start(args, Destination);
|
||||||
Source = va_arg(args, PCSZ);
|
Source = va_arg(args, PCSZ);
|
||||||
|
@ -133,6 +137,8 @@ ForwardIrpAndWait(
|
||||||
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
||||||
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||||
|
|
||||||
|
ASSERT(LowerDevice);
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
|
|
||||||
|
@ -162,6 +168,7 @@ ForwardIrpToLowerDeviceAndForget(
|
||||||
ASSERT(DeviceExtension->Common.IsFDO);
|
ASSERT(DeviceExtension->Common.IsFDO);
|
||||||
|
|
||||||
LowerDevice = DeviceExtension->LowerDevice;
|
LowerDevice = DeviceExtension->LowerDevice;
|
||||||
|
ASSERT(LowerDevice);
|
||||||
DPRINT("Serenum: calling lower device 0x%p [%wZ]\n",
|
DPRINT("Serenum: calling lower device 0x%p [%wZ]\n",
|
||||||
LowerDevice, &LowerDevice->DriverObject->DriverName);
|
LowerDevice, &LowerDevice->DriverObject->DriverName);
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
@ -180,6 +187,7 @@ ForwardIrpToAttachedFdoAndForget(
|
||||||
ASSERT(!DeviceExtension->Common.IsFDO);
|
ASSERT(!DeviceExtension->Common.IsFDO);
|
||||||
|
|
||||||
Fdo = DeviceExtension->AttachedFdo;
|
Fdo = DeviceExtension->AttachedFdo;
|
||||||
|
ASSERT(Fdo);
|
||||||
DPRINT("Serenum: calling attached Fdo 0x%p [%wZ]\n",
|
DPRINT("Serenum: calling attached Fdo 0x%p [%wZ]\n",
|
||||||
Fdo, &Fdo->DriverObject->DriverName);
|
Fdo, &Fdo->DriverObject->DriverName);
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
@ -195,6 +203,7 @@ ForwardIrpAndForget(
|
||||||
|
|
||||||
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
||||||
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||||
|
ASSERT(LowerDevice);
|
||||||
|
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
return IoCallDriver(LowerDevice, Irp);
|
return IoCallDriver(LowerDevice, Irp);
|
||||||
|
|
|
@ -99,6 +99,7 @@ SerenumPdoQueryDeviceRelations(
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
ObReferenceObject(DeviceObject);
|
ObReferenceObject(DeviceObject);
|
||||||
|
DeviceRelations->Count = 1;
|
||||||
DeviceRelations->Objects[0] = DeviceObject;
|
DeviceRelations->Objects[0] = DeviceObject;
|
||||||
|
|
||||||
*pDeviceRelations = DeviceRelations;
|
*pDeviceRelations = DeviceRelations;
|
||||||
|
|
|
@ -52,7 +52,9 @@ IrpStub(
|
||||||
{
|
{
|
||||||
DPRINT1("Serenum: FDO stub for major function 0x%lx\n",
|
DPRINT1("Serenum: FDO stub for major function 0x%lx\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||||
|
#ifndef NDEBUG
|
||||||
DbgBreakPoint();
|
DbgBreakPoint();
|
||||||
|
#endif
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +75,9 @@ IrpStub(
|
||||||
{
|
{
|
||||||
DPRINT1("Serenum: PDO stub for major function 0x%lx\n",
|
DPRINT1("Serenum: PDO stub for major function 0x%lx\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||||
|
#ifndef NDEBUG
|
||||||
DbgBreakPoint();
|
DbgBreakPoint();
|
||||||
|
#endif
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,12 +104,6 @@ DriverEntry(
|
||||||
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
|
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||||
DriverObject->MajorFunction[i] = IrpStub;
|
DriverObject->MajorFunction[i] = IrpStub;
|
||||||
|
|
||||||
/*DriverObject->MajorFunction[IRP_MJ_CREATE] = SerialCreate;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = SerialClose;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = SerialCleanup;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = SerialRead;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = SerialWrite;*/
|
|
||||||
//DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Serenum;
|
|
||||||
//DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SerialQueryInformation;
|
//DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SerialQueryInformation;
|
||||||
DriverObject->MajorFunction[IRP_MJ_PNP] = SerenumPnp;
|
DriverObject->MajorFunction[IRP_MJ_PNP] = SerenumPnp;
|
||||||
//DriverObject->MajorFunction[IRP_MJ_POWER] = SerialPower;
|
//DriverObject->MajorFunction[IRP_MJ_POWER] = SerialPower;
|
||||||
|
|
|
@ -17,6 +17,7 @@ InitializeCircularBuffer(
|
||||||
IN ULONG BufferSize)
|
IN ULONG BufferSize)
|
||||||
{
|
{
|
||||||
DPRINT("Serial: InitializeCircularBuffer(pBuffer %p, BufferSize %lu)\n", pBuffer, BufferSize);
|
DPRINT("Serial: InitializeCircularBuffer(pBuffer %p, BufferSize %lu)\n", pBuffer, BufferSize);
|
||||||
|
ASSERT(pBuffer);
|
||||||
pBuffer->Buffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, BufferSize * sizeof(UCHAR), SERIAL_TAG);
|
pBuffer->Buffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, BufferSize * sizeof(UCHAR), SERIAL_TAG);
|
||||||
if (!pBuffer->Buffer)
|
if (!pBuffer->Buffer)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -30,6 +31,7 @@ FreeCircularBuffer(
|
||||||
IN PCIRCULAR_BUFFER pBuffer)
|
IN PCIRCULAR_BUFFER pBuffer)
|
||||||
{
|
{
|
||||||
DPRINT("Serial: FreeCircularBuffer(pBuffer %p)\n", pBuffer);
|
DPRINT("Serial: FreeCircularBuffer(pBuffer %p)\n", pBuffer);
|
||||||
|
ASSERT(pBuffer);
|
||||||
ExFreePoolWithTag(pBuffer->Buffer, SERIAL_TAG);
|
ExFreePoolWithTag(pBuffer->Buffer, SERIAL_TAG);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,7 @@ IsCircularBufferEmpty(
|
||||||
IN PCIRCULAR_BUFFER pBuffer)
|
IN PCIRCULAR_BUFFER pBuffer)
|
||||||
{
|
{
|
||||||
DPRINT("Serial: IsCircularBufferEmpty(pBuffer %p)\n", pBuffer);
|
DPRINT("Serial: IsCircularBufferEmpty(pBuffer %p)\n", pBuffer);
|
||||||
|
ASSERT(pBuffer);
|
||||||
return (pBuffer->ReadPosition == pBuffer->WritePosition);
|
return (pBuffer->ReadPosition == pBuffer->WritePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +52,7 @@ PushCircularBufferEntry(
|
||||||
{
|
{
|
||||||
ULONG NextPosition;
|
ULONG NextPosition;
|
||||||
DPRINT("Serial: PushCircularBufferEntry(pBuffer %p, Entry 0x%x)\n", pBuffer, Entry);
|
DPRINT("Serial: PushCircularBufferEntry(pBuffer %p, Entry 0x%x)\n", pBuffer, Entry);
|
||||||
|
ASSERT(pBuffer);
|
||||||
ASSERT(pBuffer->Length);
|
ASSERT(pBuffer->Length);
|
||||||
NextPosition = (pBuffer->WritePosition + 1) % pBuffer->Length;
|
NextPosition = (pBuffer->WritePosition + 1) % pBuffer->Length;
|
||||||
if (NextPosition == pBuffer->ReadPosition)
|
if (NextPosition == pBuffer->ReadPosition)
|
||||||
|
@ -64,6 +68,7 @@ PopCircularBufferEntry(
|
||||||
OUT PUCHAR Entry)
|
OUT PUCHAR Entry)
|
||||||
{
|
{
|
||||||
DPRINT("Serial: PopCircularBufferEntry(pBuffer %p)\n", pBuffer);
|
DPRINT("Serial: PopCircularBufferEntry(pBuffer %p)\n", pBuffer);
|
||||||
|
ASSERT(pBuffer);
|
||||||
ASSERT(pBuffer->Length);
|
ASSERT(pBuffer->Length);
|
||||||
if (IsCircularBufferEmpty(pBuffer))
|
if (IsCircularBufferEmpty(pBuffer))
|
||||||
return STATUS_ARRAY_BOUNDS_EXCEEDED;
|
return STATUS_ARRAY_BOUNDS_EXCEEDED;
|
||||||
|
@ -80,6 +85,7 @@ IncreaseCircularBufferSize(
|
||||||
PUCHAR NewBuffer;
|
PUCHAR NewBuffer;
|
||||||
|
|
||||||
DPRINT("Serial: IncreaseCircularBufferSize(pBuffer %p, NewBufferSize %lu)\n", pBuffer, NewBufferSize);
|
DPRINT("Serial: IncreaseCircularBufferSize(pBuffer %p, NewBufferSize %lu)\n", pBuffer, NewBufferSize);
|
||||||
|
ASSERT(pBuffer);
|
||||||
ASSERT(pBuffer->Length);
|
ASSERT(pBuffer->Length);
|
||||||
if (pBuffer->Length > NewBufferSize)
|
if (pBuffer->Length > NewBufferSize)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
|
@ -26,6 +26,8 @@ SerialCreate(
|
||||||
FileObject = Stack->FileObject;
|
FileObject = Stack->FileObject;
|
||||||
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
ASSERT(FileObject);
|
||||||
|
|
||||||
if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
|
if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
|
@ -20,10 +20,10 @@ SerialGetUserBuffers(
|
||||||
OUT PVOID* BufferIn,
|
OUT PVOID* BufferIn,
|
||||||
OUT PVOID* BufferOut)
|
OUT PVOID* BufferOut)
|
||||||
{
|
{
|
||||||
ASSERT(Irp);
|
ASSERT(Irp);
|
||||||
ASSERT(BufferIn);
|
ASSERT(BufferIn);
|
||||||
ASSERT(BufferOut);
|
ASSERT(BufferOut);
|
||||||
|
|
||||||
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
|
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
|
||||||
{
|
{
|
||||||
case METHOD_BUFFERED:
|
case METHOD_BUFFERED:
|
||||||
|
@ -118,6 +118,9 @@ SerialSetLineControl(
|
||||||
UCHAR Lcr = 0;
|
UCHAR Lcr = 0;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
ASSERT(DeviceExtension);
|
||||||
|
ASSERT(NewSettings);
|
||||||
|
|
||||||
DPRINT("Serial: SerialSetLineControl(COM%lu, Settings { %lu %lu %lu })\n",
|
DPRINT("Serial: SerialSetLineControl(COM%lu, Settings { %lu %lu %lu })\n",
|
||||||
DeviceExtension->ComPort, NewSettings->StopBits, NewSettings->Parity, NewSettings->WordLength);
|
DeviceExtension->ComPort, NewSettings->StopBits, NewSettings->Parity, NewSettings->WordLength);
|
||||||
|
|
||||||
|
@ -184,6 +187,8 @@ BOOLEAN
|
||||||
SerialClearPerfStats(
|
SerialClearPerfStats(
|
||||||
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
|
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
|
||||||
{
|
{
|
||||||
|
ASSERT(DeviceExtension);
|
||||||
|
|
||||||
RtlZeroMemory(&DeviceExtension->SerialPerfStats, sizeof(SERIALPERF_STATS));
|
RtlZeroMemory(&DeviceExtension->SerialPerfStats, sizeof(SERIALPERF_STATS));
|
||||||
DeviceExtension->BreakInterruptErrorCount = 0;
|
DeviceExtension->BreakInterruptErrorCount = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -195,6 +200,7 @@ SerialGetPerfStats(IN PIRP pIrp)
|
||||||
PSERIAL_DEVICE_EXTENSION pDeviceExtension;
|
PSERIAL_DEVICE_EXTENSION pDeviceExtension;
|
||||||
pDeviceExtension = (PSERIAL_DEVICE_EXTENSION)
|
pDeviceExtension = (PSERIAL_DEVICE_EXTENSION)
|
||||||
IoGetCurrentIrpStackLocation(pIrp)->DeviceObject->DeviceExtension;
|
IoGetCurrentIrpStackLocation(pIrp)->DeviceObject->DeviceExtension;
|
||||||
|
ASSERT(DeviceExtension);
|
||||||
/*
|
/*
|
||||||
* we assume buffer is big enough to hold SerialPerfStats structure
|
* we assume buffer is big enough to hold SerialPerfStats structure
|
||||||
* caller must verify this
|
* caller must verify this
|
||||||
|
@ -212,6 +218,8 @@ SerialGetCommProp(
|
||||||
OUT PSERIAL_COMMPROP pCommProp,
|
OUT PSERIAL_COMMPROP pCommProp,
|
||||||
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
|
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
|
||||||
{
|
{
|
||||||
|
ASSERT(pCommProp);
|
||||||
|
|
||||||
RtlZeroMemory(pCommProp, sizeof(SERIAL_COMMPROP));
|
RtlZeroMemory(pCommProp, sizeof(SERIAL_COMMPROP));
|
||||||
|
|
||||||
pCommProp->PacketLength = sizeof(SERIAL_COMMPROP);
|
pCommProp->PacketLength = sizeof(SERIAL_COMMPROP);
|
||||||
|
@ -257,6 +265,7 @@ SerialGetCommStatus(
|
||||||
{
|
{
|
||||||
KIRQL Irql;
|
KIRQL Irql;
|
||||||
|
|
||||||
|
ASSERT(pSerialStatus);
|
||||||
RtlZeroMemory(pSerialStatus, sizeof(SERIAL_STATUS));
|
RtlZeroMemory(pSerialStatus, sizeof(SERIAL_STATUS));
|
||||||
|
|
||||||
pSerialStatus->Errors = 0;
|
pSerialStatus->Errors = 0;
|
||||||
|
|
|
@ -37,12 +37,13 @@ SerialQueryInformation(
|
||||||
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FileStandardInformation\n");
|
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FileStandardInformation\n");
|
||||||
if (BufferLength < sizeof(FILE_STANDARD_INFORMATION))
|
if (BufferLength < sizeof(FILE_STANDARD_INFORMATION))
|
||||||
Status = STATUS_BUFFER_OVERFLOW;
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
else
|
else if (!StandardInfo)
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
{
|
{
|
||||||
StandardInfo->AllocationSize.QuadPart = 0;
|
StandardInfo->AllocationSize.QuadPart = 0;
|
||||||
StandardInfo->EndOfFile.QuadPart = 0;
|
StandardInfo->EndOfFile.QuadPart = 0;
|
||||||
StandardInfo->Directory = FALSE;
|
StandardInfo->Directory = FALSE;
|
||||||
StandardInfo->NumberOfLinks = 0;
|
StandardInfo->NumberOfLinks = 0;
|
||||||
StandardInfo->DeletePending = FALSE; /* FIXME: should be TRUE sometimes */
|
StandardInfo->DeletePending = FALSE; /* FIXME: should be TRUE sometimes */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -52,9 +53,13 @@ SerialQueryInformation(
|
||||||
{
|
{
|
||||||
PFILE_POSITION_INFORMATION PositionInfo = (PFILE_POSITION_INFORMATION)SystemBuffer;
|
PFILE_POSITION_INFORMATION PositionInfo = (PFILE_POSITION_INFORMATION)SystemBuffer;
|
||||||
|
|
||||||
|
ASSERT(PositionInfo);
|
||||||
|
|
||||||
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FilePositionInformation\n");
|
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FilePositionInformation\n");
|
||||||
if (BufferLength < sizeof(PFILE_POSITION_INFORMATION))
|
if (BufferLength < sizeof(PFILE_POSITION_INFORMATION))
|
||||||
Status = STATUS_BUFFER_OVERFLOW;
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
|
else if (!PositionInfo)
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PositionInfo->CurrentByteOffset.QuadPart = 0;
|
PositionInfo->CurrentByteOffset.QuadPart = 0;
|
||||||
|
|
|
@ -32,6 +32,8 @@ ForwardIrpAndWait(
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
ASSERT(LowerDevice);
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
|
|
||||||
|
@ -56,6 +58,8 @@ ForwardIrpAndForget(
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT LowerDevice = ((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
PDEVICE_OBJECT LowerDevice = ((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||||
|
|
||||||
|
ASSERT(LowerDevice);
|
||||||
|
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
return IoCallDriver(LowerDevice, Irp);
|
return IoCallDriver(LowerDevice, Irp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ SerialAddDeviceInternal(
|
||||||
static ULONG ComPortNumber = 1;
|
static ULONG ComPortNumber = 1;
|
||||||
|
|
||||||
DPRINT("Serial: SerialAddDeviceInternal called\n");
|
DPRINT("Serial: SerialAddDeviceInternal called\n");
|
||||||
|
|
||||||
|
ASSERT(DeviceObject);
|
||||||
|
ASSERT(Pdo);
|
||||||
|
|
||||||
/* Create new device object */
|
/* Create new device object */
|
||||||
swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
|
swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
|
||||||
|
@ -125,12 +128,10 @@ SerialAddDevice(
|
||||||
if (Pdo == NULL)
|
if (Pdo == NULL)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
/* We have here a PDO that does not correspond to a legacy
|
/* We have here a PDO not null. It represents a real serial
|
||||||
* serial port. So call the internal AddDevice function.
|
* port. So call the internal AddDevice function.
|
||||||
*/
|
*/
|
||||||
return SerialAddDeviceInternal(DriverObject, Pdo, UartUnknown, NULL, NULL);
|
return SerialAddDeviceInternal(DriverObject, Pdo, UartUnknown, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
|
@ -160,6 +161,8 @@ SerialPnpStartDevice(
|
||||||
|
|
||||||
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
ASSERT(ResourceList);
|
||||||
|
ASSERT(DeviceExtension);
|
||||||
ASSERT(DeviceExtension->PnpState == dsStopped);
|
ASSERT(DeviceExtension->PnpState == dsStopped);
|
||||||
|
|
||||||
DeviceExtension->BaudRate = 19200 | SERIAL_BAUD_USER;
|
DeviceExtension->BaudRate = 19200 | SERIAL_BAUD_USER;
|
||||||
|
|
|
@ -37,6 +37,9 @@ ReadBytes(
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
ASSERT(DeviceObject);
|
||||||
|
ASSERT(WorkItemData);
|
||||||
|
|
||||||
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
|
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
|
||||||
Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length;
|
Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length;
|
||||||
|
@ -285,9 +288,19 @@ SerialWrite(
|
||||||
Status = PushCircularBufferEntry(&DeviceExtension->OutputBuffer, Buffer[Information]);
|
Status = PushCircularBufferEntry(&DeviceExtension->OutputBuffer, Buffer[Information]);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Serial: buffer overrun on COM%lu\n", DeviceExtension->ComPort);
|
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||||
DeviceExtension->SerialPerfStats.BufferOverrunErrorCount++;
|
{
|
||||||
break;
|
KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql);
|
||||||
|
SerialSendByte(NULL, DeviceExtension, NULL, NULL);
|
||||||
|
KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("Serial: buffer overrun on COM%lu\n", DeviceExtension->ComPort);
|
||||||
|
DeviceExtension->SerialPerfStats.BufferOverrunErrorCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Information++;
|
Information++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue