diff --git a/build.gradle b/build.gradle index ba59290..8a5c90b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'osgi' group = 'com.fazecast' archivesBaseName = 'jSerialComm' -version = '2.0.0' +version = '2.0.1' ext.moduleName = 'com.fazecast.jSerialComm' assert hasProperty('java6Home'): "Set the property 'java6Home' in your gradle.properties file pointing to a Java 6 JDK installation" diff --git a/src/main/c/Windows/Makefile b/src/main/c/Windows/Makefile index f2c30c6..470dcc5 100644 --- a/src/main/c/Windows/Makefile +++ b/src/main/c/Windows/Makefile @@ -2,9 +2,9 @@ COMPILE = cl LINK = link CFLAGS = /c /O2 /GF /GL /MT /EHsc /fp:precise /J /nologo /TP -LDFLAGS = /DLL /LTCG /NOASSEMBLY /NOLOGO +LDFLAGS = /DLL /LTCG /NOASSEMBLY /NOLOGO /DELAYLOAD:ftd2xx.dll INCLUDES = /I"$(JDK_HOME)/include" /I"$(JDK_HOME)/include/win32" -LIBRARIES = Advapi32.lib SetupAPI.lib +LIBRARIES = Advapi32.lib SetupAPI.lib DelayImp.lib DELETE = @del /q /f RMDIR = @rd /q /s MKDIR = @md diff --git a/src/main/c/Windows/SerialPort_Windows.c b/src/main/c/Windows/SerialPort_Windows.c index 2eae251..23a30b7 100644 --- a/src/main/c/Windows/SerialPort_Windows.c +++ b/src/main/c/Windows/SerialPort_Windows.c @@ -2,7 +2,7 @@ * SerialPort_Windows.c * * Created on: Feb 25, 2012 - * Last Updated on: Apr 01, 2018 + * Last Updated on: Apr 03, 2018 * Author: Will Hedgecock * * Copyright (C) 2012-2018 Fazecast, Inc. @@ -30,6 +30,7 @@ #define WIN32_LEAN_AND_MEAN #include #include +#include #include #include #include @@ -56,6 +57,38 @@ jfieldID readTimeoutField; jfieldID writeTimeoutField; jfieldID eventFlagsField; +// FTDI DLL library loader +EXTERN_C IMAGE_DOS_HEADER __ImageBase; +HINSTANCE hDllInstance = (HINSTANCE)&__ImageBase; +HMODULE LocalLoadLibrary(LPCSTR pszModuleName) +{ + CHAR szPath[MAX_PATH] = ""; + DWORD cchPath = GetModuleFileNameA(hDllInstance, szPath, MAX_PATH); + while (cchPath > 0) + { + switch(szPath[cchPath - 1]) + { + case '\\': + case '/': + case ':': + break; + default: + --cchPath; + continue; + } + break; + } + lstrcpynA(szPath + cchPath, pszModuleName, MAX_PATH - cchPath); + return LoadLibraryA(szPath); +} +FARPROC WINAPI DllLoadNotifyHook(unsigned dliNotify, PDelayLoadInfo pdli) +{ + if (dliNotify == dliNotePreLoadLibrary) + return (FARPROC)LocalLoadLibrary(pdli->szDll); + return NULL; +} +extern "C" const PfnDliHook __pfnDliNotifyHook2 = DllLoadNotifyHook; + JNIEXPORT jobjectArray JNICALL Java_com_fazecast_jSerialComm_SerialPort_getCommPorts(JNIEnv *env, jclass serialComm) { HKEY keyHandle1, keyHandle2, keyHandle3, keyHandle4, keyHandle5; diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index 807e5b3..2deff83 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -41,7 +41,7 @@ import java.util.Date; * This class provides native access to serial ports and devices without requiring external libraries or tools. * * @author Will Hedgecock <will.hedgecock@fazecast.com> - * @version 2.0.0 + * @version 2.0.1 * @see java.io.InputStream * @see java.io.OutputStream */ @@ -185,7 +185,7 @@ public final class SerialPort tempNativeLibrary.deleteOnExit(); if (isWindows) { - ftdiFileName = tempFileDirectory + (new Date()).getTime() + "-ftd2xx.dll"; + ftdiFileName = tempFileDirectory + "ftd2xx.dll"; tempFtdiLibrary = new File(ftdiFileName); tempFtdiLibrary.deleteOnExit(); } diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java b/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java index e960931..79703a6 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java @@ -31,7 +31,7 @@ import java.util.EventListener; * This interface must be implemented to enable simple event-based serial port I/O. * * @author Will Hedgecock <will.hedgecock@fazecast.com> - * @version 2.0.0 + * @version 2.0.1 * @see java.util.EventListener */ public interface SerialPortDataListener extends EventListener diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java b/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java index 0b6a284..4537fc0 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java @@ -31,7 +31,7 @@ import java.util.EventObject; * This class describes an asynchronous serial port event. * * @author Will Hedgecock <will.hedgecock@fazecast.com> - * @version 2.0.0 + * @version 2.0.1 * @see java.util.EventObject */ public final class SerialPortEvent extends EventObject diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPortPacketListener.java b/src/main/java/com/fazecast/jSerialComm/SerialPortPacketListener.java index 1bd0a18..210aced 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPortPacketListener.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPortPacketListener.java @@ -31,7 +31,7 @@ package com.fazecast.jSerialComm; * Note: Using this interface will negate any serial port read timeout settings since they make no sense in an asynchronous context. * * @author Will Hedgecock <will.hedgecock@fazecast.com> - * @version 2.0.0 + * @version 2.0.1 * @see com.fazecast.jSerialComm.SerialPortDataListener * @see java.util.EventListener */ diff --git a/src/main/resources/Windows/x86/jSerialComm.dll b/src/main/resources/Windows/x86/jSerialComm.dll index 06d5847..3684a9d 100644 Binary files a/src/main/resources/Windows/x86/jSerialComm.dll and b/src/main/resources/Windows/x86/jSerialComm.dll differ diff --git a/src/main/resources/Windows/x86/jSerialComm.exp b/src/main/resources/Windows/x86/jSerialComm.exp index 11c0583..8f27f4f 100644 Binary files a/src/main/resources/Windows/x86/jSerialComm.exp and b/src/main/resources/Windows/x86/jSerialComm.exp differ diff --git a/src/main/resources/Windows/x86/jSerialComm.lib b/src/main/resources/Windows/x86/jSerialComm.lib index bd907d0..dccdc44 100644 Binary files a/src/main/resources/Windows/x86/jSerialComm.lib and b/src/main/resources/Windows/x86/jSerialComm.lib differ diff --git a/src/main/resources/Windows/x86_64/jSerialComm.dll b/src/main/resources/Windows/x86_64/jSerialComm.dll index 3cd5e4c..3bf6bdb 100644 Binary files a/src/main/resources/Windows/x86_64/jSerialComm.dll and b/src/main/resources/Windows/x86_64/jSerialComm.dll differ diff --git a/src/main/resources/Windows/x86_64/jSerialComm.exp b/src/main/resources/Windows/x86_64/jSerialComm.exp index f071205..b7ef6a1 100644 Binary files a/src/main/resources/Windows/x86_64/jSerialComm.exp and b/src/main/resources/Windows/x86_64/jSerialComm.exp differ diff --git a/src/main/resources/Windows/x86_64/jSerialComm.lib b/src/main/resources/Windows/x86_64/jSerialComm.lib index a84e4e4..0e26996 100644 Binary files a/src/main/resources/Windows/x86_64/jSerialComm.lib and b/src/main/resources/Windows/x86_64/jSerialComm.lib differ