GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — runidbg/src/diag.rs at main · CKAndroidProject/runidbg Expand file tree/ Copy pathdiag.rsMore file actions 216 lines (190 loc) · 6.87 KB / Copy pathdiag.rsFile metadata and controls216 lines (190 loc) · 6.87 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 use std::collections::BTreeMap; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; /// 缺环境诊断快照(按字典序/编号排序,便于 JSON 输出与生成补环境脚本) #[derive(Debug, Clone, Default)] pub struct EnvDiagSnapshot { pub missing_files: BTreeMap<String, u64>, pub missing_properties: BTreeMap<String, u64>, pub missing_syscalls: BTreeMap<u64, u64>, pub missing_jni: BTreeMap<String, u64>, pub missing_hle: BTreeMap<String, u64>, pub missing_jni_fields: BTreeMap<String, u64>, pub missing_auxv: BTreeMap<u64, u64>, } impl EnvDiagSnapshot { pub fn is_empty(&self) -> bool { self.missing_files.is_empty() && self.missing_properties.is_empty() && self.missing_syscalls.is_empty() && self.missing_jni.is_empty() && self.missing_hle.is_empty() && self.missing_jni_fields.is_empty() && self.missing_auxv.is_empty() } /// 自动生成可直接粘贴运行的 QuickJS 补环境骨架代码 pub fn generate_patch_js(&self) -> String { let mut out = String::new(); out.push_str("// === runidbg 自动生成的补环境模板 ===\n"); out.push_str("// 将以下片段粘贴到你的仿真脚本中,按需填写真实返回值:\n\n"); if !self.missing_properties.is_empty() { out.push_str("// 1. 缺失的系统属性 (android.os.SystemProperties / __system_property_get)\n"); for (key, count) in &self.missing_properties { out.push_str(&format!( "emu.vfs.setProperty({key:?}, \"\"); // 命中 {count} 次\n" )); } out.push('\n'); } if !self.missing_files.is_empty() { out.push_str("// 2. 缺失的虚拟文件 (openat / stat / access -> ENOENT)\n"); for (path, count) in &self.missing_files { out.push_str(&format!( "emu.vfs.writeFile({path:?}, \"\"); // 命中 {count} 次\n" )); } out.push('\n'); } if !self.missing_jni.is_empty() { out.push_str("// 3. 缺失或未处理的 JNI 调用\n"); for (sig, count) in &self.missing_jni { out.push_str(&format!( "emu.jni.hook({sig:?}, (ctx) => {{ /* TODO: 命中 {count} 次 */ return 0; }});\n" )); } out.push('\n'); } if !self.missing_syscalls.is_empty() { out.push_str("// 4. 未实现的 ARM64 Linux Syscall (ENOSYS)\n"); for (nr, count) in &self.missing_syscalls { out.push_str(&format!( "emu.hook.syscall({nr}, (ctx) => {{ /* TODO: syscall #{nr} 命中 {count} 次 */ return 0; }});\n" )); } out.push('\n'); } if !self.missing_hle.is_empty() { out.push_str("// 5. 未实现的外部 HLE 导入符号(返回 0)\n"); for (sym, count) in &self.missing_hle { out.push_str(&format!( "emu.hook.importReplace({sym:?}, (ctx) => {{ /* TODO: 命中 {count} 次 */ return 0; }});\n" )); } out.push('\n'); } if !self.missing_jni_fields.is_empty() { out.push_str("// 6. 缺失的 JNI 静态/实例字段(返回 NULL/0)\n"); for (field_key, count) in &self.missing_jni_fields { out.push_str(&format!( "// {field_key} (命中 {count} 次) -> 可用 emu.jni.setStaticField / emu.jni.setField 注入\n" )); } out.push('\n'); } if !self.missing_auxv.is_empty() { out.push_str("// 7. 未覆盖的 getauxval(type) 类型\n"); for (at_type, count) in &self.missing_auxv { out.push_str(&format!( "// getauxval({at_type}) 命中 {count} 次 -> 可用 emu.hook.import(\"getauxval\", ...) 注入\n" )); } out.push('\n'); } if self.is_empty() { out.push_str("// 未检测到缺失的环境依赖。\n"); } out } } /// 线程安全、低开销的缺环境自动诊断器(关闭时仅 1 次 Relaxed 原子读) #[derive(Debug, Clone, Default)] pub struct EnvDiag { enabled: Arc<AtomicBool>, data: Arc<Mutex<EnvDiagSnapshot>>, } impl EnvDiag { pub fn new() -> Self { Self::default() } pub fn enable(&self) { self.enabled.store(true, Ordering::Release); } pub fn disable(&self) { self.enabled.store(false, Ordering::Release); } pub fn is_enabled(&self) -> bool { self.enabled.load(Ordering::Relaxed) } pub fn clear(&self) { if let Ok(mut g) = self.data.lock() { *g = EnvDiagSnapshot::default(); } } pub fn record_missing_file(&self, path: &str) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_files.entry(path.to_string()).or_insert(0) += 1; } } pub fn record_missing_property(&self, key: &str) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_properties.entry(key.to_string()).or_insert(0) += 1; } } pub fn record_missing_syscall(&self, nr: u64) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_syscalls.entry(nr).or_insert(0) += 1; } } pub fn record_missing_jni(&self, desc: &str) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_jni.entry(desc.to_string()).or_insert(0) += 1; } } pub fn record_missing_hle(&self, sym: &str) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_hle.entry(sym.to_string()).or_insert(0) += 1; } } pub fn record_missing_jni_field(&self, field_key: &str) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_jni_fields .entry(field_key.to_string()) .or_insert(0) += 1; } } pub fn record_missing_auxv(&self, at_type: u64) { if !self.is_enabled() { return; } if let Ok(mut g) = self.data.lock() { *g.missing_auxv.entry(at_type).or_insert(0) += 1; } } pub fn snapshot(&self) -> EnvDiagSnapshot { self.data .lock() .map(|g| g.clone()) .unwrap_or_default() } pub fn generate_patch_js(&self) -> String { self.snapshot().generate_patch_js() } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |