You’re so occupied by thinking about usage of completion ports.
They were probably not designed to be used by kernel mode
components by Microsoft, because there is no available API
to utilize them in kernel mode. I stongly recommend you to go
the way I uncovered rather than trying to do something foolishly.
Being in kernel mode you have the same potential as the completion
ports represent in user mode, so why don’t you use them?
Paul
PS: As far as APC is concerned, you don’t need it if you’re all
in kernel mode. This is important mainly for doing something
in the context of some user thread (and process), like access
to user mode memory, manage user handles etc.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of osmlist
Sent: Wednesday, November 27, 2002 6:13 PM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile and APC
Zpr?vaThanks Paul,
Yes you just remaind me the ObReferenceObjectByHandle and
IoGetRelatedDeviceObject and then you right in this way I don’t need all
the 64 events.
Maybe I’ll implement it using that way.
But once again,
Is anyone know how to use in the kernel APC and Completion port
(ZwCreateIoCompletion and ZwRemoveIoCompletion)
OS.
----- Original Message -----
From: Paul Hrdina
To: NT Developers Interest List
Sent: Wednesday, November 27, 2002 6:47 PM
Subject: [ntdev] Re: ZwWriteFile and APC
I don’t understand you… Forget the ZwWriteFile and focus on
IoBuildAsynchronousFsdRequest. You haven’t answered my question yet - so
you should know that the file must always be opened first using
IoCreateFile (or ZwCreateFile) and then you can do something with it. So
you get a handle and then you can call some file ZwXxxx routines, but
when you want to call the FSD directly, you should obtain file object
pointer. Use ObReferenceObjectByHandle to do this and then you also need
device object to pass it to IoCallDriver. Obtain it using
IoGetRelatedDeviceObject. Finally, how to specify the file object in the
request? Set the FileObject in the next Irp stack location to your file
object pointer and then you can finally call the FSD. And the FSD should
post the request to its worker thread so it will be done asynchronously
- which is what you want to do. Paul
PS: Don’t forget to call IoSetCompletionRoutine before IoCallDriver
;-))).
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of osmlist
Sent: Wednesday, November 27, 2002 5:11 PM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile and APC
Yes but then you need to do the write operation. and I want to do it
asynchronous so you need to supply an event to the ZwWrite function and
then you need a thread that will wait on multiple objects that limit to
64 objects. So Instead of using another thread I’m using the same thread
that the completion routine signals.
OS
----- Original Message -----
From: Paul Hrdina
To: NT Developers Interest List
Sent: Wednesday, November 27, 2002 5:57 PM
Subject: [ntdev] Re: ZwWriteFile and APC
Why 64 events? One kernel queue (KQUEUE) or one semaphore together with
a spin lock can do the same task. Then you have to wait only for one (or
two with the termination event) synchronization object and when the wait
is satisfied you have to remove an entry from the queue and process it.
Paul -----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of osmlist
Sent: Wednesday, November 27, 2002 3:54 PM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile and APC
Actualy you right.
I’m signaling an event (one of the 64) and there is a thread that
responsible for doing the write operation.
----- Original Message -----
From: Paul Hrdina
To: NT Developers Interest List
Sent: Wednesday, November 27, 2002 4:10 PM
Subject: [ntdev] Re: ZwWriteFile and APC
It’s not good, because file Zw routines should be called only at
PASSIVE_LEVEL and your completion routine can be called at <=
DISPATCH_LEVEL. You must have some other thread and call the FSD from
it, passing it the buffer to write from your completion routine. You can
use some kind of queue - insert items from your completion routine and
remove them in your thread.
To your first question I’m asnwering by another question ;-))) “And how
do you specify the file name for ZwWriteFile?”
Paul
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of osmlist
Sent: Wednesday, November 27, 2002 2:46 PM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile and APC
Yes I thought also about this method, and it is possible.
I that way (of using IoBuildAsynchronousFsdRequest) how / where do you
specify the file name?
About using ZwWriteFile inside a completion routine, the answer is Yes,
WHY??
OS.
----- Original Message -----
From: Paul Hrdina
To: NT Developers Interest List
Sent: Wednesday, November 27, 2002 3:27 PM
Subject: [ntdev] Re: ZwWriteFile and APC
And what about to build your own IRP for the IRP_MJ_WRITE and send it to
file system as well as you do it with your device. Then in the
completion routine you can free your buffer for the other request to
your device. Btw, do you currently use the ZwWriteFile inside your
completion routine? Paul -----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of osmlist
Sent: Wednesday, November 27, 2002 1:56 PM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile and APC
Again and maybe more clear I will try to describe what am I tring to do.
I allocated a bunch of buffers.
I have a system thread.
In the system thread I built my own IRP for each buffer and called to a
lower device (IoCallDriver) with a completion routine. When the
completion routine called my buffer was with a valide data. That data I
want to write to a file as fast as possible, because I want to use that
buffer again and send it again to the lower device to read more data. So
I thought to write to the file using asynchronously.
One way is to use ZwWriteFile with an event.
In this method I need to wait on the event to know when the operation
completes. So I wrote another thread that wait on multiple objects. But
then I limit to 64 events (and then to 64 buffers).
Another way I thought to use an APC method.
As a third method I thought to use a completion port in the kernel.
And for final I thought to transfer the buffer to user mode and then to
write it back to the file system using completion port. With this metod
I will allocate the buffer in user mode and will transfer it to the
driver using METHOD_OUT_DIRECT and I don’t need and threads in the
kernel.
If any one know how to do that as I suggest it the second and the third
way or any other comments please write back.
Thanks a lot,
OS.
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@hotmail.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@hotmail.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@hotmail.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@hotmail.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to %%email.unsub%%