1

I code a C# program to catch and resolve packets using SharpPcap and PacketDotNet. It performs well when I run it in Administrator Account, still it will popup a window as below:

The question means"Do you want to allow this app to make changes to your device? The question means"Do you want to allow this app to make changes to your device?".

However, when I log in with an Normal User account and run the program, it will faile and catch some exceptions:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SharpPcap.PcapException: 慐正瑥敇䅴慤瑰牥慎敭㩳䌠畯摬❮⁴敧⁴牥潲⁲敭獳条⁥潦⁲牥潲⁲㘨㘲㤱㈴㈷)�岔ⶵ
at SharpPcap.LibPcap.LibPcapLiveDeviceList.GetDevices()
at SharpPcap.LibPcap.LibPcapLiveDeviceList.Refresh()
at SharpPcap.LibPcap.LibPcapLiveDeviceList..ctor()
at SharpPcap.LibPcap.LibPcapLiveDeviceList.get_Instance()
--- End of inner exception stack trace ---

So, I try to run it as Administrator Identity under the Normal User account. I find out the program can run without any exception!

I really got confused with this situation. I want to know how can I run it with a normal user account and it doesn't catch exceptions!

1 Answers1

1

Most likely reason is Npcap “Admin-only Mode”

From https://npcap.com/guide/index.html

Npcap supports restricting its use to Administrators for safety purpose. If Npcap is installed with the option “Restrict Npcap driver's access to Administrators only” checked, only Built-in Administrators may access its features via user software (Nmap, Wireshark, etc). This provides a level of restriction similar to requiring root access for packet capture on Linux/UNIX.

Ayoub Kaanich
  • 992
  • 8
  • 20
  • I read the document from https://npcap.com/ and found the answer! I tried to uninstall the existed Npcap and reinstall it without checking the “Restrict Npcap driver's access to Administrators only” option. It works! Thank you so much! – Frank Zheng Sep 01 '22 at 02:07