Volume filter driver get device name

I am writing a volume filter driver in KMDF to redirect writes from one volume to another. I am not sure how to find out which volume is getting the write request. Is there some function that returns the device name such as “\Device\HarddiskVolumeX”?
Also, is there a way to do the reverse - get the device object using the name. I need to get the other device so that I can change the request target.
Actually, I’m not sure if this is the best way to go about this. Some guidance would be appreciated.
Thank you

You can use ObQueryNameString to get the name of an object, though I don’t
know that you actually need this based on your description.

I’m not sure I quite understand the rest of your post.
IoGetDeviceObjectPointer will get you a pointer to the other device object
so that you can route requests to it. Is that what you’re looking for?

-scott


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntdev…
>I am writing a volume filter driver in KMDF to redirect writes from one
>volume to another. I am not sure how to find out which volume is getting
>the write request. Is there some function that returns the device name such
>as “\Device\HarddiskVolumeX”?
> Also, is there a way to do the reverse - get the device object using the
> name. I need to get the other device so that I can change the request
> target.
> Actually, I’m not sure if this is the best way to go about this. Some
> guidance would be appreciated.
> Thank you
>
>

Thanks for the response.
ObQueryNameString should be fine. I just looked at the TrueCrypt driver and that’s what they’re using.
I’m probably not wording the question properly because I’m not sure exactly how volume filters fit in the driver stack. I was looking at doing this with a file system driver and I’m probably getting confused with the way those drivers work.
I have two volumes J: and K:, and I can get the NT device names of these. When I get a write request for volume J: I want it to get written to a particular offset in volume K: instead. I thought that to do this I needed to change the target and the offset parameter for the request and forward it. I looked at IoGetDeviceObjectPointer and found that in WDF it’s approximately equivalent to WdfIoTargetOpen, so I can use that to get the Io Target for my destination device. Then I’ll call WdfRequestChangeTarget and WdfRequestSend. Will this send my request to the right place?
Thanks for your help.

Good call avoiding the FS layer, always highly recommended if you can help
it.

Sorry I missed the KMDF part in your previous post (even though it was in
the first sentence). Yes, you’ve got the idea and it sounds like you’re on
to it.

Good luck!

-scott


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntdev…
> Thanks for the response.
> ObQueryNameString should be fine. I just looked at the TrueCrypt driver
> and that’s what they’re using.
> I’m probably not wording the question properly because I’m not sure
> exactly how volume filters fit in the driver stack. I was looking at doing
> this with a file system driver and I’m probably getting confused with the
> way those drivers work.
> I have two volumes J: and K:, and I can get the NT device names of these.
> When I get a write request for volume J: I want it to get written to a
> particular offset in volume K: instead. I thought that to do this I needed
> to change the target and the offset parameter for the request and forward
> it. I looked at IoGetDeviceObjectPointer and found that in WDF it’s
> approximately equivalent to WdfIoTargetOpen, so I can use that to get the
> Io Target for my destination device. Then I’ll call WdfRequestChangeTarget
> and WdfRequestSend. Will this send my request to the right place?
> Thanks for your help.
>