add option to build with Npcap on Windows
parent
8f6ff86448
commit
7a71a35848
|
|
@ -6,6 +6,7 @@ option(LIBICSNEO_BUILD_DOCS "Build documentation. Don't use in Visual Studio." O
|
||||||
option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON)
|
option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON)
|
||||||
option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON)
|
option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON)
|
||||||
option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON)
|
option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON)
|
||||||
|
set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
|
@ -182,8 +183,13 @@ endif(NOT WIN32)
|
||||||
|
|
||||||
# winpcap
|
# winpcap
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
if(LIBICSNEO_NPCAP_INCLUDE_DIR STREQUAL "")
|
||||||
target_include_directories(icsneocpp PUBLIC AFTER third-party/winpcap/include)
|
target_include_directories(icsneocpp PUBLIC AFTER third-party/winpcap/include)
|
||||||
add_definitions(-DWPCAP -DHAVE_REMOTE -DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DWPCAP -DHAVE_REMOTE -DWIN32_LEAN_AND_MEAN)
|
||||||
|
else()
|
||||||
|
target_include_directories(icsneocpp PUBLIC AFTER ${LIBICSNEO_NPCAP_INCLUDE_DIR})
|
||||||
|
add_definitions(-DNPCAP -DWIN32_LEAN_AND_MEAN)
|
||||||
|
endif()
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_ICSNEOC)
|
if(LIBICSNEO_BUILD_ICSNEOC)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,21 @@ bool PCAPDLL::ok() const
|
||||||
|
|
||||||
PCAPDLL::PCAPDLL()
|
PCAPDLL::PCAPDLL()
|
||||||
{
|
{
|
||||||
|
#ifdef NPCAP
|
||||||
|
BOOL(WINAPI * SetDllDirectory)(LPCTSTR);
|
||||||
|
char sysdir_name[512];
|
||||||
|
int len;
|
||||||
|
SetDllDirectory = (BOOL(WINAPI*)(LPCTSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA");
|
||||||
|
if (SetDllDirectory != NULL)
|
||||||
|
{
|
||||||
|
len = GetSystemDirectory(sysdir_name, 480); // be safe
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
strcat(sysdir_name, "\\Npcap");
|
||||||
|
SetDllDirectory(sysdir_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
dll = LoadLibrary("wpcap.dll");
|
dll = LoadLibrary("wpcap.dll");
|
||||||
|
|
||||||
if(dll == NULL) {
|
if(dll == NULL) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue