18

I'm looking to write a LSP in C# to capture and re-direct UDP packets..

I have little experience with LSP's but I've heard they can do this sort of thing, please correct me if I'm wrong, but is this possible?

I would love some example code but I will take any information or advice anyone can give on the topic. :)

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
caesay
  • 16,932
  • 15
  • 95
  • 160

4 Answers4

2

You can view example of code (c#) for LSP at https://github.com/SOLON7/HTTPSniffer. It is used for 32 Windows OS, but you can port it easely to 64 (set LspCatalog64Only during installation)

And you should remember, that you have to generate new GUID for your provider in a case of collisions with another LSP providers.

Serge P
  • 1,173
  • 3
  • 25
  • 39
  • That was a silly slip-up, I'm sorry. Nevertheless, using LSP can be banned by some technologies (for example PunkBuster) – Serge P Dec 28 '12 at 04:24
  • 2
    An addition, Microsoft encourages to use Windows Filtering Platform since Windows Vista. You can use it for your purpose. You can find example for c# here http://social.msdn.microsoft.com/Forums/en-US/wfp/thread/a65bf197-937b-401e-b15f-0e1c3decdb14 Links: http://msdn.microsoft.com/en-us/library/aa366510.aspx http://msdn.microsoft.com/en-us/windows/hardware/gg463267.aspx http://www.codeproject.com/Articles/29026/Firewall-using-Vista-s-Windows-Filtering-Platform – Serge P Dec 28 '12 at 04:45
  • I am voting this up due to the reference of Windows Filtering Platform. Unfortunately, all examples are c++. – Yecats Apr 07 '14 at 00:29
0

You need build an LSP for this, and then access it through P/Invoke. Take a look at WS SPI spec : ftp://ftp.microsoft.com/bussys/Winsock/Winsock2/WSSPI22.DOC

Jas
  • 1,141
  • 5
  • 16
0

have a look at komodia there is an article + example about LSP, unfortunaltly in C++.

But it should not be impossible to convert it.

Lars
  • 947
  • 8
  • 15
-1

Do you definitely want to write your own?

WinPCap does an excellent job of capturing packets. SharpPcap does an equally excellent job of letting you use WinPCap from C#. Both are free and, I think, open-source.

(I'm not sure if WinPCap uses LSP under the hood, but the final result is that you can inspect packets, so might be just the thing you want)

enverpex
  • 1,080
  • 2
  • 8
  • 13
  • I need to intercept/redirect packets. this possible? – caesay Apr 17 '11 at 06:03
  • @Tommy [no, it isn't](http://www.winpcap.org/pipermail/winpcap-users/2008-September/002765.html). I should have paid closer attention to your "redirect" requirement... – enverpex Apr 17 '11 at 11:03