multiple fixes & improvements

This commit is contained in:
particle-box
2026-03-07 00:00:36 +05:30
parent 97797127bd
commit 89748cd261
21 changed files with 928 additions and 172 deletions

View File

@@ -15,7 +15,7 @@ pub static CLIENT_MODULE: Lazy<MappedLib> = Lazy::new(|| {
client_module = MappedLib::new("split_config.arm".into());
if let Err(error) = client_module.search() {
panic!("Unable to find split_config.arm: {}", error);
error!("Unable to find split_config.arm: {}", error);
}
}
@@ -46,4 +46,4 @@ pub fn attach_jni_env(block: impl FnOnce(&mut jni::JNIEnv)) {
let mut env: jni::AttachGuard = jvm.attach_current_thread().expect("Failed to attach to current thread");
block(&mut env);
}
}

View File

@@ -43,7 +43,7 @@ macro_rules! dobby_hook_sym {
crate::dobby_hook!(hook_symbol, $hook);
debug!("hooked symbol: {}", $sym);
} else {
panic!("Failed to resolve symbol: {}", $sym);
error!("Failed to resolve symbol: {}", $sym);
}
};
}

View File

@@ -155,9 +155,15 @@ fn setChecksums(mut env: JNIEnv, _class: JClass, checksums_json: JString) {
fn pre_init(_env: JNIEnv, _class: JObject) {
debug!("Pre init");
linker_hook::init();
custom_font_hook::init();
fstat_hook::init();
for (name, init) in [
("linker_hook", linker_hook::init as fn()),
("custom_font_hook", custom_font_hook::init as fn()),
("fstat_hook", fstat_hook::init as fn()),
] {
if let Err(error) = std::panic::catch_unwind(init) {
error!("{} init failed: {:?}", name, error);
}
}
}
fn init(mut env: JNIEnv, _class: JObject, signature_cache: JString) -> jstring {
@@ -186,23 +192,29 @@ fn init(mut env: JNIEnv, _class: JObject, signature_cache: JString) -> jstring {
let mut threads: Vec<std::thread::JoinHandle<()>> = Vec::new();
macro_rules! async_init {
($($f:expr),*) => {
($(($name:expr, $f:expr)),* $(,)?) => {
$(
threads.push(std::thread::spawn(move || {
$f;
if let Err(error) = std::panic::catch_unwind(|| { $f; }) {
error!("{} init failed: {:?}", $name, error);
}
}));
)*
};
}
async_init!(
duplex_hook::init(),
unary_call_hook::init(),
valdi_hook::init(),
sqlite_hook::init()
("duplex_hook", duplex_hook::init()),
("unary_call_hook", unary_call_hook::init()),
("valdi_hook", valdi_hook::init()),
("sqlite_hook", sqlite_hook::init())
);
threads.into_iter().for_each(|t| t.join().unwrap());
threads.into_iter().for_each(|t| {
if let Err(error) = t.join() {
error!("native init worker panicked: {:?}", error);
}
});
info!("native init took {:?}", start_time.elapsed());

View File

@@ -19,11 +19,13 @@ def_hook!(
let content = content.into_boxed_slice();
if libc::write(memfd, content.as_ptr() as *const c_void, content.len() as libc::size_t) == -1 {
panic!("failed to write to memfd");
error!("failed to write to memfd");
return linker_openat_original.unwrap()(dir_fd, pathname, flags, mode);
}
if libc::lseek(memfd, 0, libc::SEEK_SET) == -1 {
panic!("failed to seek memfd");
error!("failed to seek memfd");
return linker_openat_original.unwrap()(dir_fd, pathname, flags, mode);
}
std::mem::forget(content);