wfp redirection udp packet is always invalid, I have rebuilt NB and NBL

I use FWPM_LAYER_ALE_AUTH_CONNECT_V4/6 and FWPM_LAYER_OUTBOUND_TRANSPORT_V4/6, and FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4 and FWPM_LAYER_DATAGRAM_DATA_V4. By assigning the context, the packet is redirected to the local port.

Use filter.action.type = FWP_ACTION_CALLOUT_TERMINATING

if (!gDriverUnloading)
{
	signalWorkerThread = IsListEmpty(&gPacketQueue);
            //....
	pClassifyOut->actionType = FWP_ACTION_BLOCK;
	pClassifyOut->rights &= ~FWPS_RIGHT_ACTION_WRITE;
	pClassifyOut->flags |= FWPS_CLASSIFY_OUT_FLAG_ABSORB;
}

The first method to rebuild nbl:

___FwpsAllocateCloneNetBufferList ,

sendArgs.remoteAddress =
	(packet->belongingFlow->toRemoteAddr ? packet->belongingFlow->toRemoteAddr
		: (UINT8*)&packet->remoteAddr);_

FwpsInjectTransportSendAsync__

The second method to rebuild nbl:

___FwpsAllocateCloneNetBufferList,

sendArgs.remoteAddress = (UCHAR*)&udpDestAddr;

status = KrnlHlprIPHeaderGet(clonedNetBufferList,
&pIPHeader,
&needToFree);

FwpsConstructIpHeaderForTransportPacket,
FwpsInjectTransportSendAsync___

The packet still cannot be redirected, can you help me?

I just used the udp demo test and found that the test was successful. My purpose is to redirect chrome’s dns request. However, the interception and rewriting of the local port cannot succeed.

You haven’t posted enough information for any concrete answers, and the stuff you have posted looks like sample code.

The packet still cannot be redirected
What exactly is happening? is a call failing? What’s the error code?

My purpose is to redirect chrome’s dns request
This should be achievable at DATAGRAM_DATA for UDP and CONNECT_REDIRECT for TCP

However, the interception and rewriting of the local port cannot succeed.
What fails? Also, you want to rewrite the remote port

J

I am very excited that you can reply to my question. I have solved the chrome dns problem. The reason for the failure is not that there is no problem with the code. Your previous reply is one of the reference materials I have developed over the past few months. I even organized these materials specially.