Changes to be committed:
modified: src/lib.rs
This commit is contained in:
parent
192248a46b
commit
7b18b0589c
15
src/lib.rs
15
src/lib.rs
@ -2,15 +2,20 @@
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub mod android {
|
pub mod android {
|
||||||
extern crate jni;
|
extern crate jni;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use self::jni::JNIEnv;
|
use self::jni::JNIEnv;
|
||||||
use self::jni::objects::{JClass, JString};
|
use self::jni::objects::{JClass, JString};
|
||||||
use self::jni::sys::{jstring};#[no_mangle]
|
use self::jni::sys::{jstring};
|
||||||
pub unsafe extern fn Java_com_alterdekim_frida_VPN_greeting(env: JNIEnv, _: JClass, java_name: JString) -> jstring {
|
|
||||||
|
|
||||||
let name: String = env.get_string(java_pattern).expect("invalid pattern string").unwrap().into();
|
#[no_mangle]
|
||||||
let mut greeting_string: String = "Hello ".to_owned();
|
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!");
|
||||||
|
|
||||||
greeting_string.push_str(&name);env.new_string(greeting_string).unwrap().into_inner()
|
output.into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user