Home » Microsoft Technologies

WFP with C#

Hi I have already written an application some time ago in C# using sockets to do many things but as you will know they dont expose the functionality or efficiency of the job in hand when creating a firewall for instance. I recently came across WFP and have been reading any documentation I can find, unfortunately for me its all referring to C++.

I could generally port code over but after reading the welcome thread in this forum I saw a statement that this platform is aimed at C/C++ developers, so is it going to be pointless trying to utilize WFP using C# considering it may need lower-level driver functionaility etc?

Thanks alot for any advice



7 Answers Found


Answer 1


I don't have any C# experience whatsoever, but I will share what I know about WFP as no one else seems to be replying to you...

I am willing to bet there is no C# in kernelspace.  In fact, I wouldn't even try using C++ in kernelspace, just plain old vanilla C.  So callout drivers are going to require some C and windows kernel coding.

However, if what you are trying to accomplish can be done using only the usermode APIs (those documented in the Windows SDK, and not in the DDK), then you have a chance in getting them to work.  I am told that there is some sort of compatibility interface for C# which allows you to call C apis from C#.  All the usermode API of WFP is is a C API, which you get by #include <fwpmu.h> and live in fwpuclnt.dll.  So, calling the WFP management APIs should reduce to the question: can you call C-language APIs from C#, which take OUT pointers, IN OUT pointers, etc.  If so, then you should be able to call the WFP management APIs.

Hope this answers your question. 

Answer 2


The user mode WFP APIs cannot currently be called from C#.

One possibility could be to add managed C++ wrappers around the WFP structures.


Answer 3

What you can do is a Managed C++ Application that calls the underlying WFP API and have a C# that calls this Managed api. I've done that and it's working fine for me.

Answer 4

is there any one have sdk for c#

Answer 5

hmm is it possible to share the managed c++ library? looking at implementing wfp  inside a c# app

Answer 6

Hi Sergio,

Could you please share your managed wrapper on WFP API?



Answer 7

Please browse the following thread.  http://social.msdn.microsoft.com/Forums/en-US/wfp/thread/a65bf197-937b-401e-b15f-0e1c3decdb14

I have directed that poster in this same area with tools and samples.

Hope this helps

Search for  WFP with C#


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure