16

I would like to create/add a virtual network adapter to a client operating system at runtime (via code), preferably in C#. Something similar to that of what VirtualBox/VMware/Himachi creates when you install their software. I am guessing this will require some C/C++ shenanigans for the driver integration, but if it is doable with only C#, all the better.

I am aware of OpenVPN, their stuff is primarily in C, and I am also aware of the TUN/TAP drivers floating around, I just didn't know if these were the only solutions not requiring me creating a fully loaded network driver for Windows.

Simpleton
  • 1,201
  • 3
  • 13
  • 16
  • I'm curious to know if it is possible to do **any** low-level Windows drivers like this in managed .NET code. I don't think I've ever heard of anything like this being done, though I may be wrong. – Dan Herbert Feb 14 '10 at 20:41

1 Answers1

14

If you need simple funcionality then you can use Microsoft Loopback Adapter. To install it use devcon tool. Here is some info about it http://support.microsoft.com/kb/311272. devcon -r install %WINDIR%\Inf\Netloop.inf *MSLOOP After that you can use WMI query with C# to obtain new connection name and then netsh to configure it (ie. netsh int ip set address name="Local Area Connection 2" static 192.168.0.3 255.0.0.0)

raf
  • 156
  • 1
  • 3
  • That is exactly what I was looking for. I am familiar with creating/utilizing MS Loopbacks, but didn't know about devcon's existence. Excellent answer, have yet to find another as logical in my searches. Thanks alot! – Simpleton Feb 19 '10 at 22:29
  • 1
    For those on Win7 x64, you may be interested in http://superuser.com/questions/305685/devcon-exe-not-working-in-windows7-x64 – user276648 Jun 05 '12 at 01:46
  • MD5 of the x64 version: 3904d0698962e09da946046020cbcb17 – user276648 Jun 05 '12 at 01:55
  • `devcon failed` for me. – Gokul E Jun 16 '14 at 08:30