Skip to content

Commit 1192d1b

Browse files
committed
Add WebUI
1 parent b352d3b commit 1192d1b

9 files changed

Lines changed: 986 additions & 42 deletions

File tree

loader/src/ptracer/monitor_impl.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,31 @@ void AppMonitor::set_tracing_state(TracingState state) { tracing_state_ = state;
3838
void AppMonitor::write_abi_status_section(std::string &status_text, const Status &daemon_status) {
3939
auto abi_name = this->zygote_.abi_name_;
4040
if (daemon_status.supported) {
41-
status_text += "\tzygote";
41+
status_text += "zygote_";
4242
status_text += abi_name;
43-
status_text += ":";
43+
status_text += "_status=";
4444
if (tracing_state_ != TRACING)
45-
status_text += "\tunknown";
45+
status_text += "unknown";
4646
else if (daemon_status.zygote_injected)
47-
status_text += "\t😋 injected";
47+
status_text += "injected";
4848
else
49-
status_text += "\t❌ not injected";
50-
status_text += "\n\tdaemon";
49+
status_text += "not_injected";
50+
status_text += "\ndaemon_";
5151
status_text += abi_name;
52-
status_text += ":";
52+
status_text += "_status=";
5353
if (daemon_status.daemon_running) {
54-
status_text += "\t😋 running";
54+
status_text += "running";
5555
if (!daemon_status.daemon_info.empty()) {
5656
status_text += "\n";
5757
status_text += daemon_status.daemon_info;
5858
}
5959
} else {
60-
status_text += "\tcrashed";
60+
status_text += "crashed";
6161
if (!daemon_status.daemon_error_info.empty()) {
62-
status_text += "(";
62+
status_text += "\ndaemon_";
63+
status_text += abi_name;
64+
status_text += "_error=";
6365
status_text += daemon_status.daemon_error_info;
64-
status_text += ")";
6566
}
6667
}
6768
}
@@ -75,34 +76,33 @@ void AppMonitor::update_status() {
7576
}
7677

7778
// Build the middle section of the status text.
78-
std::string status_text = "\tmonitor: \t";
79+
std::string status_text = "monitor_status=";
7980
switch (tracing_state_) {
8081
case TRACING:
81-
status_text += "😋 tracing";
82+
status_text += "tracing";
8283
break;
8384
case STOPPING:
8485
[[fallthrough]];
8586
case STOPPED:
86-
status_text += "stopped";
87+
status_text += "stopped";
8788
break;
8889
case EXITING:
89-
status_text += "exited";
90+
status_text += "exited";
9091
break;
9192
}
9293
if (tracing_state_ != TRACING && !monitor_stop_reason_.empty()) {
93-
status_text += "(";
94+
status_text += "\nmonitor_stop_reason=";
9495
status_text += monitor_stop_reason_;
95-
status_text += ")";
9696
}
9797

9898
// Build the full content in a single stringstream for clarity.
9999
std::stringstream ss;
100-
ss << pre_section_ << "\n" << status_text << "\n\n";
100+
ss << pre_section_ << "\n" << status_text << "\n";
101101

102102
std::string abi_section;
103103
write_abi_status_section(abi_section, zygote_.get_status());
104104

105-
ss << abi_section << "\n\n" << post_section_;
105+
ss << abi_section << "\n" << post_section_;
106106

107107
std::string final_output = ss.str();
108108
fwrite(final_output.c_str(), 1, final_output.length(), prop_file.get());
@@ -123,7 +123,6 @@ bool AppMonitor::prepare_environment() {
123123
post = true;
124124
post_section_ += line.substr(sizeof("description"));
125125
} else {
126-
(post ? post_section_ : pre_section_) += "\t";
127126
(post ? post_section_ : pre_section_) += line;
128127
}
129128
return true;

module/build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ androidComponents.onVariants { variant ->
5555
into(moduleDir)
5656
from("${rootProject.projectDir}/README.md")
5757
from("$projectDir/src") {
58-
exclude("module.prop", "action.sh", "customize.sh", "post-fs-data.sh", "service.sh", "uninstall.sh", "zygisk-ctl.sh")
58+
exclude("module.prop", "customize.sh", "post-fs-data.sh", "service.sh", "uninstall.sh", "zygisk-ctl.sh")
5959
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
6060
}
6161
from("$projectDir/src") {
@@ -69,7 +69,7 @@ androidComponents.onVariants { variant ->
6969
)
7070
}
7171
from("$projectDir/src") {
72-
include("action.sh", "customize.sh", "post-fs-data.sh", "service.sh", "uninstall.sh", "zygisk-ctl.sh")
72+
include("customize.sh", "post-fs-data.sh", "service.sh", "uninstall.sh", "zygisk-ctl.sh")
7373
val tokens = mapOf(
7474
"DEBUG" to if (buildTypeLowered == "debug") "true" else "false",
7575
"MIN_APATCH_VERSION" to "$minAPatchVersion",
@@ -89,6 +89,10 @@ androidComponents.onVariants { variant ->
8989
into("lib") {
9090
from(project(":loader").layout.buildDirectory.file("intermediates/stripped_native_libs/$variantLowered/strip${variantCapped}DebugSymbols/out/lib"))
9191
}
92+
into("webroot") {
93+
from("${rootProject.projectDir}/webroot")
94+
include("**/*")
95+
}
9296

9397
doLast {
9498
fileTree(moduleDir).visit {

module/src/action.sh

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

module/src/customize.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ if [ "$KSU" ]; then
105105
fi
106106

107107
ui_print "- Extracting module files"
108-
extract "$ZIPFILE" 'action.sh' "$MODPATH"
109108
extract "$ZIPFILE" 'module.prop' "$MODPATH"
110109
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
111110
extract "$ZIPFILE" 'service.sh' "$MODPATH"
@@ -116,8 +115,12 @@ mv "$TMPDIR/sepolicy.rule" "$MODPATH"
116115
mkdir "$MODPATH/bin"
117116
mkdir "$MODPATH/lib"
118117
mkdir "$MODPATH/lib64"
118+
mkdir "$MODPATH/webroot"
119119
mv "$MODPATH/zygisk-ctl.sh" "$MODPATH/bin/zygisk-ctl"
120120

121+
ui_print "- Extracting WebUI files"
122+
unzip -o "$ZIPFILE" "webroot/*" -x "*.sha256" -d "$MODPATH"
123+
121124
if [ "$ARCH" = "x86" ]; then
122125
ui_print "- Extracting x86 libraries"
123126
extract "$ZIPFILE" 'bin/x86/zygiskd' "$MODPATH/bin" true

webroot/index.html

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Zygisk Next WebUI</title>
8+
<link rel="stylesheet" href="style.css">
9+
<link rel="preconnect" href="https://fonts.googleapis.com">
10+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
12+
</head>
13+
14+
<body>
15+
<div class="app-container">
16+
<header class="header">
17+
<h1>NeoZygisk</h1>
18+
<div class="language-selector">
19+
<button id="lang-btn" class="icon-btn" aria-label="Change Language">
20+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
21+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
22+
<circle cx="12" cy="12" r="10"></circle>
23+
<line x1="2" y1="12" x2="22" y2="12"></line>
24+
<path
25+
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z">
26+
</path>
27+
</svg>
28+
</button>
29+
<div id="lang-dropdown" class="dropdown-menu hidden">
30+
<button data-lang="en">English</button>
31+
<button data-lang="zh">中文</button>
32+
</div>
33+
</div>
34+
</header>
35+
36+
<main class="content">
37+
<!-- Basic Information Card -->
38+
<div class="card">
39+
<h2 data-i18n="basic_info">Basic Information</h2>
40+
<div class="info-item">
41+
<label id="prop-name">NeoZygisk</label>
42+
<div class="value" id="prop-version">_</div>
43+
</div>
44+
<div class="info-item">
45+
<label data-i18n="kernel">Kernel</label>
46+
<div class="value" id="device-kernel">_</div>
47+
</div>
48+
<div class="info-item">
49+
<label>Android SDK</label>
50+
<div class="value" id="device-sdk">_</div>
51+
</div>
52+
<div class="info-item">
53+
<label>ABI</label>
54+
<div class="value" id="device-abi">_</div>
55+
</div>
56+
</div>
57+
58+
<!-- Dashboard Card -->
59+
<div class="card">
60+
<div class="card-header">
61+
<h2 data-i18n="dashboard">Dashboard</h2>
62+
<div class="actions">
63+
<button id="refresh-btn" class="icon-btn small" aria-label="Refresh">
64+
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"
65+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
66+
stroke-linejoin="round">
67+
<path d="M23 4v6h-6"></path>
68+
<path d="M1 20v-6h6"></path>
69+
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15">
70+
</path>
71+
</svg>
72+
</button>
73+
</div>
74+
</div>
75+
76+
<div class="status-row">
77+
<span data-i18n="root_impl">Root implementation</span>
78+
<span class="badge green"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
79+
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"
80+
stroke-linecap="round" stroke-linejoin="round">
81+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
82+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
83+
</svg> <span id="val-root">_</span></span>
84+
</div>
85+
<div class="status-row">
86+
<span data-i18n="zygote_monitor">Zygote Monitor</span>
87+
<span class="badge green"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
88+
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"
89+
stroke-linecap="round" stroke-linejoin="round">
90+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
91+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
92+
</svg> <span data-i18n="running" id="val-monitor">_</span></span>
93+
</div>
94+
<div class="status-row">
95+
<span>zygote (64)</span>
96+
<span class="badge green"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
97+
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"
98+
stroke-linecap="round" stroke-linejoin="round">
99+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
100+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
101+
</svg> <span data-i18n="injected" id="val-zygote64">_</span>
102+
(1001)</span>
103+
</div>
104+
<div class="status-row">
105+
<span>daemon (64)</span>
106+
<span class="badge green"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
107+
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"
108+
stroke-linecap="round" stroke-linejoin="round">
109+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
110+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
111+
</svg> <span data-i18n="running" id="val-daemon64">_</span></span>
112+
</div>
113+
114+
<div class="module-list-link" id="modules-link" style="cursor: pointer;">
115+
<span data-i18n="modules">Modules</span> (<span id="val-modules-count">_</span>)
116+
&gt;
117+
</div>
118+
</div>
119+
</main>
120+
121+
</div>
122+
123+
<!-- Modules Modal -->
124+
<div id="modules-modal" class="modal hidden">
125+
<div class="modal-content">
126+
<div class="modal-header">
127+
<h2 data-i18n="modules_list">Running Modules</h2>
128+
<button id="close-modal-btn" class="icon-btn small"><svg xmlns="http://www.w3.org/2000/svg" width="24"
129+
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
130+
stroke-linecap="round" stroke-linejoin="round">
131+
<line x1="18" y1="6" x2="6" y2="18"></line>
132+
<line x1="6" y1="6" x2="18" y2="18"></line>
133+
</svg></button>
134+
</div>
135+
<div class="modal-body">
136+
<ul id="modules-list">
137+
<!-- Module items will be populated here -->
138+
</ul>
139+
</div>
140+
</div>
141+
</div>
142+
143+
<script type="module" src="script.js"></script>
144+
</body>
145+
146+
</html>

0 commit comments

Comments
 (0)