From e233233b9448b0e44eb7b9778cef33a33c789670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20=C5=A0embera?= Date: Thu, 18 Jul 2024 13:26:39 +0200 Subject: [PATCH] Fixed Npcap related errors in PCAPDLL::PCAPDLL() --- CMakeLists.txt | 2 +- platform/windows/internal/pcapdll.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d769479..90cd4f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic 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_STATIC "Build static icsnVC40 compatibility library" ON) -set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap") +set(LIBICSNEO_NPCAP_INCLUDE_DIR "C:/Users/Vit/source/repos/npcap-sdk-1.13/Include" CACHE STRING "Npcap include directory; set to build with Npcap") # Device Drivers # You almost certainly don't want firmio for your build, diff --git a/platform/windows/internal/pcapdll.cpp b/platform/windows/internal/pcapdll.cpp index 02672f0..a42ccb1 100644 --- a/platform/windows/internal/pcapdll.cpp +++ b/platform/windows/internal/pcapdll.cpp @@ -34,9 +34,12 @@ PCAPDLL::PCAPDLL() int len = GetSystemDirectory(dllPath, 480); // be safe if (len) { _tcscat_s(dllPath, 512, TEXT("\\Npcap")); - cookie = AddDllDirectory(dllPath); + WCHAR dllPath_w[512] = { 0 }; + if (mbstowcs(dllPath_w, dllPath, 512)) { + cookie = AddDllDirectory(dllPath_w); + } } - dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_USER_DIRS); + dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); if (cookie) RemoveDllDirectory(cookie);