Hi,
I am working on an upper volume filter driver.
I am getting error as “c0000035” which means “STATUS_OBJECT_NAME_COLLISION” when trying to create device with name.
How can I create device with name for all the partitions?
Note: There are 2 disk, each with 3 partitions.
I want to access the driver from my user app that is why want to create the device with name. When specifying NULL in third parameter of “IoCreateDevice” the driver is properly loaded with all the partitions.
Below is my code,
************************************************************
NTSTATUS
sampledriverAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
{
NTSTATUS status;
IO_STATUS_BLOCK ioStatus;
PDEVICE_OBJECT filterDeviceObject;
PDEVICE_EXTENSION deviceExtension;
CCHAR ntNameBuffer[sampledriver_MAXSTR];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
PIRP irp;
STORAGE_DEVICE_NUMBER number;
ULONG registrationFlag = 0;
PWMILIB_CONTEXT wmilibContext;
PCHAR buffer;
ULONG buffersize;
UNICODE_STRING linkString;
PAGED_CODE();
//
// Create a filter device object for this device (partition).
//
DebugPrint((0, “sampledriverAddDevice: Driver %X Device %X\n”,
DriverObject, PhysicalDeviceObject));
RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME );
status = IoCreateDevice(DriverObject,
DEVICE_EXTENSION_SIZE,
&ntUnicodeString,
FILE_DEVICE_DISK,
0,
FALSE,
&filterDeviceObject);
if (!NT_SUCCESS(status)) {
DbgPrint(“sampledriverAddDevice: Cannot create filterDeviceObject: %x\n”, status); \Here I am getting error as “c0000035”
return status;
}
else
{
DbgPrint(“sampledriverAddDevice: Created filterDeviceObject\n: %x\n”, status);
}
RtlInitUnicodeString( &linkString, NT_DOSDEVICE_NAME );
status = IoCreateSymbolicLink( &linkString, &ntUnicodeString );
if (!NT_SUCCESS(status)) {
//
// Remove the existing symbol link and try and create it again.
// If this fails then quit.
//
DbgPrint(“sample!DriverEntry: IoCreateSymbolicLink failed: %x\n”, status);
IoDeleteSymbolicLink( &linkString );
status = IoCreateSymbolicLink( &linkString, &ntUnicodeString );
if (!NT_SUCCESS(status)) {
DbgPrint(“sample!DriverEntry: IoCreateSymbolicLink failed: %x\n”, status);
IoDeleteDevice(filterDeviceObject);
return status;
}
}
filterDeviceObject->Flags |= DO_DIRECT_IO;
deviceExtension = (PDEVICE_EXTENSION) filterDeviceObject->DeviceExtension;
deviceExtension->IOFirstTime = TRUE;
//
// Attaches the device object to the highest device object in the chain and
// return the previously highest device object, which is passed to
// IoCallDriver when pass IRPs down the device stack
//
deviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
deviceExtension->TargetDeviceObject =
IoAttachDeviceToDeviceStack(filterDeviceObject, PhysicalDeviceObject);
if (deviceExtension->TargetDeviceObject == NULL) {
IoDeleteDevice(filterDeviceObject);
DebugPrint((1, “sampledriverAddDevice: Unable to attach %X to target %X\n”,
filterDeviceObject, PhysicalDeviceObject));
DbgPrint( “sampledriverAddDevice: Unable to attach %X to target %X\n”,
filterDeviceObject, PhysicalDeviceObject);
return STATUS_NO_SUCH_DEVICE;
}
//
// Save the filter device object in the device extension
//
deviceExtension->DeviceObject = filterDeviceObject;
deviceExtension->PhysicalDeviceName.Buffer
= deviceExtension->PhysicalDeviceNameBuffer;
KeInitializeEvent(&deviceExtension->PagingPathCountEvent,
NotificationEvent, TRUE);
//
// default to DO_POWER_PAGABLE
//
filterDeviceObject->Flags |= DO_POWER_PAGABLE;
//
// Clear the DO_DEVICE_INITIALIZING flag
//
filterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
} // end sampledriverAddDevice()
******************************************************
This is what I got in windbg,
**********************************************************
sampledriverAddDevice: Driver 80786724 Device 80786724
sampledriverAddDevice: Created filterDeviceObject : 0
sampledriverAddDevice: Driver 80786724 Device 80786724
sampledriverAddDevice: Cannot create filterDeviceObject: c0000035
sampledriverAddDevice: Driver 80786724 Device 80786724
sampledriverAddDevice: Cannot create filterDeviceObject: c0000035
sampledriverAddDevice: Driver 80786724 Device 80786724
sampledriverAddDevice: Cannot create filterDeviceObject: c0000035
sampledriverRegisterDevice: Device name \Device\Harddisk0\Partition1
*** WARNING: Unable to verify timestamp for ntdll.dll
*** ERROR: Module load completed but symbols could not be loaded for ntdll.dll
************************************************************