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

pcap_findalldevs crashes - only when under Visual Studio debugger #393

Closed
qortex opened this issue Mar 29, 2018 · 4 comments
Closed

pcap_findalldevs crashes - only when under Visual Studio debugger #393

qortex opened this issue Mar 29, 2018 · 4 comments

Comments

@qortex
Copy link

@qortex qortex commented Mar 29, 2018

When building a simple test example and running it under Win10 inside Visual Studio debugger, I get a crash on calling "pcap_findalldevs" or "pcap_findalldevs_ex". When running outside Visual Studio debugger, no crash and works as expected.

Not related to dll load as I have no such crash when trying to call other functions from npcap (such as pcap_remoteact_cleanup or pcap_wsockinit priori to the call, just for testing purpose). Same behaviour with delay dll loading or loading at startup.

Exception thrown at 0xF5203C2A in ***.exe: 0xC0000008: An invalid handle was specified.

From stack trace and debug symbols, I understand it occurs on line 593 of AdInfo.cpp, where ppItems is null and is dereferenced - only when executed inside Visual Studio debugger.

ntdll.dll!_NtClose@4() Unknown
KernelBase.dll!RegCloseKey() Unknown
Packet.dll!PacketGetAddressesFromRegistry(const char * AdapterNameA, _NPF_IF_ADDRESS_ITEM * * ppItems) Line 593 C++
Packet.dll!PacketAddAdapterNPF(char * AdName, unsigned int flags) Line 1282 C++
Packet.dll!PacketGetAdaptersNPF() Line 1477 C++
Packet.dll!PacketPopulateAdaptersInfoList() Line 2265 C++
Packet.dll!PacketGetAdapterNames(char * pStr, unsigned long * BufferSize) Line 4606 C++
wpcap.dll!0fb78d86() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for wpcap.dll]
wpcap.dll!0fb791a4() Unknown
wpcap.dll!0fb74847() Unknown
[External Code]

Known issue? What debug info would be useful to fix?
VS2017 15.6.4 (latest)

@qortex qortex changed the title pcap_findalldevs crashes when under Visual Studio debugger pcap_findalldevs crashes - only when under Visual Studio debugger Mar 29, 2018
@qortex
Copy link
Author

@qortex qortex commented Mar 29, 2018

To complete the description, I tried to deactivate the Debug Heap as described in the referenced thread below, with no luck.

Differences between running an executable with Visual Studio debugger vs without debugger

Also tried on my laptop, same behaviour.

@dmiller-nmap
Copy link
Contributor

@dmiller-nmap dmiller-nmap commented Mar 29, 2018

Ok, looks like we called RegCloseKey on something that wasn't open. I'm analyzing it now to see where the bug is. Thanks for reporting!

@dmiller-nmap
Copy link
Contributor

@dmiller-nmap dmiller-nmap commented Mar 29, 2018

Stay tuned for the next Npcap release, which will fix this.

@qortex
Copy link
Author

@qortex qortex commented Mar 29, 2018

Alright, thanks for looking into it that fast!
I tried your patch and it works great.

(ok, I misread the debug info, sorry about the misleading ppItems non-sense!)

@fyodor fyodor transferred this issue from nmap/nmap May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants