diff --git a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java index 7eed4b0b..543b47fe 100644 --- a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java +++ b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java @@ -16,9 +16,12 @@ import com.sun.jna.PointerType; import com.sun.jna.Structure; import com.sun.jna.ptr.PointerByReference; + +import java.io.File; import java.lang.reflect.Method; import java.net.InetAddress; import java.nio.ByteOrder; +import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -58,6 +61,16 @@ class NativeMappings { private static final Map NATIVE_LOAD_LIBRARY_OPTIONS = new HashMap(); + static { + if (Platform.isWindows() && System.getProperty("jna.library.path") == null) { + File NPCAP_DIR = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile(); + + if (NPCAP_DIR.exists()) { + NativeLibrary.addSearchPath("wpcap", NPCAP_DIR.getAbsolutePath()); + } + } + } + static { com.sun.jna.Native.register( NativeMappings.class, NativeLibrary.getInstance(libName(Platform.isWindows())));