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 ;