Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
0 answers
50 views

Using SWIG to handle char* argument that is modified by the method from Java to C++

I have a C++ method : class classA { public: bool methodA(const char* a, const int b, char* c); } This is used in the C++ application as follows: int q = 5; char returnOutput[512] = "...
Shreyak Mysore Shamprasad's user avatar
1 vote
1 answer
65 views

Why JNI env (JNI interface pointer) is thread specific?

Two doubts from JNI Design Overview docs: The JNI interface pointer is only valid in the current thread. A native method, therefore, must not pass the interface pointer from one thread to another. A ...
Jatin guglani's user avatar
1 vote
1 answer
85 views

C++ JNI:Error occurred during initialization of VMFailed setting boot class path

First run main.exe it said can not find jvm.dll So I copy jvm.dll from C:\Program Files\Zulu\zulu-21\bin\server to ./ Then this is my workspace. ls jvm.dll main.cpp main.exe main.obj But second ...
kouhe3's user avatar
  • 59
0 votes
1 answer
91 views

Cannot load a native JNI library

I'm working on a Minecraft library for my own mods to use and i ran into a problem with JNI. I'm still new to the JNI and c++ stuff so i might've made a mistake but after hours of searching i didn't ...
Progames723's user avatar
0 votes
1 answer
83 views

How do I properly pre-load ASAN libraries on macOS with Java binary (JNI library) with SIP enabled

We have a large C++ library for which we have created Java bindings using SWIG (so a JNI shared library). We build for and run tests on many build platforms across macOS, Linux, and Windows; debug and ...
Nick Williams's user avatar
0 votes
0 answers
28 views

Call CallVoidMethod multiple time cause crash

I'm trying to use JSI and JNI in a React-Native app for sending ArrayBuffer without encoding data. For this, I have a C++ function receiveDataFromCpp(): extern "C" JNIEXPORT void JNICALL ...
Stéphane R.'s user avatar
  • 1,496
1 vote
1 answer
53 views

Unable to set timestamp on Android MediaCodec Image object from native c++ code

I have an created a queue to store images from ImageReader in cpp. while copying the queued items to the Image object from MediaCodec.getInputImage(index) method I'm facing an issue where the byte ...
Avaneesh's user avatar
2 votes
1 answer
96 views

Android Native Activity cannot FindClass from external AAR library

I'm trying to build a dynamic library (OpenXR api_layer) in c++ that communicates with a java SDK but I'm having issues with the JNI part of the implementation, from the OpenXR Create Layer function I ...
Naor Liron's user avatar
-1 votes
1 answer
38 views

c++ using JNI: AttachCurrentThread returns -1

I use the JNI in a cpp project, and JNI_GetCreatedJavaVMs is the function how I get JavaVM*. In the project, there is one cpp function which use JNI. And I when use it in one func, it works well. But ...
poiu144's user avatar
0 votes
1 answer
23 views

Compiler opton for detecting missing JNI prototypes?

While going through the exercise of renaming my namespace, I occasionally get tripped up by a situation where the function definitions incorporate the OLD packagename in the fct name. For example: ...
Charles Martin's user avatar
0 votes
0 answers
43 views

How to attach visual studio code to a java process on linux loading *.so files via JNI

I have the following setup on our debug machines: wsl running Ubuntu linux, main code is written in C++ and exposed as shared objects, compilation done using g++, these shared objects are then loaded ...
JJ Moore's user avatar
0 votes
0 answers
58 views

JNI Crashing when using from other header file

When i try to use the JNI pointer from another file, the main process crashes, not sure how to look up the crash reason neither. I've a cpp header file to handle java stuff using ...
Lucas Bois's user avatar
-1 votes
1 answer
159 views

Android App using C++ for serial USB access

I'm developing an Android application that needs to access a third-party library written in C that accesses the serial port through the command (*pSerialHandle) = open(deviceName, O_RDWR | O_NOCTTY | ...
Joterito's user avatar
  • 151
-1 votes
1 answer
147 views

JNI CallStaticObjectMethod is causing crash with Java 21

The company I work for recently moved to Java 21 from Java 8, which updated the JNI version as well that is used with interoperatibility with C++. All the function (written in C++) called through JNI ...
Stew's user avatar
  • 356
0 votes
1 answer
83 views

How to kill android application from c++

I am developing a library to detect rooted environment & I am able to achieve that goal but since the tools like frida, lsposed etc exists, An attacker can be easily able to hook libc's function ...
Ghost's user avatar
  • 102
-2 votes
1 answer
152 views

How can jni be leveraged for an abstract class?

I am just getting familiar with jni/java and the workflow where we want to invoke methods that are written in native code but what i am unable to understand yet is how JNI can be leveraged if the ...
bourne's user avatar
  • 1,217
0 votes
1 answer
95 views

Invoking Java Methods from C++, class not found

