SEHException : External component has thrown an exception.
I'm getting the above exception in the following part of the code when I run the program.
The exception occurs at this lineCode:IntPtr fcode = IntPtr.Zero; bpf_program bpf = new bpf_program(); fcode = Marshal.AllocHGlobal(Marshal.SizeOf(bpf)); Marshal.StructureToPtr(bpf,fcode,false); string fter = "ip and tcp"; if (wpcap_wrap.pcap_compile(ref adhandle, ref fcode, fter, 1, nmask) < 0) { Console.WriteLine("Unable to compile filter"); } if (wpcap_wrap.pcap_setfilter(ref adhandle, ref fcode) < 0) Console.WriteLine("Error setting filter"); Marshal.FreeHGlobal(fcode);
I declared the method as followsCode:if (wpcap_wrap.pcap_setfilter(ref adhandle, ref fcode) < 0)
I'm trying to write an app that filters packets.Code:[DllImport("wpcap.dll")] public static extern int pcap_setfilter(ref IntPtr p,ref IntPtr fp);
Any help would be greatly appreciated.




Reply With Quote