I am compiling the following program in Visual Studio 2015 Community Edition.
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <pcap.h>
int main(int argc, char **argv)
{
pcap_if_t *alldevsp, *device;
char errbuf[100];
int count = 1;
//First get the list of available devices
printf("Finding available devices ... ");
if (pcap_findalldevs(&alldevsp, errbuf))
{
printf("Error finding devices : %s", errbuf);
exit(1);
}
printf("Done");
//Print the available devices
printf("\nAvailable Devices are :\n");
for (device = alldevsp; device != NULL; device = device->next)
{
printf("%d. %s - %s\n", count, device->name, device->description);
count++;
}
return 0;
}
For pcap I have downloaded the library from Npcap project @ GitHub. I installed the release for getting the DLL and using its SDK library for header and linker libraries. The installation of DLL is from the release package 0.0.8-r2 and SDK is from 0.0.7-r9.
Following several pointers over the net how to setup the environment, I have following setting.
- Configuration Properties -> C/C++ -> General -> Additional Include Directories -> Path to header folder from SDK.
- Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> WIN32 _DEBUG _CONSOLE WPCAP HAVE_REMOTE
- Configuration Properties -> Linker -> General -> Additional Library Directory -> Path to library folder from SDK.
- Configuration Properties -> Linker -> Input -> Additional Dependencies -> wpcap.lib Packet.lib
DLL from release exe gets installed in C:\Windows\System32\Npcap. System is Windows 10 Home.
Question:
The above program compiles fine.
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1> HelloWorld.cpp
1> HelloWorld.vcxproj -> C:\Users\xxx\documents\visual studio 2015\Projects\HelloWorld\Debug\HelloWorld.exe
1> HelloWorld.vcxproj -> C:\Users\xxx\documents\visual studio 2015\Projects\HelloWorld\Debug\HelloWorld.pdb (Full PDB)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
When I run it, it was complaining about missing wpcap.dll file. I am new to VS as well as VC++, I googled and simplest technique I found just get over the issue, I copied the DLL from System32 to folder where .exe file was getting generated.
After this DLL issue went away, but now I am getting.
'HelloWorld.exe' (Win32): Loaded 'C:\Users\xxx\Documents\Visual Studio 2015\Projects\HelloWorld\Debug\HelloWorld.exe'. Symbols loaded.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\ntdll.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\kernel32.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\KernelBase.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\ucrtbased.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\syswow64\vcruntime140d.dll'. Cannot find or open the PDB file.
The thread 0x160c has exited with code -1073741701 (0xc000007b).
The thread 0xd5c has exited with code -1073741701 (0xc000007b).
The thread 0x16c4 has exited with code -1073741701 (0xc000007b).
The program '[9632] HelloWorld.exe' has exited with code -1073741701 (0xc000007b).
I googled it, it seems there is mix of 64 bit and 32 bit DLL. I have no clue how to start debugging this issue.
I would really appreciate if some one guides me, to solve.
- Better way (good practice in VC++ world) to find DLL instead of copying to exe folder.
- Tips on how to find which DLL is causing the issue.
Thanks for the time.