使用StdCallFunctionMapper重命名JNA中的DLL函数 [英] renaming DLL functions in JNA using StdCallFunctionMapper
问题描述
c_aa_find_devices()
的函数。但是所有的功能都是从 c_aa
开始,我想将其重命名为 find_devices()
。 从我收集的方式来做,这是与 StdCallFunctionMapper
,但是我在一个例子中找不到如何使用它的文档(即如何映射一个DLL通过名称或按顺序到包装的Java库接口中的所需名称进行功能)。任何关于文档位置的建议?
使用StdCallMapper不会做得好 - 它应该映射werid windows std lib将嵌入的总字节长度嵌入作为名称的一部分的名称。因为它只是为了std lib(只是猜测,但99%你的功能不是这样)。
如果您的DLL在所有功能上使用一些常用的前缀,您只需使用以下类似的东西:
class Mapper实现FunctionMapper {
public String getFunctionName(NativeLibrary library,Method method){
return GenieConnector.FUNCTION_PREFIX + method.getName();
}
}
其中 GenieConnector.FUNCTION_PREFIX
是共同的前缀。请记住,我实现 FunctionMapper
,不扩展 StdCallMapper
I'm trying to use JNA with a DLL in Windows, so far I was able to successfully call a function called c_aa_find_devices()
. But all the functions start with c_aa
and I would like to rename it to find_devices()
.
From what I gather the way to do this is with StdCallFunctionMapper
but I can't find the documentation of how to use it in an example (i.e. how to map a DLL function by name or by ordinal to a desired name in the wrapped Java library interface). Any suggestions on where the docs are?
Using StdCallMapper won't do good - it is supposed to map werid windows std lib names that have embedded total byte lenght of parameters embedded as part of the name. Since it is done to std lib only (just guessing on that, but 99% you'r functions are not the case).
If your dll uses some common prefix on all functions you need just to use something like:
class Mapper implements FunctionMapper{
public String getFunctionName(NativeLibrary library, Method method) {
return GenieConnector.FUNCTION_PREFIX + method.getName();
}
}
Where GenieConnector.FUNCTION_PREFIX
is that common prefix. Bear in mind that i implement FunctionMapper
, not extend StdCallMapper
这篇关于使用StdCallFunctionMapper重命名JNA中的DLL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!