I was experimenting with how to invoke the Methods from C++, I got this far: #include <jni.h> #include <iostream> // Function to create the JVM and call the sayHi method void ...
Joseph's user avatar
  • 73
1 vote
0 answers
129 views

JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x80

JNI method NewStringUTF expects input as a modified UTF8 string, the difference between Standard UTF-8 and modified UTF-8 is in how it handles the null (U+0000) character. In standard UTF-8, the null ...
Jatin guglani's user avatar
2 votes
1 answer
321 views

How to represent C++ class in java to be used via FFI?

I have following sample code in C++ class SomeClass: public ISomeClass { private: int myMember; public: SomeClass(int value) : myMember(value) {} __declspec(dllexport) int GetCount() ...
Bojan Vukasovic's user avatar
0 votes
0 answers
121 views

React Native Javascript Native Interface (JSI) Linking failure on Android

I'm trying to get a JavaScript Native Interface module working on Android. Can anyone help? I can compile the app including the CPP library. The app opens, runs the MyJsiNamespace::...
Adonis Gaitatzis's user avatar
3 votes
0 answers
63 views

Trying to pass a structure from C++ to Kotlin through JNI, and I am having to do endian conversion and bit shifting, is there a better way to do this? [duplicate]

I have a union defined in C++, as follows: static union uns { uint64_t data; struct { uint64_t a : 32; uint64_t b : ...
Anumey Sharma's user avatar
0 votes
1 answer
87 views

DllMain is not called after injection

I had a working code that interacted with JNI. When I injected the DLL, everything worked. I decided to improve my program and add a GUI using ImGui and MinHook. After that, DllMain stopped being ...
Nikita's user avatar
  • 41
1 vote
1 answer
86 views

How can I include jar files for clojure in JNI inside a c++ binary created with bazel

Hello I am working on this project: https://github.com/svazqz/plClojure But currently I am facing an issue after building the c++ binary, when I run the file create after the build step I get: # # A ...
svazq's user avatar
  • 11
3 votes
1 answer
161 views

Why SIGSEGV behaves differently from other Exception codes in Android?

I am building an Android application with Native code. I want to handle the exceptions such as SIGSEGV, SIGFPE, SIGILL, etc. My objective is that in the unlikely scenario that one of them occurs, I am ...
Wolfie's user avatar
  • 91
0 votes
1 answer
134 views

What is the best container to store an {arbitrary jobject}'s data in C++?

I am writing an app that should use jobject's fields multiple times at a great speed. Since retrieving fields from jobjects is pretty slow, I want to do it once and then read and write fields of some ...
Tech of the Absence's user avatar
0 votes
1 answer
208 views

I don't know how to solve "local reference table overflow" error in android JNI

I am experiencing a local reference overflow error when running my algorithm written in JNI. The code works fine up to 2000-3000 iterations, but after that, it crashes with the error message "...
JunLEE's user avatar
  • 35
0 votes
0 answers
106 views

Invoke jar from C++ using JNI

I am trying to call a .jar file from native code. It seems no matter what I try, I always get the following error: Error occurred during initialization of VM Failed setting boot class path. I have ...
user avatar
0 votes
1 answer
69 views

JNI - Call java method with a Functional Interface parameter from cpp

I would to know if there is a way to call a java method from cpp with a Functional Interface and use this callback inside my java code. This is my code : Main.java import java.util.function.Consumer; ...
justcodin's user avatar
  • 1,005
0 votes
0 answers
54 views

Generate SWIG JNI for reference pointer

I am trying to generate JNI wrappers using SWIG (4.1) for the following C++ code. The Header.h looks like this: class Butler { public: Butler(); ~Butler(); void setHoursAvailable(int ...
Sahaj's user avatar
  • 21
0 votes
1 answer
104 views

Unable to create or access file at path: /storage/self/primary/Download/ from native-lib.cpp in android studio

In one of my project it requires me to create/read/write file at path /storage/self/primary/Download/ from .cpp file in android studio,but I'm unable to access to that path. As of now I am able to ...
Pranav's user avatar
  • 1
1 vote
1 answer
145 views

Unable to find compiled c++ library function

I have a file called libmylibrary.a and a header file called mylibrary.h this contains a function called myfunction(). I combined them with a cpp file (HelloWorldJNI.cpp) to make a new library named ...
Roohein Malhotra's user avatar
1 vote
1 answer
79 views

How to monitor class loading and track origin jar using jvmti, jni or jvm function

I am making an antiCheating program for java game. I want to monitor the loading of all classes and find out which jar file it is loaded from, or is dynamically generated, so that I can calaulate hash ...
150149's user avatar
  • 11
0 votes
2 answers
114 views

Run jar file that only exists in memory, larger than what a java byte array can hold

To give a quick overview of what my goal is, I've built an application that injects a DLL into a java process, which then proceeds to attempt to load and run a jar file from a remote host. Note that ...
SteveOberst's user avatar
0 votes
0 answers
186 views

Attempting to create a JVM in a process unexpectedly crashes due to OOM

I'm trying to debug an ODBC driver which is implemented partially in Java (using C++ & JNI). We have a test tool which is used to run tests against the driver, but when it tries to load it, during ...
Bwmat's user avatar
  • 4,546
0 votes
1 answer
141 views

Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider when using Admob with C++

I'm trying to add Admob advertising to a C++ Android game. The game uses NativeActivity and doesn't ship any Java code at all - it's all pure C++ and JNI code. I've followed the Admob C++ instructions ...
Kazade's user avatar
  • 1,327
2 votes
0 answers
61 views

How to define multiple classes at the same time using JNI [duplicate]

I have two classes that depend on each other in Java. Example: public class A { public B b; } public class B{ public A a; } Now, I must define these two classes in JNI using env->...
bruhderek's user avatar
0 votes
1 answer
181 views

How to define a resource with JNI

In JNI, I know that you can define a class using env->DefineClass. For example, jclass klass = client->env->DefineClass(nullptr, classLoader, (const jbyte*) classBytes, (jsize) ...
bruhderek's user avatar
2 votes
1 answer
831 views

How to apply Android R8 obfuscation to native code?

I'm developing an Android app that has to be obfuscated for security reasons. Some classes and fields that are obfuscated by R8 are used in my C++ code, so of course the obfuscation step breaks this ...
Paul-Etienne's user avatar
  • 1,018
0 votes
0 answers
48 views

JNI call to FindClass returns null when run on a new thread [duplicate]

I am writing an Android appliction and am using JNI to call Java functions from C++. The following code works as expected, retrieving a reference to a static Java method and then calling it. _JNIEnv *...
Jonny Nightingale's user avatar
0 votes
0 answers
182 views

Calling JNI_CreateJavaVM just hangs

Just trying debug what wrong with harness code, which was compiled with command: ┌──(kali㉿kali)-[~/…/experimment/research/PoCs/android-afl-qemu] └─$ export CC=/home/kali/Android/Sdk/ndk/22.1.7171670/...
Boom's user avatar
  • 25
0 votes
0 answers
54 views

JNI FindClass unable to find class from a packaged jar file

I am unable to use JNIs FindClass function to detect a class from a packaged jar file. If I do not package the jar file (class files not within sub-folders) JNIs FindClass is successful, however I ...
mya's user avatar
  • 81
0 votes
1 answer
89 views

How to call runOnUiThread in Android JNI C++

I have a method called "contactMSFServers" in Android JNI C++ which sends the post request to a API and get the JSON Returned and based on the JSON Success code i am showing toast but the ...
Maaz Arfi's user avatar
0 votes
1 answer
73 views

JNI NoClassDefFoundError while executing method in injected jar

I am getting NoClassDefFoundError when trying to inject a jar file into a running java process. Jar file bytes: static const unsigned char lib_bytes[] = { 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, ...
Derek Li's user avatar
  • 124
0 votes
0 answers
121 views

Why does FindLibrary return 0?

I'm trying to create a launcher for SAMP Android. Everything was going well until the integration of SAMP itself (build69). libsamp.so cannot find the address of the neighboring libGTASA.so library. ...
Daniil Solodkov's user avatar
0 votes
0 answers
81 views

Why few of my symbols don't appear in my .so file? [duplicate]

I am creating an Android native application, where I have many cpp files and few kt files. With the use of cpp files, I am compiling static libraries which gives me .a extension files and as a whole I ...
Rohan Pande's user avatar
1 vote
1 answer
193 views

How to use JNI without having to add jvm.dll location into Environment Variables Path

One way to make JNI work is to go into Environment Variables and add into User or System Path the folder where jvm.dll is located (.../bin/server). But this means that on a client machine, when your ...
user avatar
1 vote
0 answers
131 views

Unable to run android app with prebuilt native library

I have a library written in c++, and it is pre built by Androi NDK clang++ with Makefile command, like this: libfoo.so: $(CXX) -c -Wall -Werror -fpic ${SRC_PATH}foo.cpp $(CXX) -shared -o ...
MinhNV's user avatar
  • 187
1 vote
1 answer
75 views

Constructing an object crashes jvm

Constructing an object crashes the jvm because the constructor is not found. The signature is correct and the constructor exists. This is my new object code: JavaObject(jclass klass, const char *...
Derek Li's user avatar
  • 124
0 votes
0 answers
427 views

Native Android Crash SIGNAL 11(SIGSEGV)

How to debug a signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3634323064373235 in Android JNI? I have tried using debugger to find out the root cause but the app is getting crashed randomly (...
Ghostop's user avatar
  • 45
1 vote
1 answer
1k views

JNI DETECTED ERROR IN APPLICATION: Thread using JNIEnv* from different thread

When I try to call the function in the java class, I get the following error. ava_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: thread Thread[21,tid=15479,Native,Thread*=0x7d932413a0,peer=...
Mustafa Maden's user avatar

1
2 3 4 5
57