ZwWriteFile failed

hi all,
I have kernel mode filter driver.
Which sits between mini stream driver and usbbus driver.
I want to tap the data coming from ministream driver and write it to a
file.
I created a file successfully, but i tried write to that file i got
error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
and i am also getting page fault error.
Is any knows about this problem ??

: MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
: Phone : +91-80-8410222 Fax : +91-80-8410219 __________|

> I created a file successfully, but i tried write to that file i got

error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …

Make sure that the file is created with the GENERIC_WRITE
permission (This could be one reason ).

and i am also getting page fault error.
Is any knows about this problem ??

Probably, you are using this call in IRQL > PASSIVE_LEVEL.
You should only use this in IRQL = PASSIVE_LEVEL.

Cheers,

  • Jay

----- Original Message -----
From: “Mahammadrafi Maniyar”
To: “NT Developers Interest List”
Sent: Saturday, June 22, 2002 6:44 AM
Subject: [ntdev] ZwWriteFile failed

> hi all,
> I have kernel mode filter driver.
> Which sits between mini stream driver and usbbus driver.
> I want to tap the data coming from ministream driver and write it to a
> file.
> I created a file successfully, but i tried write to that file i got
> error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> and i am also getting page fault error.
> Is any knows about this problem ??
> –
> : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> : Phone : +91-80-8410222 Fax : +91-80-8410219 __________ |
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@vsnl.net
> To unsubscribe send a blank email to %%email.unsub%%

Hi jayadev,
i am posting the ZwCreatFile parameters which i used to create a file.
InitializeObjectAttributes ( &ObjectAttributes,
&FullFileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );

ntStatus = ZwCreateFile( &FileHandle,
GENERIC_WRITE,
&ObjectAttributes,
&IoStatus,
NULL, // alloc size =
none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE ,
NULL, // eabuffer
0 ); // ealength
and the write call have these parameters
ntStatus = ZwWriteFile ( FileHandle,

NULL,
NULL,
NULL,
&IoStatus,
temp,
sizeof(int),
0,
NULL);

Jayadev wrote:

> I created a file successfully, but i tried write to that file i got
> error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …

Make sure that the file is created with the GENERIC_WRITE
permission (This could be one reason ).

> and i am also getting page fault error.
> Is any knows about this problem ??

Probably, you are using this call in IRQL > PASSIVE_LEVEL.
You should only use this in IRQL = PASSIVE_LEVEL.

Cheers,

  • Jay

----- Original Message -----
From: “Mahammadrafi Maniyar”
> To: “NT Developers Interest List”
> Sent: Saturday, June 22, 2002 6:44 AM
> Subject: [ntdev] ZwWriteFile failed
>
> > hi all,
> > I have kernel mode filter driver.
> > Which sits between mini stream driver and usbbus driver.
> > I want to tap the data coming from ministream driver and write it to a
> > file.
> > I created a file successfully, but i tried write to that file i got
> > error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> > and i am also getting page fault error.
> > Is any knows about this problem ??
> > –
> > : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> > : Phone : +91-80-8410222 Fax : +91-80-8410219 |
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@vsnl.net
> > To unsubscribe send a blank email to %%email.unsub%%
>
> —
> You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
> To unsubscribe send a blank email to %%email.unsub%%


: MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
: Phone : +91-80-8410222 Fax : +91-80-8410219
|

Looks like things are fine … try giving 0 to ShareAccess parameter in
ZwCreateFile( ).

  • Jay

----- Original Message -----
From: “Mahammadrafi Maniyar”
To: “NT Developers Interest List”
Sent: Saturday, June 22, 2002 9:11 AM
Subject: [ntdev] Re: ZwWriteFile failed

> Hi jayadev,
> i am posting the ZwCreatFile parameters which i used to create a file.
> InitializeObjectAttributes ( &ObjectAttributes,
> &FullFileName,
> OBJ_CASE_INSENSITIVE,
> NULL,
> NULL );
>
> ntStatus = ZwCreateFile( &FileHandle,
> GENERIC_WRITE,
> &ObjectAttributes,
> &IoStatus,
> NULL, // alloc size =
> none
> FILE_ATTRIBUTE_NORMAL,
> FILE_SHARE_WRITE,
> FILE_OVERWRITE_IF,
> FILE_NON_DIRECTORY_FILE ,
> NULL, // eabuffer
> 0 ); // ealength
> and the write call have these parameters
> ntStatus = ZwWriteFile ( FileHandle,
>
> NULL,
> NULL,
> NULL,
> &IoStatus,
> temp,
> sizeof(int),
> 0,
> NULL);
>
>
>
> Jayadev wrote:
>
> > > I created a file successfully, but i tried write to that file i got
> > > error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> >
> > Make sure that the file is created with the GENERIC_WRITE
> > permission (This could be one reason ).
> >
> > > and i am also getting page fault error.
> > > Is any knows about this problem ??
> >
> > Probably, you are using this call in IRQL > PASSIVE_LEVEL.
> > You should only use this in IRQL = PASSIVE_LEVEL.
> >
> > Cheers,
> > - Jay
> >
> > ----- Original Message -----
> > From: “Mahammadrafi Maniyar”
> > To: “NT Developers Interest List”
> > Sent: Saturday, June 22, 2002 6:44 AM
> > Subject: [ntdev] ZwWriteFile failed
> >
> > > hi all,
> > > I have kernel mode filter driver.
> > > Which sits between mini stream driver and usbbus driver.
> > > I want to tap the data coming from ministream driver and write it to a
> > > file.
> > > I created a file successfully, but i tried write to that file i got
> > > error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> > > and i am also getting page fault error.
> > > Is any knows about this problem ??
> > > –
> > > : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> > > : Phone : +91-80-8410222 Fax : +91-80-8410219 |
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@vsnl.net
> > > To unsubscribe send a blank email to %%email.unsub%%
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
> > To unsubscribe send a blank email to %%email.unsub%%
>
> –
> : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> : Phone : +91-80-8410222 Fax : +91-80-8410219
|
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@vsnl.net
> To unsubscribe send a blank email to %%email.unsub%%

STATUS_OBJECT_TYPE_MISMATCH is the result of the fact that the passed handle
is not reffering to a IoFileObjectType
object. Internaly ZwWriteFile wil translate this handle to an object
pointer, and it will try to validate it as a file object.
If this check aint true, it will give back this status.

My guess is that you pass a incorect handle to ZwWriteFile. You did checked
the return Status if your ZwCreateFile , isnt it ? Make sure the function
succeds. Cause I think it aint.

Thanx Dan,
Ya i am checking the return value of ZwCreateFile it showing me status 0.
i am posting the code which i am using to create and write to file.
i am posting the ZwCreatFile parameters which i used to create a file.

InitializeObjectAttributes ( &ObjectAttributes,
&FullFileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );

ntStatus = ZwCreateFile( &FileHandle,
GENERIC_WRITE,
&ObjectAttributes,
&IoStatus,
NULL, // alloc size =
none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE ,
NULL, // eabuffer
0 ); // ealength
and the write call have these parameters
ntStatus = ZwWriteFile ( FileHandle,

NULL,
NULL,
NULL,
&IoStatus,
temp,
sizeof(int),
0,
NULL);

Dan Partelly wrote:

STATUS_OBJECT_TYPE_MISMATCH is the result of the fact that the passed handle
is not reffering to a IoFileObjectType
object. Internaly ZwWriteFile wil translate this handle to an object
pointer, and it will try to validate it as a file object.
If this check aint true, it will give back this status.

My guess is that you pass a incorect handle to ZwWriteFile. You did checked
the return Status if your ZwCreateFile , isnt it ? Make sure the function
succeds. Cause I think it aint.


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to %%email.unsub%%


: MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
: Phone : +91-80-8410222 Fax : +91-80-8410219 __________|

If you are in kernel mode, you should specify OBJ_KERNEL_HANDLE. That would
fix the problem you are seeing if you are performing these operations in
different process contexts.

Regards,

Tony

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

-----Original Message-----
From: Mahammadrafi Maniyar [mailto:xxxxx@tataelxsi.co.in]
Sent: Monday, June 24, 2002 12:04 AM
To: NT Developers Interest List
Subject: [ntdev] Re: ZwWriteFile failed

