Problems reading from a file on the network during open completio-n.

Hi All,

Firstly, thanks to the two who replied to my last message, sending a
IRP_MJ_CLEANUP then an IRP_MJ_CLOSE fixed the problem I had.

My new problem is this!

In my worker during open completion I read a header from the file that was
opened.
The code below works for all local filesystems, mapped and non mapped
network drives, apart from in one case.
This one case is when I’m trying to read the header during when the file has
been opened CreateProcess.
IoCallDriver returns STATUS_INVALID_PARAMETER / 0xC000000D.
Open for the same file in notepad works fine.


KeInitializeEvent( &kEvent, NotificationEvent, FALSE );
pReadIrp = IoBuildSynchronousFsdRequest( IRP_MJ_READ, pDeviceObject,
pBuffer, Length, Offset, &kEvent, pIoStatusBlock );

if( pReadIrp )
{
PIO_STACK_LOCATION pReadStack = IoGetNextIrpStackLocation( pReadIrp
);

OrigByteOffset = pFileObject->CurrentByteOffset;

pReadIrp->Flags = IRP_NOCACHE | IRP_READ_OPERATION;

pReadIrp->Tail.Overlay.Thread = KeGetCurrentThread();
pReadIrp->RequestorMode = KernelMode;

pReadStack->FileObject = pFileObject;
pReadStack->DeviceObject = pDeviceObject;

ntStatus = IoCallDriver( pDeviceObject, pReadIrp );

if (ntStatus == STATUS_PENDING)
KeWaitForSingleObject( &kEvent, Executive, KernelMode,
FALSE, NULL );
else
IoStatusBlock->Status = ntStatus;

pFileObject->CurrentByteOffset = OrigByteOffset;
}

Rob Linegar
Software Engineer
Data Encryption Systems Limited