chenxinyu
驱动牛犊
驱动牛犊
  • 注册日期2004-04-09
  • 最后登录2004-12-07
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1177回复:2

DS开发驱程问题。20分奉送!

楼主#
更多 发布于:2004-11-04 20:33
下面是用DS2.6生成端点2的BULK写。一调用计算机就自动重起。
谁能告诉我哪错了。20分。上回有人跟我说是因为DS2.6有bug,是不是真的?
NTSTATUS D12testDevice::Write(KIrp I)
{
t << "Entering D12testDevice::Write, " << I << EOL;
// TODO: Check the incoming request.  Replace "FALSE" in the following
// line with a check that returns TRUE if the request is not valid.
  if (I.IoctlInputBufferSize()<=0)
{
// Invalid parameter in the Write request
I.Information() = 0;
return I.PnpComplete(this, STATUS_INVALID_PARAMETER);
}

ULONG dwTotalSize = I.IoctlInputBufferSize();
ULONG dwMaxSize = m_Endpoint2OUT.MaximumTransferSize();


if (dwTotalSize > dwMaxSize)
{
ASSERT(dwMaxSize);
dwTotalSize = dwMaxSize;
}

PUCHAR pBuffer = (PUCHAR)I.IoctlBuffer();

KMemory Mem(pBuffer, dwTotalSize);
Mem.SetPageArray();

// Allocate a new context structure for Irp completion
USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO;
if (pCompInfo == NULL)
{
I.Information() = 0;
return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
}

// TODO: Select the correct pipe to write to

// Create an URB to do actual Bulk write to the pipe
PURB pUrb = m_Endpoint2OUT.BuildBulkTransfer(
Mem,          // Where is data coming from?
dwTotalSize,  // How much data to read?
FALSE,        // direction (FALSE = OUT)
NULL  // Link to next URB
);        

if (pUrb == NULL)
{
delete pCompInfo;
I.Information() = 0;
return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
}

// Initialize context structure
pCompInfo->m_pClass = this;
pCompInfo->m_pUrb = pUrb;

    // Submit the URB to our USB device
NTSTATUS status;
status = m_Endpoint2OUT.SubmitUrb(I, pUrb, LinkTo(WriteComplete), pCompInfo, 0);
return status;
}
wdy9927
驱动老牛
驱动老牛
  • 注册日期2003-08-04
  • 最后登录2017-02-04
  • 粉丝0
  • 关注0
  • 积分89分
  • 威望143点
  • 贡献值0点
  • 好评度23点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2004-11-05 08:13
http://www.driverdevelop.com/forum/html_8374.html?1099034906

////////////
wdy9927
驱动老牛
驱动老牛
  • 注册日期2003-08-04
  • 最后登录2017-02-04
  • 粉丝0
  • 关注0
  • 积分89分
  • 威望143点
  • 贡献值0点
  • 好评度23点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2004-11-05 08:14
但我不知道你的问题是否是这个原因/
游客

返回顶部