阅读:1028回复:1
斑竹,你能回答一下吗?
我在passthru.c 里添加了如下东西:
Status = IoCreateDevice (DriverObject, //driver object 0, //DeviceExtensionSize &DeviceName,//前面定一切初始化了 FILE_DEVICE_UNKNOWN,//DeviceType 0, //DeviceCharacteristics FALSE, //Exclusive &DeviceObject); //DeviceObject ASSERT(Status == NDIS_STATUS_SUCCESS); Status = IoCreateSymbolicLink( &SymbolicName/%前面定一切初始化了*/, &DeviceName ); ASSERT(Status == NDIS_STATUS_SUCCESS); boolSymbolic=TRUE; DeviceObject->Flags |= DO_BUFFERED_IO; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DeviceIoControl; DriverObject->DriverUnload =DriverUnload; NTSTATUS DeviceIoControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { PIO_STACK_LOCATION irpSp; ULONG functionCode; irpSp = IoGetCurrentIrpStackLocation(Irp); functionCode=irpSp->Parameters.DeviceIoControl.IoControlCode; if(functionCode==IO_TEST) { DBGPRINT(\"==> IOControling..........<==\\n\"); return 1; } return 1; } VOID DriverUnload( IN PDRIVER_OBJECT DriverObject ) {} 在passthru.h中添加了如下东西: /*―――――――――――――――――――――――――――――――――――――― 自定义设备名 */ #define DEVICE_NAME L\"\\\\Device\\\\NByte\" #define SYMBOLIC_NAME L\"\\\\DosDevices\\\\NByte\" /*―――――――――――――――――――――――――――――――――――――― 自定义I/O控制函数 */ VOID DriverUnload( IN PDRIVER_OBJECT DriverObject ); NTSTATUS DeviceIoControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); 我想用过应用程序和驱动程序通讯于是在应用程序里调用如下: HANDLE hFile; hFile=CreateFile(TEXT(\"\\\\\\\\.\\\\NByte\"), GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0 ); if(hFile == INVALID_HANDLE_VALUE) { return FALSE; } 结果一执行就自动重起,我的系统都快被折腾死了,我也会被折腾死了,请救救我吧!!谢谢!!! |
|
沙发#
发布于:2003-04-27 02:48
I have re your mail.
|
|
|