I try to Winsock kernel and write a test project that set up the wsk environment, but the error occured while building project the visual studio can not link the definitions of wsk functions.
I thought there was my fault and some headers are missing on my pc, but I grab the first project on internet that use wsk.h and it's compiled successfully. enter image description here
#include <ntddk.h>
#include <wsk.h>
NTSTATUS registerWSKApp();
NTSTATUS wskAppWorkerRoutine();
NTSTATUS registerWSKApp()
{
NTSTATUS status;
WSK_CLIENT_NPI wskClientNpi{};
wskClientNpi.ClientContext = NULL;
wskClientNpi.Dispatch = &dispatchTable;
status = WskRegister(&wskClientNpi, &wskRegistration);
return status;
}
NTSTATUS wskAppWorkerRoutine()
{
KdPrint(("[+] Call of wskAppWorkerRoutine!"));
NTSTATUS status;
WSK_PROVIDER_NPI wskProviderNpi;
status = WskCaptureProviderNPI(
&wskRegistration,
WSK_NO_WAIT,
&wskProviderNpi
);
if (!NT_SUCCESS(status))
{
if (status == STATUS_NOINTERFACE)
{
KdPrint(("[-] A requested WSK version is not supported!\n"));
return status;
}
return status;
}
KdPrint(("[+] Succesfully capture NPI!\n"));
//
// 1. Create socket
// 2. Bind socket
// 3. listen socket
// 4. accept connection
// 5. receive data
//
WSK_APP_SOCKET_CONTEXT socketContext { 0 };
//creation of socket
status = createListeningSocket(&wskProviderNpi, &socketContext, NULL);
if (!NT_SUCCESS(status))
{
KdPrint(("[-] Failed to create listening socket!\n"));
}
return status;
}
I try to solve problem in netiodef.h by trying all the compiler settings that are related with this issue, but it isn't help
If your linker reports unresolved symbols in "wsk.h" and sub headers you need to explicitly point the linker to the “netio.lib” library in additional dependencies.
I think that information should be added in the article "Registering a Winsock Kernel Application" on learn.microsoft.com