Ring 0 and File Read/Write in different thread contexts

Hi All !
Sorry for my English…
How can i read/write from/to file from 0 ring,
in NT driver. ZwCreateFile return HANDLE and this HANDLE
is valid only in thread context where it was create.
When i process IRP, i must write to file, but irp
is in other thread context. and ZwReadFile return STATUS_OBJECT_TYPE_MISMATCH

// There is a mismatch between the type of object required by the requested
// operation and the type of object that is specified in the request.
//
#define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS)0xC0000024L)

I create system thread, and in context of this thread
i create file, then i put all irp to queue, and in this
thread i pop irp from queue and write to file…

But i think it not good… How can i do this best.
Don’t open file in thread, how open it out of thread
and then use in thread ?

Thanks all who can answer !!!


Den mailto:xxxxx@yandex.ru


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> I create system thread, and in context of this thread

i create file, then i put all irp to queue, and in this
thread i pop irp from queue and write to file…

But i think it not good…

No, this is OK.
You can also retrieve a file object from the handle and then read/write the
file from any thread by IoBuildSynchronousFsdRequest/IoCallDriver.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You cannot open a file “outside” a thread. The basic schedulable entity in
NT the thread. Yor code will always execute in the context of a thread , and
there is not much you can do abt it. Also , handles are per/process entites
, not per thread.
You can use ObReferenceObjectByHandle on the file handle to obtain a
pointer to a FILE_OBJECT , which can be subsequently used for IO operations
. Or you can ensure that all your file IO operations will be executed only
and only in the context of the same process.

----- Original Message -----
From: “Den.yandex”
To: “NT Developers Interest List”
Sent: Friday, May 11, 2001 12:45 AM
Subject: [ntdev] Ring 0 and File Read/Write in different thread contexts

> Hi All !
> Sorry for my English…
> How can i read/write from/to file from 0 ring,
> in NT driver. ZwCreateFile return HANDLE and this HANDLE
> is valid only in thread context where it was create.
> When i process IRP, i must write to file, but irp
> is in other thread context. and ZwReadFile return
STATUS_OBJECT_TYPE_MISMATCH
>
> // There is a mismatch between the type of object required by the
requested
> // operation and the type of object that is specified in the request.
> //
> #define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS)0xC0000024L)
>
> I create system thread, and in context of this thread
> i create file, then i put all irp to queue, and in this
> thread i pop irp from queue and write to file…
>
> But i think it not good… How can i do this best.
> Don’t open file in thread, how open it out of thread
> and then use in thread ?
>
> Thanks all who can answer !!!
>
> –
> Den mailto:xxxxx@yandex.ru
>
>
>
> —
> You are currently subscribed to ntdev as: danp@jb.rdsor.ro
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

>>I create system thread, and in context of this thread
i create file, then i put all irp to queue, and in this
thread i pop irp from queue and write to file…<<

This is correct.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Den.yandex
Sent: Thursday, May 10, 2001 2:46 PM
To: NT Developers Interest List
Subject: [ntdev] Ring 0 and File Read/Write in different thread contexts

Hi All !
Sorry for my English…
How can i read/write from/to file from 0 ring,
in NT driver. ZwCreateFile return HANDLE and this HANDLE
is valid only in thread context where it was create.
When i process IRP, i must write to file, but irp
is in other thread context. and ZwReadFile return
STATUS_OBJECT_TYPE_MISMATCH

// There is a mismatch between the type of object required by
the requested
// operation and the type of object that is specified in the request.
//
#define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS)0xC0000024L)

I create system thread, and in context of this thread
i create file, then i put all irp to queue, and in this
thread i pop irp from queue and write to file…

But i think it not good… How can i do this best.
Don’t open file in thread, how open it out of thread
and then use in thread ?

Thanks all who can answer !!!


Den mailto:xxxxx@yandex.ru


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com