Skip to content

Commit

Permalink
bugfixes for loading z3 on windows (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-gwassermann authored Mar 31, 2023
1 parent b6d3fe1 commit ce442a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/kaiju/common/KaijuNativeLibraryLoaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ private KaijuNativeLibraryLoaderUtil() {}
public static void loadLibrary(String name) throws FileNotFoundException, UnsatisfiedLinkError {
// System.mapLibraryName will add "lib" and proper extension depending on OS
// so e.g., call mapLibraryName("z3") to get libz3.so on linux
// but on windows mapLibraryName("z3") will get z3.dll so call mapLibraryName("libz3")
File libraryPath = Application.getOSFile("kaiju", System.mapLibraryName(name));
System.load(libraryPath.getAbsolutePath());
}

}
13 changes: 11 additions & 2 deletions src/main/java/kaiju/tools/ghihorn/GhiHornPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ public class GhiHornPlugin extends ProgramPlugin implements AutoAnalysisManagerL

static {
try {
KaijuNativeLibraryLoaderUtil.loadLibrary("z3");
KaijuNativeLibraryLoaderUtil.loadLibrary("z3java");
if (Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {
// load dependents first if on windows
KaijuNativeLibraryLoaderUtil.loadLibrary("vcruntime140");
KaijuNativeLibraryLoaderUtil.loadLibrary("vcruntime140_1");
KaijuNativeLibraryLoaderUtil.loadLibrary("msvcp140");
KaijuNativeLibraryLoaderUtil.loadLibrary("libz3");
KaijuNativeLibraryLoaderUtil.loadLibrary("libz3java");
} else {
KaijuNativeLibraryLoaderUtil.loadLibrary("z3");
KaijuNativeLibraryLoaderUtil.loadLibrary("z3java");
}
String z3status = "Z3 version: " + Version.getFullVersion();
z3LibsFound = true;
} catch (Throwable t) {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/kaiju/tools/statuscheck/KaijuStatusCheckDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import docking.DockingWindowManager;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GLabel;
import ghidra.framework.Platform;
import resources.ResourceManager;

import kaiju.common.*;
Expand All @@ -62,8 +63,17 @@ class KaijuStatusCheckDialog extends DialogComponentProvider {

static {
try {
KaijuNativeLibraryLoaderUtil.loadLibrary("z3");
KaijuNativeLibraryLoaderUtil.loadLibrary("z3java");
if (Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {
// load dependents first if on windows
KaijuNativeLibraryLoaderUtil.loadLibrary("vcruntime140");
KaijuNativeLibraryLoaderUtil.loadLibrary("vcruntime140_1");
KaijuNativeLibraryLoaderUtil.loadLibrary("msvcp140");
KaijuNativeLibraryLoaderUtil.loadLibrary("libz3");
KaijuNativeLibraryLoaderUtil.loadLibrary("libz3java");
} else {
KaijuNativeLibraryLoaderUtil.loadLibrary("z3");
KaijuNativeLibraryLoaderUtil.loadLibrary("z3java");
}
z3LibsFound = true;
} catch (Throwable t) {
z3LibsFound = false;
Expand Down

0 comments on commit ce442a4

Please sign in to comment.