Skip to content

Java library to load native DLL's from memory instead of the filesystem

License

Notifications You must be signed in to change notification settings

JasperGeurtz/MemDLL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MemDLL

Load native DLL's from memory instead of the filesystem like required by JNA/JNI. For now windows-x64 only.

Uses MemoryModule to load the dll from memory.

Usecase

Often when using JNA with custom dll's you need to manually extract the dll from your jar. This library aims to avoid these unnecessary steps.

Example Comparison

Using MemDLL

interface MyDLL {
    void someFunc();
}
// load dll directly from resources, no copying
URL dllUrl = MyDLL.class.getClassLoader().getResource("MyDLL.dll");
MyDLL myDLL = MemDLL.load(dllUrl, MyDLL.class);
myDLL.someFunc();

Using only JNA

interface MyDLL extends Library {
    void someFunc();
}

//get from resources and copy to temp folder
File dllLocation = new File(System.getProperty("java.io.tmpdir"), "MyDLL.dll");
Files.copy(MyDLL.class.getClassLoader().getResourceAsStream("MyDLL.dll"), dllLocation.toPath());

// load dll
System.load(dllLocation.getAbsolutePath());
MyDLL myDLL = Native.load("MyDLL", MyDLL.class);
myDLL.someFunc();

Usage

  • add it to your gradle/maven project via JitPack
  • alternatively download the latest jar from the releases

About

Java library to load native DLL's from memory instead of the filesystem

Resources

License

Stars

Watchers

Forks

Packages

No packages published