diff --git a/src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java b/src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java index fa93b89..5c051d9 100644 --- a/src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java +++ b/src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java @@ -138,11 +138,22 @@ private static File extractAndLoadNativeLibrary() throws IOException, IllegalSta } String mappedLibName = System.mapLibraryName(libraryLogicalName); - String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.')); - String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.')); + File tempFile; + + if (os.contains("win")) { + // Use a fixed file name under Windows: randomx.dll + Path tempDir = Files.createTempDirectory("randomx-"); + tempDir.toFile().deleteOnExit(); + tempFilePath = tempDir.resolve("randomx.dll"); // Fixed name + } else { + // Linux and macOS uses the default temporary files policy + String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.')); + String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.')); + tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix); + } + + tempFile = tempFilePath.toFile(); - tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix); - File tempFile = tempFilePath.toFile(); tempFile.deleteOnExit(); Files.copy(libStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING); diff --git a/src/main/resources/native/librandomx_windows_x86_64.dll b/src/main/resources/native/librandomx_windows_x86_64.dll index a624f27..4981f4a 100644 Binary files a/src/main/resources/native/librandomx_windows_x86_64.dll and b/src/main/resources/native/librandomx_windows_x86_64.dll differ