WsKSendTo返回STATUS_INVALID_DEVICE_STATE:这是什么意思?

时间:2009-07-21 15:08:30

标签: windows sockets device-driver

我在打开的套接字上调用WsKSendTo(irp在回调中返回成功)。但是该套接字上的WskSendTo返回c0000184,引用的是STATUS_INVALID_DEVICE_STATE。这会解决什么样的错误?

我在发送例程中遗漏了什么吗?

    psc->dstaddr.sin_family = AF_INET;
psc->dstaddr.sin_port = 0x6973;  // big endian
psc->dstaddr.sin_addr.S_un.S_un_b.s_b1 = 0x02;
psc->dstaddr.sin_addr.S_un.S_un_b.s_b2 = 
    psc->dstaddr.sin_addr.S_un.S_un_b.s_b3 = 0x17;
psc->dstaddr.sin_addr.S_un.S_un_b.s_b4 = 0x0a;

// create IRP
psc->pirp = IoAllocateIrp(1, FALSE);
if(!psc->pirp){
    DbgPrint("ShoutShout: IRP not allocated\n");
    FreeShoutContext(psc);
    return STATUS_UNSUCCESSFUL;
}
IoSetCompletionRoutine(
    psc->pirp,
    ShoutShoutComplete,
    psc,
    TRUE,
    TRUE,
    TRUE
    );

// initiate send
const WSK_PROVIDER_DATAGRAM_DISPATCH *dispatch = 
    (PWSK_PROVIDER_DATAGRAM_DISPATCH)sockContext->socket->Dispatch;
status = dispatch->WskSendTo(  
    sockContext->socket,       //PWSK_SOCKET
    &psc->buf,                 //__in PWSK_BUF
    NULL,                      // undocumented IN ULONG  Flags,   
    (PSOCKADDR)&psc->dstaddr,  // IN PSOCKADDR  RemoteAddress OPTIONAL, 
    0,             //  IN SIZE_T  ControlInfoLength, 
    0,             //  IN PCMSGHDR  ControlInfo OPTIONAL,  
    psc->pirp);        //  IN PIRP  Irp    );

之后状态和pirp-> IoStatus->状态包含上述错误代码,并且未发送任何内容(或到达目的地)。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

如果套接字未完全初始化,则返回

c0000184。例如,如果套接字尚未绑定到某个地址。在userland中存在同样的问题,总是绑定你的套接字! (这里使用WskBind。)

同步初始化过程的各个步骤也很有用:使用KEVENT分配套接字上下文,套接字创建和绑定(请参阅KeInitializeEvent开始)。