Hello,
I am developing driver based on WDF that implements winsock kernel module. According to documentation winsock has two main objects: client and socket. I am looking to graceful disconnect socket during cleanup call when my socket unloads. I found that I can initialize objects with object attributes structure which contains EvtCleanupCallback I could use. The question is can I create wsk socket (or wsk client objects) like an any object in WDF?
Cheers!
SocketCreate method:
/-----------------------------------------------------/
NTSTATUS SocketCreate(_In_ PDEVICE_CONTEXT DeviceContext, _Out_ PSOCKET_CONTEXT *SocketContext)
{
NTSTATUS status;
WDF_OBJECT_ATTRIBUTES socketAttributes;
WSK_SOCKET socket;
PSOCKET_CONTEXT socketContext;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&socketAttributes, SOCKET_CONTEXT);
socketAttributes.EvtCleanupCallback = EvtSocketCleanup;
socketAttributes.ParentObject = DeviceContext->Device;
status = WdfObjectCreate(&socketAttributes, &socket);
socketContext = GetSocketContext((WDFOBJECT)&socket);
socketContext->Socket = socket;
*SocketContext = socketContext;
return status;
}
/-----------------------------------------------------/