FirewallPermission: For the XP SP2 enabled!
June 26, 2004
I just finished building version 1.0.0.0 of my FirewallPermission implementation it is a custom permission and associated declaritive security attribute which uses the Windows Firewall COM interfaces to check whether a program has inbound access on a port enabled.
The implementation is pretty basic right now, but if there is an interest in this then I will rev it with some more enumerations for allowing more fine grained definition of the access required. At the moment you use it like this:
[FirewallPermission(SecurityAction.Demand, Port = 1234)]
public void SomeCode()
{
}
If the demand fails then you get a SecurityException. It will only run on machines that have Windows XP SP2 installed – maybe this is enough of an incentive for you to get off your butt and test out your applications on it!
There are a few things you need to be aware of. First – the interop library has been hacked – its what VS.NET generates, except it has been disassembled and strongly signed. Second, if you get in there and tweak the code remember that VS.NET runs the C# compiler in-proc so it will always use the old version of the permission to emit the XML into the IL stream. I worked around this by doing the editing in VS.NET but then defering to the command-line to do a build and test.
Hope it works, if you have any questions, problems or feedback just leave some comments on this post or e-mail me at mitch.denny@notgartner.com.
June 27, 2004 at 12:00 am
Cool! BTW, you can have VS.NET strong-sign the interop library. Go to the project’s properties and there enter the path for your snk file in the “Wrapper Assembly Key File” field.
August 10, 2005 at 12:00 am
i am hand held device programmer ,
i am facing one problem with my client PC . actually on PC win Xp pro with friewall is installed , and i am using that pc as wireless server, but its not allowing me to access due to friewall, pls send me vb.net that should bypass firewall . i will be thankful to u .
thanks and regards
Shams
mohd_shams@hotmail.com