How to attach to virtual volume device stack by name?

Hi all,

In order to attach to device stack by name I always did the following sequence:

InitializeObjectAttributes( &objectAttributes, DeviceName, … )
ZwCreateFile( &fileHandle, SYNCHRONIZE|FILE_READ_DATA, objectAttributes, … )
ObReferenceObjectByHandle( fileHandle, …, &volumeFileObject )
StackDeviceObject = IoGetBaseFileSystemDeviceObject( volumeFileObject );
IoCreateDevice( …, StackDeviceObject->DeviceType, …, &DeviceObject )

IoAttachDeviceToDeviceStackSafe(DeviceObject, StackDeviceObject, …)

It looks ugly, but worked fine for all devices until I tried it on virtual volume device. It failed on second step: ZwCreateFile returned 0xc0000002(STATUS_NOT_IMPLEMENTED)

I’m almost sure, there is another way get virtual volume device object by name, w/o ZwCreateFile call. Can you help me with it, please?

what about IoGetDeviceObjectPointer ?

On Tue, Apr 10, 2012 at 6:27 PM, wrote:

> Hi all,
>
> In order to attach to device stack by name I always did the following
> sequence:
>
> InitializeObjectAttributes( &objectAttributes, DeviceName, … )
> ZwCreateFile( &fileHandle, SYNCHRONIZE|FILE_READ_DATA, objectAttributes,
> … )
> ObReferenceObjectByHandle( fileHandle, …, &volumeFileObject )
> StackDeviceObject = IoGetBaseFileSystemDeviceObject( volumeFileObject );
> IoCreateDevice( …, StackDeviceObject->DeviceType, …, &DeviceObject )
> …
> IoAttachDeviceToDeviceStackSafe(DeviceObject, StackDeviceObject, …)
>
> It looks ugly, but worked fine for all devices until I tried it on virtual
> volume device. It failed on second step: ZwCreateFile returned
> 0xc0000002(STATUS_NOT_IMPLEMENTED)
>
> I’m almost sure, there is another way get virtual volume device object by
> name, w/o ZwCreateFile call. Can you help me with it, please?
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

>what about IoGetDeviceObjectPointer ?

…which is internally ZwOpenFile+ObReferenceObjectByHandle+IoGetRelatedDeviceObject+ZwClose


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

and same attributes ?

On Tue, Apr 10, 2012 at 7:10 PM, Maxim S. Shatskih
wrote:

> >what about IoGetDeviceObjectPointer ?
>
> …which is internally
> ZwOpenFile+ObReferenceObjectByHandle+IoGetRelatedDeviceObject+ZwClose
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

IoGetDeviceObjectPointer with FILE_READ_DATA returned same status: 0xc0000002(STATUS_NOT_IMPLEMENTED)