Click to See Complete Forum and Search --> : Java programmer new to C#/using C# and Win32API


icl77
January 14th, 2010, 05:01 PM
Hi guys, im a newbie to C# having programmed with Java a fair amount.

Im currently writing my own (amateur) intrusion detection system and the reason i haven't done this in Java is that a friend told me it would be easier to access the OS using C#.

I was wondering if you guys could give me a few basics how to do something like check a port using the win32API in C# and I could use that as an example and go from there.

I have tried finding books on the subject, but only found a MSPress C/C++ on the api

Thanks in advance

BigEd781
January 14th, 2010, 06:29 PM
Not sure what you mean exactly when you say "check a port". Are you referring to serial port communications, TCP/IP, etc? Here is a tutorial on serial port communication in C#, you probably do not need to use the Win32 API directly at all.

http://www.dreamincode.net/forums/showtopic35775.htm

icl77
January 14th, 2010, 09:20 PM
Not sure what you mean exactly when you say "check a port". Are you referring to serial port communications, TCP/IP, etc? Here is a tutorial on serial port communication in C#, you probably do not need to use the Win32 API directly at all.

http://www.dreamincode.net/forums/showtopic35775.htm

Hey, basically ive been told say i want to monitor a port which is letting msn messenger traffic through, i would not be able to connect to that port via C# because 'msn messenger' would have rights over the port and c# would find that port is 'unavailable'.

So a friend of mine suggesed that i would need to go a level down, to the OS in order to monitor TCP and UDP ports.

In addition, i was hoping to monitor registry changes for particular keys etc.

Hope this clarifies?

icl77
January 15th, 2010, 04:40 PM
bump

HanneSThEGreaT
January 16th, 2010, 04:09 AM
http://www.codeproject.com/KB/IP/UDP_Send_Receive.aspx

http://www.c-sharpcorner.com/UploadFile/patricklam/simpleTcpUdpServerClientPL211222005040054AM/simpleTcpUdpServerClientPL2.aspx

Please don't bump threads.

memeloo
January 16th, 2010, 05:07 AM
I think this is what you're looking for .NET WinPCap (http://geekswithblogs.net/dotnetnomad/archive/2008/01/31/119140.aspx)

icl77
January 22nd, 2010, 07:29 PM
I think this is what you're looking for .NET WinPCap (http://geekswithblogs.net/dotnetnomad/archive/2008/01/31/119140.aspx)


http://pcapdotnet.codeplex.com/

Would someone be able to give me some advice how i actually get this 'wrapper' stuff set up?

I'm not the world's best when it comes to libraries. Ive got VS2008 Pro installed, so i have access to all .NET methods.

Arjay
January 23rd, 2010, 02:47 PM
I suggest starting with the tutorial:

Pcap.Net tutorial: a step by step guide to using Pcap.Net (http://pcapdotnet.codeplex.com/wikipage?title=Pcap.Net%20Tutorial&referringTitle=Pcap.Net%20User%20Guide).