Changes to be committed:

modified:   src/lib.rs
This commit is contained in:
Michael Wain 2024-09-15 21:34:16 +03:00
parent 192248a46b
commit 7b18b0589c

View File

@ -1,16 +1,21 @@
#[cfg(target_os="android")]
#[allow(non_snake_case)]
pub mod android {
extern crate jni;
use super::*;
use self::jni::JNIEnv;
use self::jni::objects::{JClass, JString};
use self::jni::sys::{jstring};#[no_mangle]
pub unsafe extern fn Java_com_alterdekim_frida_VPN_greeting(env: JNIEnv, _: JClass, java_name: JString) -> jstring {
extern crate jni;
let name: String = env.get_string(java_pattern).expect("invalid pattern string").unwrap().into();
let mut greeting_string: String = "Hello ".to_owned();
use super::*;
use self::jni::JNIEnv;
use self::jni::objects::{JClass, JString};
use self::jni::sys::{jstring};
greeting_string.push_str(&name);env.new_string(greeting_string).unwrap().into_inner()
}
#[no_mangle]
pub unsafe extern fn Java_com_alterdekim_frida_FridaVPN_greeting(env: JNIEnv, _: JClass, java_pattern: JString) -> jstring {
// Our Java companion code might pass-in "world" as a string, hence the name.
let world = rust_greeting(env.get_string(java_pattern).expect("invalid pattern string").as_ptr());
// Retake pointer so that we can use it below and allow memory to be freed when it goes out of scope.
let world_ptr = CString::from_raw(world);
let output = env.new_string(world_ptr.to_str().unwrap()).expect("Couldn't create java string!");
output.into_inner()
}
}