Skip to content

Commit 8cc9441

Browse files
committed
feat: introduce r3solvr
1 parent 97fc6e8 commit 8cc9441

7 files changed

Lines changed: 36 additions & 206 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@ futures = "0.3"
2626
glob = "0.3"
2727
jni = "0.21"
2828
log = "0.4"
29-
lzma-rs = "0.3"
3029
memfd = "0.6"
3130
nix = { version = "0.31" }
3231
notify = "9.0.0-rc.1"
33-
object = "0.38"
3432
parking_lot = "0.12"
3533
once_cell = "1.21"
3634
once_map = "0.4"
3735
procfs = "0.18"
3836
prost = "0.14"
3937
prost-build = "0.14"
38+
r3solvr = { git = "https://github.com/Mufanc/r3solvr" }
4039
regex-lite = "0.1"
4140
scopeguard = "1.2"
4241
serde = { version = "1.0", features = ["derive"] }

src/core/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ env_logger = { workspace = true }
2121
futures = { workspace = true }
2222
jni = { workspace = true }
2323
log = { workspace = true }
24-
lzma-rs = { workspace = true }
2524
memfd = { workspace = true }
2625
nix = { workspace = true, features = ["feature", "fs", "process", "ptrace", "resource", "signal", "socket", "uio", "user"] }
2726
notify = { workspace = true }
28-
object = { workspace = true }
2927
once_cell = { workspace = true }
3028
once_map = { workspace = true }
3129
parking_lot = { workspace = true }
3230
procfs = { workspace = true }
3331
prost = { workspace = true }
32+
r3solvr = { workspace = true }
3433
regex-lite = { workspace = true }
3534
scopeguard = { workspace = true }
3635
serde = { workspace = true }

src/core/src/binary.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub mod cpp;
22
pub mod library;
3-
pub mod symbol;

src/core/src/binary/library.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::binary::symbol::{CachedSymbolResolver, Symbol};
21
use anyhow::Result;
32
use once_cell::sync::Lazy;
43
use once_map::OnceMap;
4+
use r3solvr::{CachedResolver, Symbol, SymbolResolver};
55

66
static SYSTEM_LIBRARY_RESOLVER: Lazy<SystemLibraryResolver> = Lazy::new(SystemLibraryResolver::new);
77

88
pub struct SystemLibraryResolver<'a> {
9-
resolvers: OnceMap<String, CachedSymbolResolver<'a>>,
9+
resolvers: OnceMap<String, CachedResolver<'a>>,
1010
}
1111

1212
impl SystemLibraryResolver<'_> {
@@ -16,12 +16,12 @@ impl SystemLibraryResolver<'_> {
1616
}
1717
}
1818

19-
pub fn resolve(&self, name: &str, pattern: &str) -> Result<Symbol> {
20-
self.resolvers.map_try_insert(
21-
name.into(),
22-
|name| CachedSymbolResolver::from_file(format!("/system/lib64/{name}.so")),
23-
|_, v| v.resolve(pattern),
24-
)?
19+
pub fn resolve(&self, library_name: &str, symbol_name: &str) -> Result<Symbol> {
20+
Ok(self.resolvers.map_try_insert(
21+
library_name.into(),
22+
|name| CachedResolver::from_file(format!("/system/lib64/{name}.so")),
23+
|_, v| v.lookup_symbol(symbol_name),
24+
)??)
2525
}
2626

2727
pub fn instance() -> &'static Self {

src/core/src/binary/symbol.rs

Lines changed: 0 additions & 170 deletions
This file was deleted.

src/core/src/injector/app.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use crate::binary::cpp::ArgCounter;
2-
use crate::binary::symbol::{Section, Symbol, SymbolResolver};
32
use anyhow::{Context, Result};
43
use log::info;
54
use once_cell::sync::Lazy;
5+
use r3solvr::{BasicResolver, Query, Section, Symbol, SymbolResolver};
66
use strum::IntoEnumIterator;
77
use zynx_bridge_shared::zygote::SpecializeVersion;
8+
use zynx_misc::ext::ResultExt;
89

910
mod embryo;
1011
pub mod policy;
@@ -24,13 +25,22 @@ pub struct SpecializeCommonConfig {
2425

2526
impl SpecializeCommonConfig {
2627
fn resolve() -> Result<Self> {
27-
let resolver = SymbolResolver::from_file(SC_LIBRARY_PATH)?;
28+
let resolver = BasicResolver::from_file(SC_LIBRARY_PATH)?;
2829

2930
let (sym, ver) = SpecializeVersion::iter()
30-
.find_map(|ver| resolver.find_symbol(ver.as_ref()).map(|sym| (sym, ver)))
31+
.find_map(|ver| {
32+
resolver
33+
.lookup_symbol(
34+
Query::new(ver.as_ref())
35+
.with_prefix(true)
36+
.with_debugdata(true),
37+
)
38+
.map(|sym| (sym, ver))
39+
.ok_or_warn()
40+
})
3141
.context("no known SpecializeCommon symbol found in libandroid_runtime.so")?;
3242

33-
let sec = resolver.find_section(sym.section_index)?;
43+
let sec = resolver.lookup_section(sym.section_index)?;
3444
let args_count = ArgCounter::count_args_for_symbol(&sym.name)?;
3545

3646
Ok(Self {

0 commit comments

Comments
 (0)