Directly using VirtualBox from Java #5

Merged
NorbiPeti merged 60 commits from directvb into master 2019-04-18 23:29:21 +00:00
5 changed files with 37 additions and 0 deletions
Showing only changes of commit 026edffed4 - Show all commits

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
libpxc.so
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.

View file

@ -0,0 +1,5 @@
package sznp.virtualcomputer;
public interface PXCLib {
int convert(int[] px, long[] out);
}

View file

@ -0,0 +1,19 @@
package sznp.virtualcomputer;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import jnr.ffi.LibraryLoader;
import java.io.File;
import java.nio.ByteBuffer;
public class Test {
public static void main(String[] args) {
System.out.println(new File("").getAbsolutePath());
PXCLib pxc = LibraryLoader.create(PXCLib.class).search(new File("").getAbsolutePath()).load("pxc");
ByteBuffer bb = ByteBuffer.allocateDirect(2);
long[] x = new long[]{Pointer.nativeValue(Native.getDirectBufferPointer(bb))};
pxc.convert(new int[]{5, 10}, x);
System.out.println(bb.get(0)); //19 AYY
}
}

View file

@ -7,4 +7,5 @@ pxct: pxct.c pxc
pxc: pxc.c pxc: pxc.c
$(CC) -Wall -c -fpic pxc.c -o obj/pxc.o $(CC) -Wall -c -fpic pxc.c -o obj/pxc.o
$(CC) -Wall -shared obj/pxc.o -o out/libpxc.so $(CC) -Wall -shared obj/pxc.o -o out/libpxc.so
cp out/libpxc.so ../

View file

@ -1,7 +1,17 @@
#include <stdio.h> #include <stdio.h>
typedef long long int lli;
void* image=NULL;
void setSource(lli address) {
image=(void*)address;
}
int convert(int px[], int *out[]) { int convert(int px[], int *out[]) {
printf("convert...\n"); printf("convert...\n");
printf("px0: %d\n", px[0]);
*out[0]=19;
return 0; return 0;
} }