本人使用的硬件是Ez-usb fx2系列68013芯片
但是怎么
NTSTATUS
Ezusb_PnPAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
/*++
Routine Description:
This routine is called to create a new instance of the device
Arguments:
DriverObject - pointer to the driver object for this instance of Ezusb
PhysicalDeviceObject - pointer to a device object created by the bus
Return Value:
STATUS_SUCCESS if successful,
STATUS_UNSUCCESSFUL otherwise
--*/
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT fdo = NULL;
PDEVICE_EXTENSION pdx;
WCHAR KernelDeviceNameBuffer[] = L"\\Device\\Ezusb-0";
UNICODE_STRING KernelDeviceNameUnicode;
WCHAR UserDeviceLinkBuffer[] = L"\\DosDevices\\Ezusb-0";
UNICODE_STRING UserDeviceLinkUnicode;
RtlInitUnicodeString (&KernelDeviceNameUnicode,
KernelDeviceNameBuffer);//&KernelDeviceNameUnicode
Ezusb_KdPrint(("enter Ezusb_PnPAddDevice\n"));
ntStatus = IoCreateDevice (DriverObject,
sizeof (DEVICE_EXTENSION),
NULL,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&fdo);
if (NT_SUCCESS(ntStatus))
{
pdx = fdo->DeviceExtension;
/*RtlInitUnicodeString (&UserDeviceLinkUnicode,
UserDeviceLinkBuffer);
ntStatus = IoCreateSymbolicLink (&UserDeviceLinkUnicode,
&KernelDeviceNameUnicode);
RtlCopyMemory(pdx->DeviceLinkName,
UserDeviceLinkBuffer,
sizeof(UserDeviceLinkBuffer));
*/
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
fdo->Flags |= DO_DIRECT_IO;
pdx->PhysicalDeviceObject=PhysicalDeviceObject;
pdx->StackDeviceObject =
IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);
ASSERT (pdx->StackDeviceObject != NULL);
pdx->usage = 1;
pdx->OpenHandles++;
KeInitializeEvent(&pdx->evRemove,
NotificationEvent,
FALSE); }
Ezusb_KdPrint(("exit Ezusb_PnPAddDevice (%x)\n", ntStatus));
return ntStatus;
}
本人只要使用设备描述符L"\\Device\\Ezusb-0"; ,这个些代码,编译出来的驱动程序就不能正常加载,加载到一半时就出问题,代码31,请问高手这是怎么回事,这例程都是一些例子程序中拷贝过来,应该没有问题啊
忘记了,里面还有注释没有去掉,正常如下:
NTSTATUS
Ezusb_PnPAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
/*++
Routine Description:
This routine is called to create a new instance of the device
Arguments:
DriverObject - pointer to the driver object for this instance of Ezusb
PhysicalDeviceObject - pointer to a device object created by the bus
Return Value:
STATUS_SUCCESS if successful,
STATUS_UNSUCCESSFUL otherwise
--*/
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT fdo = NULL;
PDEVICE_EXTENSION pdx;
WCHAR KernelDeviceNameBuffer[] = L"\\Device\\Ezusb-0";
UNICODE_STRING KernelDeviceNameUnicode;
WCHAR UserDeviceLinkBuffer[] = L"\\DosDevices\\Ezusb-0";
UNICODE_STRING UserDeviceLinkUnicode;
RtlInitUnicodeString (&KernelDeviceNameUnicode,
KernelDeviceNameBuffer);//&KernelDeviceNameUnicode
Ezusb_KdPrint(("enter Ezusb_PnPAddDevice\n"));
ntStatus = IoCreateDevice (DriverObject,
sizeof (DEVICE_EXTENSION),
NULL,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&fdo);
if (NT_SUCCESS(ntStatus))
{
pdx = fdo->DeviceExtension;
RtlInitUnicodeString (&UserDeviceLinkUnicode,
UserDeviceLinkBuffer);
ntStatus = IoCreateSymbolicLink (&UserDeviceLinkUnicode,
&KernelDeviceNameUnicode);
RtlCopyMemory(pdx->DeviceLinkName,
UserDeviceLinkBuffer,
sizeof(UserDeviceLinkBuffer));
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
fdo->Flags |= DO_DIRECT_IO;
pdx->PhysicalDeviceObject=PhysicalDeviceObject;
pdx->StackDeviceObject =
IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);
ASSERT (pdx->StackDeviceObject != NULL);
pdx->usage = 1;
pdx->OpenHandles++;
KeInitializeEvent(&pdx->evRemove,
NotificationEvent,
FALSE); }
Ezusb_KdPrint(("exit Ezusb_PnPAddDevice (%x)\n", ntStatus));
return ntStatus;
}
终于有人来回话了,晕,可以结贴了,问题我早就解决了,只是没有人回复,没法结贴啊