阅读:1046回复:2
求助:debug出现了错误
我的程序每次debug到deviceiocontrol()时,就会提示说指令引用的内存不能为write.但事实上我的outBuffer指向的一个数组的起始地址,应该不存在指针错误。
下面是程序: UINT WriteProc( LPVOID ) { BOOLEAN bResult; short outBuffer[512]; ULONG OutPacketSize; if (WriteLength()>=MAX_BUFFER_SIZE) { OutPacketSize=MAX_BUFFER_SIZE; } else { OutPacketSize=WriteLength(); } WriteCompleteEvent=CreateEvent(0,FALSE,FALSE,NULL); BULK_TRANSFER_CONTROL OutBulkControl; if (bOpenDriver (&hOutDevice) != TRUE) { AfxMessageBox(\"Failed to open the device\",MB_OK); hOutDevice = NULL; } OutBulkControl.pipeNum=0; if (hOutDevice != NULL) { for (int i=0;i<OutPacketSize;i++) outBuffer = WriteDeQueue (); bResult=DeviceIoControl(hOutDevice, IOCTL_EZUSB_BULK_WRITE, &OutBulkControl, sizeof(BULK_TRANSFER_CONTROL), outBuffer, OutPacketSize, 0, NULL); if (WriteCompleteEvent) SetEvent(WriteCompleteEvent); suswrite=1; CloseHandle(hOutDevice); } return bResult; } 上面是辅助线程函数,下面是主程序: CWinThread* myWriteThread = AfxBeginThread (WriteProc,NULL,THREAD_PRIORITY_HIGHEST,0,0,NULL); 每次debug运行到DeviceIoControl()时就会提示指令引用的内存不能为write?. 大家帮帮忙,这程序到底错在哪里? 我自己是怎么也看不出来了。 bow,bow |
|
沙发#
发布于:2005-03-08 19:11
bResult=DeviceIoControl(hOutDevice, IOCTL_EZUSB_BULK_WRITE,
&OutBulkControl, sizeof(BULK_TRANSFER_CONTROL), outBuffer, OutPacketSize, 0, NULL); 改为: DWORD ret; bResult=DeviceIoControl(hOutDevice, IOCTL_EZUSB_BULK_WRITE, &OutBulkControl, sizeof(BULK_TRANSFER_CONTROL), outBuffer, OutPacketSize, &ret, NULL); |
|
板凳#
发布于:2005-03-08 20:20
bResult=DeviceIoControl(hOutDevice, IOCTL_EZUSB_BULK_WRITE, THX 我漏掉了这里。 给你加分。 |
|