JNA - 传递给系统调用的数据区域太小

时间:2017-07-18 21:41:14

标签: jna numa

对Windows Server 2012 R2 Standard使用JNA 4.4.0。

我可以调用GetCurrentThreadId(),但GetActiveProcessorGroupCount()失败:

import com.sun.jna.LastErrorException;
import com.sun.jna.Library;
import com.sun.jna.Native;

public interface WinLibrary extends Library {
    public int GetCurrentThreadId() throws LastErrorException;

    public short GetActiveProcessorGroupCount() throws LastErrorException;

    public static void main(String[] args) {
        WinLibrary lib = (WinLibrary) Native.loadLibrary("kernel32", WinLibrary.class);

        System.out.println(lib.GetCurrentThreadId());
        //8599

        System.out.println(lib.GetActiveProcessorGroupCount());
    }
}

以下例外:

Exception in thread "main" com.sun.jna.LastErrorException: [122] The data area passed to a system call is too small.
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:415)
at com.sun.jna.Function.invoke(Function.java:354)
at com.sun.jna.Library$Handler.invoke(Library.java:244)
at com.sun.proxy.$Proxy0.GetActiveProcessorGroupCount(Unknown Source)
at WinLibrary.main(WinLibrary.java:16)

不确定如何解释“传递给系统调用的数据区域太小”,因为我实际上没有为该方法提供任何内容。有什么想法吗?

更新:

如果我删除抛出的LastErrorException它可以工作,但是Native.getLastError()返回122,它在the doc中:

ERROR_INSUFFICIENT_BUFFER
122 (0x7A)
The data area passed to a system call is too small.

0 个答案:

没有答案