You can create a buffer with com.sun.jna.Memory and assign it to the
pParameter field of your structure.
On Jan 11, 2009, at 9:04 PM, fejjsong wrote:
But the structure SM_ALGORITHM,typedef void * PSM_VOID,I will set
it as unsigned char[] ,such as
unsigned char IV[32].In jna I parse this struct's second arg: public
byte[] pParameter.You told me use
the Pointer and SM_ALGORITHM,but the function still return a value:
0x0030,the arg is not suited.
How can I do?
------------------ 原始邮件 ------------------
发件人: "Timothy Wall"<twal...@dev.java.net>;
发送时间: 2009年1月9日(星期五) 晚上8:48
收件人: "fejjsong"<fejj...@vip.qq.com>;
主题: Re: The struct mapping problem JNA
Structures are passed as arguments by reference by default. You can
use SM_ALGORITHM_TYPE, not SM_ALGORITHM_TYPE.ByReference.
pParameter should be Pointer, not byte[].
On Jan 9, 2009, at 1:57 AM, fejjsong wrote:
Hi Timothy:
I'm form China and my English is poor.
Here is a struct:
typedef unsigned long int SM_ALGORITHM_TYPE;
typedef void * PSM_VOID;
typedef unsigned long int SM_ULONG;
typedef struct _SM_ALGORITHM{
SM_ALGORITHM_TYPE AlgoType;
PSM_VOID pParameter;
SM_ULONG ulParameterLen; // In bytes
#ifdef __cplusplus
_SM_ALGORITHM()
{
AlgoType = 0;
pParameter = NULL;
ulParameterLen = 0;
}
#endif
} SM_ALGORITHM, *PSM_ALGORITHM;
In JNA i parse this struct like:
public static class SM_ALGORITHM extends Structure {
public static class ByReference extends SM_ALGORITHM implements
Structure.ByReference {
}
public NativeLong AlgoType;
public byte[] pParameter;
public NativeLong ulParameterLen;
}
and there have a function:
SM_HashInit(
SM_PIPE_HANDLE hPipe,
PSM_ALGORITHM pAlgo
)
In JNA i parse this function like:
public short SM_HashInit(NativeLong hPipe, SM_ALGORITHM.ByReference
sm);
But the function return a value:0x0030,the arg is not suited.The
problem is the second arg,but I have no idea.
Please help me ,thanks very much!