Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winpkFilterDriver.GetNetworkDevices() returns no device #531

Open
clw-helb opened this issue Sep 2, 2024 · 15 comments
Open

winpkFilterDriver.GetNetworkDevices() returns no device #531

clw-helb opened this issue Sep 2, 2024 · 15 comments

Comments

@clw-helb
Copy link

clw-helb commented Sep 2, 2024

When running the WinpkFilterDriver(ndisapi)-example the method GetNetworkDevices returns no device.
What could be the reason for this?
And yes: I manually build/copied ndisapi.dll (from https://github.com/wiresock/ndisapi ) into the build folder

Thx in advance
Clemens

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 2, 2024

The fact that you copied the DLL, means you already did something wrong.

You need to use the installer https://github.com/wiresock/ndisapi/releases

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

Hi Ayoub,
I have Wiresock installed.
api.Version returns 4294967295.
Also when invoking "directly"
_ndisApi.GetTcpipBoundAdaptersInfo()
via ndisApi (NdisApiDotNet) I do get my network devices

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

@clw-helb paste the full code you are using

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

it's the WinpkFilterExample ;-)

If you mean the "direct ndisapi" Code, then:

using NdisApi; // the ndisapi.net.dll
...
public class WinpkFilterTest
{
    private NdisApiDotNet _ndisApi = new NdisApiDotNet(null);

    public Collection<string> GetAllDevices()
    {
        var adapterList = _ndisApi.GetTcpipBoundAdaptersInfo();
        if (!adapterList.Item1)
        {
            Console.WriteLine("WinpkFilter failed to query active interfaces. Exiting.");
        }
        Collection<string> deviceList = new Collection<string>();
        foreach (var adapter in adapterList.Item2)
        {
            var adapterName = adapter.Name;
            var adapterFriendlyName = adapter.FriendlyName;
            deviceList.Add(adapterFriendlyName);
        }

        return deviceList;
    }
}

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

The code that uses GetNetworkDevices

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

The code that uses GetNetworkDevices

as I said: it's the SharpPcap WinpkFilterExample "as is"

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

Could you debug https://github.com/dotpcap/sharppcap/blob/master/SharpPcap/WinpkFilter/WinpkFilterDriver.cs#L66 and check returned value of adapterList ?

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

adapterList is empty, adapterList.AdapterCount == 0

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

GetTcpipBoundAdaptersInfo is a function driver, we have little control over its behavior, things to consider

  • Run application as admin
  • Cross check if you are using x64 or x86

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

upfront: I appreciate your help

Run application as admin

doesn't change the behaviour

Cross check if you are using x64 or x86

x64

Interestingly: although having installed Windows Packet Filter x64, 3.6.1.1, I can run the example only if I place the ndisapi.dll in the build folder, eg
sharppcap\Examples\WinpkFilterExample\bin\x64\Debug\net8.0
If not, I get
System.DllNotFoundException: 'Unable to load DLL 'ndisapi.dll' or one of its dependencies: Das angegebene Modul wurde nicht gefunden. (0x8007007E)'

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

What's the return value of "GetTcpipBoundAdaptersInfo" ?

@clw-helb
Copy link
Author

clw-helb commented Sep 3, 2024

a tuple where Item1 is a boolean (I guess success) and Item2 is a collection of NdisApi.NetworkAdapter (see https://github.com/wiresock/ndisapi/blob/master/ndisapi.net/ndisapicl.h)

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 3, 2024

and what about the return value from the example?

@clw-helb
Copy link
Author

clw-helb commented Sep 4, 2024

as I said:
an empty TcpAdapterList

@kayoub5
Copy link
Collaborator

kayoub5 commented Sep 15, 2024

@clw-helb I can't reproduce the issue, and I have no control over what GetTcpipBoundAdaptersInfo returns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants