Пример #1
0
        public void WinDivertRecieveTest()
        {
            // Start WinDivert and make sure it returned a valid handle
            IntPtr divert = WinDivert._WinDivertOpen("tcp", WinDivert.Layer.SOCKET, 0, WinDivert.Flag.SNIFF | WinDivert.Flag.RECV_ONLY);

            Assert.AreNotEqual(WinDivert.INVALID_HANDLE_VALUE, divert, GetLastError());

            WinDivertBuffer buf = new WinDivertBuffer();

            Assert.AreEqual((uint)65536, buf.Length);

            uint len = 0;
            bool success;

            WinDivert.Address pAddress = new WinDivert.Address();

            success = WinDivert._WinDivertRecv(divert, buf.BufferPointer, buf.Length, ref len, ref pAddress);

            Assert.IsTrue(success);
            Assert.AreEqual((uint)65536, buf.Length);
            Assert.IsTrue(len < buf.Length);

            //Debug.WriteLine(System.Text.Encoding.UTF8.GetString(buf._buffer, 0, buf._buffer.Length));
            //Debug.WriteLine(pAddress.ToString());

            WinDivert._WinDivertClose(divert);
            WinDivert.StopDriver();
        }
Пример #2
0
 static extern long GetAddressValueFrom([In] WinDivert.Address address, [MarshalAs(UnmanagedType.LPStr)] string fieldName);