RE: problems while trying to read file from driver in win 2k

Give it an offset. Since you didn’t specify synchronous I/O on the file,
you are responsible for providing the offset parameter to the read call.

Alternatively, use FILE_SYNCHRONOUS_IO_NONALERT in addition to
FILE_NON_DIRECTORY_FILE when you open the file. Then you can rely on the
current byte offset.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Girish Gurunathan [mailto:xxxxx@wipro.com]
Sent: Tuesday, April 30, 2002 8:52 AM
To: NT Developers Interest List
Subject: [ntdev] problems while trying to read file from driver in win2k

Hi,

I am trying to read a structure from a file (HDD) into the device
extension of my driver,

{
[…]

RtlInitUnicodeString(&PathPrefix, L"\??\");
/* Allocate memory for full path name */
FullPath.MaximumLength = puniFileName->MaximumLength +
PathPrefix.Length;
FullPath.Buffer = (PWCHAR)ExAllocatePool(NonPagedPool,
FullPath.MaximumLength);

RtlCopyUnicodeString(&FullPath, &PathPrefix);
RtlAppendUnicodeStringToString(&FullPath, puniFileName);

/* Open the file */
InitializeObjectAttributes(&objAttrib, &FullPath, OBJ_CASE_INSENSITIVE
| OBJ_KERNEL_HANDLE, NULL, NULL);

status = ZwCreateFile(&hFile, GENERIC_READ | GENERIC_WRITE,
&objAttrib,
&ioStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN,
FILE_NON_DIRECTORY_FILE, NULL, 0);

[…]

status = ZwReadFile(hFile, NULL, NULL, NULL, &ioStatusBlock,
&(pDevExt->MyInfo), sizeof(MY_INFO_t), NULL, NULL);

[…]
}

I am able to open the file, but ZwReadFile fails with error code C000000D
(STATUS_INVALID_PARAMETER). The code (above) is called from an IOCTL (from
user mode) dispatch routine.

Anyone?

  • Girish

You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to %%email.unsub%%