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

Not loading npcap when WinPcap and npcap coexist. #6

Open
spacemeowx2 opened this issue Aug 14, 2019 · 3 comments
Open

Not loading npcap when WinPcap and npcap coexist. #6

spacemeowx2 opened this issue Aug 14, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@spacemeowx2
Copy link
Contributor

spacemeowx2 commented Aug 14, 2019

It seems that we prefer npcap. But when WinPcap and npcap coexist, rawsock actually loads WinPcap.

pub const DEFAULT_PATHS: [&'static str; 4] = [
"NPcap\\Packet.dll",
"Packet.dll",
"Npcap\\wpcap.dll",
"wpcap.dll"
];

Since Npcap\wpcap.dll searchs Packet.dll instead of Npcap\Packet.dll(could be seen using procmon), and Npcap\wpcap.dll wouldn't load correctly with wrong Packet.dll.

And because what we need is wpcap.dll, I think all Packet.dll could be removed from default paths.

Solution:

I think it should be an issue about dlopen.

According to the document (npcap-sdk-1.03/docs/npcap-devguide.html#npcap-feature-native in npcap-sdk-1.03.zip), we need to call SetDllDirectory to make wpcap.dll loading right dll.

You need to do the following one step:

Before calling LoadLibrary to load wpcap.dll, call SetDllDirectory to add C:\Windows\System32\Npcap\ to DLL search path.

@szymonwieloch
Copy link
Owner

@spacemeowx2 Thank you for your report. I have done some debugging and research to better understand the problem.

You are basically right - npcap when installed together with wpcap is installed in such a way that you cannot just open it using LoadLibrary(). This is unexpected. However my understanding is that it works OK when installed as the main library.

We have two choices here. The first one is to assume that rawsock supports only "full" installation of npcap. The second one is to modify the code so that it loads npcap even when installed together with wpcap. My prefference is the second option but at the same time I can see it as a kind of costly change with relatively small value. Not many users will be using npcap together with wpcap and still strictly prefer the first one. Additionally I would like to first implement in dlopen a feature that would allow you to set dll search path from within the process in a portable way. I am not even sure if this is possible (maybe the setenv() function on POSIX will allow you to modify LD_LIBRARY_PATH variable, maybe not).

So I will keep this issue as an low-priority enhancement and try to extend dlopen first.

@szymonwieloch szymonwieloch reopened this Aug 17, 2019
@szymonwieloch szymonwieloch added the enhancement New feature or request label Aug 17, 2019
@szymonwieloch
Copy link
Owner

Blocked by: dlopen issue

@tan-wei
Copy link

tan-wei commented Oct 16, 2019

Is any workaround now?
After I have a glance at the discussion, I think I can release with 2 dll files in the current directory, which is not that elegant. :-P

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

No branches or pull requests

3 participants