Thanx Dan,
Ya i am checking the return value of ZwCreateFile it showing me status 0.
i am posting the code which i am using to create and write to file.
i am posting the ZwCreatFile parameters which i used to create a file.

InitializeObjectAttributes ( &ObjectAttributes,
&FullFileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );

ntStatus = ZwCreateFile( &FileHandle,
GENERIC_WRITE,
&ObjectAttributes,
&IoStatus,
NULL, // alloc size =
none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE ,
NULL, // eabuffer
0 ); // ealength
and the write call have these parameters
ntStatus = ZwWriteFile ( FileHandle,

NULL,
NULL,
NULL,
&IoStatus,
temp,
sizeof(int),
0,
NULL);

Dan Partelly wrote:

STATUS_OBJECT_TYPE_MISMATCH is the result of the fact that the passed
handle
is not reffering to a IoFileObjectType
object. Internaly ZwWriteFile wil translate this handle to an object
pointer, and it will try to validate it as a file object.
If this check aint true, it will give back this status.

My guess is that you pass a incorect handle to ZwWriteFile. You did
checked
the return Status if your ZwCreateFile , isnt it ? Make sure the function
succeds. Cause I think it aint.


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to %%email.unsub%%


: MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
: Phone : +91-80-8410222 Fax : +91-80-8410219 __________|


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

I think you should check for the status of ZwCreateFile. If you pass a name
that’s really not a file name but some other object name (like a named
event) you will get this status.


This posting is provided “AS IS” with no warranties, and confers no rights.
“Mahammadrafi Maniyar” wrote in message
news:xxxxx@ntdev…
>
> Hi jayadev,
> i am posting the ZwCreatFile parameters which i used to create a file.
> InitializeObjectAttributes ( &ObjectAttributes,
> &FullFileName,
> OBJ_CASE_INSENSITIVE,
> NULL,
> NULL );
>
> ntStatus = ZwCreateFile( &FileHandle,
> GENERIC_WRITE,
> &ObjectAttributes,
> &IoStatus,
> NULL, // alloc size =
> none
> FILE_ATTRIBUTE_NORMAL,
> FILE_SHARE_WRITE,
> FILE_OVERWRITE_IF,
> FILE_NON_DIRECTORY_FILE ,
> NULL, // eabuffer
> 0 ); // ealength
> and the write call have these parameters
> ntStatus = ZwWriteFile ( FileHandle,
>
> NULL,
> NULL,
> NULL,
> &IoStatus,
> temp,
> sizeof(int),
> 0,
> NULL);
>
>
>
> Jayadev wrote:
>
> > > I created a file successfully, but i tried write to that file i got
> > > error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> >
> > Make sure that the file is created with the GENERIC_WRITE
> > permission (This could be one reason ).
> >
> > > and i am also getting page fault error.
> > > Is any knows about this problem ??
> >
> > Probably, you are using this call in IRQL > PASSIVE_LEVEL.
> > You should only use this in IRQL = PASSIVE_LEVEL.
> >
> > Cheers,
> > - Jay
> >
> > ----- Original Message -----
> > From: “Mahammadrafi Maniyar”
> > To: “NT Developers Interest List”
> > Sent: Saturday, June 22, 2002 6:44 AM
> > Subject: [ntdev] ZwWriteFile failed
> >
> > > hi all,
> > > I have kernel mode filter driver.
> > > Which sits between mini stream driver and usbbus driver.
> > > I want to tap the data coming from ministream driver and write it to a
> > > file.
> > > I created a file successfully, but i tried write to that file i got
> > > error code 0xC0000024 i,e STATUS_OBJECT_MISMATCH …
> > > and i am also getting page fault error.
> > > Is any knows about this problem ??
> > > –
> > > : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> > > : Phone : +91-80-8410222 Fax : +91-80-8410219 |
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@vsnl.net
> > > To unsubscribe send a blank email to %%email.unsub%%
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
> > To unsubscribe send a blank email to %%email.unsub%%
>
> –
> : MdRafi Maniyar : Networking & Comm. Gp, Tata Elxsi Ltd |
> : Phone : +91-80-8410222 Fax : +91-80-8410219
|
>
>
>
>