Code: Select all
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define MAX_BATCH 20 // Number of packets to capture per batch
#define MAX_PACKET_SIZE 1500
UINT recvCount = 0;
UINT8 packets[20 * MAX_PACKET_SIZE]; // Space for up to 20 packets
WINDIVERT_ADDRESS addr[20]; // Addresses for up to 20 packets
UINT addr_len = sizeof(addr);
int main()
{
HANDLE handle = WinDivertOpen("inbound and !loopback", WINDIVERT_LAYER_NETWORK, 0, 0);
if (handle == INVALID_HANDLE_VALUE) {
std::cerr