Skip to content

Commit 0dba05c

Browse files
committed
feat: improve CLI help and version output
1 parent bf8b89d commit 0dba05c

5 files changed

Lines changed: 31 additions & 7 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@ Place shared libraries (`.so`) or dex files (`.dex`) in `/data/adb/zynx/liteload
1717

1818
### Force Debuggable
1919

20+
> Requires `--cfg-enable-debugger` to be enabled.
21+
2022
Set the system property `debug.zynx.debuggable.<package_name>` to `1` to force-enable debugging for the specified app:
2123

2224
```shell
2325
setprop debug.zynx.debuggable.com.example.app 1
2426
```
2527

28+
### Zygisk (WIP)
29+
30+
> Requires `--cfg-enable-zygisk` to be enabled.
31+
32+
Enables Zygisk compatibility layer, allowing Zynx to load Zygisk modules.
33+
2634
## License
2735

2836
MIT

src/core/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use aya_build::{Package, Toolchain};
22
use std::env;
33
use std::error::Error;
4+
use std::process::Command;
45

56
fn main() -> Result<(), Box<dyn Error>> {
67
if env::var("PROFILE")? == "debug" {
@@ -25,5 +26,11 @@ fn main() -> Result<(), Box<dyn Error>> {
2526

2627
prost_build::compile_protos(&proto_files, &[proto_src])?;
2728

29+
let output = Command::new("git").args(["rev-parse", "HEAD"]).output()?;
30+
let commit_hash = String::from_utf8(output.stdout)?.trim().to_string();
31+
32+
println!("cargo:rustc-env=GIT_COMMIT_HASH={commit_hash}");
33+
println!("cargo:rerun-if-changed={}/.git/HEAD", env!("ROOT_DIR"));
34+
2835
Ok(())
2936
}

src/core/src/cli.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
use clap::Parser;
22

33
#[derive(Parser)]
4+
#[command(about = "Zynx - an eBPF-based Android process injection framework", version, long_version = concat!(env!("CARGO_PKG_VERSION"), " (commit ", env!("GIT_COMMIT_HASH"), ")"))]
45
pub struct Cli {
5-
#[clap(long, help = "run zynx in daemon mode", conflicts_with = "configs")]
6+
#[clap(
7+
long,
8+
help = "Run Zynx in daemon mode (usually used for KernelSU/Magisk module)",
9+
conflicts_with = "configs"
10+
)]
611
pub daemon: bool,
712

8-
#[clap(long, help = "disable debugger", group = "configs")]
9-
pub cfg_disable_debugger: bool,
13+
#[clap(
14+
long,
15+
help = "Enable debugger (allow force-debuggable for apps)",
16+
group = "configs"
17+
)]
18+
pub cfg_enable_debugger: bool,
1019

11-
#[clap(long, help = "enable zygisk", group = "configs")]
20+
#[clap(long, help = "Enable zygisk compat", group = "configs")]
1221
pub cfg_enable_zygisk: bool,
1322
}
1423

src/core/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static INSTANCE: OnceLock<ZynxConfigs> = OnceLock::new();
66

77
#[derive(Debug)]
88
pub struct ZynxConfigs {
9-
pub disable_debugger: bool,
9+
pub enable_debugger: bool,
1010
pub enable_zygisk: bool,
1111
}
1212

@@ -27,7 +27,7 @@ impl ZynxConfigs {
2727

2828
fn from_cli(cli: &Cli) -> Self {
2929
Self {
30-
disable_debugger: cli.cfg_disable_debugger,
30+
enable_debugger: cli.cfg_enable_debugger,
3131
enable_zygisk: cli.cfg_enable_zygisk,
3232
}
3333
}

src/core/src/injector/app/policy/debugger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl PolicyProvider for DebuggerPolicyProvider {
1616
}
1717

1818
async fn check(&self, args: &EmbryoCheckArgs<'_>) -> PolicyDecision {
19-
if ZynxConfigs::instance().disable_debugger {
19+
if !ZynxConfigs::instance().enable_debugger {
2020
return PolicyDecision::Deny;
2121
}
2222

0 commit comments

Comments
 (0)