Nmap: pcap_findalldevs crashes - only when under Visual Studio debugger

Created on 29 Mar 2018  路  4Comments  路  Source: nmap/nmap

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)

Npcap bug

Most helpful comment

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

All 4 comments

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.

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!

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

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!)

Was this page helpful?
0 / 5 - 0 ratings