FirewallPermission: For the XP SP2 enabled!

I just finished building version 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


2 thoughts on “FirewallPermission: For the XP SP2 enabled!

  1. Ælij Arbel

    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.

  2. Mohd Shamsuddin

    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 that should bypass firewall . i will be thankful to u .

    thanks and regards


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s