Hi,
I have been struggling to find examples on void* example in JNA. I am trying to understand how to use Pointer in JNA.
For example
IN C :
int PTOsetApiOpt(int iOpt,void* lpValue,int iLen)
Parameters: iOpt: int
lpData: address from which data should be read.
iLen: length of data
returns int values : 0 as success or -1 as failure.
How do we write that in JAVA using JNA? I have tried this in JAVA
public MyTest{
public interface MyLibrary extends Library {
public int PTOsetApiOpt(int iOpt,Pointer lpValue,int iLen);
}
public static void main(String[] args) {
MyLibrary myLib = (MyLibrary)MyLibrary.INSTANCE;
int result = myLib.PTOsetApiOpt(1,new Pointer(0),1024);
}
I get JVM crash when myLib.PTOsetApiOpt is invoked. I am guessing this is because of new Pointer statement. How can I create a Pointer and use it as parameter without JVM crash? I have been stuck on it for 2 days. Any tips would be great. Thanks in advance.
Regards, -Vid-