IoReportDetectedDevice return error STATUS_NO_SUCH_DEVICE

Hello
Bug IoReportDetectedDevice return error STATUS_NO_SUCH_DEVICE.

Why ???

NTSTATUS _CreateVDF(PDRIVER_OBJECT DriverObject,PDEVICE_OBJECT DeviceObject,PVFUMS_CREATE cd)
{
USHORT ui=0;
PDEVICE_EXTENSION_MOTHER g=gm();
NTSTATUS status=STATUS_INTERNAL_ERROR;
KdPrintf((“Internal CreateVDF\n”));

if (g!=NULL)
{
for (ui=0;ui {
PDEVICE_OBJECT gvd=(PDEVICE_OBJECT)g->device_letter[ui];
if (gvd==NULL)
{

PDEVICE_OBJECT diskDeviceObject=NULL;
WCHAR _namedriver[256];
UNICODE_STRING dn;
//NTSTATUS status;
PPARAMVDF gvd_extension;
KdPrintf((“Internal CreateVDF : NULL entry finded %d\n”,ui));
swprintf(_namedriver,L"\Device\sivaller_vfum_index%d",ui);
KdPrintf((“Internal CreateVDF : namedriver %ws \n”,_namedriver));
RtlInitUnicodeString( &dn, _namedriver );
status=STATUS_SUCCESS;
/status= IoCreateDevice(DriverObject, // DriverObject
0, // DeviceExtensionSize
NULL, // DeviceName
FILE_DEVICE_VIRTUAL_DISK, // DeviceType
FILE_DEVICE_IS_MOUNTED, // DeviceCharacteristics
FALSE, // Not Exclusive
&diskDeviceObject // DeviceObject
);
/

if (status==STATUS_SUCCESS)
{
status=IoCreateDevice(DriverObject,
sizeof (TPARAMVDF),
&dn,
FILE_DEVICE_DISK_FILE_SYSTEM,
FILE_DEVICE_IS_MOUNTED,
FALSE,
&gvd);
if (status!=STATUS_SUCCESS)
{
KdPrintf((“Internal CreateVDF Error Ceate diskfile status %x\n”,status));
IoDeleteDevice(diskDeviceObject);
}
}
else
KdPrintf((“Internal CreateVDF Error Internal CreateVDF : Creating Virtual Disk status %x\n”,status));
KdPrintf((“Internal CreateVDF : IoCreateDevice DeviceObject=%x return %x\n”,gvd,status));
if (status==STATUS_SUCCESS)
{

KdPrintf((“Internal CreateVDF : SUCCESS \n”));
gvd_extension=(PPARAMVDF)gvd->DeviceExtension;
if (gvd_extension!=NULL)
{

HANDLE thread_handle;
PDEVICE_OBJECT pnpDeviceObject = NULL;
KdPrintf((“Internal CreateVDF : SUCCESS gvd_extension with vdf=%x\n”,gvd_extension));
memset(gvd_extension,0,sizeof (TPARAMVDF));
wcscpy(gvd_extension->_namedriver,_namedriver);

gvd_extension->dv=diskDeviceObject;
ExInitializeFastMutex(&gvd_extension->HeaderMutex);

FsRtlSetupAdvancedHeader(&gvd_extension->VHeader, &gvd_extension->HeaderMutex);

KeInitializeEvent(&gvd_extension->delaychangedir,SynchronizationEvent, FALSE);
KeInitializeEvent(&gvd_extension->waitbegindeviceiocontrol,SynchronizationEvent, FALSE);
KeInitializeEvent(&gvd_extension->waitenddeviceiocontrol,SynchronizationEvent, FALSE);
FsRtlNotifyInitializeSync( &gvd_extension->NotifySync );
KeInitializeSpinLock(&gvd_extension->list_lock);
InitializeListHead(&gvd_extension->list_head);
InitializeListHead( &gvd_extension->DirNotifyList );

KeInitializeEvent(&gvd_extension->request_event,
SynchronizationEvent, FALSE);

status = IoReportDetectedDevice(
DriverObject,
InterfaceTypeUndefined,
0,
0,
NULL,
NULL,
FALSE,
&pnpDeviceObject);
KdPrintf((“Internal CreateVDF IoReportDetectedDevice return error status %x\n”,status));
if (status!=STATUS_SUCCESS)
{
IoDeleteDevice(gvd);
return status;
}
gvd->Flags &= ~DO_DEVICE_INITIALIZING;
if (IoAttachDeviceToDeviceStack(pnpDeviceObject, gvd) != NULL) {
KdPrintf((" IoAttachDeviceToDeviceStack success\n"));
} else {
KdPrintf((" IoAttachDeviceToDeviceStack failed\n");
IoDeleteDevice(gvd);
return STATUS_UNSUCCESSFUL;
}

status = IoRegisterDeviceInterface(
gvd,
&xGUID_DEVINTERFACE_DISK,
NULL,
gvd_extension->_interface1);
);
KdPrintf((“Internal CreateVDF IoRegisterDeviceInterface return error status %x\n”,status));
if (status!=STATUS_SUCCESS)
{
IoDeleteDevice(gvd);
return status;
}

status = IoSetDeviceInterfaceState(&gvd_extension->_interface1, TRUE);

if (status!=STATUS_SUCCESS){
KdPrintf((" IoSetDeviceInterfaceState success\n"));
} else {
KdPrintf((" IoSetDeviceInterfaceState failed: 0x%x\n", status));
IoDeleteDevice(gvd);
return status;
}

status = IoRegisterDeviceInterface(
gvd,
&MOUNTDEV_MOUNTED_DEVICE_GUID,
NULL,
gvd_extension->_interface2);

KdPrintf((“Internal CreateVDF IoRegisterDeviceInterface return error status %x\n”,status));
if (status!=STATUS_SUCCESS)
{
IoDeleteDevice(gvd);
return status;
}

status = IoSetDeviceInterfaceState(&gvd_extension->_interface2, TRUE);

if (status!=STATUS_SUCCESS)
{
KdPrintf((" IoSetDeviceInterfaceState success\n"));
} else {
KdPrintf((" IoSetDeviceInterfaceState failed: 0x%x\n", status));
IoDeleteDevice(gvd);
return status;
}

thread_handle=NULL;
status = PsCreateSystemThread(&thread_handle,
(ACCESS_MASK) 0L,
NULL,
NULL,
NULL,
VFUM_DeviceThread,
gvd);
//status=STATUS_ACCESS_DENIED;

if (!NT_SUCCESS(status))
{
PDEVICE_EXTENSION_MOTHER pm;
KdPrintf((“[VFUM] Cannot create device thread. (%#x)\n”, status));

IoDeleteDevice(DeviceObject);
IoDeleteDevice(diskDeviceObject);

}
else
{

ZwClose(thread_handle);
gvd->Flags &= ~DO_DEVICE_INITIALIZING;

//MUTEX_INIT(gvd_extension->lock);
g->device_letter[ui]=gvd;
//IoRegisterFileSystem(gvd);
status=STATUS_SUCCESS;
goto tr;
}
}
else
{
KdPrintf((“Internal CreateVDF : fail gvd_extension=NULL \n”));
IoDeleteDevice(gvd);
return STATUS_INTERNAL_ERROR;
}
}

}
}
KdPrintf((“Internal CreateVDF : Too many device\n”));
return STATUS_TOO_MANY_OPENED_FILES;
}
tr:;
return status;
}

thank you for help ;

Why do you think you need this? You are defining a legacy device with
this call which should be the root of the stack, but then you are
attaching the device to the device stack? Your code is confused, what
are you really trying to do?

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@sivaller.no-ip.org” wrote in
message news:xxxxx@ntdev:

> Hello
> Bug IoReportDetectedDevice return error STATUS_NO_SUCH_DEVICE.
>
> Why ???
>
> NTSTATUS _CreateVDF(PDRIVER_OBJECT DriverObject,PDEVICE_OBJECT DeviceObject,PVFUMS_CREATE cd)
> {
> USHORT ui=0;
> PDEVICE_EXTENSION_MOTHER g=gm();
> NTSTATUS status=STATUS_INTERNAL_ERROR;
> KdPrintf((“Internal CreateVDF\n”));
>
> if (g!=NULL)
> {
> for (ui=0;ui> {
> PDEVICE_OBJECT gvd=(PDEVICE_OBJECT)g->device_letter[ui];
> if (gvd==NULL)
> {
>
> PDEVICE_OBJECT diskDeviceObject=NULL;
> WCHAR _namedriver[256];
> UNICODE_STRING dn;
> //NTSTATUS status;
> PPARAMVDF gvd_extension;
> KdPrintf((“Internal CreateVDF : NULL entry finded %d\n”,ui));
> swprintf(_namedriver,L"\Device\sivaller_vfum_index%d",ui);
> KdPrintf((“Internal CreateVDF : namedriver %ws \n”,_namedriver));
> RtlInitUnicodeString( &dn, _namedriver );
> status=STATUS_SUCCESS;
> /status= IoCreateDevice(DriverObject, // DriverObject
> 0, // DeviceExtensionSize
> NULL, // DeviceName
> FILE_DEVICE_VIRTUAL_DISK, // DeviceType
> FILE_DEVICE_IS_MOUNTED, // DeviceCharacteristics
> FALSE, // Not Exclusive
> &diskDeviceObject // DeviceObject
> );
/
>
> if (status==STATUS_SUCCESS)
> {
> status=IoCreateDevice(DriverObject,
> sizeof (TPARAMVDF),
> &dn,
> FILE_DEVICE_DISK_FILE_SYSTEM,
> FILE_DEVICE_IS_MOUNTED,
> FALSE,
> &gvd);
> if (status!=STATUS_SUCCESS)
> {
> KdPrintf((“Internal CreateVDF Error Ceate diskfile status %x\n”,status));
> IoDeleteDevice(diskDeviceObject);
> }
> }
> else
> KdPrintf((“Internal CreateVDF Error Internal CreateVDF : Creating Virtual Disk status %x\n”,status));
> KdPrintf((“Internal CreateVDF : IoCreateDevice DeviceObject=%x return %x\n”,gvd,status));
> if (status==STATUS_SUCCESS)
> {
>
>
> KdPrintf((“Internal CreateVDF : SUCCESS \n”));
> gvd_extension=(PPARAMVDF)gvd->DeviceExtension;
> if (gvd_extension!=NULL)
> {
>
>
> HANDLE thread_handle;
> PDEVICE_OBJECT pnpDeviceObject = NULL;
> KdPrintf((“Internal CreateVDF : SUCCESS gvd_extension with vdf=%x\n”,gvd_extension));
> memset(gvd_extension,0,sizeof (TPARAMVDF));
> wcscpy(gvd_extension->_namedriver,_namedriver);
>
>
>
>
> gvd_extension->dv=diskDeviceObject;
> ExInitializeFastMutex(&gvd_extension->HeaderMutex);
>
> FsRtlSetupAdvancedHeader(&gvd_extension->VHeader, &gvd_extension->HeaderMutex);
>
>
> KeInitializeEvent(&gvd_extension->delaychangedir,SynchronizationEvent, FALSE);
> KeInitializeEvent(&gvd_extension->waitbegindeviceiocontrol,SynchronizationEvent, FALSE);
> KeInitializeEvent(&gvd_extension->waitenddeviceiocontrol,SynchronizationEvent, FALSE);
> FsRtlNotifyInitializeSync( &gvd_extension->NotifySync );
> KeInitializeSpinLock(&gvd_extension->list_lock);
> InitializeListHead(&gvd_extension->list_head);
> InitializeListHead( &gvd_extension->DirNotifyList );
>
>
> KeInitializeEvent(&gvd_extension->request_event,
> SynchronizationEvent, FALSE);
>
>
>
> status = IoReportDetectedDevice(
> DriverObject,
> InterfaceTypeUndefined,
> 0,
> 0,
> NULL,
> NULL,
> FALSE,
> &pnpDeviceObject);
> KdPrintf((“Internal CreateVDF IoReportDetectedDevice return error status %x\n”,status));
> if (status!=STATUS_SUCCESS)
> {
> IoDeleteDevice(gvd);
> return status;
> }
> gvd->Flags &= ~DO_DEVICE_INITIALIZING;
> if (IoAttachDeviceToDeviceStack(pnpDeviceObject, gvd) != NULL) {
> KdPrintf((" IoAttachDeviceToDeviceStack success\n"));
> } else {
> KdPrintf((" IoAttachDeviceToDeviceStack failed\n");
> IoDeleteDevice(gvd);
> return STATUS_UNSUCCESSFUL;
> }
>
>
> status = IoRegisterDeviceInterface(
> gvd,
> &xGUID_DEVINTERFACE_DISK,
> NULL,
> gvd_extension->_interface1);
> );
> KdPrintf((“Internal CreateVDF IoRegisterDeviceInterface return error status %x\n”,status));
> if (status!=STATUS_SUCCESS)
> {
> IoDeleteDevice(gvd);
> return status;
> }
>
> status = IoSetDeviceInterfaceState(&gvd_extension->_interface1, TRUE);
>
> if (status!=STATUS_SUCCESS){
> KdPrintf((" IoSetDeviceInterfaceState success\n"));
> } else {
> KdPrintf((" IoSetDeviceInterfaceState failed: 0x%x\n", status));
> IoDeleteDevice(gvd);
> return status;
> }
>
> status = IoRegisterDeviceInterface(
> gvd,
> &MOUNTDEV_MOUNTED_DEVICE_GUID,
> NULL,
> gvd_extension->_interface2);
>
> KdPrintf((“Internal CreateVDF IoRegisterDeviceInterface return error status %x\n”,status));
> if (status!=STATUS_SUCCESS)
> {
> IoDeleteDevice(gvd);
> return status;
> }
>
> status = IoSetDeviceInterfaceState(&gvd_extension->_interface2, TRUE);
>
> if (status!=STATUS_SUCCESS)
> {
> KdPrintf((" IoSetDeviceInterfaceState success\n"));
> } else {
> KdPrintf((" IoSetDeviceInterfaceState failed: 0x%x\n", status));
> IoDeleteDevice(gvd);
> return status;
> }
>
>
>
> thread_handle=NULL;
> status = PsCreateSystemThread(&thread_handle,
> (ACCESS_MASK) 0L,
> NULL,
> NULL,
> NULL,
> VFUM_DeviceThread,
> gvd);
> //status=STATUS_ACCESS_DENIED;
>
> if (!NT_SUCCESS(status))
> {
> PDEVICE_EXTENSION_MOTHER pm;
> KdPrintf((“[VFUM] Cannot create device thread. (%#x)\n”, status));
>
> IoDeleteDevice(DeviceObject);
> IoDeleteDevice(diskDeviceObject);
>
>
>
> }
> else
> {
>
> ZwClose(thread_handle);
> gvd->Flags &= ~DO_DEVICE_INITIALIZING;
>
>
> //MUTEX_INIT(gvd_extension->lock);
> g->device_letter[ui]=gvd;
> //IoRegisterFileSystem(gvd);
> status=STATUS_SUCCESS;
> goto tr;
> }
> }
> else
> {
> KdPrintf((“Internal CreateVDF : fail gvd_extension=NULL \n”));
> IoDeleteDevice(gvd);
> return STATUS_INTERNAL_ERROR;
> }
> }
>
>
>
> }
> }
> KdPrintf((“Internal CreateVDF : Too many device\n”));
> return STATUS_TOO_MANY_OPENED_FILES;
> }
> tr:;
> return status;
> }
>
> thank you for help ;

i am uninstall “unkown peripheral” from control panel and i reboot this machine.
it’s ok.

Other problem IoRegisterDeviceInterface return my STATUS_INVALID_DEVICE_REQUEST

#define xDEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
const GUID FAR name

xDEFINE_GUID(MOUNTDEV_MOUNTED_DEVICE_GUID, 0x53f5630d, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
xDEFINE_GUID(xGUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);

i redefine MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK, because build show error unresolvable external MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK.

Well IoRegisterDeviceInterface would return
STATUS_INVALID_DEVICE_REQUEST, the call is for PnP devices and
IoReportDetectedDevice makes this a legacy device.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@sivaller.no-ip.org” wrote in
message news:xxxxx@ntdev:

> i am uninstall “unkown peripheral” from control panel and i reboot this machine.
> it’s ok.
>
> Other problem IoRegisterDeviceInterface return my STATUS_INVALID_DEVICE_REQUEST
>
>
> #define xDEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) <br>> const GUID FAR name
>
>
> xDEFINE_GUID(MOUNTDEV_MOUNTED_DEVICE_GUID, 0x53f5630d, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
> xDEFINE_GUID(xGUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
>
> i redefine MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK, because build show error unresolvable external MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK.

xxxxx@sivaller.no-ip.org wrote:

i am uninstall “unkown peripheral” from control panel and i reboot this machine.
it’s ok.

Other problem IoRegisterDeviceInterface return my STATUS_INVALID_DEVICE_REQUEST

Of course. Device interfaces can only be used by PnP devices. Your
device is not a PnP device.

Don asked the most important question. Instead of hacking around
blindly, tell us what you are trying to accomplish.

i redefine MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK, because
build show error unresolvable external MOUNTDEV_MOUNTED_DEVICE_GUID and GUID_DEVINTERFACE_DISK

Did that really seem like the right way to solve this problem? Did you
do any web searching on this problem before you hacked in a solution?
If so, you would have encountered:
#include <initguid.h>


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.</initguid.h>

I want to do:
I want with the command FSCTL_SET_REPARSE_POINT IOCTL to make a link directory to my virtual disk containing some virtual files installed with DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM and devicecharacteristics = FILE_DEVICE_IS_MOUNTED.

When I call API definedosdevice it’s OK, it works for a drive letter, I can see my files and virtual directory, but it’s don’t work when click directory linked to my disk containing virtual files.

FSCTL_SET_REPARSE_POINT return always getlasterror 0.

when i click on the link , explorer show error
“The data present in the reparse point buffer is invalid”

The documentation for ReportDetectedDevice doesn’t list some parameters you passed as NULL as OPTIONAL.

@Don, Tim: The function creates a root enumerated stack, with PDO. There is no reason IoRegisterDeviceInterface should not work (other than that you’re supposed to pass the PDO to it, not FDO, as the OP does).

xxxxx@broadcom.com wrote:

@Don, Tim: The function creates a root enumerated stack, with PDO. …

I’m not sure what leads you to that conclusion. He never told us
whether this was called from AddDevice or from DriverEntry.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

@Tim:

The documentation for IoReportDetectedDevice says that the function (optionally) creates a PDO, the caller then attaches an FDO to it. The device is marked as root-enumerated and made persistent. The PNP manager considers the device started and won’t send START_DEVICE.
On next boots, IoReportDetectedDevice should not be called; the stack will be recreated the normal PNP way from the stored persistent information. Whether just reported, or recreated, this is a normal device stack, and it is legal to create a device interface on it. I suppose that’s what serial.sys does for the legacy ports.

> The documentation for IoReportDetectedDevice says that the function (optionally) creates a PDO

The use of IoReportDetectedDevice to create a root PDO without having an INF file is not working properly on recent Windows versions.

So, having an INF file, signatures and doing the full driver install procedure is a must to have a root PDO.


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