0

I would like to process a logic that determines the security level of the device.

That logic has been written in C++, And It works fairly well.I'm returning either int or jstring.

I have a java class that communicates with my Native code.

I don't want to get the response through my java method return value for security reasons. Because there are some hooking tools, With that one can change the return type and parameter passed to any java method.

My objective is to store the result in memory at C++ and the same has to be accessed at java code.

MohanRaj
  • 662
  • 1
  • 6
  • 21

1 Answers1

0

As far as I know this is not possible, you could try creating an object in Java and passing that to C++, store the information you need and just read it on the Java side.

Adrian
  • 79
  • 6
  • The problem is I still need to call Java method with an object as an argument, That can be modified with hooking. I want to call a function in C++ without any arguments to be passed and no return type from the C++ function. C++ function result to be stored in a common memory and could be accessible from Java method. – MohanRaj Feb 14 '18 at 05:19
  • What is the best approach then? – MohanRaj Feb 14 '18 at 07:08
  • 1
    You could call the C++ method without any parameters from Java, once it arrives in the C++ method you can access the object parameters of the Java object that called it with the JNIEnv* and jobject that is passed by the java environment to C++ by default. With this you can actually access the variables you want or functions in that object that called C++. Here's a link of examples [Examples](https://www.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html) go to section 5. – Adrian Feb 15 '18 at 05:46