Error in IoGetDiskDeviceObject 0xc000000d

I have a driver which is based sfilter,the problem is get dos letter fail when attach a volume.
the step is:
1.IoGetDeviceAttachmentBaseRef , get the lowest-level device object.
2.IoGetDiskDeviceObject ,get disk device associated with a given file system volume device object.
3.IoVolumeDeviceToDosName, get MS-DOS path for a specified device object?

It will be get MS-DOS path normal when OS has started,but it will fail when restart OS ,or some volume reloaded,IoGetDiskDeviceObject return code 0xc000000d.

Any hint?Thanks in advance.

Show the code sample please

2013/5/30

> I have a driver which is based sfilter,the problem is get dos letter fail
> when attach a volume.
> the step is:
> 1.IoGetDeviceAttachmentBaseRef , get the lowest-level device object.
> 2.IoGetDiskDeviceObject ,get disk device associated with a given file
> system volume device object.
> 3.IoVolumeDeviceToDosName, get MS-DOS path for a specified device object?
>
> It will be get MS-DOS path normal when OS has started,but it will fail
> when restart OS ,or some volume reloaded,IoGetDiskDeviceObject return code
> 0xc000000d.
>
> Any hint?Thanks in advance.
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> 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
>

// Code sample

//VolDevObj? Pointer to the device object in the stack to which the SourceDevice object is to be attached.
NTSTATUS FltGetVolDosAndNtName(IN PDEVICE_OBJECT VolDevObj,
IN OUT PUNICODE_STRING VolDosName,
IN OUT PUNICODE_STRING VolNtName,
IN PVPB *ppVpb)
{
NTSTATUS status;
UNICODE_STRING uniDosName;
PDEVICE_OBJECT StorageVolDeviceObject;
PDEVICE_OBJECT FileSysDeviceObject;
PDEVICE_OBJECT pNextDeviceObject = NULL;
UNICODE_STRING NtPathHeader;
SHORT ntLen;

FileSysDeviceObject = IoGetDeviceAttachmentBaseRef(VolDevObj);
if ( FileSysDeviceObject )
{
//==============================================
// Get the disk volume device object associate
// with the file system volume device object.
//==============================================
status = IoGetDiskDeviceObject(FileSysDeviceObject, &StorageVolDeviceObject);
if ( !NT_SUCCESS(status) )
{
KdPrint((“[FileFlt | FltGetVolDosAndNtName] IoGetDiskDeviceObject Failed! Status: %#x\n”, status));

ObDereferenceObject(FileSysDeviceObject);
return status;
}

//==============================================
// Get the NT name of the disk device object.
//==============================================
// …

ObDereferenceObject(StorageVolDeviceObject);
if ( ppVpb && NT_SUCCESS(status) )
{
*ppVpb = StorageVolDeviceObject->Vpb;
}

ObDereferenceObject(FileSysDeviceObject);
}

return status;
}

You get STATUS_INVALID_PARAMETER because you pass wrong DeviceObject to
IoGetDiskDeviceObject.

2013/5/30

> // Code sample
>
> //VolDevObj? Pointer to the device object in the stack to which the
> SourceDevice object is to be attached.
> NTSTATUS FltGetVolDosAndNtName(IN PDEVICE_OBJECT VolDevObj,
> IN OUT
> PUNICODE_STRING VolDosName,
> IN OUT
> PUNICODE_STRING VolNtName,
> IN PVPB *ppVpb)
> {
> NTSTATUS status;
> UNICODE_STRING uniDosName;
> PDEVICE_OBJECT StorageVolDeviceObject;
> PDEVICE_OBJECT FileSysDeviceObject;
> PDEVICE_OBJECT pNextDeviceObject = NULL;
> UNICODE_STRING NtPathHeader;
> SHORT ntLen;
>
> FileSysDeviceObject = IoGetDeviceAttachmentBaseRef(VolDevObj);
> if ( FileSysDeviceObject )
> {
> //==============================================
> // Get the disk volume device object associate
> // with the file system volume device object.
> //==============================================
> status = IoGetDiskDeviceObject(FileSysDeviceObject,
> &StorageVolDeviceObject);
> if ( !NT_SUCCESS(status) )
> {
> KdPrint((“[FileFlt | FltGetVolDosAndNtName]
> IoGetDiskDeviceObject Failed! Status: %#x\n”, status));
>
> ObDereferenceObject(FileSysDeviceObject);
> return status;
> }
>
> //==============================================
> // Get the NT name of the disk device object.
> //==============================================
> // …
>
> ObDereferenceObject(StorageVolDeviceObject);
> if ( ppVpb && NT_SUCCESS(status) )
> {
> *ppVpb = StorageVolDeviceObject->Vpb;
> }
>
> ObDereferenceObject(FileSysDeviceObject);
> }
>
> return status;
> }
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> 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
>