Skip to content

pcap_findalldevs crashes - only when under Visual Studio debugger #393

Closed

Description

@qortex

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)

Activity

  1. changed the title [-]pcap_findalldevs crashes when under Visual Studio debugger[/-] [+]pcap_findalldevs crashes - only when under Visual Studio debugger[/+] on Mar 29, 2018
  2. qortex commented on Mar 29, 2018

    @qortex
    Author

    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.

  3. dmiller-nmap commented on Mar 29, 2018

    @dmiller-nmap
    Contributor

    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!

  4. dmiller-nmap commented on Mar 29, 2018

    @dmiller-nmap
    Contributor

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

  5. qortex commented on Mar 29, 2018

    @qortex
    Author

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

  6. transferred this issue fromnmap/nmapon May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions