DDK Topic Feedback

Hi,
When I Open a file by using ZwCreateFile in file system filter driver:

ZwCreateFile(
&FileHandle,
FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,
FILE_OPEN
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS,// |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

Then I will random access the file by calling
ZwSetInformationFile(FileHandle,&IoStatusBlock,
&position, sizeof(FILE_POSITION_INFORMATION),FilePositionInformation);

to set current read/write position. It works only first 3 times, then I got status = 0xC000000D.

Can any one have any idea to fix that. Thanks advance for any help.

Xj. Fu

Build date: Thursday, January 16, 2003 Topic Title: FILE_POSITION_INFORMATION

Of course, you don’t show us the object attributes you set for this
operation, which is where I suspect the issue arises. Might I suggest
that you use OBJ_KERNEL_HANDLE if you are not already so doing? This
ensures that the handle is valid in ANY process context, not just in the
process that was running at the time you called ZwCreateFile.

I’d also suggest that you use IoCreateFileSpecifyDeviceObjectHint (if it
is available) and IoCreateFile (if it is not). But these are not
causing your specific problem, they just head off other problems you’ll
see in the future.

Regards,

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com http:</http:>


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 2:05 AM
To: ntfsd redirect
Cc: ntfsd redirect
Subject: [ntfsd] DDK Topic Feedback

Hi,

When I Open a file by using ZwCreateFile in file system filter
driver:

ZwCreateFile(
&FileHandle,
FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,

FILE_OPEN
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS,// |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

Then I will random access the file by calling

ZwSetInformationFile(FileHandle,&IoStatusBlock,
&position,
sizeof(FILE_POSITION_INFORMATION),FilePositionInformation);

to set current read/write position. It works only first 3 times, then I
got status = 0xC000000D.

Can any one have any idea to fix that. Thanks advance for any help.

Xj. Fu

Build date: Thursday, January 16, 2003 Topic Title:
FILE_POSITION_INFORMATION —
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you, Tony,

I did set OBJ_KERNEL_HANDLE like below:

RtlInitUnicodeString( &ObjectName,FileName);

InitializeObjectAttributes(
&ObjectAttributes,
&ObjectName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL)

The file name like “??\c:\folder\file”

The file was open, and I did some of read, and write by calling ZwReadFile and ZwWriteFile. First 5 time read and write are fine, than I get return status as 0xC000000D.

Regards,

Xj. Fu
----- Original Message -----
From: Tony Mason
To: Windows File Systems Devs Interest List
Sent: Monday, February 21, 2005 11:36 PM
Subject: RE: [ntfsd] DDK Topic Feedback

Of course, you don’t show us the object attributes you set for this operation, which is where I suspect the issue arises. Might I suggest that you use OBJ_KERNEL_HANDLE if you are not already so doing? This ensures that the handle is valid in ANY process context, not just in the process that was running at the time you called ZwCreateFile.

I’d also suggest that you use IoCreateFileSpecifyDeviceObjectHint (if it is available) and IoCreateFile (if it is not). But these are not causing your specific problem, they just head off other problems you’ll see in the future.

Regards,

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 2:05 AM
To: ntfsd redirect
Cc: ntfsd redirect
Subject: [ntfsd] DDK Topic Feedback

Hi,

When I Open a file by using ZwCreateFile in file system filter driver:

ZwCreateFile(
&FileHandle,
FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,

FILE_OPEN
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS,// |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

Then I will random access the file by calling

ZwSetInformationFile(FileHandle,&IoStatusBlock,
&position, sizeof(FILE_POSITION_INFORMATION),FilePositionInformation);

to set current read/write position. It works only first 3 times, then I got status = 0xC000000D.

Can any one have any idea to fix that. Thanks advance for any help.

Xj. Fu

Build date: Thursday, January 16, 2003 Topic Title: FILE_POSITION_INFORMATION —
Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Well, looking up the error (there are numerous ways to do this, I just
looked in ntstatus.h):

#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)

So the underlying FSD is not happy about what you are passing to it.

But in re-reading your note I note that I’m not sure which function is
returning this; my first reading was that it was the SetInformation
operation that failed, but then reading your second note it sounds like
it might be a read or write operation that is failing. Set information
only fails (as far as I can tell) if the file is opened for non-cached
I/O and you seek to a non-aligned location. Read seems to only fail if
you read from an open directory. Neither of these seem to apply to your
case, so unfortunately, you will probably have to debug the specifics of
the failure. One disadvantage of a layered system is that an operation
can fail at a variety of different locations and it can sometimes be
difficult to figure out which layer failed the request.

I would suggest using IrpTracker to watch the system calls and the IRPs
passed in order to narrow down the specific location of the failure.
Then, using the IFS Kit samples, you should be able to further refine
information about where the request is failing.

I hope this helps.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com http:</http:>


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 3:35 AM
To: ntfsd redirect
Subject: Re: [ntfsd] DDK Topic Feedback

Thank you, Tony,

I did set OBJ_KERNEL_HANDLE like below:

RtlInitUnicodeString( &ObjectName,FileName);

InitializeObjectAttributes(
&ObjectAttributes,
&ObjectName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL)

The file name like “??\c:\folder\file”

The file was open, and I did some of read, and write by calling
ZwReadFile and ZwWriteFile. First 5 time read and write are fine, than I
get return status as 0xC000000D.

Regards,

Xj. Fu

----- Original Message -----

From: Tony Mason mailto:xxxxx

To: Windows File Systems Devs Interest List
mailto:xxxxx

Sent: Monday, February 21, 2005 11:36 PM

Subject: RE: [ntfsd] DDK Topic Feedback

Of course, you don’t show us the object attributes you set for
this operation, which is where I suspect the issue arises. Might I
suggest that you use OBJ_KERNEL_HANDLE if you are not already so doing?
This ensures that the handle is valid in ANY process context, not just
in the process that was running at the time you called ZwCreateFile.

I’d also suggest that you use
IoCreateFileSpecifyDeviceObjectHint (if it is available) and
IoCreateFile (if it is not). But these are not causing your specific
problem, they just head off other problems you’ll see in the future.

Regards,

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com http:</http:>

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 2:05 AM
To: ntfsd redirect
Cc: ntfsd redirect
Subject: [ntfsd] DDK Topic Feedback

Hi,

When I Open a file by using ZwCreateFile in file system
filter driver:

ZwCreateFile(
&FileHandle,
FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,

FILE_OPEN
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS,// |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

Then I will random access the file by calling

ZwSetInformationFile(FileHandle,&IoStatusBlock,
&position,
sizeof(FILE_POSITION_INFORMATION),FilePositionInformation);

to set current read/write position. It works only first 3 times,
then I got status = 0xC000000D.

Can any one have any idea to fix that. Thanks advance for any
help.

Xj. Fu

Build date: Thursday, January 16, 2003 Topic Title:
FILE_POSITION_INFORMATION —
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com</mailto:xxxxx></mailto:xxxxx>

Thank you Tony,
You had great help for me.
I did try use ZwSetInformationFile to set position and using Offset when call ZwReadFile and ZwWriteFile, Read and write on either 4K size only or mix of 512 Bytes and 4K . Same error code I will get after 3 or 4 times read/write. Do you have any more idea about it? Thank you again.

Regards,
Xj Fu
----- Original Message -----
From: Tony Mason
To: Windows File Systems Devs Interest List
Sent: Tuesday, February 22, 2005 6:16 AM
Subject: RE: [ntfsd] DDK Topic Feedback

Well, looking up the error (there are numerous ways to do this, I just looked in ntstatus.h):

#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)

So the underlying FSD is not happy about what you are passing to it.

But in re-reading your note I note that I’m not sure which function is returning this; my first reading was that it was the SetInformation operation that failed, but then reading your second note it sounds like it might be a read or write operation that is failing. Set information only fails (as far as I can tell) if the file is opened for non-cached I/O and you seek to a non-aligned location. Read seems to only fail if you read from an open directory. Neither of these seem to apply to your case, so unfortunately, you will probably have to debug the specifics of the failure. One disadvantage of a layered system is that an operation can fail at a variety of different locations and it can sometimes be difficult to figure out which layer failed the request.

I would suggest using IrpTracker to watch the system calls and the IRPs passed in order to narrow down the specific location of the failure. Then, using the IFS Kit samples, you should be able to further refine information about where the request is failing.

I hope this helps.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 3:35 AM
To: ntfsd redirect
Subject: Re: [ntfsd] DDK Topic Feedback

Thank you, Tony,

I did set OBJ_KERNEL_HANDLE like below:

RtlInitUnicodeString( &ObjectName,FileName);

InitializeObjectAttributes(
&ObjectAttributes,
&ObjectName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL)

The file name like “??\c:\folder\file”

The file was open, and I did some of read, and write by calling ZwReadFile and ZwWriteFile. First 5 time read and write are fine, than I get return status as 0xC000000D.

Regards,

Xj. Fu

----- Original Message -----

From: Tony Mason

To: Windows File Systems Devs Interest List

Sent: Monday, February 21, 2005 11:36 PM

Subject: RE: [ntfsd] DDK Topic Feedback

Of course, you don’t show us the object attributes you set for this operation, which is where I suspect the issue arises. Might I suggest that you use OBJ_KERNEL_HANDLE if you are not already so doing? This ensures that the handle is valid in ANY process context, not just in the process that was running at the time you called ZwCreateFile.

I’d also suggest that you use IoCreateFileSpecifyDeviceObjectHint (if it is available) and IoCreateFile (if it is not). But these are not causing your specific problem, they just head off other problems you’ll see in the future.

Regards,

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Tuesday, February 22, 2005 2:05 AM
To: ntfsd redirect
Cc: ntfsd redirect
Subject: [ntfsd] DDK Topic Feedback

Hi,

When I Open a file by using ZwCreateFile in file system filter driver:

ZwCreateFile(
&FileHandle,
FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,

FILE_OPEN
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS,// |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

Then I will random access the file by calling

ZwSetInformationFile(FileHandle,&IoStatusBlock,
&position, sizeof(FILE_POSITION_INFORMATION),FilePositionInformation);

to set current read/write position. It works only first 3 times, then I got status = 0xC000000D.

Can any one have any idea to fix that. Thanks advance for any help.

Xj. Fu

Build date: Thursday, January 16, 2003 Topic Title: FILE_POSITION_INFORMATION —
Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Maybe it will help you if you will try to work with the file
the same way in user mode ? Try to write a small testprogram
which makes the same things and see if the error will occur again.

If yes, you may send the WHOLE test program to us and we’ll try to help you.

L.

Thank you. I have resolved this problem by using the way Tony said. Thanks Tony again.

Xj Fu
----- Original Message -----
From: Ladislav Zezula
To: Windows File Systems Devs Interest List
Sent: Tuesday, February 22, 2005 11:33 PM
Subject: Re: [ntfsd] DDK Topic Feedback

Maybe it will help you if you will try to work with the file
the same way in user mode ? Try to write a small testprogram
which makes the same things and see if the error will occur again.

If yes, you may send the WHOLE test program to us and we’ll try to help you.

L.


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com