|
19 | 19 | package airsquared.blobsaver.app.natives;
|
20 | 20 |
|
21 | 21 | import airsquared.blobsaver.app.natives.NativeUtils.CFunctionName;
|
| 22 | +import com.sun.jna.FunctionMapper; |
| 23 | +import com.sun.jna.Library; |
| 24 | +import com.sun.jna.Native; |
| 25 | +import com.sun.jna.NativeLibrary; |
22 | 26 | import com.sun.jna.Pointer;
|
23 | 27 | import com.sun.jna.Structure;
|
24 | 28 | import com.sun.jna.ptr.PointerByReference;
|
25 | 29 |
|
| 30 | +import java.util.Map; |
| 31 | + |
26 | 32 | /**
|
27 | 33 | * https://github.com/libimobiledevice/libirecovery/blob/master/src/libirecovery.c
|
28 | 34 | */
|
@@ -67,15 +73,19 @@ public static class irecv_device_info extends Structure {
|
67 | 73 |
|
68 | 74 |
|
69 | 75 | static {
|
70 |
| - try { |
71 |
| - NativeUtils.register(Libimobiledevice.class, "irecovery"); |
72 |
| - } catch (UnsatisfiedLinkError e) { |
73 |
| - try { |
74 |
| - NativeUtils.register(Libimobiledevice.class, "irecovery-1.0"); |
75 |
| - } catch (UnsatisfiedLinkError e2) { |
76 |
| - e.addSuppressed(e2); |
77 |
| - throw e; |
78 |
| - } |
79 |
| - } |
| 76 | +// try { |
| 77 | +// NativeUtils.register(Libimobiledevice.class, "irecovery"); |
| 78 | +// } catch (UnsatisfiedLinkError e) { |
| 79 | +// try { |
| 80 | +// NativeUtils.register(Libimobiledevice.class, "irecovery-1.0"); |
| 81 | +// } catch (UnsatisfiedLinkError e2) { |
| 82 | +// e.addSuppressed(e2); |
| 83 | +// throw e; |
| 84 | +// } |
| 85 | +// } |
| 86 | + Native.register(Libirecovery.class, NativeLibrary.getInstance("irecovery", Map.of(Library.OPTION_CLASSLOADER, Libirecovery.class.getClassLoader(), |
| 87 | + Library.OPTION_FUNCTION_MAPPER, (FunctionMapper) (lib, method) -> |
| 88 | + method.isAnnotationPresent(CFunctionName.class) ? |
| 89 | + method.getAnnotation(CFunctionName.class).value() : method.getName()))); |
80 | 90 | }
|
81 | 91 | }
|
0 commit comments