### Get Default Java VM Init Args (C/C++) Source: https://lsposed.org/LSPlant/jni_8h Retrieves the default initialization arguments for the Java Virtual Machine. This function is typically used in native code to obtain default settings before creating or attaching to a VM. It requires a pointer to a structure that will be populated with the arguments. ```c JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * _args_); ``` -------------------------------- ### Get Java VM (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Retrieves the Java Virtual Machine interface pointer. It takes the JNI environment and a pointer to a JavaVM pointer to be filled as input. ```cpp jint GetJavaVM(JavaVM **vm) { return functions->GetJavaVM(this,vm); } ``` -------------------------------- ### Java VM Load Handler (C/C++) Source: https://lsposed.org/LSPlant/jni_8h The entry point called when a Java Virtual Machine is loaded. This function is crucial for initializing JNI environments and performing setup tasks before Java code execution begins. It receives a pointer to the JavaVM and reserved data. ```c JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM * _vm_, void * _reserved_); ``` -------------------------------- ### JNI Functions for VM Management Source: https://lsposed.org/LSPlant/jni_8h This snippet lists JNI functions for managing the Java Virtual Machine (JVM). It includes functions for retrieving default VM initialization arguments, creating a new VM, and getting a list of already created VMs. ```c _JNI_IMPORT_OR_EXPORT_ jint JNICALL | JNI_GetDefaultJavaVMInitArgs (void *args) _JNI_IMPORT_OR_EXPORT_ jint JNICALL | JNI_CreateJavaVM (JavaVM **pvm, void **penv, void *args) _JNI_IMPORT_OR_EXPORT_ jint JNICALL | JNI_GetCreatedJavaVMs (JavaVM **, jsize, jsize *) ``` -------------------------------- ### JNI Utility and VM Functions (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Includes miscellaneous utility functions and definitions related to the Java Virtual Machine (VM) itself. This covers operations like getting the VM pointer, handling reserved fields, and other lower-level JNI interactions. ```c JavaVM ** vm; void * reserved0; void * reserved1; void * reserved2; void * reserved3; void * reserved4; void * reserved5; void * reserved6; void * reserved7; void * reserved8; void * reserved9; void * reserved10; void * reserved11; void * reserved12; void * reserved13; void * reserved14; void * reserved15; void * reserved16; void * reserved17; void * reserved18; void * reserved19; void * reserved20; void * ``` -------------------------------- ### JNI Version and Error Handling Functions Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Includes functions for getting the JNI version and handling critical errors. `GetVersion` returns the version of the JNI interface, and `FatalError` is used for unrecoverable errors. ```c jint (JNICALL *GetVersion)(JNIEnv *env); void (JNICALL *FatalError)(JNIEnv *env, const char *msg); ``` -------------------------------- ### Get String Region (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Copies a region of a Java string into a character buffer. It takes the JNI environment, the Java string, the starting index, the length of the region, and the destination buffer as input. ```cpp void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) { functions->GetStringRegion(this,str,start,len,buf); } ``` -------------------------------- ### Get String UTF Region (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Copies a region of a Java string (UTF-8 encoded) into a character buffer. It takes the JNI environment, the Java string, the starting index, the length of the region, and the destination buffer as input. ```cpp void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) { functions->GetStringUTFRegion(this,str,start,len,buf); } ``` -------------------------------- ### JNI_GetDefaultJavaVMInitArgs Source: https://lsposed.org/LSPlant/jni_8h_source Retrieves the default initialization arguments for creating a Java VM. This is useful for setting up the `JavaVMInitArgs` structure. ```APIDOC ## JNI_GetDefaultJavaVMInitArgs ### Description Retrieves the default initialization arguments for creating a Java Virtual Machine. This function populates a `JavaVMInitArgs` structure with default values that can be further customized. ### Method JNI Function ### Endpoint N/A (Native Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **args** (void *) - Output - Pointer to a `JavaVMInitArgs` structure that will be populated with default values. ### Request Example ```c JavaVMInitArgs vm_args; JNI_GetDefaultJavaVMInitArgs(&vm_args); // Modify vm_args as needed before calling JNI_CreateJavaVM ``` ### Response #### Success Response (0) - Returns 0 on success. #### Response Example ```json { "status": "success", "message": "Default VM init args retrieved." } ``` #### Error Response (Non-zero) - Returns a non-zero error code on failure. ``` -------------------------------- ### LSPlant Initialization and Configuration Source: https://lsposed.org/LSPlant/lsplant_8hpp_source Initializes LSPlant and configures its behavior through the InitInfo struct. This includes setting up inline hookers, symbol resolvers, and generated names for hooked methods and classes. It requires a JNIEnv pointer and an InitInfo object. ```cpp #include #include #include namespace lsplant { inline namespace v2 { struct InitInfo { using InlineHookFunType = std::function; using InlineUnhookFunType = std::function; using ArtSymbolResolver = std::function; using ArtSymbolPrefixResolver = std::function; InlineHookFunType inline_hooker; InlineUnhookFunType inline_unhooker; ArtSymbolResolver art_symbol_resolver; ArtSymbolPrefixResolver art_symbol_prefix_resolver; std::string_view generated_class_name = "LSPHooker_"; std::string_view generated_source_name = "LSP"; std::string_view generated_field_name = "hooker"; std::string_view generated_method_name = "{target}"; }; [[nodiscard, maybe_unused, gnu::visibility("default")]] bool Init(JNIEnv *env, const InitInfo &info); } // namespace v2 } // namespace lsplant ``` -------------------------------- ### Get jmethodID via JNI Source: https://lsposed.org/LSPlant/structJNINativeInterface__ These functions are used to obtain a jmethodID, which is a reference to a Java method. They include methods for getting the ID of an instance method, a static method, or converting a reflected method to a jmethodID. ```c JNINativeInterface_::jmethodID _FromReflectedMethod_(); JNINativeInterface_::jmethodID _GetMethodID_(); JNINativeInterface_::jmethodID _GetStaticMethodID_(); ``` -------------------------------- ### Get String Critical (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Gets direct access to the characters of a Java string. This function should be used with caution as it can prevent garbage collection. It takes the JNI environment, the string, and a pointer to a boolean indicating if a copy was made as input. ```cpp const jchar * GetStringCritical(jstring string, jboolean *isCopy) { return functions->GetStringCritical(this,string,isCopy); } ``` -------------------------------- ### JNI VM Initialization and Attachment Structures (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Structures used for initializing and attaching to the Java Virtual Machine (JVM) from native code. JavaVMInitArgs configures JVM startup options, while JavaVMAttachArgs specifies arguments for attaching to a running JVM. ```c typedef struct JavaVMOption { char *optionString; void *extraInfo; } JavaVMOption; typedef struct JavaVMInitArgs { jint version; jint nOptions; JavaVMOption *options; jboolean ignoreUnrecognized; } JavaVMInitArgs; typedef struct JavaVMAttachArgs { const char *version; char *name; jobject group; } JavaVMAttachArgs; ``` -------------------------------- ### lsplant::v2::Init Source: https://lsposed.org/LSPlant/namespacelsplant_1_1v2 Initializes LSPlant for hooking operations. This function prefetches necessary symbols and hooks specific functions, requiring a JNIEnv with unrestricted access to hidden APIs. ```APIDOC ## POST /websites/lsposed_lsplant/Init ### Description Initializes LSPlant for hooking operations. This function prefetches necessary symbols and hooks specific functions, requiring a JNIEnv with unrestricted access to hidden APIs. ### Method POST ### Endpoint /websites/lsposed_lsplant/Init ### Parameters #### Query Parameters - **env** (JNIEnv *) - Required - The Java environment. Must not be null. #### Request Body - **info** (InitInfo &) - Required - Information for initialization, including inline hooker, unhooker, and symbol resolver for libart.so. ### Request Body Example ```json { "env": "", "info": { "inline_hooker": "", "unhooker": "", "symbol_resolver": { "libart_path": "/path/to/libart.so" } } } ``` ### Response #### Success Response (200) - **success** (bool) - Indicates whether initialization succeeded. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Get Primitive Array Critical (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Gets direct access to the elements of a primitive array. This function should be used with caution as it can prevent garbage collection. It takes the JNI environment, the array, and a pointer to a boolean indicating if a copy was made as input. ```cpp void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { return functions->GetPrimitiveArrayCritical(this,array,isCopy); } ``` -------------------------------- ### Get and Set Field Functions in JNI Source: https://lsposed.org/LSPlant/jni_8h_source These functions are used to get and set field values of Java objects from native code. They include functions for various primitive types and object types. They require a JNIEnv pointer, an object, and a field ID. Setters also require a value. ```C jfieldID (JNICALL *GetFieldID) (JNIEnv *env, jclass clazz, const char *name, const char *sig); jobject (JNICALL *GetObjectField) (JNIEnv *env, jobject obj, jfieldID fieldID); jboolean (JNICALL *GetBooleanField) (JNIEnv *env, jobject obj, jfieldID fieldID); jbyte (JNICALL *GetByteField) (JNIEnv *env, jobject obj, jfieldID fieldID); jchar (JNICALL *GetCharField) (JNIEnv *env, jobject obj, jfieldID fieldID); jshort (JNICALL *GetShortField) (JNIEnv *env, jobject obj, jfieldID fieldID); jint (JNICALL *GetIntField) (JNIEnv *env, jobject obj, jfieldID fieldID); jlong (JNICALL *GetLongField) (JNIEnv *env, jobject obj, jfieldID fieldID); jfloat (JNICALL *GetFloatField) (JNIEnv *env, jobject obj, jfieldID fieldID); jdouble (JNICALL *GetDoubleField) (JNIEnv *env, jobject obj, jfieldID fieldID); void (JNICALL *SetObjectField) (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); void (JNICALL *SetBooleanField) (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); void (JNICALL *SetByteField) (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); void (JNICALL *SetCharField) (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); void (JNICALL *SetShortField) (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); void (JNICALL *SetIntField) (JNIEnv *env, jobject obj, jfieldID fieldID, jint val); void (JNICALL *SetLongField) (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); void (JNICALL *SetFloatField) (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); void (JNICALL *SetDoubleField) (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); ``` -------------------------------- ### Monitor Enter (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Enters the monitor for a given Java object. This is equivalent to a synchronized block in Java. It takes the JNI environment and the object as input. ```cpp jint MonitorEnter(jobject obj) { return functions->MonitorEnter(this,obj); } ``` -------------------------------- ### Module Access Source: https://lsposed.org/LSPlant/jni_8h_source Function to get the Java module associated with a class. ```APIDOC ## Module Access ### Description This function retrieves the Java `Module` object associated with a given Java class. This is relevant for applications using Java's module system (JPMS). ### Method - `GetModule` ### Endpoint N/A (This is a native C/C++ function called from Java via JNI) ### Parameters - **clazz** (jclass) - The Java class for which to retrieve the module. ### Request Example ```c jclass myClass = env->FindClass("com/example/MyClass"); jobject module = env->GetModule(myClass); if (module != NULL) { // Process the module object // env->DeleteLocalRef(module); // If necessary } // env->DeleteLocalRef(myClass); // If necessary ``` ### Response #### Success Response Returns a `jobject` representing the Java `Module`. #### Error Response Returns `NULL` if the class has no module or an error occurs. #### Response Example ```json // Returns a jobject reference (e.g., 0x...) or null ``` ``` -------------------------------- ### Char Array Methods Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Documentation for the native method used to create new char arrays. ```APIDOC ## POST /jcharArray() ### Description This native method is used to create a new Java char array. ### Method POST ### Endpoint /jcharArray() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **env** (JNIEnv*) - The JNI environment pointer. - **length** (jsize) - The desired length of the char array. ### Request Example ```json { "env": "JNIEnv_ptr", "length": 50 } ``` ### Response #### Success Response (200) - **return_value** (jcharArray) - A reference to the newly created Java char array. #### Response Example ```json { "return_value": "jcharArray_ref" } ``` ``` -------------------------------- ### JNI Field Access Functions Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Functions for getting and setting fields of Java objects. ```APIDOC ## JNI Field Access Functions ### Description These functions allow native code to access and modify instance fields of Java objects. ### Method Various (e.g., `GetFieldID`, `GetObjectField`, `SetBooleanField`, etc.) ### Endpoint N/A (JNI Function) ### Parameters - **env** (JNIEnv *) - The JNI environment pointer. - **obj** (jobject) - The Java object whose field is to be accessed or modified. - **fieldName** (const char *) - The name of the field. - **signature** (const char *) - The signature of the field. - **value**: The value to set for the field (for setter functions). ### Request Example ```c // Example for getting an integer field jint fieldValue = (*env)->GetIntField(env, obj, fieldID); // Example for setting a boolean field (*env)->SetBooleanField(env, obj, fieldID, JNI_TRUE); ``` ### Response - **Return Value**: Depends on the specific function (e.g., `jfieldID`, `jobject`, `void`). #### Success Response (200) N/A (JNI Function) #### Response Example N/A ``` -------------------------------- ### Class Methods Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Provides documentation for native methods related to class manipulation, including defining, finding, and retrieving class information. ```APIDOC ## POST /jclass() ### Description These native methods are used for defining new classes, finding existing classes, getting the class of an object, and retrieving the superclass of a class. ### Method POST ### Endpoint /jclass() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This endpoint does not explicitly define a request body in the provided documentation. The specific method called would dictate any required parameters. ### Request Example ```json { "method_name": "_FindClass_", "name": "java/lang/String" } ``` ### Response #### Success Response (200) - **return_value** (jclass) - A reference to the class object. #### Response Example ```json { "return_value": "jclass_ref" } ``` ``` -------------------------------- ### JNI Get Short Field Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Retrieves the short value of a field from a Java object or class. ```APIDOC ## GET /jshort/getShortField ### Description Retrieves the short value of an instance field from a Java object. ### Method GET ### Endpoint /jshort/getShortField ### Parameters #### Path Parameters None #### Query Parameters - **obj** (jobject) - Required - The Java object. - **fieldID** (jfieldID) - Required - The field ID. ### Request Example None ### Response #### Success Response (200) - **value** (jshort) - The short value of the field. #### Response Example ```json { "value": 15 } ``` ## GET /jshort/getStaticShortField ### Description Retrieves the short value of a static field from a Java class. ### Method GET ### Endpoint /jshort/getStaticShortField ### Parameters #### Path Parameters None #### Query Parameters - **clazz** (jclass) - Required - The Java class. - **fieldID** (jfieldID) - Required - The field ID. ### Request Example None ### Response #### Success Response (200) - **value** (jshort) - The short value of the static field. #### Response Example ```json { "value": 20 } ``` ``` -------------------------------- ### Byte Array Methods Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Documentation for the native method used to create new byte arrays. ```APIDOC ## POST /jbyteArray() ### Description This native method is used to create a new Java byte array. ### Method POST ### Endpoint /jbyteArray() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **env** (JNIEnv*) - The JNI environment pointer. - **length** (jsize) - The desired length of the byte array. ### Request Example ```json { "env": "JNIEnv_ptr", "length": 100 } ``` ### Response #### Success Response (200) - **return_value** (jbyteArray) - A reference to the newly created Java byte array. #### Response Example ```json { "return_value": "jbyteArray_ref" } ``` ``` -------------------------------- ### JNI Field Accessors Source: https://lsposed.org/LSPlant/jni_8h_source Functions for getting and setting static and instance fields of various primitive types. ```APIDOC ## JNI Field Accessors ### Description Provides functions to access and modify static and instance fields of Java objects. ### Methods #### GetStaticIntField - **Method**: `CallStaticIntMethod` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - **Response**: - **Success Response (200)**: - `jint` - The value of the static integer field. #### SetStaticIntField - **Method**: `SetStaticIntField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jint) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### GetIntField - **Method**: `GetIntField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jint` - The value of the instance integer field. #### SetIntField - **Method**: `SetIntField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jint) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetFloatField - **Method**: `GetFloatField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jfloat` - The value of the instance float field. #### SetFloatField - **Method**: `SetFloatField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jfloat) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetDoubleField - **Method**: `GetDoubleField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jdouble` - The value of the instance double field. #### SetDoubleField - **Method**: `SetDoubleField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jdouble) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetLongField - **Method**: `GetLongField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jlong` - The value of the instance long field. #### SetLongField - **Method**: `SetLongField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jlong) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetBooleanField - **Method**: `GetBooleanField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jboolean` - The value of the instance boolean field. #### SetBooleanField - **Method**: `SetBooleanField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jboolean) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetByteField - **Method**: `GetByteField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jbyte` - The value of the instance byte field. #### SetByteField - **Method**: `SetByteField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jbyte) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetCharField - **Method**: `GetCharField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jchar` - The value of the instance char field. #### SetCharField - **Method**: `SetCharField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jchar) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetShortField - **Method**: `GetShortField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jshort` - The value of the instance short field. #### SetShortField - **Method**: `SetShortField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - `value` (jshort) - Required - The new value for the instance field. - **Response**: - **Success Response (200)**: void #### GetStaticBooleanField - **Method**: `GetStaticBooleanField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - **Response**: - **Success Response (200)**: - `jboolean` - The value of the static boolean field. #### SetStaticBooleanField - **Method**: `SetBooleanField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jboolean) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### SetStaticByteField - **Method**: `SetByteField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jbyte) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### SetStaticCharField - **Method**: `SetStaticCharField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jchar) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### SetStaticShortField - **Method**: `SetStaticShortField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jshort) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### SetStaticLongField - **Method**: `SetLongField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jlong) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### SetStaticObjectField - **Method**: `SetObjectField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - `value` (jobject) - Required - The new value for the static field. - **Response**: - **Success Response (200)**: void #### GetObjectField - **Method**: `GetObjectField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the instance field. - **Response**: - **Success Response (200)**: - `jobject` - The value of the instance object field. #### GetStaticObjectField - **Method**: `GetStaticObjectField` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `fieldID` (jfieldID) - Required - The ID of the static field. - **Response**: - **Success Response (200)**: - `jobject` - The value of the static object field. #### GetObjectArrayElement - **Method**: `GetObjectArrayElement` - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobjectArray) - Required - The object array. - `index` (jsize) - Required - The index of the element. - **Response**: - **Success Response (200)**: - `jobject` - The object at the specified index. #### SetObjectArrayElement - **Method**: `SetObjectArrayElement` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobjectArray) - Required - The object array. - `index` (jsize) - Required - The index of the element. - `value` (jobject) - Required - The object to set. - **Response**: - **Success Response (200)**: void #### GetStringField - **Method**: `GetStringField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the string field. - **Response**: - **Success Response (200)**: - `jstring` - The value of the string field. #### SetStringField - **Method**: `SetStringField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the string field. - `value` (jstring) - Required - The new value for the string field. - **Response**: - **Success Response (200)**: void #### GetObjectField - **Method**: `GetObjectField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the object field. - **Response**: - **Success Response (200)**: - `jobject` - The value of the object field. #### SetObjectField - **Method**: `SetObjectField` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `obj` (jobject) - Required - The object instance. - `fieldID` (jfieldID) - Required - The ID of the object field. - `value` (jobject) - Required - The new value for the object field. - **Response**: - **Success Response (200)**: void #### GetFieldID - **Method**: `GetFieldID` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the field. - `name` (const char *) - Required - The name of the field. - `sig` (const char *) - Required - The signature of the field. - **Response**: - **Success Response (200)**: - `jfieldID` - The ID of the field. #### GetStaticFieldID - **Method**: `GetStaticFieldID` (example, actual method not fully defined) - **Endpoint**: N/A (JNI function) - **Parameters**: - `env` (JNIEnv *) - Required - JNI environment pointer. - `clazz` (jclass) - Required - The class containing the static field. - `name` (const char *) - Required - The name of the static field. - `sig` (const char *) - Required - The signature of the static field. - **Response**: - **Success Response (200)**: - `jfieldID` - The ID of the static field. ### Request Example ```json { "env": "JNIEnv *", "clazz": "jclass", "obj": "jobject", "fieldID": "jfieldID", "value": "any" } ``` ### Response Example ```json { "result": "field value or void" } ``` ``` -------------------------------- ### Char Methods Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Provides documentation for native methods related to handling char data types, including method invocation and field retrieval. ```APIDOC ## POST /jchar() ### Description These native methods are used for invoking methods that return or operate on char data types, and for retrieving char fields. ### Method POST ### Endpoint /jchar() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This endpoint does not explicitly define a request body in the provided documentation. The specific method called would dictate any required parameters. ### Request Example ```json { "method_name": "_CallCharMethod_", "object": "jobject_id", "method_id": "jmethodID_value", "args": ["char_value"] } ``` ### Response #### Success Response (200) - **return_value** (jchar) - The char value returned by the invoked method or retrieved from the field. #### Response Example ```json { "return_value": 'a' } ``` ``` -------------------------------- ### Array Operations Source: https://lsposed.org/LSPlant/jni_8h_source Functions for array manipulation, including getting array length and creating object arrays. ```APIDOC ## Array Operations ### Description This section covers essential functions for working with Java arrays, such as obtaining the length of an array and creating new object arrays. ### Methods - **GetArrayLength** - **Description**: Returns the number of elements in a Java array. - **Method**: N/A (Internal JNI function wrapper) - **Endpoint**: N/A - **NewObjectArray** - **Description**: Creates a new Java array of objects. - **Method**: N/A (Internal JNI function wrapper) - **Endpoint**: N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **jsize**: The number of elements in the array. - **jobjectArray**: A reference to the newly created object array. #### Response Example None ``` -------------------------------- ### LSPlant Initialization API Source: https://lsposed.org/LSPlant/lsplant_8hpp_source Provides functions for initializing and configuring LSPlant, including setting up hooker types and symbol resolvers. ```APIDOC ## POST /api/lsplant/init ### Description Initializes LSPlant for the proceeding hook. It mainly prefetch needed symbols and hook some functions. ### Method POST ### Endpoint /api/lsplant/init ### Parameters #### Request Body - **env** (JNIEnv *) - Required - Pointer to the JNI environment. - **info** (InitInfo) - Required - Initialization information structure. - **inline_hooker** (std::function) - Optional - Function to perform inline hooking. - **inline_unhooker** (std::function) - Optional - Function to perform inline unhooking. - **art_symbol_resolver** (std::function) - Optional - Function to resolve ART symbols. - **art_symbol_prefix_resolver** (std::function) - Optional - Function to resolve ART symbol prefixes. - **generated_class_name** (std::string_view) - Optional - Default: "LSPHooker_". - **generated_source_name** (std::string_view) - Optional - Default: "LSP". - **generated_field_name** (std::string_view) - Optional - Default: "hooker". - **generated_method_name** (std::string_view) - Optional - Default: "{target}". ### Request Example ```json { "env": "", "info": { "inline_hooker": "", "inline_unhooker": "", "art_symbol_resolver": "", "art_symbol_prefix_resolver": "", "generated_class_name": "MyHooker_", "generated_source_name": "MyLSP", "generated_field_name": "hooker_field", "generated_method_name": "my_method" } } ``` ### Response #### Success Response (200) - **success** (bool) - True if initialization was successful, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Get Version (JNI) Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Retrieves the version of the JNI. This can be used to check for compatibility with different Java versions. ```c JNINativeInterface_::jint _GetVersion_() ``` -------------------------------- ### JNI Static Field Access Functions Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Functions for getting and setting static fields of Java classes. ```APIDOC ## JNI Static Field Access Functions ### Description These functions allow native code to access and modify static fields of Java classes. ### Method Various (e.g., `GetStaticFieldID`, `GetStaticObjectField`, `SetStaticBooleanField`, etc.) ### Endpoint N/A (JNI Function) ### Parameters - **env** (JNIEnv *) - The JNI environment pointer. - **clazz** (jclass) - The Java class whose static field is to be accessed or modified. - **fieldName** (const char *) - The name of the static field. - **signature** (const char *) - The signature of the static field. - **value**: The value to set for the static field (for setter functions). ### Request Example ```c // Example for getting a static integer field jint staticFieldValue = (*env)->GetStaticIntField(env, clazz, staticFieldID); // Example for setting a static double field (*env)->SetStaticDoubleField(env, clazz, staticFieldID, 3.14); ``` ### Response - **Return Value**: Depends on the specific function (e.g., `jfieldID`, `jobject`, `void`). #### Success Response (200) N/A (JNI Function) #### Response Example N/A ``` -------------------------------- ### JNI Native Interface - Object and String Creation (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Includes functions for creating new Java objects, global references, and Java strings from native code. ```c jobject(JNICALL *NewGlobalRef})( JNIEnv *env, jobject lobj); jobject(JNICALL *NewObjectA})( JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); jstring(JNICALL *NewString})( JNIEnv *env, const jchar *unicode, jsize len); ``` -------------------------------- ### Get Module (C/C++) Source: https://lsposed.org/LSPlant/jni_8h_source Retrieves the module associated with a Java class. It takes the JNI environment and the class object as input. ```cpp jobject GetModule(jclass clazz) { return functions->GetModule(this, clazz); } ``` -------------------------------- ### Initialize LSPlant Source: https://lsposed.org/LSPlant/namespacelsplant Initializes LSPlant for proceeding hooks by prefetching symbols and hooking functions. Requires a JNIEnv with access to hidden APIs, typically obtained in JNI_OnLoad(). ```cpp bool Init (JNIEnv *env, const InitInfo &info) | Initialize LSPlant for the proceeding hook. It mainly prefetch needed symbols and hook some functions. The env should not have any restriction for accessing hidden APIs. You can obtain such a JNIEnv in JNI_OnLoad(). ``` -------------------------------- ### Get Int Field (JNI) Source: https://lsposed.org/LSPlant/structJNINativeInterface__ Retrieves the value of an int field from a Java object. This function is used to access instance int fields. ```c JNINativeInterface_::jint _GetIntField_() ```