fixed bugs, memory leaks, etc
This commit is contained in:
1 parent
aa4f6b6ddc
commit
c3f8f23c1d
124 files changed
+1060
-420
No files matched your search
@@ -1,5 +1,5 @@
|
||||
//! The loader worker: JVM discovery, payload installation into Fabric's Knot class loader, native registration, bootstrap.
|
||||
use crate::bridge::{init_jvmti, native_class_bytes, native_log, native_redefine};
|
||||
use crate::bridge::{init_jvmti, native_class_bytes, native_log, native_redefine, native_release};
|
||||
use crate::jni::*;
|
||||
use crate::log;
|
||||
use std::ffi::{c_char, c_void};
|
||||
@@ -28,6 +28,13 @@ pub fn run() {
|
||||
unsafe fn install() -> Result<(), String> {
|
||||
let vm = find_vm()?;
|
||||
let env = attach_current_thread(vm)?;
|
||||
struct Detach(VmPtr);
|
||||
impl Drop for Detach {
|
||||
fn drop(&mut self) {
|
||||
unsafe { detach_current_thread(self.0) }
|
||||
}
|
||||
}
|
||||
let _detach = Detach(vm);
|
||||
let jni = Jni::new(env);
|
||||
log!("attached to the JVM");
|
||||
|
||||
@@ -160,6 +167,11 @@ unsafe fn register_natives(jni: &Jni, loader: JObject) -> Result<(), String> {
|
||||
signature: c"(Ljava/lang/Class;[B)I".as_ptr(),
|
||||
fn_ptr: native_redefine as *const () as usize as *mut c_void,
|
||||
},
|
||||
NativeMethod {
|
||||
name: c"release".as_ptr(),
|
||||
signature: c"()V".as_ptr(),
|
||||
fn_ptr: native_release as *const () as usize as *mut c_void,
|
||||
},
|
||||
NativeMethod {
|
||||
name: c"log".as_ptr(),
|
||||
signature: c"(Ljava/lang/String;)V".as_ptr(),
|
||||
|
||||
Reference in new issue
Block a user