阅读:1020回复:4
WDM驱动高手请进
NTSTATUS Pci5030_109Device::DeviceControl(KIrp I)
{ NTSTATUS status; switch (I.IoctlCode()) { ... case IOCTL_hu_test1: status = IOCTL_hu_test1_Handler(I); break; ... } if (status == STATUS_PENDING) { return status; } else { return I.PnpComplete(this, status); } } NTSTATUS Pci5030_109Device::IOCTL_hu_test1_Handler(KIrp I) { NTSTATUS status = STATUS_SUCCESS; ULONG hu_test1[7]; //m_MemoryRange0.ind(addr_clkspeed_reg,hu_test1,6); for(int i=0;i<=6;i++)hu_test1=i;//本来是想用上句给hu_test1[7]赋值的 if(I.IoctlOutputBufferSize()>=(6*sizeof(ULONG))) { I.IoctlBuffer()=hu_test1; I.Information()=6*sizeof(ULONG); return STATUS_SUCCESS; } else { I.Information() = 0; return STATUS_BUFFER_TOO_SMALL; } } void Test_IOCTL_hu_test1(void) { ULONG bufOutput[7];//[IOCTL_OUTBUF_SIZE]; ULONG nOutput; // Call device IO Control interface (IOCTL_hu_test) in driver printf(\"Issuing Ioctl to device - \"); if (!DeviceIoControl(hDevice, IOCTL_hu_test1, NULL, 0, bufOutput, 7*sizeof(ULONG), &nOutput, NULL) ) { printf(\"ERROR: DeviceIoControl returns %0x.\", GetLastError()); Exit(1); } for(int i=0;i<=6;i++) printf(\"hutest is %lx:\\n \",bufOutput); } IOCTL_hu_test1是METHOD_BUFFERED方式的,执行Test_IOCTL_hu_test1(),结果是死机。为何??高手救我! |
|
沙发#
发布于:2003-11-04 16:44
IOCTL_hu_test1_Handler()执行后,你在那里完成了IPR?
|
|
板凳#
发布于:2003-11-07 00:57
谢谢jeosph
不好意思,上面贴的不是很清楚 NTSTATUS Pci5030_109Device::IOCTL_hu_test1_Handler(KIrp I) { NTSTATUS status = STATUS_SUCCESS; ULONG hu_test1[7]; //m_MemoryRange0.ind(addr_clkspeed_reg,hu_test1,6); //1// for(int i=0;i<=6;i++)hu_test1=i; //2// if(I.IoctlOutputBufferSize()>=(6*sizeof(ULONG))) { I.IoctlBuffer()=hu_test1; I.Information()=6*sizeof(ULONG); return STATUS_SUCCESS; } else { I.Information() = 0; return STATUS_BUFFER_TOO_SMALL; } } void Test_IOCTL_hu_test1(void) { ULONG bufOutput[7]; ULONG nOutput; printf(\"Issuing Ioctl to device - \"); if (!DeviceIoControl(hDevice, IOCTL_hu_test1, NULL, 0, bufOutput, 7*sizeof(ULONG), &nOutput, NULL) ) { printf(\"ERROR: DeviceIoControl returns %0x.\", GetLastError()); Exit(1); } for(int i=0;i<=6;i++) printf(\"hutest is %lx:\\n \",bufOutput); } 本意是从偏移地址addr_clkspeed_reg连续读6个双字到缓冲区hu_test1,驱动程序从hu_test1读得数据。 但不知为何死机。怀疑是1处有问题索性用2替代,仍死机。不知高手可否告知原因?谢谢 [编辑 - 11/7/03 by iamhuhuhu] |
|
地板#
发布于:2003-11-07 10:02
[quote]谢谢jeosph
不好意思,上面贴的不是很清楚 NTSTATUS Pci5030_109Device::IOCTL_hu_test1_Handler(KIrp I) { NTSTATUS status = STATUS_SUCCESS; ULONG hu_test1[7]; <------------------*** //m_MemoryRange0.ind(addr_clkspeed_reg,hu_test1,6); //1// for(int i=0;i<=6;i++)hu_test1=i; //2// if(I.IoctlOutputBufferSize()>=(6*sizeof(ULONG))) { I.IoctlBuffer()=hu_test1;<------------*** I.Information()=6*sizeof(ULONG); return STATUS_SUCCESS; } hu_test[7]是一个局部变量,I.IoctlBuffer() = hu_test1 能行吗? |
|
地下室#
发布于:2003-11-07 12:05
有道理啊,不过为什么如下面的程序可行?
NTSTATUS Pci5030_109Device::IOCTL_hu_test1_Handler(KIrp I) { NTSTATUS status = STATUS_SUCCESS; ULONG hu_test1; hu_test1=m_MemoryRange0.ind(addr_test_ctrl_reg); if(I.IoctlOutputBufferSize()>=(6*sizeof(ULONG))) { (ULONG*)I.IoctlBuffer()=hu_test1; I.Information()=sizeof(ULONG); return STATUS_SUCCESS; } else { I.Information() = 0; return STATUS_BUFFER_TOO_SMALL; } } [编辑 - 11/7/03 by iamhuhuhu] |
|