Windows 7 SP1
我正在编写一个文件系统驱动程序,尝试使用套接字发送数据。
NTSTATUS NTAPI Connect(IN PWSK_SOCKET WskSocket, IN PSOCKADDR RemoteAddress)
{
KEVENT CompletionEvent = { 0 };
PIRP Irp = NULL;
NTSTATUS status = STATUS_UNSUCCESSFUL;
PWSK_PROVIDER_CONNECTION_DISPATCH SocketDispatcher;
if (g_SocketState != INITIALIZED || !WskSocket || !RemoteAddress)
return STATUS_INVALID_PARAMETER;
status = InitWskData(&Irp, &CompletionEvent);
if (!NT_SUCCESS(status))
{
DbgPrint("Connect(): InitWskData() Failed Status 0x%08X\n", status);
return status;
}
SocketDispatcher = (PWSK_PROVIDER_CONNECTION_DISPATCH)WskSocket->Dispatch;
status = SocketDispatcher->WskConnect(WskSocket, RemoteAddress, 0, Irp); // <-- this line fails
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&CompletionEvent, Executive, KernelMode, FALSE, NULL);
status = Irp->IoStatus.Status;
}
IoFreeIrp(Irp);
return status;
}
创建套接字成功,WSKStart()
成功。
但连接套接字报告错误。
status = SocketDispatcher->WskConnect(WskSocket, RemoteAddress, 0, Irp);
状态代码为0xC0000184
。
有什么问题?