IoCallDriver( IRP_MJ_READ ) returns immediately

IoCallDriver( IRP_MJ_READ ) returns immediately

Post by SM » Wed, 08 Oct 2003 20:33:43


Hello group,
i'm writing a virtual serial driver that open another
serial port using IoGetDeviceObjectPointer() function.
I need to build an hidden protocol so i need to receive
a 3-byte data packet from the real serial port and
recreate the coded event on my virtual port.

I'm in a trouble reading the data from the real port:
i wrote the following function to build a synchronous IRP to read a char:

NTSTATUS Read(IN PREMSER_DEVICE_EXTENSION pDevExt, PUCHAR pRxBuffer)
{
PIRP pSerIrp;
KEVENT evRx;
NTSTATUS status;
LARGE_INTEGER liStartOffs = RtlConvertLongToLargeInteger(0);
IO_STATUS_BLOCK iosb;

KeInitializeEvent ( &evRx, NotificationEvent, FALSE);

KdPrint(("-- Waiting char %X %X\n", pDevExt->pSerialObj, pDevExt->pFileObj));
pSerIrp = IoBuildSynchronousFsdRequest(
IRP_MJ_READ,
pDevExt->pSerialObj,
pRxBuffer, 1,
&liStartOffs, &evRx, &iosb
);

if(pSerIrp==NULL)
{
KdPrint((" NO IRP Rx\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}

status = IoCallDriver( pDevExt->pSerialObj, pSerIrp);
if (status==STATUS_PENDING) {
status = KeWaitForSingleObject( &evRx, Executive, KernelMode, FALSE, NULL);
}
status = iosb.Status;
DbgPrint("-> Read #b=%d - 0x%02X [0x%X]\n", iosb.Information, *pRxBuffer,
status);
return status;
}

The problem is that the IoCallDriver() return immediately,
the event is signalled, all the status variables are SUCCESS but
iosb.Information is always 0 (bytes read).

Anyone can help me ?
Of course, i need to wait for a char and read the correct char ....

Thanks
regards
 
 
 

IoCallDriver( IRP_MJ_READ ) returns immediately

Post by Slava M. U » Wed, 08 Oct 2003 21:13:30


[...]


Do you set the timeouts? Geez, why do I ask the same questions twice a day
:-)

S

 
 
 

IoCallDriver( IRP_MJ_READ ) returns immediately

Post by SM » Thu, 09 Oct 2003 00:09:02

Thanks a lot again .....
"Slava M. Usov" < XXXX@XXXXX.COM > ha scritto nel messaggio