How comes ZwReadFile cannot work when reading files from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com

Is the read in the same process context as the create?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 9:18 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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

Jamey,
(Remote file write)
my ZwCreateFile() and my ZwWriteFile() are in the same thread which is a
part of a dispatch routine.

Laura.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 12:37 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Is the read in the same process context as the create?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 9:18 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com

What dispatch routine?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 10:42 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Jamey,
(Remote file write)
my ZwCreateFile() and my ZwWriteFile() are in the same thread which is a
part of a dispatch routine.

Laura.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 12:37 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Is the read in the same process context as the create?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 9:18 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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

It is FS filter driver dispatch routine for IRP_MJ_Xxx
Here is my code:

case IRP_MJ_WRITE:

if(isTheFile)
{
DbgPrint((“We Should write here !\n”));

RtlInitUnicodeString(&myObjectName,L"\??\UNC\Test-k9p45xhil5\CopyFile\t
est.txt");

InitializeObjectAttributes(&myObjectAttr,
&myObjectName,OBJ_KERNEL_HANDLE,NULL,NULL);
ntStatus=ZwCreateFile(&myCopyFile,FILE_APPEND_DATA,&myObjectAttr,
&myIoStatus,
NULL,FILE_ATTRIBUTE_NORMAL,FILE_SHARE_READ,
FILE_OPEN_IF,NULL,NULL,0);

hookCompletion=NT_SUCCESS(ntStatus);
if(!hookCompletion)
{
DbgPrint((“Cannot create the target file object.\n”));
}
else
{
WCHAR myBuffer=L"test";
ULONG myLength;
LARGE_INTEGER myByteOffset;
myLength=5;
myByteOffset=currentIrpStack->Parameters.Write.ByteOffset;

ntStatus=ZwWriteFile(myCopyFile,NULL,NULL,NULL,&myIoStatus,myBuffer,
myLength,NULL,NULL);
hookCompletion=NT_SUCCESS(ntStatus);
if(!hookCompletion){
DbgPrint((“Filemirr: Could not Write to remote file\n”));
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 1:53 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

What dispatch routine?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 10:42 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Jamey,
(Remote file write)
my ZwCreateFile() and my ZwWriteFile() are in the same thread which is a
part of a dispatch routine.

Laura.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 12:37 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Is the read in the same process context as the create?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 9:18 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
To unsubscribe sen
d a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com

The problem is that the read and write routines can and will be called
at a raised IRQL (<= DISPATCH) to handle paging request from the memory
manager (memory mapped files and cached files).

You need to get the IRP to passive level first and then do you IO.

Also, it is very inefficient to open and close on the read and write
routines.

You should create a worker thread and a queue the IRPS to that worker
thread; this puts you in passive level. You should also keep the file
open (say from the time the thread is created until the time the thread
terminates), or something like this.

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 11:16 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

It is FS filter driver dispatch routine for IRP_MJ_Xxx
Here is my code:

case IRP_MJ_WRITE:

if(isTheFile)
{
DbgPrint((“We Should write here !\n”));

RtlInitUnicodeString(&myObjectName,L"\??\UNC\Test-k9p45xhil5\CopyFil
e\t
est.txt");

InitializeObjectAttributes(&myObjectAttr,
&myObjectName,OBJ_KERNEL_HANDLE,NULL,NULL);
ntStatus=ZwCreateFile(&myCopyFile,FILE_APPEND_DATA,&myObjectAttr,
&myIoStatus,
NULL,FILE_ATTRIBUTE_NORMAL,FILE_SHARE_READ,
FILE_OPEN_IF,NULL,NULL,0);

hookCompletion=NT_SUCCESS(ntStatus);
if(!hookCompletion)
{
DbgPrint((“Cannot create the target file object.\n”));
}
else
{
WCHAR myBuffer=L"test";
ULONG myLength;
LARGE_INTEGER myByteOffset;
myLength=5;
myByteOffset=currentIrpStack->Parameters.Write.ByteOffset;

ntStatus=ZwWriteFile(myCopyFile,NULL,NULL,NULL,&myIoStatus,myBuffer,
myLength,NULL,NULL);
hookCompletion=NT_SUCCESS(ntStatus);
if(!hookCompletion){
DbgPrint((“Filemirr: Could not Write to remote file\n”));
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 1:53 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

What dispatch routine?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 10:42 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Jamey,
(Remote file write)
my ZwCreateFile() and my ZwWriteFile() are in the same thread which is a
part of a dispatch routine.

Laura.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Tuesday, May 28, 2002 12:37 PM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Is the read in the same process context as the create?

Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of gaoren
Sent: Tuesday, May 28, 2002 9:18 AM
To: File Systems Developers
Subject: [ntfsd] RE: How comes ZwReadFile cannot work when reading files
from remote machine

Dear Philip,
I met the same problem with ZwWriteFile().
Could you tell me the solution after you get any answer?
(I posted my question here. but no answer.)
Thank you very much.

Laura

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Philip Hong
Sent: Tuesday, May 28, 2002 6:55 AM
To: File Systems Developers
Subject: [ntfsd] How comes ZwReadFile cannot work when reading files
from remote machine

Hi all,

I found a problem of using ZwReadFile for reading files from a mapped
drive of a remote machine.

I found that I can successfully opened a remote file by using

ZwOpenFile(&ntFileHandle, SYNCHRONIZE | FILE_ANY_ACCESS,
&objectAttributes, &ioStatus,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE |
FILE_NO_INTERMEDIATE_BUFFERING);

But, I got error either 0xC0000008 or 0xC000020C when using

ZwReadFile(ntFileHandle, NULL, NULL, NULL,
&ioStatus, buf, buf_size, 0, NULL);

How can I solve the above problem ?

Thanks in advance.

– Philip


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
To unsubscribe sen
d a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com


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