File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file. In
result I have file handle. Of course, this handle is valid only in the
process, in the context of which ZwCreateFile was called. So the
question is: I need to operate with that file (by
ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive
handle for that file (for ZwXxx functions) which will be valid for other
processes?
I tried next way but without success:

  • ObReferenceObjectByHandle gives me pointer to the kernel Object
  • then it looks like that in any process context I can get file handle
    with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,
Sab

File handle for ANY process context Use the OBJ_KERNEL_HANDLE flag, this will solve the problem.
This flag is not supported on NT4 though.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: Sasha Bublik - (BS)
To: Windows File Systems Devs Interest List
Sent: Tuesday, July 13, 2004 6:04 PM
Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file. In result I have file handle. Of course, this handle is valid only in the process, in the context of which ZwCreateFile was called. So the question is: I need to operate with that file (by ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive handle for that file (for ZwXxx functions) which will be valid for other processes?
I tried next way but without success:

  • ObReferenceObjectByHandle gives me pointer to the kernel Object
  • then it looks like that in any process context I can get file handle with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,
Sab


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

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

Why don’t you try creating a kernel handle? See
InitializeObjectAttributes for the details, but this will create a
handle used only in kernel mode, but from arbitrary process context.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the Next OSR File Systems Class October
18, 2004 in Silicon Valley!


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sasha Bublik - (BS)
Sent: Tuesday, July 13, 2004 10:05 AM
To: ntfsd redirect
Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file. In
result I have file handle. Of course, this handle is valid only in the
process, in the context of which ZwCreateFile was called. So the
question is: I need to operate with that file (by
ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive
handle for that file (for ZwXxx functions) which will be valid for other
processes?
I tried next way but without success:

  • ObReferenceObjectByHandle gives me pointer to the kernel Object
  • then it looks like that in any process context I can get file handle
    with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,
Sab


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

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Maxim.

But I need some solution for NT4 too.

What would you suggest for it?

Thanks.


Bye,
Sab


From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Tuesday, July 13, 2004 5:28 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] File handle for ANY process context

Use the OBJ_KERNEL_HANDLE flag, this will solve the problem.

This flag is not supported on NT4 though.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

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

From: Sasha Bublik - (BS) mailto:xxxxx

To: Windows File Systems Devs Interest List
mailto:xxxxx

Sent: Tuesday, July 13, 2004 6:04 PM

Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file.
In result I have file handle. Of course, this handle is valid only in
the process, in the context of which ZwCreateFile was called. So the
question is: I need to operate with that file (by
ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive
handle for that file (for ZwXxx functions) which will be valid for other
processes?
I tried next way but without success:
- ObReferenceObjectByHandle gives me pointer to the kernel
Object
- then it looks like that in any process context I can get file
handle with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,</mailto:xxxxx></mailto:xxxxx>

If you must support NT 4.0, then you should use worker threads to create
the handles and perform the I/O operations (or do the I/O operations via
IRPs that you construct.)

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the Next OSR File Systems Class October
18, 2004 in Silicon Valley!


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sasha Bublik - (BS)
Sent: Tuesday, July 13, 2004 10:55 AM
To: ntfsd redirect
Subject: RE: [ntfsd] File handle for ANY process context

Thanks Maxim.

But I need some solution for NT4 too.

What would you suggest for it?

Thanks.


Bye,
Sab


From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Tuesday, July 13, 2004 5:28 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] File handle for ANY process context

Use the OBJ_KERNEL_HANDLE flag, this will solve the problem.

This flag is not supported on NT4 though.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

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

From: Sasha Bublik - (BS) mailto:xxxxx

To: Windows File Systems Devs Interest List
mailto:xxxxx

Sent: Tuesday, July 13, 2004 6:04 PM

Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file.
In result I have file handle. Of course, this handle is valid only in
the process, in the context of which ZwCreateFile was called. So the
question is: I need to operate with that file (by
ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive
handle for that file (for ZwXxx functions) which will be valid for other
processes?
I tried next way but without success:
- ObReferenceObjectByHandle gives me pointer to the kernel
Object
- then it looks like that in any process context I can get file
handle with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,


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

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

File handle for ANY process contextOn NT4, you may use ObOpenObjectByPointer, it wil give you
handle available in current process. You have to save the file
object, though.

L.

File handle for ANY process context Offload the work with this handle to ExQueueWorkItem callbacks.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: Sasha Bublik - (BS)
To: Windows File Systems Devs Interest List
Sent: Tuesday, July 13, 2004 6:54 PM
Subject: RE: [ntfsd] File handle for ANY process context

Thanks Maxim.

But I need some solution for NT4 too.

What would you suggest for it?

Thanks.


Bye,
Sab


From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Tuesday, July 13, 2004 5:28 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] File handle for ANY process context

Use the OBJ_KERNEL_HANDLE flag, this will solve the problem.

This flag is not supported on NT4 though.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

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

From: Sasha Bublik - (BS)

To: Windows File Systems Devs Interest List

Sent: Tuesday, July 13, 2004 6:04 PM

Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file. In result I have file handle. Of course, this handle is valid only in the process, in the context of which ZwCreateFile was called. So the question is: I need to operate with that file (by ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive handle for that file (for ZwXxx functions) which will be valid for other processes?
I tried next way but without success:

  • ObReferenceObjectByHandle gives me pointer to the kernel Object
  • then it looks like that in any process context I can get file handle with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,


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

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

Sasha,

The following should work for both NT and 2K …

Open the file in System Context, and save its File Handle and its File Object, which you have to reference via ObReferenceObjectByHandle API.

To access the file, if in system context, use the handle that you got when you opened it. In the context of other processes, get the context safe handle via

ObOpenObjectByPointer API, using the File Object. Make sure to close the handle that was created via ObOpenObjectByPointer.

Once you are done with the file, close it in system context, and dereference the File Object.

-Ilya.

-----Original Message-----
From: Sasha Bublik - (BS) [mailto:xxxxx@mastereye.kiev.ua]
Sent: Tuesday, July 13, 2004 10:55 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] File handle for ANY process context

Thanks Maxim.

But I need some solution for NT4 too.

What would you suggest for it?

Thanks.


Bye,
Sab


From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Tuesday, July 13, 2004 5:28 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] File handle for ANY process context

Use the OBJ_KERNEL_HANDLE flag, this will solve the problem.

This flag is not supported on NT4 though.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

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

From: Sasha Bublik - (BS) mailto:xxxxx

To: Windows File Systems Devs Interest List mailto:xxxxx

Sent: Tuesday, July 13, 2004 6:04 PM

Subject: [ntfsd] File handle for ANY process context

Hello guys,

I have a such problem.
In my driver I use function ZwCreateFile to create/open a file. In result I have file handle. Of course, this handle is valid only in the process, in the context of which ZwCreateFile was called. So the question is: I need to operate with that file (by ZwReadFile/ZwWriteFile/etc.) in ANY process contexts. How can I receive handle for that file (for ZwXxx functions) which will be valid for other processes?
I tried next way but without success:
- ObReferenceObjectByHandle gives me pointer to the kernel Object
- then it looks like that in any process context I can get file handle with the help of ObInsertObject, but in reality I have BSOD

Thanks.

Bye,


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

You are currently subscribed to ntfsd as: xxxxx@softricity.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</mailto:xxxxx></mailto:xxxxx>