I am implementing a WFP redirector based on https://github.com/microsoft/Windows-driver-samples/tree/master/network/trans/WFPSampler. Now driver redirects traffic successfully and i can recive redirected data in my proxy server, however i have problem with getting original desitnation address/port by WSAIoctl(SIO_QUERY_WFP_CONNECTION_REDIRECT_CONTEXT) which returns WSAEINVAL. I call WSAIoctl right after accept() returned successfully. Here is how i call it:
SOCKET s = accept(ListenSocket, NULL, NULL);
SOCKADDR_STORAGE *ss = (SOCKADDR_STORAGE *)new BYTE[sizeof(SOCKADDR_STORAGE)*2];
DWORD ret = 0;
int a = WSAIoctl(
s,
SIO_QUERY_WFP_CONNECTION_REDIRECT_CONTEXT,
NULL, 0, ss,
sizeof(SOCKADDR_STORAGE)*2, &ret,
NULL, NULL);