Skip to content
Advertisement

Tag: jna

Decide GNU or MUSL build of linux in Java

I have a Java desktop application which is supposed to run in both GNU Linux distributions (Debian and Ubuntu) and MUSL Linux distributions (Alpine). My application uses a native library also and native library build is different for both type of Linux distributions. I will deliver both with my application in different folders. So at runtime Java program needs to

Redirecting stdout from C lib in Java in JNA

I want to redirect the stdout and stderr C streams to Java, but I am struggling to do so. I used the result of this thread: https://users.jna.dev.java.narkive.com/VdgNgCIb/jna-solutions-to-catch-stdout-stderr-of-dll but it still does not work as intended. Here is my C code (I compiled it as a TestPrintf.dll library): And my Java code: The interface for catching the stdout stream: The interface

How to call setProcessMitigationPolicy using JNA

I’m trying to convert this piece of C++ code into Java code via JNA: I already have the function SetProcessMitigationPolicy from Kernel32.dll and I’m able to call it, but how to pass such parameters? Can you please provide an example of it? UPDATE: I have tried the following code, but it is still not working. Is the function declaration correct?

Where to get Java Native Access Platform sources?

I am trying to build from sources that sources https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.5.0/ Java Native Access Platform version 5.5.0, and I am getting jna-platform-5.5.0.jar size – 1233K which is much less than https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.jar. In the same time, the recommended sources Do not produce jna-platform-5.5.0.jar at all. Could you tell me where to get real sources of Java Native Access Platform version 5.5.0 ?

java.lang.Error: Invalid memory access on 32 bit Windows

I have JNA wrapper for a C DLL. It works fine, except when used on a Windows 32-bit system. Here is a simplified example: I created JNA bindings as follows: The first function SetData() works fine on both 32-bit as well as 64-bit Windows, but the second function crashes on Windows 7 32-bit. I tried using NativeLong as suggested in

Why does Kernel32 OpenProcess function return null?

I’m trying to make an application that reads the memory of another (non-Java & 32bit) application using JNA. So far I know how to find process ID and base address of modules. And right before reading memory I need to open process and the OpenProcess function simply returns null. Also, I’m using Windows 10. How can I get a process

Debugging COM interface mapping in JNA

After mapping Vss.h and several others headers to Java/JNA (see this question) I am trying to run some of the COM object methods and have a problem debugging them. I do not know if I am calling the correct method or one with similar parameters. Some of the error codes I find in the JNA documentation here, but it does

Kotlin JNA getting declared field names to be empty list

The code below is highly inspired by this answer and this answer, and I am trying to get it work with Kotlin language, rather than Java that was given in the answer there. It is basically based on JNA (Java Native Access), which essentially pulls the SYSTEM_BATTERY_STATE from the Windows Native library (on C++) to get information about the battery

Java JNA – Base Address Finding

I am currently attempting to read/write to memory through the use of JNA for Java. For the past week I have tried a multitude of solutions, mostly from [similar projects][1] I have found online, but nothing has resolved my problem. I know I am receiving the correct process ID of the program, then I create a Pointer using the openProcess

Advertisement