jna

JNA simple function call works on linux (x64) but not on windows (x86)

风流意气都作罢 提交于 2019-12-11 07:36:52
问题 I am trying to run the following C function from Java using JNA, but I get an error (Invalid memory access) on x86 windows (DLL) but not in x64 linux (.SO). c function char* testcopy(char* out,char* in) { strcpy(out,in); free(in); return out; }; C test: works in both platforms (Eclipse CDT/MVC++) When the function is exposed via linux shared library or windows dll and called directly in C, result is OK. ... char out[10]; char* res; char* in = (char*)malloc(3*sizeof(char)); strcpy(in,"ab");

Java: JNA SystemParametersInfo parameters type

十年热恋 提交于 2019-12-11 07:36:42
问题 I only started to experiment with JNA, and stuck trying to call this function w/o exception Native prototype: BOOL WINAPI SystemParametersInfo( __in UINT uiAction, __in UINT uiParam, __inout PVOID pvParam, __in UINT fWinIni ); I've suggested such JNA equivalent: public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); boolean SystemParametersInfo( UINT_PTR uiAction, UINT_PTR uiParam, Pointer pvParam, UINT_PTR fWinIni ); public

JNA link failure Error on Cassandra Startup

こ雲淡風輕ζ 提交于 2019-12-11 07:13:42
问题 I am am trying to run Cassandra instance through eclipse on Windows. In Eclipse run configuration I have specified org.apache.cassandra.service.CassandraDaemon class and in VM arguments I have specified below mentioned VM arguments : -Dcassandra.config=file:C:\nw_servers\apache-cassandra-2.1.3\conf\cassandra.yaml -Dcassandra-foreground -ea -Xmx1G -Dlog4j.configuration=file:C:\nw_servers\apache-cassandra-2.1.3\conf\log4j-server.properties When I run the CassandraDaemon class in eclipse i get

Jna path resolving

╄→гoц情女王★ 提交于 2019-12-11 06:46:24
问题 Im trying to use GStreamer in eclipse via jna. Processing provides a library for that and all is fine if i try to run the code by running the sketch as an applet from eclipse, but when i try to execute the whole application i get a list of warnings(on Camera first call) like this one (javaw.exe:3840): GStreamer-WARNING **: Failed to load plugin 'C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstvorbis.dll': `C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins

Getting an opaque struct returned by parameter in JNA

ぐ巨炮叔叔 提交于 2019-12-11 06:14:27
问题 I'm trying to call a method in Apple's Security.h framework that returns a struct by reference, like so: int findSomething(SomeStruct *s) (Specifically, it's this method, and I'm trying to get itemRef . There's a usage example here.) The problem is that I don't know what fields SomeStruct has or how big it is. It only exists to be passed to other native library functions. So, I want something like this (Java): interface SomeLib extends Library { int findSomething(Pointer p); } ... Pointer p =

How to map a pointer pointer to a structure by JNA?

北城以北 提交于 2019-12-11 06:09:38
问题 Now I have defined a c structure as following: struct HostNameEntry { char *hostName; struct HostNameEntry *next; }; And I have defined a method as following: listHosts(HostNameEntry **hostNameListPtr) The above method will retun a HostNameEntry back the caller. How to mapping this structure/method by JNA? And how to get the hostName stored in HostNameEntry? Thanks a lot 回答1: You tag a version of your HostNameEntry class with Structure.ByReference to force the field to take on a pointer value

Clicking Past a Transparent Frame (Java)

本秂侑毒 提交于 2019-12-11 05:57:46
问题 I am trying to develop an application in Java (Swing) that lets me overlay a grid on the screen, and be able to click things behind the grid -- say, an icon the desktop for example. Would I approach this problem with a Transparent JFrame or a Transparent JWindow? Whatever I use, the transparent window/frame needs to always be on top. occupy the entire screen. register every click with a mouse listener. record the coordinates of the clicks on the screen. allow me to use the Graphics class to

Sending a JNA Pointer from one Java application to another Java application

那年仲夏 提交于 2019-12-11 05:53:42
问题 I have a client and a server application. The client sends String commands to the server, which uses JNA to make relevant calls to two DLL library interfaces. Naturally, I will be required at some point to use Pointers on the java side of things.I am unable to send Pointer objects over the socket connection as they are not serializable. To get around this, I thought that I would get the native long value of the Pointer using Pointer.nativeValue(p), send that long value over the connection and

JNA DLL Function Call implementation

不问归期 提交于 2019-12-11 04:43:06
问题 I have tried and failed! first ill show you the c++ code im trying to imitate then the JNA java code i came up with (half of it works). C++ Code typedef struct { int DeviceType; int Handle; int NumberOfClients; int SerialNumber; int MaxAllowedClients; } NeoDevice; typedef int (__stdcall *FINDNEODEVICES)(unsigned long DeviceTypes, NeoDevice *pNeoDevice, int *pNumDevices); extern FINDNEODEVICES icsneoFindNeoDevices; bool LoadDLLAPI(HINSTANCE &hAPIDLL){ icsneoFindNeoDevices = (FINDNEODEVICES)

How to run chrome using JNA?

家住魔仙堡 提交于 2019-12-11 03:25:13
问题 I wrote some java code. how to run chrome using JNA in windows(32bit). then I like to get the hwnd of it. As you know, FindWindow is simple solution but if chrome doesn't running, it doesn't work. FindWindow example below like code is possible? HWND hwnd = User32.CreateProcess(...); below code open chrome. but sizing, maxmizing doesn't work. public interface Kernel32 extends StdCallLibrary { Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class); boolean CreateProcessA(